his_api_controller.go 428KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/json"
  6. "fmt"
  7. "gdyb/controllers"
  8. "gdyb/enums"
  9. "gdyb/models"
  10. "gdyb/service"
  11. "gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/axgle/mahonia"
  14. "github.com/jinzhu/gorm"
  15. "github.com/shopspring/decimal"
  16. "io"
  17. "io/ioutil"
  18. "math/rand"
  19. "net/http"
  20. "os"
  21. "path/filepath"
  22. "strconv"
  23. "strings"
  24. "syscall"
  25. "time"
  26. "unsafe"
  27. )
  28. type HisApiController struct {
  29. controllers.BaseAuthAPIController
  30. }
  31. func HisManagerApiRegistRouters() {
  32. //挂号
  33. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  34. //上传就诊信息-上传明细-结算
  35. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  36. //查询
  37. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  38. //对总账
  39. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  40. //对明细
  41. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  42. //退费,退明细
  43. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  44. //退号
  45. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  46. //退明细
  47. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  48. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  49. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  50. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  51. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  52. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  53. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  54. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  55. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  56. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  57. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  58. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  59. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  60. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  61. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  62. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  63. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  64. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  65. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  66. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  67. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  68. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  69. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  70. beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  71. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  72. beego.Router("/api/check", &HisApiController{}, "get:Check")
  73. beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  74. beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  75. }
  76. func (c *HisApiController) Check3101() {
  77. patient_id, _ := c.GetInt64("patient_id")
  78. his_patient_id, _ := c.GetInt64("his_patient_id")
  79. admin_user_id, _ := c.GetInt64("admin_user_id")
  80. adminUser := c.GetAdminUserInfo()
  81. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  82. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  83. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  84. record_time := c.GetString("record_time")
  85. trig_scen := c.GetString("trig_scen")
  86. timeLayout := "2006-01-02"
  87. loc, _ := time.LoadLocation("Local")
  88. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  89. if err != nil {
  90. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  91. return
  92. }
  93. recordDateTime := theTime.Unix()
  94. var patientPrescription models.HisPrescriptionInfo
  95. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  96. if patientPrescription.ID == 0 {
  97. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  98. }
  99. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  100. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  101. //
  102. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  103. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  104. var pp models.PublicParams
  105. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  106. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  107. pp.FixmedinsName = miConfig.OrgName
  108. pp.FixmedinsCode = miConfig.Code
  109. pp.RequestUrl = miConfig.Url
  110. pp.Cainfo = miConfig.Cainfo
  111. pp.SecretKey = miConfig.SecretKey
  112. pp.AccessKey = miConfig.AccessKey
  113. pp.OpterName = roles.UserName
  114. var config []*models.HisXtDiagnoseConfig
  115. for _, item := range diagnosis_ids {
  116. id, _ := strconv.ParseInt(item, 10, 64)
  117. diagnosisConfig, _ := service.FindDiagnoseById(id)
  118. config = append(config, &diagnosisConfig)
  119. }
  120. var pd models.PatientDtos
  121. pd.PatnID = his.PsnNo
  122. pd.PatnName = his.Name
  123. pd.Gend = his.Gend
  124. pd.Brdy = his.Brdy
  125. pd.Poolarea = his.InsuplcAdmdvs
  126. pd.CurrMdtrtID = his.Number
  127. var fed models.FsiEncounterDtos
  128. fed.MdtrtID = his.Number
  129. fed.MedinsID = miConfig.Code
  130. fed.MedinsName = miConfig.OrgName
  131. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  132. fed.MedMdtrtType = "1"
  133. fed.MedinsType = "1"
  134. fed.MedinsLv = "11"
  135. tm := time.Unix(his.RecordDate, 0)
  136. s_tm := tm.Format("2006-01-02 15:04:05")
  137. fed.AdmDate = s_tm
  138. fed.DscgDate = s_tm
  139. fed.DscgMainDiseCodg = config[0].CountryCode
  140. fed.DscgMainDiseName = config[0].CountryContentName
  141. //诊断信息
  142. var fdds []*models.FsiDiagnoseDtos
  143. for index, item := range config {
  144. if index == 0 {
  145. var fdd models.FsiDiagnoseDtos
  146. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  147. fdd.InoutDiseType = "1"
  148. fdd.MaindiseFlag = "1"
  149. fdd.DiseDate = s_tm
  150. fdd.DiasSrtNo = "1"
  151. fdd.DiseName = item.CountryContentName
  152. fdd.DiseCodg = item.CountryCode
  153. fdds = append(fdds, &fdd)
  154. } else {
  155. var fdd models.FsiDiagnoseDtos
  156. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  157. fdd.InoutDiseType = "1"
  158. fdd.MaindiseFlag = "1"
  159. fdd.DiseDate = s_tm
  160. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  161. fdd.DiseName = item.CountryContentName
  162. fdd.DiseCodg = item.CountryCode
  163. fdds = append(fdds, &fdd)
  164. }
  165. }
  166. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  167. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  168. fed.AdmDeptName = department.Name
  169. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  170. fed.DscgDeptName = department.Name
  171. fed.MedMdtrtType = "1"
  172. fed.MedType = "11"
  173. //if his.Insutype == "390" {
  174. // fed.MedType = "1402"
  175. //} else {
  176. // fed.MedType = "9933"
  177. //}
  178. var orders []*models.FsiOrderDtos
  179. if trig_scen == "2" {
  180. //处方医嘱信息
  181. for _, item := range prescriptions {
  182. for _, subItem := range item.HisDoctorAdviceInfo {
  183. var order models.FsiOrderDtos
  184. order.RxID = strconv.FormatInt(item.ID, 10)
  185. order.Rxno = strconv.FormatInt(item.ID, 10)
  186. order.LongDrordFlag = "0"
  187. order.HilistType = "1"
  188. order.ChrgType = "1"
  189. order.DrordBhvr = "-"
  190. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  191. order.HosplistName = subItem.BaseDrugLib.DrugName
  192. order.HilistLv = "1"
  193. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  194. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  195. order.HosplistName = subItem.BaseDrugLib.DrugName
  196. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  197. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  198. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  199. order.OwnpayAmt = ""
  200. order.SelfpayAmt = ""
  201. order.Spec = ""
  202. order.SpecUnt = ""
  203. order.DrordBegnDate = s_tm
  204. order.DrordStopDate = ""
  205. order.DrordDrCodg = "1"
  206. order.DrordDeptName = department.Name
  207. order.DrordDrCodg = "1"
  208. order.DrordDrName = doctor_info.UserName
  209. order.DrordDrProfttl = ""
  210. order.CurrDrordFlag = "1"
  211. orders = append(orders, &order)
  212. }
  213. for _, subItem := range item.HisPrescriptionProject {
  214. if subItem.Type == 2 {
  215. var order models.FsiOrderDtos
  216. order.RxID = strconv.FormatInt(item.ID, 10)
  217. order.Rxno = strconv.FormatInt(item.ID, 10)
  218. order.LongDrordFlag = "0"
  219. order.HilistType = "1"
  220. order.ChrgType = "1"
  221. order.DrordBhvr = "-"
  222. order.HilistCode = subItem.HisProject.MedicalCode
  223. order.HosplistName = subItem.HisProject.ProjectName
  224. order.HilistLv = "1"
  225. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  226. order.HosplistCode = subItem.HisProject.MedicalCode
  227. order.HosplistName = subItem.HisProject.ProjectName
  228. order.Cnt = subItem.Count
  229. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  230. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  231. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  232. order.OwnpayAmt = ""
  233. order.SelfpayAmt = ""
  234. order.Spec = ""
  235. order.SpecUnt = ""
  236. order.DrordBegnDate = s_tm
  237. order.DrordStopDate = ""
  238. order.DrordDrCodg = "1"
  239. order.DrordDeptName = department.Name
  240. order.DrordDrCodg = "1"
  241. order.DrordDrName = doctor_info.UserName
  242. order.DrordDrProfttl = ""
  243. order.CurrDrordFlag = "1"
  244. orders = append(orders, &order)
  245. }
  246. if subItem.Type == 3 {
  247. var order models.FsiOrderDtos
  248. order.RxID = strconv.FormatInt(item.ID, 10)
  249. order.Rxno = strconv.FormatInt(item.ID, 10)
  250. order.LongDrordFlag = "0"
  251. order.HilistType = "1"
  252. order.ChrgType = "1"
  253. order.DrordBhvr = "-"
  254. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  255. order.HosplistName = subItem.GoodInfo.GoodName
  256. order.HilistLv = "1"
  257. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  258. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  259. order.HosplistName = subItem.GoodInfo.GoodName
  260. order.Cnt = subItem.Count
  261. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  262. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  263. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  264. order.OwnpayAmt = ""
  265. order.SelfpayAmt = ""
  266. order.Spec = ""
  267. order.SpecUnt = ""
  268. order.DrordBegnDate = s_tm
  269. order.DrordStopDate = ""
  270. order.DrordDrCodg = "1"
  271. order.DrordDeptName = department.Name
  272. order.DrordDrCodg = "1"
  273. order.DrordDrName = doctor_info.UserName
  274. order.DrordDrProfttl = ""
  275. order.CurrDrordFlag = "1"
  276. orders = append(orders, &order)
  277. }
  278. }
  279. }
  280. //处方医嘱信息
  281. }
  282. fed.MatnStas = "0"
  283. fed.MedfeeSumamt = "0"
  284. fed.OwnpayAmt = "0"
  285. fed.SelfpayAmt = "0"
  286. fed.AcctPayamt = "0"
  287. fed.MaAmt = "0"
  288. fed.HifpPayamt = "0"
  289. fed.SetlTotlnum = "1"
  290. fed.Insutype = his.Insutype
  291. fed.ReimFlag = "0"
  292. fed.OutSetlFlag = "0"
  293. var fopd []*models.FsiOperationDtosData
  294. data := make(map[string]interface{})
  295. data["fed"] = fed
  296. data["fdd"] = fdds
  297. data["fod"] = orders
  298. data["pd"] = pd
  299. data["pp"] = pp
  300. data["fopd"] = fopd
  301. data["trig_scen"] = trig_scen
  302. fmt.Println(data)
  303. fmt.Println(fed)
  304. fmt.Println(fdds)
  305. fmt.Println(orders)
  306. fmt.Println(pd)
  307. fmt.Println(pp)
  308. fmt.Println(fopd)
  309. client := &http.Client{}
  310. bytesData, _ := json.Marshal(data)
  311. var req *http.Request
  312. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  313. resp, _ := client.Do(req)
  314. defer resp.Body.Close()
  315. body, ioErr := ioutil.ReadAll(resp.Body)
  316. if ioErr != nil {
  317. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  319. return
  320. }
  321. var respJSON map[string]interface{}
  322. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  323. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  325. return
  326. }
  327. //手术操作集合
  328. //手术操作集合
  329. }
  330. func (c *HisApiController) Check3102() {
  331. patient_id, _ := c.GetInt64("patient_id")
  332. order_id, _ := c.GetInt64("order_id")
  333. his_patient_id, _ := c.GetInt64("his_patient_id")
  334. admin_user_id, _ := c.GetInt64("admin_user_id")
  335. trig_scen := c.GetString("trig_scen")
  336. adminUser := c.GetAdminUserInfo()
  337. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  338. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  339. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  340. record_time := c.GetString("record_time")
  341. order, _ := service.GetHisOrderByID(order_id)
  342. timeLayout := "2006-01-02"
  343. loc, _ := time.LoadLocation("Local")
  344. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  345. if err != nil {
  346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  347. return
  348. }
  349. recordDateTime := theTime.Unix()
  350. var patientPrescription models.HisPrescriptionInfo
  351. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  352. if patientPrescription.ID == 0 {
  353. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  354. }
  355. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  356. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  357. //
  358. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  359. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  360. var pp models.PublicParams
  361. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  362. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  363. pp.FixmedinsName = miConfig.OrgName
  364. pp.FixmedinsCode = miConfig.Code
  365. pp.RequestUrl = miConfig.Url
  366. pp.Cainfo = miConfig.Cainfo
  367. pp.SecretKey = miConfig.SecretKey
  368. pp.AccessKey = miConfig.AccessKey
  369. pp.OpterName = roles.UserName
  370. var config []*models.HisXtDiagnoseConfig
  371. for _, item := range diagnosis_ids {
  372. id, _ := strconv.ParseInt(item, 10, 64)
  373. diagnosisConfig, _ := service.FindDiagnoseById(id)
  374. config = append(config, &diagnosisConfig)
  375. }
  376. var pd models.PatientDtos
  377. pd.PatnID = his.PsnNo
  378. pd.PatnName = his.Name
  379. pd.Gend = his.Gend
  380. pd.Brdy = his.Brdy
  381. pd.Poolarea = his.InsuplcAdmdvs
  382. pd.CurrMdtrtID = his.Number
  383. var fed models.FsiEncounterDtos
  384. fed.MdtrtID = his.Number
  385. fed.MedinsID = miConfig.Code
  386. fed.MedinsName = miConfig.OrgName
  387. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  388. fed.MedMdtrtType = "1"
  389. fed.MedinsType = "1"
  390. fed.MedinsLv = "11"
  391. tm := time.Unix(his.RecordDate, 0)
  392. s_tm := tm.Format("2006-01-02 15:04:05")
  393. fed.AdmDate = s_tm
  394. fed.DscgDate = s_tm
  395. fed.DscgMainDiseCodg = config[0].CountryCode
  396. fed.DscgMainDiseName = config[0].CountryContentName
  397. //诊断信息
  398. var fdds []*models.FsiDiagnoseDtos
  399. for index, item := range config {
  400. if index == 0 {
  401. var fdd models.FsiDiagnoseDtos
  402. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  403. fdd.InoutDiseType = "1"
  404. fdd.MaindiseFlag = "1"
  405. fdd.DiseDate = s_tm
  406. fdd.DiasSrtNo = "1"
  407. fdd.DiseName = item.CountryContentName
  408. fdd.DiseCodg = item.CountryCode
  409. fdds = append(fdds, &fdd)
  410. } else {
  411. var fdd models.FsiDiagnoseDtos
  412. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  413. fdd.InoutDiseType = "1"
  414. fdd.MaindiseFlag = "1"
  415. fdd.DiseDate = s_tm
  416. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  417. fdd.DiseName = item.CountryContentName
  418. fdd.DiseCodg = item.CountryCode
  419. fdds = append(fdds, &fdd)
  420. }
  421. }
  422. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  423. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  424. fed.AdmDeptName = department.Name
  425. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  426. fed.DscgDeptName = department.Name
  427. fed.MedType = order.MedType
  428. //处方医嘱信息
  429. var orders []*models.FsiOrderDtos
  430. //for _, item := range prescriptions {
  431. // for _, subItem := range item.HisDoctorAdviceInfo {
  432. // var order models.FsiOrderDtos
  433. // order.RxID = strconv.FormatInt(item.ID, 10)
  434. // order.Rxno = strconv.FormatInt(item.ID, 10)
  435. // order.LongDrordFlag = "0"
  436. // order.HilistType = "1"
  437. // order.ChrgType = "1"
  438. // order.DrordBhvr = "-"
  439. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  440. // order.HosplistName = subItem.BaseDrugLib.DrugName
  441. // order.HilistLv = "1"
  442. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  443. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  444. // order.HosplistName = subItem.BaseDrugLib.DrugName
  445. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  446. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  447. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  448. // order.OwnpayAmt = ""
  449. // order.SelfpayAmt = ""
  450. // order.Spec = ""
  451. // order.SpecUnt = ""
  452. // order.DrordBegnDate = s_tm
  453. // order.DrordStopDate = ""
  454. // order.DrordDrCodg = "1"
  455. // order.DrordDeptName = department.Name
  456. // order.DrordDrCodg = "1"
  457. // order.DrordDrName = doctor_info.UserName
  458. // order.DrordDrProfttl = ""
  459. // order.CurrDrordFlag = "1"
  460. // orders = append(orders, &order)
  461. // }
  462. // for _, subItem := range item.HisPrescriptionProject {
  463. // if subItem.Type == 2 {
  464. // var order models.FsiOrderDtos
  465. // order.RxID = strconv.FormatInt(item.ID, 10)
  466. // order.Rxno = strconv.FormatInt(item.ID, 10)
  467. // order.LongDrordFlag = "0"
  468. // order.HilistType = "1"
  469. // order.ChrgType = "1"
  470. // order.DrordBhvr = "-"
  471. // order.HilistCode = subItem.HisProject.MedicalCode
  472. // order.HosplistName = subItem.HisProject.ProjectName
  473. // order.HilistLv = "1"
  474. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  475. // order.HosplistCode = subItem.HisProject.MedicalCode
  476. // order.HosplistName = subItem.HisProject.ProjectName
  477. // order.Cnt = subItem.Count
  478. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  479. //
  480. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  481. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  482. // order.OwnpayAmt = ""
  483. // order.SelfpayAmt = ""
  484. // order.Spec = ""
  485. // order.SpecUnt = ""
  486. // order.DrordBegnDate = s_tm
  487. // order.DrordStopDate = ""
  488. // order.DrordDrCodg = "1"
  489. // order.DrordDeptName = department.Name
  490. // order.DrordDrCodg = "1"
  491. // order.DrordDrName = doctor_info.UserName
  492. // order.DrordDrProfttl = ""
  493. // order.CurrDrordFlag = "1"
  494. // orders = append(orders, &order)
  495. //
  496. // }
  497. // if subItem.Type == 3 {
  498. //
  499. // var order models.FsiOrderDtos
  500. // order.RxID = strconv.FormatInt(item.ID, 10)
  501. // order.Rxno = strconv.FormatInt(item.ID, 10)
  502. // order.LongDrordFlag = "0"
  503. // order.HilistType = "1"
  504. // order.ChrgType = "1"
  505. // order.DrordBhvr = "-"
  506. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  507. // order.HosplistName = subItem.GoodInfo.GoodName
  508. // order.HilistLv = "1"
  509. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  510. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  511. // order.HosplistName = subItem.GoodInfo.GoodName
  512. // order.Cnt = subItem.Count
  513. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  514. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  515. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  516. // order.OwnpayAmt = ""
  517. // order.SelfpayAmt = ""
  518. // order.Spec = ""
  519. // order.SpecUnt = ""
  520. // order.DrordBegnDate = s_tm
  521. // order.DrordStopDate = ""
  522. // order.DrordDrCodg = "1"
  523. // order.DrordDeptName = department.Name
  524. // order.DrordDrCodg = "1"
  525. // order.DrordDrName = doctor_info.UserName
  526. // order.DrordDrProfttl = ""
  527. // order.CurrDrordFlag = "1"
  528. // orders = append(orders, &order)
  529. //
  530. // }
  531. // }
  532. //}
  533. for _, item := range prescriptions {
  534. for _, subItem := range item.HisDoctorAdviceInfo {
  535. var order models.FsiOrderDtos
  536. order.RxID = strconv.FormatInt(item.ID, 10)
  537. order.Rxno = strconv.FormatInt(item.ID, 10)
  538. order.LongDrordFlag = "0"
  539. order.HilistType = "1"
  540. order.ChrgType = "1"
  541. order.DrordBhvr = "-"
  542. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  543. order.HosplistName = subItem.BaseDrugLib.DrugName
  544. order.HilistLv = "1"
  545. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  546. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  547. order.HosplistName = subItem.BaseDrugLib.DrugName
  548. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  549. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  550. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  551. order.OwnpayAmt = ""
  552. order.SelfpayAmt = ""
  553. order.Spec = ""
  554. order.SpecUnt = ""
  555. order.DrordBegnDate = s_tm
  556. order.DrordStopDate = ""
  557. order.DrordDrCodg = "1"
  558. order.DrordDeptName = department.Name
  559. order.DrordDrCodg = "1"
  560. order.DrordDrName = doctor_info.UserName
  561. order.DrordDrProfttl = ""
  562. order.CurrDrordFlag = "1"
  563. orders = append(orders, &order)
  564. }
  565. for _, subItem := range item.HisPrescriptionProject {
  566. if subItem.Type == 2 {
  567. var order models.FsiOrderDtos
  568. order.RxID = strconv.FormatInt(item.ID, 10)
  569. order.Rxno = strconv.FormatInt(item.ID, 10)
  570. order.LongDrordFlag = "0"
  571. order.HilistType = "1"
  572. order.ChrgType = "1"
  573. order.DrordBhvr = "-"
  574. order.HilistCode = subItem.HisProject.MedicalCode
  575. order.HosplistName = subItem.HisProject.ProjectName
  576. order.HilistLv = "1"
  577. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  578. order.HosplistCode = subItem.HisProject.MedicalCode
  579. order.HosplistName = subItem.HisProject.ProjectName
  580. order.Cnt = subItem.Count
  581. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  582. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  583. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  584. order.OwnpayAmt = ""
  585. order.SelfpayAmt = ""
  586. order.Spec = ""
  587. order.SpecUnt = ""
  588. order.DrordBegnDate = s_tm
  589. order.DrordStopDate = ""
  590. order.DrordDrCodg = "1"
  591. order.DrordDeptName = department.Name
  592. order.DrordDrCodg = "1"
  593. order.DrordDrName = doctor_info.UserName
  594. order.DrordDrProfttl = ""
  595. order.CurrDrordFlag = "1"
  596. orders = append(orders, &order)
  597. }
  598. if subItem.Type == 3 {
  599. var order models.FsiOrderDtos
  600. order.RxID = strconv.FormatInt(item.ID, 10)
  601. order.Rxno = strconv.FormatInt(item.ID, 10)
  602. order.LongDrordFlag = "0"
  603. order.HilistType = "1"
  604. order.ChrgType = "1"
  605. order.DrordBhvr = "-"
  606. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  607. order.HosplistName = subItem.GoodInfo.GoodName
  608. order.HilistLv = "1"
  609. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  610. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  611. order.HosplistName = subItem.GoodInfo.GoodName
  612. order.Cnt = subItem.Count
  613. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  614. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  615. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  616. order.OwnpayAmt = ""
  617. order.SelfpayAmt = ""
  618. order.Spec = ""
  619. order.SpecUnt = ""
  620. order.DrordBegnDate = s_tm
  621. order.DrordStopDate = ""
  622. order.DrordDrCodg = "1"
  623. order.DrordDeptName = department.Name
  624. order.DrordDrCodg = "1"
  625. order.DrordDrName = doctor_info.UserName
  626. order.DrordDrProfttl = ""
  627. order.CurrDrordFlag = "1"
  628. orders = append(orders, &order)
  629. }
  630. }
  631. }
  632. //处方医嘱信息
  633. fed.MatnStas = "0"
  634. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  635. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  636. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  637. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  638. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  639. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  640. fed.SetlTotlnum = "1"
  641. fed.Insutype = his.Insutype
  642. fed.ReimFlag = "0"
  643. fed.OutSetlFlag = "0"
  644. var fopd []*models.FsiOperationDtosData
  645. data := make(map[string]interface{})
  646. data["fed"] = fed
  647. data["fdd"] = fdds
  648. data["fod"] = orders
  649. data["pd"] = pd
  650. data["pp"] = pp
  651. data["fopd"] = fopd
  652. data["trig_scen"] = trig_scen
  653. client := &http.Client{}
  654. bytesData, _ := json.Marshal(data)
  655. var req *http.Request
  656. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  657. resp, _ := client.Do(req)
  658. defer resp.Body.Close()
  659. body, ioErr := ioutil.ReadAll(resp.Body)
  660. if ioErr != nil {
  661. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  663. return
  664. }
  665. var respJSON map[string]interface{}
  666. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  667. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  669. return
  670. }
  671. //手术操作集合
  672. //手术操作集合
  673. }
  674. func (c *HisApiController) Check() {
  675. psn_no := c.GetString("psn_no")
  676. in := c.GetString("in")
  677. mt := c.GetString("mt")
  678. baseParams := models.BaseParams{
  679. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  680. FixmedinsCode: "H15049901371",
  681. InsuplcAdmdvs: "150499",
  682. MdtrtareaAdmvs: "150499",
  683. OrgName: "赤峰费森血液透析中心",
  684. Doctor: "1111",
  685. }
  686. service.Gdyb2001(baseParams, psn_no, in, mt)
  687. }
  688. func (c *HisApiController) GetPsnNcdsInfo() {
  689. admin_user_id, _ := c.GetInt64("admin_user_id")
  690. patient_id, _ := c.GetInt64("patient_id")
  691. id, _ := c.GetInt64("id")
  692. adminUser := c.GetAdminUserInfo()
  693. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  694. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  695. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  696. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  697. psn_record, _ := service.GetPsnNCDSRecordById(id)
  698. //
  699. //if psn_record.ID == 0 {
  700. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  701. // return
  702. //}
  703. var res Result5301
  704. var res10265 Result5301For10265
  705. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  706. psn_info, _ := service.GetPsnByPatientId(patient_id)
  707. var api string
  708. if miConfig.MdtrtareaAdmvs == "320921" {
  709. api = "http://192.168.3.111:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  710. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  711. } else {
  712. api = "http://192.168.5.251:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  713. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  714. }
  715. resp, requestErr := http.Get(api)
  716. if requestErr != nil {
  717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  718. return
  719. }
  720. body, ioErr := ioutil.ReadAll(resp.Body)
  721. if ioErr != nil {
  722. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  724. return
  725. }
  726. var respJSON map[string]interface{}
  727. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  728. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  730. return
  731. }
  732. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  733. result, _ := json.Marshal(respJSON)
  734. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  735. utils.ErrorLog("解析失败:%v", err)
  736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  737. return
  738. }
  739. res.ErrMsg = res10265.ErrMsg
  740. res.Output = res10265.Output
  741. res.InfRefmsgid = res10265.InfRefmsgid
  742. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  743. res.Infcode = infocode
  744. } else {
  745. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  746. var dat map[string]interface{}
  747. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  748. fmt.Println(dat)
  749. } else {
  750. fmt.Println(err)
  751. }
  752. userJSONBytes, _ := json.Marshal(dat)
  753. if miConfig.Code == "H15049901371" {
  754. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  755. utils.ErrorLog("解析失败:%v", err)
  756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  757. return
  758. }
  759. res.InfRefmsgid = res10265.InfRefmsgid
  760. res.Output = res10265.Output
  761. res.ErrMsg = res10265.ErrMsg
  762. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  763. res.Infcode = infocode
  764. } else {
  765. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  766. utils.ErrorLog("解析失败:%v", err)
  767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  768. return
  769. }
  770. }
  771. }
  772. if res.Infcode == 0 {
  773. c.ServeSuccessJSON(map[string]interface{}{
  774. "result": res.Output.Result,
  775. })
  776. }
  777. }
  778. func (c *HisApiController) CheckInsutype() {
  779. his_patient_id, _ := c.GetInt64("his_patient_id")
  780. admin_user_id, _ := c.GetInt64("admin_user_id")
  781. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  782. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  783. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  784. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  785. var dat map[string]interface{}
  786. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  787. fmt.Println(dat)
  788. } else {
  789. fmt.Println(err)
  790. }
  791. userJSONBytes, _ := json.Marshal(dat)
  792. var res Result90100
  793. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  794. utils.ErrorLog("解析失败:%v", err)
  795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  796. return
  797. }
  798. if res.Infcode != 0 {
  799. c.ServeSuccessJSON(map[string]interface{}{
  800. "failed_code": -10,
  801. "msg": res.ErrMsg,
  802. })
  803. return
  804. } else {
  805. fmt.Println(res)
  806. }
  807. }
  808. func (c *HisApiController) CheckCardPWD() {
  809. card_pwd := c.GetString("card_pwd")
  810. his_patient_id, _ := c.GetInt64("his_patient_id")
  811. admin_user_id, _ := c.GetInt64("admin_user_id")
  812. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  813. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  814. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  815. psn, _ := service.GetPsnByPatientId(his.PatientId)
  816. bas := strings.Split(psn.CardInfo, "|")
  817. basNumber := bas[2]
  818. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  819. var dat map[string]interface{}
  820. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  821. fmt.Println(dat)
  822. } else {
  823. fmt.Println(err)
  824. }
  825. userJSONBytes, _ := json.Marshal(dat)
  826. var res Result90991
  827. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  828. utils.ErrorLog("解析失败:%v", err)
  829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  830. return
  831. }
  832. if res.Infcode != 0 {
  833. c.ServeSuccessJSON(map[string]interface{}{
  834. "failed_code": -10,
  835. "msg": res.ErrMsg,
  836. })
  837. return
  838. } else {
  839. if res.Output.Result.SscnoCheckStat == "0" {
  840. var msg string
  841. switch res.Output.Result.CardStat {
  842. case "00":
  843. msg = "未激活"
  844. break
  845. case "10":
  846. msg = "激活"
  847. break
  848. case "20":
  849. msg = "窗口挂失"
  850. break
  851. case "21":
  852. msg = "电话挂失"
  853. break
  854. case "22":
  855. msg = "单位网上申报挂失"
  856. break
  857. case "23":
  858. msg = "保健办挂失"
  859. break
  860. case "24":
  861. msg = "个人网上挂失"
  862. break
  863. case "25":
  864. msg = "网上服务大厅挂失"
  865. break
  866. case "30":
  867. msg = "注销"
  868. break
  869. case "40":
  870. msg = "回收"
  871. break
  872. case "99":
  873. msg = "制卡中(无效卡)"
  874. break
  875. }
  876. c.ServeSuccessJSON(map[string]interface{}{
  877. "failed_code": -10,
  878. "msg": msg,
  879. })
  880. return
  881. } else {
  882. c.ServeSuccessJSON(map[string]interface{}{
  883. "msg": "校验成功",
  884. })
  885. return
  886. }
  887. }
  888. }
  889. func (c *HisApiController) ReadCard() {
  890. id_card_type, _ := c.GetInt64("id_card_type")
  891. admin_user_id, _ := c.GetInt64("admin_user_id")
  892. certificates, _ := c.GetInt64("certificates")
  893. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  894. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  895. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  896. switch id_card_type {
  897. case 1:
  898. if miConfig.MdtrtareaAdmvs == "421300" {
  899. var res ResultTwo
  900. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  901. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  902. "&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)
  903. resp, requestErr := http.Get(api)
  904. if requestErr != nil {
  905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  906. return
  907. }
  908. body, ioErr := ioutil.ReadAll(resp.Body)
  909. if ioErr != nil {
  910. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  912. return
  913. }
  914. var respJSON map[string]interface{}
  915. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  916. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  918. return
  919. }
  920. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  921. result, _ := json.Marshal(respJSON)
  922. fmt.Println("log")
  923. fmt.Println(string(result))
  924. if err := json.Unmarshal([]byte(result), &res); err != nil {
  925. utils.ErrorLog("解析失败:%v", err)
  926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  927. return
  928. }
  929. if res.Infcode == 0 {
  930. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  931. if err == gorm.ErrRecordNotFound {
  932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  933. return
  934. } else if err != nil {
  935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  936. return
  937. } else {
  938. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  939. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  940. infoStr := string(Iinfos)
  941. idetinfoStr := string(Idetinfos)
  942. psn := &models.HisPsn{
  943. PsnNo: res.Output.Baseinfo.PsnNo,
  944. Age: res.Output.Baseinfo.Age,
  945. PatientId: patient.ID,
  946. Certno: res.Output.Baseinfo.Certno,
  947. Brdy: res.Output.Baseinfo.Brdy,
  948. Gend: res.Output.Baseinfo.Gend,
  949. Naty: res.Output.Baseinfo.Naty,
  950. PsnCertType: res.Output.Baseinfo.PsnCertType,
  951. PsnName: res.Output.Baseinfo.PsnName,
  952. Idetinfo: idetinfoStr,
  953. Insuinfo: infoStr,
  954. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  955. }
  956. service.CreateHisPsn(psn)
  957. c.ServeSuccessJSON(map[string]interface{}{
  958. "patient": patient,
  959. "number": res.Output.Baseinfo.Certno,
  960. })
  961. }
  962. } else {
  963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  964. return
  965. }
  966. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  967. var api string
  968. if miConfig.MdtrtareaAdmvs == "320921" {
  969. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  970. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  971. fmt.Println(api)
  972. } else {
  973. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  974. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  975. }
  976. resp, requestErr := http.Get(api)
  977. if requestErr != nil {
  978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  979. return
  980. }
  981. body, ioErr := ioutil.ReadAll(resp.Body)
  982. if ioErr != nil {
  983. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  985. return
  986. }
  987. var respJSON map[string]interface{}
  988. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  989. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  991. return
  992. }
  993. var status string
  994. status = respJSON["data"].(map[string]interface{})["status"].(string)
  995. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  996. //console.log()
  997. fmt.Println("type===")
  998. fmt.Println(card_type)
  999. var token string
  1000. var res ResultTwo //1101结果
  1001. var res10265 ResultTwo10265 //1101结果
  1002. var card_info string //卡信息
  1003. var busi_card_info string
  1004. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1005. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1006. if status == "0" { //读卡成功
  1007. if card_type == "1" {
  1008. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1009. result, _ := json.Marshal(respJSON)
  1010. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1011. utils.ErrorLog("解析失败:%v", err)
  1012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1013. return
  1014. }
  1015. res.ErrMsg = res10265.ErrMsg
  1016. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1017. res.Infcode = infocode
  1018. res.Output = res10265.Output
  1019. res.InfRefmsgid = res10265.InfRefmsgid
  1020. } else {
  1021. //var card_info string //卡信息
  1022. //var busi_card_info string
  1023. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1024. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1025. //fmt.Println(card_info)
  1026. //fmt.Println(busi_card_info)
  1027. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1028. result, _ := json.Marshal(respJSON)
  1029. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1030. utils.ErrorLog("解析失败:%v", err)
  1031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1032. return
  1033. }
  1034. res.ErrMsg = res10265.ErrMsg
  1035. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1036. res.Infcode = infocode
  1037. res.Output = res10265.Output
  1038. res.InfRefmsgid = res10265.InfRefmsgid
  1039. }
  1040. if res.Infcode == 0 {
  1041. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1042. if err == gorm.ErrRecordNotFound {
  1043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1044. return
  1045. } else if err != nil {
  1046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1047. return
  1048. } else {
  1049. if card_type == "1" {
  1050. bas := strings.Split(card_info, "|")
  1051. basNumber := bas[2]
  1052. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1053. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1054. infoStr := string(Iinfos)
  1055. idetinfoStr := string(Idetinfos)
  1056. psn := &models.HisPsn{
  1057. PsnNo: res.Output.Baseinfo.PsnNo,
  1058. Age: res.Output.Baseinfo.Age,
  1059. PatientId: patient.ID,
  1060. Certno: res.Output.Baseinfo.Certno,
  1061. Brdy: res.Output.Baseinfo.Brdy,
  1062. Gend: res.Output.Baseinfo.Gend,
  1063. Naty: res.Output.Baseinfo.Naty,
  1064. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1065. PsnName: res.Output.Baseinfo.PsnName,
  1066. Idetinfo: idetinfoStr,
  1067. Insuinfo: infoStr,
  1068. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1069. CardInfo: card_info,
  1070. VerifyNumber: busi_card_info,
  1071. }
  1072. service.CreateHisPsn(psn)
  1073. c.ServeSuccessJSON(map[string]interface{}{
  1074. "patient": patient,
  1075. "number": basNumber,
  1076. })
  1077. } else {
  1078. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1079. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1080. infoStr := string(Iinfos)
  1081. idetinfoStr := string(Idetinfos)
  1082. psn := &models.HisPsn{
  1083. PsnNo: res.Output.Baseinfo.PsnNo,
  1084. Age: res.Output.Baseinfo.Age,
  1085. PatientId: patient.ID,
  1086. Certno: res.Output.Baseinfo.Certno,
  1087. Brdy: res.Output.Baseinfo.Brdy,
  1088. Gend: res.Output.Baseinfo.Gend,
  1089. Naty: res.Output.Baseinfo.Naty,
  1090. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1091. PsnName: res.Output.Baseinfo.PsnName,
  1092. Idetinfo: idetinfoStr,
  1093. Insuinfo: infoStr,
  1094. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1095. CardInfo: card_info,
  1096. VerifyNumber: token,
  1097. }
  1098. service.CreateHisPsn(psn)
  1099. c.ServeSuccessJSON(map[string]interface{}{
  1100. "patient": patient,
  1101. "number": token,
  1102. })
  1103. }
  1104. }
  1105. } else {
  1106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1107. return
  1108. }
  1109. } else { //读卡失败
  1110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1111. return
  1112. }
  1113. } else {
  1114. if initFlag == 0 {
  1115. c.TestGetBasBaseInit()
  1116. }
  1117. basStr := c.GetBasBaseInfo()
  1118. if len(basStr) == 0 {
  1119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1120. return
  1121. }
  1122. fmt.Println(basStr)
  1123. bas := strings.Split(basStr, "|")
  1124. basNumber := bas[1]
  1125. fmt.Println(basNumber)
  1126. card_sn := bas[3]
  1127. fmt.Println(card_sn)
  1128. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1129. var dat map[string]interface{}
  1130. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1131. fmt.Println(dat)
  1132. } else {
  1133. fmt.Println(err)
  1134. }
  1135. userJSONBytes, _ := json.Marshal(dat)
  1136. var res ResultTwo
  1137. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1138. utils.ErrorLog("解析失败:%v", err)
  1139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1140. return
  1141. }
  1142. if res.Infcode == 0 {
  1143. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1144. if err == gorm.ErrRecordNotFound {
  1145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1146. return
  1147. } else if err != nil {
  1148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1149. return
  1150. } else {
  1151. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1152. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1153. infoStr := string(Iinfos)
  1154. idetinfoStr := string(Idetinfos)
  1155. psn := &models.HisPsn{
  1156. PsnNo: res.Output.Baseinfo.PsnNo,
  1157. Age: res.Output.Baseinfo.Age,
  1158. PatientId: patient.ID,
  1159. Certno: res.Output.Baseinfo.Certno,
  1160. Brdy: res.Output.Baseinfo.Brdy,
  1161. Gend: res.Output.Baseinfo.Gend,
  1162. Naty: res.Output.Baseinfo.Naty,
  1163. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1164. PsnName: res.Output.Baseinfo.PsnName,
  1165. Idetinfo: idetinfoStr,
  1166. Insuinfo: infoStr,
  1167. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1168. CardInfo: basStr,
  1169. VerifyNumber: "",
  1170. }
  1171. service.CreateHisPsn(psn)
  1172. c.ServeSuccessJSON(map[string]interface{}{
  1173. "patient": patient,
  1174. "number": basNumber,
  1175. })
  1176. }
  1177. } else {
  1178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1179. return
  1180. }
  1181. break
  1182. }
  1183. case 2:
  1184. SFZStr := c.GetSFZBaseInfo()
  1185. id_card_str := strings.Split(SFZStr, "^")
  1186. id_card_number := id_card_str[0]
  1187. card_sn := ""
  1188. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1189. var dat map[string]interface{}
  1190. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1191. fmt.Println(dat)
  1192. } else {
  1193. fmt.Println(err)
  1194. }
  1195. userJSONBytes, _ := json.Marshal(dat)
  1196. var res ResultTwo
  1197. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1198. utils.ErrorLog("解析失败:%v", err)
  1199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1200. return
  1201. }
  1202. if res.Infcode == 0 {
  1203. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1204. if err == gorm.ErrRecordNotFound {
  1205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1206. return
  1207. } else if err != nil {
  1208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1209. return
  1210. } else {
  1211. c.ServeSuccessJSON(map[string]interface{}{
  1212. "patient": patient,
  1213. "number": id_card_number,
  1214. })
  1215. }
  1216. } else {
  1217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1218. return
  1219. }
  1220. break
  1221. case 3:
  1222. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1223. var api string
  1224. if miConfig.MdtrtareaAdmvs == "320921" {
  1225. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1226. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  1227. fmt.Println(api)
  1228. } else {
  1229. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1230. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  1231. }
  1232. resp, requestErr := http.Get(api)
  1233. if requestErr != nil {
  1234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1235. return
  1236. }
  1237. body, ioErr := ioutil.ReadAll(resp.Body)
  1238. if ioErr != nil {
  1239. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1241. return
  1242. }
  1243. var respJSON map[string]interface{}
  1244. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1245. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1247. return
  1248. }
  1249. var status string
  1250. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1251. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1252. var token string
  1253. var res ResultTwo //1101结果
  1254. var res10265 ResultTwo10265 //1101结果
  1255. var card_info string //卡信息
  1256. var busi_card_info string
  1257. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1258. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1259. if status == "0" { //读卡成功
  1260. if card_type == "1" {
  1261. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1262. result, _ := json.Marshal(respJSON)
  1263. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1264. utils.ErrorLog("解析失败:%v", err)
  1265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1266. return
  1267. }
  1268. res.ErrMsg = res10265.ErrMsg
  1269. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1270. res.Infcode = infocode
  1271. res.Output = res10265.Output
  1272. res.InfRefmsgid = res10265.InfRefmsgid
  1273. } else {
  1274. //var card_info string //卡信息
  1275. //var busi_card_info string
  1276. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1277. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1278. //fmt.Println(card_info)
  1279. //fmt.Println(busi_card_info)
  1280. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1281. result, _ := json.Marshal(respJSON)
  1282. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1283. utils.ErrorLog("解析失败:%v", err)
  1284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1285. return
  1286. }
  1287. res.ErrMsg = res10265.ErrMsg
  1288. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1289. res.Infcode = infocode
  1290. res.Output = res10265.Output
  1291. res.InfRefmsgid = res10265.InfRefmsgid
  1292. }
  1293. if res.Infcode == 0 {
  1294. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1295. if err == gorm.ErrRecordNotFound {
  1296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1297. return
  1298. } else if err != nil {
  1299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1300. return
  1301. } else {
  1302. if card_type == "1" {
  1303. bas := strings.Split(card_info, "|")
  1304. basNumber := bas[2]
  1305. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1306. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1307. infoStr := string(Iinfos)
  1308. idetinfoStr := string(Idetinfos)
  1309. psn := &models.HisPsn{
  1310. PsnNo: res.Output.Baseinfo.PsnNo,
  1311. Age: res.Output.Baseinfo.Age,
  1312. PatientId: patient.ID,
  1313. Certno: res.Output.Baseinfo.Certno,
  1314. Brdy: res.Output.Baseinfo.Brdy,
  1315. Gend: res.Output.Baseinfo.Gend,
  1316. Naty: res.Output.Baseinfo.Naty,
  1317. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1318. PsnName: res.Output.Baseinfo.PsnName,
  1319. Idetinfo: idetinfoStr,
  1320. Insuinfo: infoStr,
  1321. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1322. CardInfo: card_info,
  1323. VerifyNumber: busi_card_info,
  1324. }
  1325. service.CreateHisPsn(psn)
  1326. c.ServeSuccessJSON(map[string]interface{}{
  1327. "patient": patient,
  1328. "number": basNumber,
  1329. })
  1330. } else {
  1331. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1332. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1333. infoStr := string(Iinfos)
  1334. idetinfoStr := string(Idetinfos)
  1335. psn := &models.HisPsn{
  1336. PsnNo: res.Output.Baseinfo.PsnNo,
  1337. Age: res.Output.Baseinfo.Age,
  1338. PatientId: patient.ID,
  1339. Certno: res.Output.Baseinfo.Certno,
  1340. Brdy: res.Output.Baseinfo.Brdy,
  1341. Gend: res.Output.Baseinfo.Gend,
  1342. Naty: res.Output.Baseinfo.Naty,
  1343. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1344. PsnName: res.Output.Baseinfo.PsnName,
  1345. Idetinfo: idetinfoStr,
  1346. Insuinfo: infoStr,
  1347. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1348. CardInfo: card_info,
  1349. VerifyNumber: token,
  1350. }
  1351. service.CreateHisPsn(psn)
  1352. c.ServeSuccessJSON(map[string]interface{}{
  1353. "patient": patient,
  1354. "number": token,
  1355. })
  1356. }
  1357. }
  1358. } else {
  1359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1360. return
  1361. }
  1362. } else { //读卡失败
  1363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1364. return
  1365. }
  1366. }
  1367. break
  1368. case 4:
  1369. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1370. var api string
  1371. if miConfig.MdtrtareaAdmvs == "320921" {
  1372. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1373. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  1374. fmt.Println(api)
  1375. } else {
  1376. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1377. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  1378. }
  1379. resp, requestErr := http.Get(api)
  1380. if requestErr != nil {
  1381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1382. return
  1383. }
  1384. body, ioErr := ioutil.ReadAll(resp.Body)
  1385. if ioErr != nil {
  1386. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1388. return
  1389. }
  1390. var respJSON map[string]interface{}
  1391. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1392. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1394. return
  1395. }
  1396. var status string
  1397. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1398. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1399. var token string
  1400. var res ResultTwo //1101结果
  1401. var res10265 ResultTwo10265 //1101结果
  1402. if status == "0" { //读卡成功
  1403. var card_info string //卡信息
  1404. var busi_card_info string
  1405. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1406. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1407. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1408. fmt.Println(card_info)
  1409. fmt.Println(busi_card_info)
  1410. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1411. result, _ := json.Marshal(respJSON)
  1412. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1413. utils.ErrorLog("解析失败:%v", err)
  1414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1415. return
  1416. }
  1417. res.ErrMsg = res10265.ErrMsg
  1418. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1419. res.Infcode = infocode
  1420. res.Output = res10265.Output
  1421. res.InfRefmsgid = res10265.InfRefmsgid
  1422. if res.Infcode == 0 {
  1423. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1424. if err == gorm.ErrRecordNotFound {
  1425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1426. return
  1427. } else if err != nil {
  1428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1429. return
  1430. } else {
  1431. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1432. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1433. infoStr := string(Iinfos)
  1434. idetinfoStr := string(Idetinfos)
  1435. psn := &models.HisPsn{
  1436. PsnNo: res.Output.Baseinfo.PsnNo,
  1437. Age: res.Output.Baseinfo.Age,
  1438. PatientId: patient.ID,
  1439. Certno: res.Output.Baseinfo.Certno,
  1440. Brdy: res.Output.Baseinfo.Brdy,
  1441. Gend: res.Output.Baseinfo.Gend,
  1442. Naty: res.Output.Baseinfo.Naty,
  1443. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1444. PsnName: res.Output.Baseinfo.PsnName,
  1445. Idetinfo: idetinfoStr,
  1446. Insuinfo: infoStr,
  1447. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1448. CardInfo: card_info,
  1449. VerifyNumber: token,
  1450. }
  1451. service.CreateHisPsn(psn)
  1452. c.ServeSuccessJSON(map[string]interface{}{
  1453. "patient": patient,
  1454. "number": token,
  1455. })
  1456. }
  1457. } else {
  1458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1459. return
  1460. }
  1461. } else { //读卡失败
  1462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1463. return
  1464. }
  1465. }
  1466. break
  1467. }
  1468. }
  1469. var initFlag int64 = 0
  1470. func (c *HisApiController) TestGetBasBaseInit() {
  1471. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1472. Iinit := DllDef.MustFindProc("Init")
  1473. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1474. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  1475. if ret != 0 {
  1476. fmt.Println("SSCard的报错原因:", err)
  1477. fmt.Println("SSCard的运算结果为:", ret)
  1478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1479. return
  1480. }
  1481. result := int(ret)
  1482. fmt.Println("SSCard的运算结果为1:", result)
  1483. initFlag = 1
  1484. return
  1485. }
  1486. func (c *HisApiController) GetSFZBaseInfo() string {
  1487. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1488. readCard := DllDef.MustFindProc("ReadSFZ")
  1489. if readCard == nil {
  1490. fmt.Println("readcard is nil")
  1491. readCard = DllDef.MustFindProc("ReadSFZ")
  1492. }
  1493. str := make([]byte, 256)
  1494. str1 := make([]byte, 256)
  1495. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1496. fmt.Println(r)
  1497. return string(str)
  1498. }
  1499. func (c *HisApiController) GetBasBaseInfo() string {
  1500. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1501. readCard := DllDef.MustFindProc("ReadCardBas")
  1502. if readCard == nil {
  1503. fmt.Println("readcard is nil")
  1504. readCard = DllDef.MustFindProc("ReadCardBas")
  1505. }
  1506. str := make([]byte, 1024)
  1507. str1 := make([]byte, 1024)
  1508. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  1509. fmt.Println(string(str1))
  1510. fmt.Println(string(str))
  1511. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1512. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1513. if ret2 != 0 {
  1514. return ""
  1515. }
  1516. return string(str)
  1517. }
  1518. type CustomFundPay struct {
  1519. FundPayType string `json:"fund_pay_type"`
  1520. FundPayamt float64 `json:"fund_payamt"`
  1521. }
  1522. func (c *HisApiController) GetSettleList() {
  1523. order_id, _ := c.GetInt64("order_id")
  1524. admin_user_id, _ := c.GetInt64("admin_user_id")
  1525. order, _ := service.GetHisOrderByIDTwo(order_id)
  1526. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1527. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1528. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1529. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1530. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1531. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1532. if order.ID == 0 {
  1533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1534. return
  1535. }
  1536. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1537. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1538. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1539. fmt.Println(count)
  1540. var zero string
  1541. number := count + 1
  1542. if number >= 1000 {
  1543. zero = "0000" + strconv.FormatInt(number, 10)
  1544. } else if number >= 10000 {
  1545. zero = "000" + strconv.FormatInt(number, 10)
  1546. } else if number >= 100000 {
  1547. zero = "00" + strconv.FormatInt(number, 10)
  1548. } else if number >= 1000000 {
  1549. zero = "0" + strconv.FormatInt(number, 10)
  1550. } else {
  1551. zero = strconv.FormatInt(number, 10)
  1552. }
  1553. fmt.Println(zero)
  1554. struct4101 := service.Struct4101{
  1555. PsnNo: order.PsnNo,
  1556. MdtrtId: order.MdtrtId,
  1557. SetlId: order.SetlId,
  1558. PsnName: order.PsnName,
  1559. Gend: order.Gend,
  1560. Brdy: his.Brdy,
  1561. Age: his.Age,
  1562. Naty: order.Naty,
  1563. PatnCertType: "01",
  1564. Certno: order.Certno,
  1565. Prfs: "90",
  1566. ConerName: roles[0].UserName,
  1567. PatnRlts: "99",
  1568. ConerAddr: miConfig.OrgName,
  1569. ConerTel: admin.Mobile,
  1570. HiType: order.Insutype,
  1571. Insuplc: miConfig.InsuplcAdmdvs,
  1572. MaindiagFlag: "1",
  1573. BillCode: last_order.FaPiaoCode,
  1574. BillNo: zero,
  1575. BizSn: order.Number,
  1576. PsnSelfPay: order.PsnPartAmt,
  1577. PsnOwnPay: order.PsnPartAmt,
  1578. AcctPay: order.AcctPay,
  1579. PsnCashpay: order.PsnCashPay,
  1580. HiPaymtd: "1",
  1581. Hsorg: miConfig.InsuplcAdmdvs,
  1582. HsorgOpter: miConfig.InsuplcAdmdvs,
  1583. MedinsFillPsn: curRoles.UserName,
  1584. MedinsFillDept: depart.Name,
  1585. IptMedType: "2",
  1586. }
  1587. struct4101.SetlBegnDate = order.SetlTime
  1588. struct4101.SetlEndDate = order.SetlTime
  1589. time_arr := strings.Split(order.SetlTime, " ")
  1590. struct4101.AdmTime = time_arr[0]
  1591. struct4101.AdmEndTime = time_arr[0]
  1592. var rf []CustomFundPay
  1593. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1594. var tempFunPays []service.CustomStruct
  1595. for _, item := range rf {
  1596. var tempFunPay service.CustomStruct
  1597. tempFunPay.FundPayamt = item.FundPayamt
  1598. tempFunPay.FundPayType = item.FundPayType
  1599. tempFunPays = append(tempFunPays, tempFunPay)
  1600. }
  1601. struct4101.CustomStruct = tempFunPays
  1602. var tempDiaginfos []service.DiaginfoStructTwo
  1603. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1604. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1605. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  1606. var config []*models.HisXtDiagnoseConfig
  1607. for _, item := range diagnosis_ids {
  1608. id, _ := strconv.ParseInt(item, 10, 64)
  1609. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1610. config = append(config, &diagnosisConfig)
  1611. }
  1612. for index, item := range config {
  1613. if index == 0 {
  1614. var tempDiaginfo service.DiaginfoStructTwo
  1615. tempDiaginfo.DiagCode = item.CountryCode
  1616. tempDiaginfo.DiagName = item.CountryContentName
  1617. tempDiaginfo.DiagType = "1"
  1618. tempDiaginfo.MaindiagFlag = "1"
  1619. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1620. } else {
  1621. var tempDiaginfo service.DiaginfoStructTwo
  1622. tempDiaginfo.DiagCode = item.CountryCode
  1623. tempDiaginfo.DiagName = item.CountryContentName
  1624. tempDiaginfo.DiagType = "2"
  1625. tempDiaginfo.MaindiagFlag = "0"
  1626. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1627. }
  1628. }
  1629. struct4101.Diseinfo = tempDiaginfos
  1630. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1631. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1632. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1633. tempOpspdiseinfo2.OprnOprtCode = ""
  1634. tempOpspdiseinfo2.OprnOprtName = ""
  1635. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1636. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1637. var iteminfo service.IteminfoStruct
  1638. var bedCostTotal float64 = 0 //床位总费
  1639. var bedCostSelfTotal float64 = 0 //床位自费
  1640. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1641. var operationCostTotal float64 = 0 //手术费
  1642. var operationCostSelfTotal float64 = 0 //手术费
  1643. var operationCostPartSelfTotal float64 = 0 //手术费
  1644. var otherCostTotal float64 = 0 //其他费用
  1645. var otherCostSelfTotal float64 = 0 //其他费用
  1646. var otherCostPartSelfTotal float64 = 0 //其他费用
  1647. var materialCostTotal float64 = 0 //材料费
  1648. var materialCostSelfTotal float64 = 0 //材料费
  1649. var materialCostPartSelfTotal float64 = 0 //材料费
  1650. var westernMedicineCostTotal float64 = 0 //西药费
  1651. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1652. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1653. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1654. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1655. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1656. var checkCostTotal float64 = 0 //检查费
  1657. var checkCostSelfTotal float64 = 0 //检查费
  1658. var checkCostPartSelfTotal float64 = 0 //检查费
  1659. var laboratoryCostTotal float64 = 0 //化验费
  1660. var laboratoryCostSelfTotal float64 = 0 //化验费
  1661. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1662. var treatCostTotal float64 = 0 //治疗费用
  1663. var treatCostSelfTotal float64 = 0 //治疗费用
  1664. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1665. decimal.DivisionPrecision = 2
  1666. var bed_fulamt_ownpay_amt float64 = 0
  1667. var operation_fulamt_ownpay_amt float64 = 0
  1668. var other_fulamt_ownpay_amt float64 = 0
  1669. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1670. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1671. var check_fulamt_ownpay_amt float64 = 0
  1672. var material_fulamt_ownpay_amt float64 = 0
  1673. var laboratory_fulamt_ownpay_amt float64 = 0
  1674. var treat_fulamt_ownpay_amt float64 = 0
  1675. var bed_claa_sunmfee float64 = 0
  1676. var bed_clab_amt float64 = 0
  1677. var bed_other_amt float64 = 0
  1678. var operation_claa_sunmfee float64 = 0
  1679. var operation_clab_amt float64 = 0
  1680. var operation_other_amt float64 = 0
  1681. var other_claa_sunmfee float64 = 0
  1682. var other_clab_amt float64 = 0
  1683. var other_other_amt float64 = 0
  1684. var westernMedicine_claa_sunmfee float64 = 0
  1685. var westernMedicine_clab_amt float64 = 0
  1686. var westernMedicine_other_amt float64 = 0
  1687. var chineseTraditional_claa_sunmfee float64 = 0
  1688. var chineseTraditional_clab_amt float64 = 0
  1689. var chineseTraditional_other_amt float64 = 0
  1690. var check_claa_sunmfee float64 = 0
  1691. var check_clab_amt float64 = 0
  1692. var check_other_amt float64 = 0
  1693. var material_claa_sunmfee float64 = 0
  1694. var material_clab_amt float64 = 0
  1695. var material_other_amt float64 = 0
  1696. var laboratory_claa_sunmfee float64 = 0
  1697. var laboratory_clab_amt float64 = 0
  1698. var laboratory_other_amt float64 = 0
  1699. var treat_claa_sunmfee float64 = 0
  1700. var treat_clab_amt float64 = 0
  1701. var treat_other_amt float64 = 0
  1702. for _, item := range order.HisOrderInfo {
  1703. if item.MedChrgitmType == "01" { //床位费
  1704. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1705. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1706. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1707. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1708. if item.ChrgitmLv == "1" {
  1709. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1710. }
  1711. if item.ChrgitmLv == "2" {
  1712. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1713. }
  1714. if item.ChrgitmLv == "3" {
  1715. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1716. }
  1717. }
  1718. if item.MedChrgitmType == "03" { //检查费
  1719. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1720. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1721. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1722. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1723. if item.ChrgitmLv == "1" {
  1724. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1725. }
  1726. if item.ChrgitmLv == "2" {
  1727. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1728. }
  1729. if item.ChrgitmLv == "3" {
  1730. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1731. }
  1732. }
  1733. if item.MedChrgitmType == "04" { //化验费
  1734. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1735. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1736. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1737. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1738. if item.ChrgitmLv == "1" {
  1739. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1740. }
  1741. if item.ChrgitmLv == "2" {
  1742. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1743. }
  1744. if item.ChrgitmLv == "3" {
  1745. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1746. }
  1747. }
  1748. if item.MedChrgitmType == "05" { //治疗费
  1749. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1750. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1751. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1752. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1753. if item.ChrgitmLv == "1" {
  1754. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1755. }
  1756. if item.ChrgitmLv == "2" {
  1757. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1758. }
  1759. if item.ChrgitmLv == "3" {
  1760. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1761. }
  1762. }
  1763. if item.MedChrgitmType == "06" { //手术费
  1764. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1765. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1766. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1767. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1768. if item.ChrgitmLv == "1" {
  1769. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1770. }
  1771. if item.ChrgitmLv == "2" {
  1772. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1773. }
  1774. if item.ChrgitmLv == "3" {
  1775. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1776. }
  1777. }
  1778. if item.MedChrgitmType == "08" { //材料费
  1779. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1780. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1781. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1782. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1783. if item.ChrgitmLv == "1" {
  1784. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1785. }
  1786. if item.ChrgitmLv == "2" {
  1787. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1788. }
  1789. if item.ChrgitmLv == "3" {
  1790. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1791. }
  1792. }
  1793. if item.MedChrgitmType == "09" { //西药费
  1794. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1795. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1796. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1797. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1798. if item.ChrgitmLv == "1" {
  1799. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1800. }
  1801. if item.ChrgitmLv == "2" {
  1802. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1803. }
  1804. if item.ChrgitmLv == "3" {
  1805. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1806. }
  1807. }
  1808. if item.MedChrgitmType == "11" { //中成费
  1809. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1810. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1811. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1812. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1813. if item.ChrgitmLv == "1" {
  1814. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1815. }
  1816. if item.ChrgitmLv == "2" {
  1817. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1818. }
  1819. if item.ChrgitmLv == "3" {
  1820. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1821. }
  1822. }
  1823. if item.MedChrgitmType == "14" { //其他费
  1824. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1825. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1826. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1827. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1828. if item.ChrgitmLv == "1" {
  1829. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1830. }
  1831. if item.ChrgitmLv == "2" {
  1832. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1833. }
  1834. if item.ChrgitmLv == "3" {
  1835. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1836. }
  1837. }
  1838. }
  1839. var iteminfoStructs []service.IteminfoStruct
  1840. if bedCostTotal != 0 {
  1841. iteminfo.MedChrgitm = "01"
  1842. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1843. iteminfo.Amt = bedCostTotal
  1844. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1845. iteminfo.ClabAmt = bed_clab_amt
  1846. iteminfo.OthAmt = bed_other_amt
  1847. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1848. }
  1849. if checkCostTotal != 0 {
  1850. iteminfo.MedChrgitm = "03"
  1851. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1852. iteminfo.Amt = checkCostTotal
  1853. iteminfo.ClaaSumfee = check_claa_sunmfee
  1854. iteminfo.ClabAmt = check_clab_amt
  1855. iteminfo.OthAmt = check_other_amt
  1856. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1857. }
  1858. if laboratoryCostTotal != 0 {
  1859. iteminfo.MedChrgitm = "04"
  1860. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1861. iteminfo.Amt = laboratoryCostTotal
  1862. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1863. iteminfo.ClabAmt = laboratory_clab_amt
  1864. iteminfo.OthAmt = laboratory_other_amt
  1865. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1866. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1867. }
  1868. if treatCostTotal != 0 {
  1869. iteminfo.MedChrgitm = "05"
  1870. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1871. iteminfo.Amt = treatCostTotal
  1872. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1873. iteminfo.ClabAmt = treat_clab_amt
  1874. iteminfo.OthAmt = treat_other_amt
  1875. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1876. //(struct4101.IteminfoStruct, iteminfo)
  1877. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1878. }
  1879. if operationCostTotal != 0 {
  1880. iteminfo.MedChrgitm = "06"
  1881. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1882. iteminfo.Amt = operationCostTotal
  1883. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1884. iteminfo.ClabAmt = operation_clab_amt
  1885. iteminfo.OthAmt = operation_other_amt
  1886. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1887. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1888. }
  1889. if materialCostTotal != 0 {
  1890. iteminfo.MedChrgitm = "08"
  1891. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1892. iteminfo.Amt = materialCostTotal
  1893. iteminfo.ClaaSumfee = material_claa_sunmfee
  1894. iteminfo.ClabAmt = material_clab_amt
  1895. iteminfo.OthAmt = material_other_amt
  1896. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1897. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1898. }
  1899. if westernMedicineCostTotal != 0 {
  1900. iteminfo.MedChrgitm = "09"
  1901. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1902. iteminfo.Amt = westernMedicineCostTotal
  1903. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1904. iteminfo.ClabAmt = westernMedicine_clab_amt
  1905. iteminfo.OthAmt = westernMedicine_other_amt
  1906. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1907. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1908. }
  1909. if chineseTraditionalMedicineCostTotal != 0 {
  1910. iteminfo.MedChrgitm = "11"
  1911. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1912. iteminfo.Amt = westernMedicineCostTotal
  1913. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1914. iteminfo.ClabAmt = westernMedicine_clab_amt
  1915. iteminfo.OthAmt = westernMedicine_other_amt
  1916. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1917. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1918. }
  1919. if otherCostTotal != 0 {
  1920. iteminfo.MedChrgitm = "14"
  1921. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1922. iteminfo.Amt = otherCostTotal
  1923. iteminfo.ClaaSumfee = other_claa_sunmfee
  1924. iteminfo.ClabAmt = other_clab_amt
  1925. iteminfo.OthAmt = other_other_amt
  1926. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1927. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1928. }
  1929. struct4101.IteminfoStruct = iteminfoStructs
  1930. struct4101.Ntly = "中国"
  1931. struct4101.AdmCaty = "A03.06"
  1932. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  1933. fmt.Println(result)
  1934. var dat map[string]interface{}
  1935. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1936. fmt.Println(dat)
  1937. } else {
  1938. fmt.Println(err)
  1939. }
  1940. userJSONBytes, _ := json.Marshal(dat)
  1941. var res ResultSeventeen
  1942. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1943. utils.ErrorLog("解析失败:%v", err)
  1944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1945. return
  1946. }
  1947. if res.Infcode != 0 {
  1948. c.ServeSuccessJSON(map[string]interface{}{
  1949. "failed_code": -10,
  1950. "msg": res.ErrMsg,
  1951. })
  1952. return
  1953. } else {
  1954. order.FaPiaoNumber = zero
  1955. order.FaPiaoCode = last_order.FaPiaoCode
  1956. service.UpdateOrder(order)
  1957. hisFundSettleListResult := &models.HisFundSettleListResult{
  1958. Number: res.Output.SetlListId,
  1959. Status: 1,
  1960. Ctime: time.Now().Unix(),
  1961. Mtime: time.Now().Unix(),
  1962. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1963. IsUpload: 1,
  1964. OrderId: order_id,
  1965. }
  1966. service.CreateUploadRecord(hisFundSettleListResult)
  1967. c.ServeSuccessJSON(map[string]interface{}{
  1968. "msg": "上传成功",
  1969. "result": hisFundSettleListResult,
  1970. })
  1971. return
  1972. }
  1973. }
  1974. func (c *HisApiController) GetSettleListHospital() {
  1975. order_id, _ := c.GetInt64("order_id")
  1976. admin_user_id, _ := c.GetInt64("admin_user_id")
  1977. order, _ := service.GetHisOrderByIDTwo(order_id)
  1978. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1979. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1980. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1981. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1982. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1983. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1984. if order.ID == 0 {
  1985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1986. return
  1987. }
  1988. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1989. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1990. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1991. fmt.Println(count)
  1992. var zero string
  1993. number := count + 1
  1994. if number >= 1000 {
  1995. zero = "0000" + strconv.FormatInt(number, 10)
  1996. } else if number >= 10000 {
  1997. zero = "000" + strconv.FormatInt(number, 10)
  1998. } else if number >= 100000 {
  1999. zero = "00" + strconv.FormatInt(number, 10)
  2000. } else if number >= 1000000 {
  2001. zero = "0" + strconv.FormatInt(number, 10)
  2002. } else {
  2003. zero = strconv.FormatInt(number, 10)
  2004. }
  2005. fmt.Println(zero)
  2006. struct4101 := service.Struct4101{
  2007. PsnNo: order.PsnNo,
  2008. MdtrtId: order.MdtrtId,
  2009. SetlId: order.SetlId,
  2010. PsnName: order.PsnName,
  2011. Gend: order.Gend,
  2012. Brdy: his.Brdy,
  2013. Age: int64(order.Age),
  2014. Naty: order.Naty,
  2015. PatnCertType: "01",
  2016. Certno: order.Certno,
  2017. Prfs: "90",
  2018. ConerName: roles[0].UserName,
  2019. PatnRlts: "99",
  2020. ConerAddr: miConfig.OrgName,
  2021. ConerTel: admin.Mobile,
  2022. HiType: order.Insutype,
  2023. Insuplc: miConfig.InsuplcAdmdvs,
  2024. MaindiagFlag: "1",
  2025. BillCode: last_order.FaPiaoCode,
  2026. BillNo: zero,
  2027. BizSn: order.Number,
  2028. PsnSelfPay: order.PsnPartAmt,
  2029. PsnOwnPay: order.PsnPartAmt,
  2030. AcctPay: order.AcctPay,
  2031. PsnCashpay: order.PsnCashPay,
  2032. HiPaymtd: "1",
  2033. Hsorg: miConfig.InsuplcAdmdvs,
  2034. HsorgOpter: miConfig.InsuplcAdmdvs,
  2035. MedinsFillPsn: curRoles.UserName,
  2036. MedinsFillDept: depart.Name,
  2037. IptMedType: "2",
  2038. AdmTime: his.InHosptialTime,
  2039. AdmEndTime: his.OutHosptialTime,
  2040. }
  2041. struct4101.SetlBegnDate = order.SetlTime
  2042. struct4101.SetlEndDate = order.SetlTime
  2043. var rf []CustomFundPay
  2044. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2045. var tempFunPays []service.CustomStruct
  2046. for _, item := range rf {
  2047. var tempFunPay service.CustomStruct
  2048. tempFunPay.FundPayamt = item.FundPayamt
  2049. tempFunPay.FundPayType = item.FundPayType
  2050. tempFunPays = append(tempFunPays, tempFunPay)
  2051. }
  2052. struct4101.CustomStruct = tempFunPays
  2053. var tempDiaginfos []service.DiaginfoStructTwo
  2054. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2055. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2056. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2057. var config []*models.HisXtDiagnoseConfig
  2058. for _, item := range diagnosis_ids {
  2059. id, _ := strconv.ParseInt(item, 10, 64)
  2060. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2061. config = append(config, &diagnosisConfig)
  2062. }
  2063. for index, item := range config {
  2064. if index == 0 {
  2065. var tempDiaginfo service.DiaginfoStructTwo
  2066. tempDiaginfo.DiagCode = item.CountryCode
  2067. tempDiaginfo.DiagName = item.CountryContentName
  2068. tempDiaginfo.DiagType = "1"
  2069. tempDiaginfo.MaindiagFlag = "1"
  2070. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2071. } else {
  2072. var tempDiaginfo service.DiaginfoStructTwo
  2073. tempDiaginfo.DiagCode = item.CountryCode
  2074. tempDiaginfo.DiagName = item.CountryContentName
  2075. tempDiaginfo.DiagType = "2"
  2076. tempDiaginfo.MaindiagFlag = "0"
  2077. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2078. }
  2079. }
  2080. struct4101.Diseinfo = tempDiaginfos
  2081. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2082. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2083. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2084. tempOpspdiseinfo2.OprnOprtCode = ""
  2085. tempOpspdiseinfo2.OprnOprtName = ""
  2086. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2087. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2088. var iteminfo service.IteminfoStruct
  2089. var bedCostTotal float64 = 0 //床位总费
  2090. var bedCostSelfTotal float64 = 0 //床位自费
  2091. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2092. var operationCostTotal float64 = 0 //手术费
  2093. var operationCostSelfTotal float64 = 0 //手术费
  2094. var operationCostPartSelfTotal float64 = 0 //手术费
  2095. var otherCostTotal float64 = 0 //其他费用
  2096. var otherCostSelfTotal float64 = 0 //其他费用
  2097. var otherCostPartSelfTotal float64 = 0 //其他费用
  2098. var materialCostTotal float64 = 0 //材料费
  2099. var materialCostSelfTotal float64 = 0 //材料费
  2100. var materialCostPartSelfTotal float64 = 0 //材料费
  2101. var westernMedicineCostTotal float64 = 0 //西药费
  2102. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2103. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2104. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2105. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2106. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2107. var checkCostTotal float64 = 0 //检查费
  2108. var checkCostSelfTotal float64 = 0 //检查费
  2109. var checkCostPartSelfTotal float64 = 0 //检查费
  2110. var laboratoryCostTotal float64 = 0 //化验费
  2111. var laboratoryCostSelfTotal float64 = 0 //化验费
  2112. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2113. var treatCostTotal float64 = 0 //治疗费用
  2114. var treatCostSelfTotal float64 = 0 //治疗费用
  2115. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2116. decimal.DivisionPrecision = 2
  2117. var bed_fulamt_ownpay_amt float64 = 0
  2118. var operation_fulamt_ownpay_amt float64 = 0
  2119. var other_fulamt_ownpay_amt float64 = 0
  2120. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2121. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2122. var check_fulamt_ownpay_amt float64 = 0
  2123. var material_fulamt_ownpay_amt float64 = 0
  2124. var laboratory_fulamt_ownpay_amt float64 = 0
  2125. var treat_fulamt_ownpay_amt float64 = 0
  2126. var bed_claa_sunmfee float64 = 0
  2127. var bed_clab_amt float64 = 0
  2128. var bed_other_amt float64 = 0
  2129. var operation_claa_sunmfee float64 = 0
  2130. var operation_clab_amt float64 = 0
  2131. var operation_other_amt float64 = 0
  2132. var other_claa_sunmfee float64 = 0
  2133. var other_clab_amt float64 = 0
  2134. var other_other_amt float64 = 0
  2135. var westernMedicine_claa_sunmfee float64 = 0
  2136. var westernMedicine_clab_amt float64 = 0
  2137. var westernMedicine_other_amt float64 = 0
  2138. var chineseTraditional_claa_sunmfee float64 = 0
  2139. var chineseTraditional_clab_amt float64 = 0
  2140. var chineseTraditional_other_amt float64 = 0
  2141. var check_claa_sunmfee float64 = 0
  2142. var check_clab_amt float64 = 0
  2143. var check_other_amt float64 = 0
  2144. var material_claa_sunmfee float64 = 0
  2145. var material_clab_amt float64 = 0
  2146. var material_other_amt float64 = 0
  2147. var laboratory_claa_sunmfee float64 = 0
  2148. var laboratory_clab_amt float64 = 0
  2149. var laboratory_other_amt float64 = 0
  2150. var treat_claa_sunmfee float64 = 0
  2151. var treat_clab_amt float64 = 0
  2152. var treat_other_amt float64 = 0
  2153. for _, item := range order.HisOrderInfo {
  2154. if item.MedChrgitmType == "01" { //床位费
  2155. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2156. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2157. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2158. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2159. if item.ChrgitmLv == "1" {
  2160. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2161. }
  2162. if item.ChrgitmLv == "2" {
  2163. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2164. }
  2165. if item.ChrgitmLv == "3" {
  2166. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2167. }
  2168. }
  2169. if item.MedChrgitmType == "03" { //检查费
  2170. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2171. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2172. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2173. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2174. if item.ChrgitmLv == "1" {
  2175. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2176. }
  2177. if item.ChrgitmLv == "2" {
  2178. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2179. }
  2180. if item.ChrgitmLv == "3" {
  2181. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2182. }
  2183. }
  2184. if item.MedChrgitmType == "04" { //化验费
  2185. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2186. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2187. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2188. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2189. if item.ChrgitmLv == "1" {
  2190. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2191. }
  2192. if item.ChrgitmLv == "2" {
  2193. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2194. }
  2195. if item.ChrgitmLv == "3" {
  2196. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2197. }
  2198. }
  2199. if item.MedChrgitmType == "05" { //治疗费
  2200. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2201. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2202. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2203. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2204. if item.ChrgitmLv == "1" {
  2205. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2206. }
  2207. if item.ChrgitmLv == "2" {
  2208. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2209. }
  2210. if item.ChrgitmLv == "3" {
  2211. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2212. }
  2213. }
  2214. if item.MedChrgitmType == "06" { //手术费
  2215. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2216. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2217. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2218. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2219. if item.ChrgitmLv == "1" {
  2220. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2221. }
  2222. if item.ChrgitmLv == "2" {
  2223. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2224. }
  2225. if item.ChrgitmLv == "3" {
  2226. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2227. }
  2228. }
  2229. if item.MedChrgitmType == "08" { //材料费
  2230. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2231. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2232. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2233. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2234. if item.ChrgitmLv == "1" {
  2235. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2236. }
  2237. if item.ChrgitmLv == "2" {
  2238. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2239. }
  2240. if item.ChrgitmLv == "3" {
  2241. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2242. }
  2243. }
  2244. if item.MedChrgitmType == "09" { //西药费
  2245. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2246. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2247. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2248. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2249. if item.ChrgitmLv == "1" {
  2250. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2251. }
  2252. if item.ChrgitmLv == "2" {
  2253. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2254. }
  2255. if item.ChrgitmLv == "3" {
  2256. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2257. }
  2258. }
  2259. if item.MedChrgitmType == "11" { //中成费
  2260. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2261. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2262. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2263. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2264. if item.ChrgitmLv == "1" {
  2265. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2266. }
  2267. if item.ChrgitmLv == "2" {
  2268. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2269. }
  2270. if item.ChrgitmLv == "3" {
  2271. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2272. }
  2273. }
  2274. if item.MedChrgitmType == "14" { //其他费
  2275. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2276. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2277. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2278. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2279. if item.ChrgitmLv == "1" {
  2280. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2281. }
  2282. if item.ChrgitmLv == "2" {
  2283. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2284. }
  2285. if item.ChrgitmLv == "3" {
  2286. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2287. }
  2288. }
  2289. }
  2290. var iteminfoStructs []service.IteminfoStruct
  2291. if bedCostTotal != 0 {
  2292. iteminfo.MedChrgitm = "01"
  2293. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2294. iteminfo.Amt = bedCostTotal
  2295. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2296. iteminfo.ClabAmt = bed_clab_amt
  2297. iteminfo.OthAmt = bed_other_amt
  2298. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2299. }
  2300. if checkCostTotal != 0 {
  2301. iteminfo.MedChrgitm = "03"
  2302. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2303. iteminfo.Amt = checkCostTotal
  2304. iteminfo.ClaaSumfee = check_claa_sunmfee
  2305. iteminfo.ClabAmt = check_clab_amt
  2306. iteminfo.OthAmt = check_other_amt
  2307. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2308. }
  2309. if laboratoryCostTotal != 0 {
  2310. iteminfo.MedChrgitm = "04"
  2311. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2312. iteminfo.Amt = laboratoryCostTotal
  2313. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2314. iteminfo.ClabAmt = laboratory_clab_amt
  2315. iteminfo.OthAmt = laboratory_other_amt
  2316. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2317. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2318. }
  2319. if treatCostTotal != 0 {
  2320. iteminfo.MedChrgitm = "05"
  2321. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2322. iteminfo.Amt = treatCostTotal
  2323. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2324. iteminfo.ClabAmt = treat_clab_amt
  2325. iteminfo.OthAmt = treat_other_amt
  2326. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2327. //(struct4101.IteminfoStruct, iteminfo)
  2328. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2329. }
  2330. if operationCostTotal != 0 {
  2331. iteminfo.MedChrgitm = "06"
  2332. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2333. iteminfo.Amt = operationCostTotal
  2334. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2335. iteminfo.ClabAmt = operation_clab_amt
  2336. iteminfo.OthAmt = operation_other_amt
  2337. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2338. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2339. }
  2340. if materialCostTotal != 0 {
  2341. iteminfo.MedChrgitm = "08"
  2342. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2343. iteminfo.Amt = materialCostTotal
  2344. iteminfo.ClaaSumfee = material_claa_sunmfee
  2345. iteminfo.ClabAmt = material_clab_amt
  2346. iteminfo.OthAmt = material_other_amt
  2347. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2348. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2349. }
  2350. if westernMedicineCostTotal != 0 {
  2351. iteminfo.MedChrgitm = "09"
  2352. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2353. iteminfo.Amt = westernMedicineCostTotal
  2354. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2355. iteminfo.ClabAmt = westernMedicine_clab_amt
  2356. iteminfo.OthAmt = westernMedicine_other_amt
  2357. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2358. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2359. }
  2360. if chineseTraditionalMedicineCostTotal != 0 {
  2361. iteminfo.MedChrgitm = "11"
  2362. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2363. iteminfo.Amt = westernMedicineCostTotal
  2364. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2365. iteminfo.ClabAmt = westernMedicine_clab_amt
  2366. iteminfo.OthAmt = westernMedicine_other_amt
  2367. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2368. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2369. }
  2370. if otherCostTotal != 0 {
  2371. iteminfo.MedChrgitm = "14"
  2372. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2373. iteminfo.Amt = otherCostTotal
  2374. iteminfo.ClaaSumfee = other_claa_sunmfee
  2375. iteminfo.ClabAmt = other_clab_amt
  2376. iteminfo.OthAmt = other_other_amt
  2377. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2378. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2379. }
  2380. struct4101.IteminfoStruct = iteminfoStructs
  2381. struct4101.Ntly = "中国"
  2382. struct4101.AdmCaty = "A03.06"
  2383. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2384. fmt.Println(result)
  2385. var dat map[string]interface{}
  2386. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2387. fmt.Println(dat)
  2388. } else {
  2389. fmt.Println(err)
  2390. }
  2391. userJSONBytes, _ := json.Marshal(dat)
  2392. var res ResultSeventeen
  2393. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2394. utils.ErrorLog("解析失败:%v", err)
  2395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2396. return
  2397. }
  2398. if res.Infcode != 0 {
  2399. c.ServeSuccessJSON(map[string]interface{}{
  2400. "failed_code": -10,
  2401. "msg": res.ErrMsg,
  2402. })
  2403. return
  2404. } else {
  2405. order.FaPiaoNumber = zero
  2406. order.FaPiaoCode = last_order.FaPiaoCode
  2407. service.UpdateOrder(order)
  2408. hisFundSettleListResult := &models.HisFundSettleListResult{
  2409. Number: res.Output.SetlListId,
  2410. Status: 1,
  2411. Ctime: time.Now().Unix(),
  2412. Mtime: time.Now().Unix(),
  2413. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2414. IsUpload: 1,
  2415. OrderId: order_id,
  2416. }
  2417. service.CreateUploadRecord(hisFundSettleListResult)
  2418. c.ServeSuccessJSON(map[string]interface{}{
  2419. "msg": "上传成功",
  2420. "result": hisFundSettleListResult,
  2421. })
  2422. return
  2423. }
  2424. }
  2425. func (c *HisApiController) GetBatchSettleList() {
  2426. orders, _ := service.GetAllHisOrder(10106)
  2427. for _, item := range orders {
  2428. order_id := item.ID
  2429. order, _ := service.GetHisOrderByIDTwo(order_id)
  2430. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2431. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2432. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2433. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  2434. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2435. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2436. if order.ID == 0 {
  2437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2438. return
  2439. }
  2440. if his.BalanceAccountsType == 2 {
  2441. continue
  2442. }
  2443. struct4101 := service.Struct4101{
  2444. PsnNo: order.PsnNo,
  2445. MdtrtId: order.MdtrtId,
  2446. SetlId: order.SetlId,
  2447. PsnName: order.PsnName,
  2448. Gend: order.Gend,
  2449. Brdy: his.Brdy,
  2450. Age: his.Age,
  2451. Naty: order.Naty,
  2452. PatnCertType: "01",
  2453. Certno: order.Certno,
  2454. Prfs: "90",
  2455. ConerName: roles[0].UserName,
  2456. PatnRlts: "99",
  2457. ConerAddr: miConfig.OrgName,
  2458. ConerTel: admin.Mobile,
  2459. HiType: order.Insutype,
  2460. Insuplc: his.InsuplcAdmdvs,
  2461. MaindiagFlag: "1",
  2462. BillCode: order.FaPiaoCode,
  2463. BillNo: order.FaPiaoNumber,
  2464. BizSn: order.Number,
  2465. PsnSelfPay: order.PsnPartAmt,
  2466. PsnOwnPay: order.PsnPartAmt,
  2467. AcctPay: order.AcctPay,
  2468. PsnCashpay: order.PsnCashPay,
  2469. HiPaymtd: "1",
  2470. Hsorg: his.InsuplcAdmdvs,
  2471. HsorgOpter: his.InsuplcAdmdvs,
  2472. MedinsFillPsn: curRoles.UserName,
  2473. MedinsFillDept: depart.Name,
  2474. IptMedType: "2",
  2475. }
  2476. struct4101.SetlBegnDate = order.SetlTime
  2477. struct4101.SetlEndDate = order.SetlTime
  2478. //if order.SettleType == 1 {
  2479. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  2480. // dateStr := t.Format("2006-01-02")
  2481. // struct4101.SetlBegnDate = dateStr
  2482. // struct4101.SetlEndDate = dateStr
  2483. //} else {
  2484. // t := time.Unix(int64(order.SettleStartTime), 0)
  2485. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  2486. // dateStartStr := t.Format("2006-01-02")
  2487. // dateEndStr := t2.Format("2006-01-02")
  2488. // struct4101.SetlBegnDate = dateStartStr
  2489. // struct4101.SetlEndDate = dateEndStr
  2490. //}
  2491. var rf []CustomFundPay
  2492. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2493. var tempFunPays []service.CustomStruct
  2494. var tempFunPay610100 service.CustomStruct
  2495. for _, item := range rf {
  2496. if item.FundPayType == "610100" {
  2497. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  2498. tempFunPay610100.FundPayType = item.FundPayType
  2499. } else {
  2500. var tempFunPay service.CustomStruct
  2501. tempFunPay.FundPayamt = item.FundPayamt
  2502. tempFunPay.FundPayType = item.FundPayType
  2503. tempFunPays = append(tempFunPays, tempFunPay)
  2504. }
  2505. }
  2506. tempFunPays = append(tempFunPays, tempFunPay610100)
  2507. struct4101.CustomStruct = tempFunPays
  2508. var tempDiaginfos []service.DiaginfoStructTwo
  2509. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2510. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2511. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2512. var config []*models.HisXtDiagnoseConfig
  2513. for _, item := range diagnosis_ids {
  2514. id, _ := strconv.ParseInt(item, 10, 64)
  2515. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2516. config = append(config, &diagnosisConfig)
  2517. }
  2518. for index, item := range config {
  2519. if index == 0 {
  2520. var tempDiaginfo service.DiaginfoStructTwo
  2521. tempDiaginfo.DiagCode = item.CountryCode
  2522. tempDiaginfo.DiagName = item.CountryContentName
  2523. tempDiaginfo.DiagType = "1"
  2524. tempDiaginfo.MaindiagFlag = "1"
  2525. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2526. } else {
  2527. var tempDiaginfo service.DiaginfoStructTwo
  2528. tempDiaginfo.DiagCode = item.CountryCode
  2529. tempDiaginfo.DiagName = item.CountryContentName
  2530. tempDiaginfo.DiagType = "2"
  2531. tempDiaginfo.MaindiagFlag = "0"
  2532. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2533. }
  2534. }
  2535. struct4101.Diseinfo = tempDiaginfos
  2536. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2537. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2538. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2539. tempOpspdiseinfo2.OprnOprtCode = ""
  2540. tempOpspdiseinfo2.OprnOprtName = ""
  2541. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2542. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2543. var iteminfo service.IteminfoStruct
  2544. var bedCostTotal float64 = 0 //床位总费
  2545. var bedCostSelfTotal float64 = 0 //床位自费
  2546. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2547. var examineCostTotal float64 = 0 //诊查总费
  2548. var examineCostSelfTotal float64 = 0 //诊查自费
  2549. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  2550. var nursingCostTotal float64 = 0 //护理总费
  2551. var nursingCostSelfTotal float64 = 0 //护理自费
  2552. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  2553. var chineseMedicineCostTotal float64 = 0 //中成药
  2554. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  2555. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  2556. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  2557. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  2558. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  2559. var registerCostTotal float64 = 0 //一般诊疗费
  2560. var registerCostSelfTotal float64 = 0 //一般诊疗费
  2561. var registerPartSelfTotal float64 = 0 //一般诊疗费
  2562. var operationCostTotal float64 = 0 //手术费
  2563. var operationCostSelfTotal float64 = 0 //手术费
  2564. var operationCostPartSelfTotal float64 = 0 //手术费
  2565. var otherCostTotal float64 = 0 //其他费用
  2566. var otherCostSelfTotal float64 = 0 //其他费用
  2567. var otherCostPartSelfTotal float64 = 0 //其他费用
  2568. var materialCostTotal float64 = 0 //材料费
  2569. var materialCostSelfTotal float64 = 0 //材料费
  2570. var materialCostPartSelfTotal float64 = 0 //材料费
  2571. var westernMedicineCostTotal float64 = 0 //西药费
  2572. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2573. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2574. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2575. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2576. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2577. var checkCostTotal float64 = 0 //检查费
  2578. var checkCostSelfTotal float64 = 0 //检查费
  2579. var checkCostPartSelfTotal float64 = 0 //检查费
  2580. var laboratoryCostTotal float64 = 0 //化验费
  2581. var laboratoryCostSelfTotal float64 = 0 //化验费
  2582. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2583. var treatCostTotal float64 = 0 //治疗费用
  2584. var treatCostSelfTotal float64 = 0 //治疗费用
  2585. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2586. decimal.DivisionPrecision = 2
  2587. var bed_fulamt_ownpay_amt float64 = 0
  2588. var examine_fulamt_ownpay_amt float64 = 0
  2589. var nursing_fulamt_ownpay_amt float64 = 0
  2590. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  2591. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  2592. var register_fulamt_ownpay_amt float64 = 0
  2593. var operation_fulamt_ownpay_amt float64 = 0
  2594. var other_fulamt_ownpay_amt float64 = 0
  2595. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2596. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2597. var check_fulamt_ownpay_amt float64 = 0
  2598. var material_fulamt_ownpay_amt float64 = 0
  2599. var laboratory_fulamt_ownpay_amt float64 = 0
  2600. var treat_fulamt_ownpay_amt float64 = 0
  2601. var bed_claa_sunmfee float64 = 0
  2602. var bed_clab_amt float64 = 0
  2603. var bed_other_amt float64 = 0
  2604. var examine_claa_sunmfee float64 = 0
  2605. var examine_clab_amt float64 = 0
  2606. var examine_other_amt float64 = 0
  2607. var nursing_claa_sunmfee float64 = 0
  2608. var nursing_clab_amt float64 = 0
  2609. var nursing_other_amt float64 = 0
  2610. var chinese_medicine_claa_sunmfee float64 = 0
  2611. var chinese_medicine_clab_amt float64 = 0
  2612. var chinese_medicine_other_amt float64 = 0
  2613. var commonly_treatment_claa_sunmfee float64 = 0
  2614. var commonly_treatment_clab_amt float64 = 0
  2615. var commonly_treatment_other_amt float64 = 0
  2616. var operation_claa_sunmfee float64 = 0
  2617. var operation_clab_amt float64 = 0
  2618. var operation_other_amt float64 = 0
  2619. var other_claa_sunmfee float64 = 0
  2620. var other_clab_amt float64 = 0
  2621. var other_other_amt float64 = 0
  2622. var westernMedicine_claa_sunmfee float64 = 0
  2623. var westernMedicine_clab_amt float64 = 0
  2624. var westernMedicine_other_amt float64 = 0
  2625. var chineseTraditional_claa_sunmfee float64 = 0
  2626. var chineseTraditional_clab_amt float64 = 0
  2627. var chineseTraditional_other_amt float64 = 0
  2628. var check_claa_sunmfee float64 = 0
  2629. var check_clab_amt float64 = 0
  2630. var check_other_amt float64 = 0
  2631. var material_claa_sunmfee float64 = 0
  2632. var material_clab_amt float64 = 0
  2633. var material_other_amt float64 = 0
  2634. var laboratory_claa_sunmfee float64 = 0
  2635. var laboratory_clab_amt float64 = 0
  2636. var laboratory_other_amt float64 = 0
  2637. var treat_claa_sunmfee float64 = 0
  2638. var treat_clab_amt float64 = 0
  2639. var treat_other_amt float64 = 0
  2640. var register_claa_sunmfee float64 = 0
  2641. var register_clab_amt float64 = 0
  2642. var register_other_amt float64 = 0
  2643. for _, item := range order.HisOrderInfo {
  2644. if item.MedChrgitmType == "01" { //床位费
  2645. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2646. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2647. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2648. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2649. if item.ChrgitmLv == "1" {
  2650. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2651. }
  2652. if item.ChrgitmLv == "2" {
  2653. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2654. }
  2655. if item.ChrgitmLv == "3" {
  2656. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2657. }
  2658. }
  2659. if item.MedChrgitmType == "02" { //诊查
  2660. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2661. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2662. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2663. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2664. if item.ChrgitmLv == "1" {
  2665. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2666. }
  2667. if item.ChrgitmLv == "2" {
  2668. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2669. }
  2670. if item.ChrgitmLv == "3" {
  2671. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2672. }
  2673. }
  2674. if item.MedChrgitmType == "03" { //检查费
  2675. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2676. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2677. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2678. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2679. if item.ChrgitmLv == "1" {
  2680. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2681. }
  2682. if item.ChrgitmLv == "2" {
  2683. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2684. }
  2685. if item.ChrgitmLv == "3" {
  2686. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2687. }
  2688. }
  2689. if item.MedChrgitmType == "04" { //化验费
  2690. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2691. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2692. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2693. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2694. if item.ChrgitmLv == "1" {
  2695. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2696. }
  2697. if item.ChrgitmLv == "2" {
  2698. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2699. }
  2700. if item.ChrgitmLv == "3" {
  2701. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2702. }
  2703. }
  2704. if item.MedChrgitmType == "05" { //治疗费
  2705. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2706. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2707. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2708. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2709. if item.ChrgitmLv == "1" {
  2710. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2711. }
  2712. if item.ChrgitmLv == "2" {
  2713. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2714. }
  2715. if item.ChrgitmLv == "3" {
  2716. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2717. }
  2718. }
  2719. if item.MedChrgitmType == "06" { //手术费
  2720. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2721. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2722. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2723. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2724. if item.ChrgitmLv == "1" {
  2725. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2726. }
  2727. if item.ChrgitmLv == "2" {
  2728. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2729. }
  2730. if item.ChrgitmLv == "3" {
  2731. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2732. }
  2733. }
  2734. if item.MedChrgitmType == "07" { //手术费
  2735. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2736. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2737. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2738. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2739. if item.ChrgitmLv == "1" {
  2740. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2741. }
  2742. if item.ChrgitmLv == "2" {
  2743. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2744. }
  2745. if item.ChrgitmLv == "3" {
  2746. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2747. }
  2748. }
  2749. if item.MedChrgitmType == "08" { //材料费
  2750. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2751. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2752. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2753. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2754. if item.ChrgitmLv == "1" {
  2755. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2756. }
  2757. if item.ChrgitmLv == "2" {
  2758. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2759. }
  2760. if item.ChrgitmLv == "3" {
  2761. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2762. }
  2763. }
  2764. if item.MedChrgitmType == "09" { //西药费
  2765. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2766. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2767. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2768. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2769. if item.ChrgitmLv == "1" {
  2770. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2771. }
  2772. if item.ChrgitmLv == "2" {
  2773. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2774. }
  2775. if item.ChrgitmLv == "3" {
  2776. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2777. }
  2778. }
  2779. if item.MedChrgitmType == "10" { //中药饮片
  2780. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2781. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2782. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2783. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2784. if item.ChrgitmLv == "1" {
  2785. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2786. }
  2787. if item.ChrgitmLv == "2" {
  2788. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2789. }
  2790. if item.ChrgitmLv == "3" {
  2791. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2792. }
  2793. }
  2794. if item.MedChrgitmType == "11" { //中成费
  2795. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2796. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2797. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2798. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2799. if item.ChrgitmLv == "1" {
  2800. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2801. }
  2802. if item.ChrgitmLv == "2" {
  2803. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2804. }
  2805. if item.ChrgitmLv == "3" {
  2806. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2807. }
  2808. }
  2809. if item.MedChrgitmType == "12" { //中成费
  2810. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2811. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2812. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2813. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2814. if item.ChrgitmLv == "1" {
  2815. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2816. }
  2817. if item.ChrgitmLv == "2" {
  2818. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2819. }
  2820. if item.ChrgitmLv == "3" {
  2821. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2822. }
  2823. }
  2824. if item.MedChrgitmType == "13" { //中成费
  2825. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2826. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2827. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2828. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2829. if item.ChrgitmLv == "1" {
  2830. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2831. }
  2832. if item.ChrgitmLv == "2" {
  2833. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2834. }
  2835. if item.ChrgitmLv == "3" {
  2836. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2837. }
  2838. }
  2839. if item.MedChrgitmType == "14" { //其他费
  2840. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2841. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2842. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2843. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2844. if item.ChrgitmLv == "1" {
  2845. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2846. }
  2847. if item.ChrgitmLv == "2" {
  2848. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2849. }
  2850. if item.ChrgitmLv == "3" {
  2851. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2852. }
  2853. }
  2854. }
  2855. var iteminfoStructs []service.IteminfoStruct
  2856. if bedCostTotal != 0 {
  2857. iteminfo.MedChrgitm = "01"
  2858. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2859. iteminfo.Amt = bedCostTotal
  2860. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2861. iteminfo.ClabAmt = bed_clab_amt
  2862. iteminfo.OthAmt = bed_other_amt
  2863. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2864. }
  2865. if examineCostTotal != 0 {
  2866. iteminfo.MedChrgitm = "02"
  2867. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  2868. iteminfo.Amt = examineCostTotal
  2869. iteminfo.ClaaSumfee = examine_claa_sunmfee
  2870. iteminfo.ClabAmt = examine_clab_amt
  2871. iteminfo.OthAmt = examine_other_amt
  2872. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2873. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2874. }
  2875. if checkCostTotal != 0 {
  2876. iteminfo.MedChrgitm = "03"
  2877. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2878. iteminfo.Amt = checkCostTotal
  2879. iteminfo.ClaaSumfee = check_claa_sunmfee
  2880. iteminfo.ClabAmt = check_clab_amt
  2881. iteminfo.OthAmt = check_other_amt
  2882. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2883. }
  2884. if laboratoryCostTotal != 0 {
  2885. iteminfo.MedChrgitm = "04"
  2886. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2887. iteminfo.Amt = laboratoryCostTotal
  2888. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2889. iteminfo.ClabAmt = laboratory_clab_amt
  2890. iteminfo.OthAmt = laboratory_other_amt
  2891. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2892. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2893. }
  2894. if treatCostTotal != 0 {
  2895. iteminfo.MedChrgitm = "05"
  2896. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2897. iteminfo.Amt = treatCostTotal
  2898. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2899. iteminfo.ClabAmt = treat_clab_amt
  2900. iteminfo.OthAmt = treat_other_amt
  2901. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2902. //(struct4101.IteminfoStruct, iteminfo)
  2903. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2904. }
  2905. if operationCostTotal != 0 {
  2906. iteminfo.MedChrgitm = "06"
  2907. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2908. iteminfo.Amt = operationCostTotal
  2909. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2910. iteminfo.ClabAmt = operation_clab_amt
  2911. iteminfo.OthAmt = operation_other_amt
  2912. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2913. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2914. }
  2915. if nursingCostTotal != 0 {
  2916. iteminfo.MedChrgitm = "07"
  2917. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  2918. iteminfo.Amt = nursingCostTotal
  2919. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  2920. iteminfo.ClabAmt = nursing_clab_amt
  2921. iteminfo.OthAmt = nursing_other_amt
  2922. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2923. }
  2924. if materialCostTotal != 0 {
  2925. iteminfo.MedChrgitm = "08"
  2926. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2927. iteminfo.Amt = materialCostTotal
  2928. iteminfo.ClaaSumfee = material_claa_sunmfee
  2929. iteminfo.ClabAmt = material_clab_amt
  2930. iteminfo.OthAmt = material_other_amt
  2931. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2932. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2933. }
  2934. if westernMedicineCostTotal != 0 {
  2935. iteminfo.MedChrgitm = "09"
  2936. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2937. iteminfo.Amt = westernMedicineCostTotal
  2938. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2939. iteminfo.ClabAmt = westernMedicine_clab_amt
  2940. iteminfo.OthAmt = westernMedicine_other_amt
  2941. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2942. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2943. }
  2944. if chineseMedicineCostTotal != 0 {
  2945. iteminfo.MedChrgitm = "10"
  2946. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  2947. iteminfo.Amt = chineseMedicineCostTotal
  2948. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  2949. iteminfo.ClabAmt = chinese_medicine_clab_amt
  2950. iteminfo.OthAmt = chinese_medicine_other_amt
  2951. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2952. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2953. }
  2954. if chineseTraditionalMedicineCostTotal != 0 {
  2955. iteminfo.MedChrgitm = "11"
  2956. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2957. iteminfo.Amt = westernMedicineCostTotal
  2958. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2959. iteminfo.ClabAmt = westernMedicine_clab_amt
  2960. iteminfo.OthAmt = westernMedicine_other_amt
  2961. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2962. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2963. }
  2964. if commonlyTreatmentCostTotal != 0 {
  2965. iteminfo.MedChrgitm = "12"
  2966. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  2967. iteminfo.Amt = commonlyTreatmentCostTotal
  2968. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  2969. iteminfo.ClabAmt = commonly_treatment_clab_amt
  2970. iteminfo.OthAmt = commonly_treatment_other_amt
  2971. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2972. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2973. }
  2974. if registerCostTotal != 0 {
  2975. iteminfo.MedChrgitm = "13"
  2976. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  2977. iteminfo.Amt = registerCostTotal
  2978. iteminfo.ClaaSumfee = register_claa_sunmfee
  2979. iteminfo.ClabAmt = register_clab_amt
  2980. iteminfo.OthAmt = register_other_amt
  2981. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2982. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2983. }
  2984. if otherCostTotal != 0 {
  2985. iteminfo.MedChrgitm = "14"
  2986. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2987. iteminfo.Amt = otherCostTotal
  2988. iteminfo.ClaaSumfee = other_claa_sunmfee
  2989. iteminfo.ClabAmt = other_clab_amt
  2990. iteminfo.OthAmt = other_other_amt
  2991. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2992. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2993. }
  2994. struct4101.IteminfoStruct = iteminfoStructs
  2995. struct4101.Ntly = "中国"
  2996. struct4101.AdmCaty = "A03.06"
  2997. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  2998. fmt.Println(result)
  2999. var dat map[string]interface{}
  3000. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3001. fmt.Println(dat)
  3002. } else {
  3003. fmt.Println(err)
  3004. }
  3005. userJSONBytes, _ := json.Marshal(dat)
  3006. var res ResultSeventeen
  3007. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3008. utils.ErrorLog("解析失败:%v", err)
  3009. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3010. adminUser := c.GetAdminUserInfo()
  3011. errlog := &models.HisOrderError{
  3012. UserOrgId: adminUser.CurrentOrgId,
  3013. Ctime: time.Now().Unix(),
  3014. Mtime: time.Now().Unix(),
  3015. ErrMsg: res.ErrMsg + "解析失败",
  3016. Status: 1,
  3017. PatientId: order_id,
  3018. Stage: 10106,
  3019. }
  3020. service.CreateErrMsgLog(errlog)
  3021. continue
  3022. }
  3023. if res.Infcode != 0 {
  3024. adminUser := c.GetAdminUserInfo()
  3025. errlog := &models.HisOrderError{
  3026. UserOrgId: adminUser.CurrentOrgId,
  3027. Ctime: time.Now().Unix(),
  3028. Mtime: time.Now().Unix(),
  3029. ErrMsg: res.ErrMsg,
  3030. Status: 1,
  3031. PatientId: order_id,
  3032. Stage: 10106,
  3033. }
  3034. service.CreateErrMsgLog(errlog)
  3035. continue
  3036. } else {
  3037. hisFundSettleListResult := &models.HisFundSettleListResult{
  3038. Number: res.Output.SetlListId,
  3039. Status: 1,
  3040. Ctime: time.Now().Unix(),
  3041. Mtime: time.Now().Unix(),
  3042. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3043. IsUpload: 1,
  3044. OrderId: order_id,
  3045. }
  3046. service.CreateUploadRecord(hisFundSettleListResult)
  3047. continue
  3048. }
  3049. }
  3050. }
  3051. func (c *HisApiController) GetOrgInfo() {
  3052. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  3053. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  3054. }
  3055. func (c *HisApiController) GetHisPatientInfo() {
  3056. medical_insurance_card := c.GetString("medical_insurance_card")
  3057. id_card_type, _ := c.GetInt64("id_card_type")
  3058. id_card := c.GetString("id_card")
  3059. adminInfo := c.GetAdminUserInfo()
  3060. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3061. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3062. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  3063. IdCardNo := ""
  3064. if id_card_type == 1 {
  3065. IdCardNo = medical_insurance_card
  3066. } else if id_card_type == 2 {
  3067. IdCardNo = id_card
  3068. }
  3069. if config.IsOpen == 1 {
  3070. 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
  3071. resp, requestErr := http.Get(api)
  3072. if requestErr != nil {
  3073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3074. return
  3075. }
  3076. defer resp.Body.Close()
  3077. body, ioErr := ioutil.ReadAll(resp.Body)
  3078. if ioErr != nil {
  3079. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3081. return
  3082. }
  3083. var respJSON map[string]interface{}
  3084. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3085. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3087. return
  3088. }
  3089. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3090. userJSONBytes, _ := json.Marshal(userJSON)
  3091. var res ResultTwo
  3092. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3093. utils.ErrorLog("解析失败:%v", err)
  3094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3095. return
  3096. }
  3097. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3098. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3099. infoStr := string(Iinfos)
  3100. idetinfoStr := string(Idetinfos)
  3101. if res.Infcode == 0 {
  3102. his := models.VMHisPatient{
  3103. Status: 1,
  3104. Ctime: time.Now().Unix(),
  3105. Mtime: time.Now().Unix(),
  3106. PsnNo: res.Output.Baseinfo.PsnNo,
  3107. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3108. Certno: res.Output.Baseinfo.Certno,
  3109. PsnName: res.Output.Baseinfo.PsnName,
  3110. Gend: res.Output.Baseinfo.Gend,
  3111. Naty: res.Output.Baseinfo.Naty,
  3112. Brdy: res.Output.Baseinfo.Brdy,
  3113. Age: res.Output.Baseinfo.Age,
  3114. Iinfo: infoStr,
  3115. Idetinfo: idetinfoStr,
  3116. UserOrgId: adminInfo.CurrentOrgId,
  3117. IsReturn: 1,
  3118. IdCardType: id_card_type,
  3119. }
  3120. c.ServeSuccessJSON(map[string]interface{}{
  3121. "info": his,
  3122. })
  3123. } else {
  3124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3125. return
  3126. }
  3127. }
  3128. }
  3129. //func GetBasBaseInfo() (jsonStr string, err error) {
  3130. //
  3131. // handle := syscall.NewLazyDLL("SSCard.dll")
  3132. // add := handle.NewProc("ReadCardBas")
  3133. // str := make([]byte, 1024)
  3134. // str1 := make([]byte, 1024)
  3135. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3136. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3137. //
  3138. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3139. //
  3140. // fmt.Println("> Add(4,5)的结果为:", ret)
  3141. // handle.Release()
  3142. //
  3143. // return "", nil
  3144. //
  3145. //}
  3146. //func GetQRBaseInfo() (jsonStr string, err error) {
  3147. // handle := syscall.LoadDLL("SSCard.dll")
  3148. // ReadCardBas := handle.FindProc("GetQRBase")
  3149. //
  3150. // str := make([]byte, 256)
  3151. // str1 := make([]byte, 256)
  3152. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3153. //
  3154. // fmt.Println(string(str))
  3155. // fmt.Println(r)
  3156. // return string(str), nil
  3157. //}
  3158. //func CardInit() int {
  3159. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  3160. // add := DllTestDef.MustFindProc("Init")
  3161. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3162. // if err != nil {
  3163. // fmt.Println("SSCard的运算结果为:", ret)
  3164. // }
  3165. // result := int(ret)
  3166. // return result
  3167. //}
  3168. //func CardInit() int {
  3169. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3170. // if err != nil {
  3171. // fmt.Println("SSCard的运算结果为:", ret)
  3172. // }
  3173. // fmt.Println(err)
  3174. // result := int(ret)
  3175. // return result
  3176. //}
  3177. func IntPtr(n int) uintptr {
  3178. return uintptr(n)
  3179. }
  3180. func StrPtr(s string) uintptr {
  3181. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3182. }
  3183. type Result2001 struct {
  3184. Cainfo interface{} `json:"cainfo"`
  3185. ErrMsg string `json:"err_msg"`
  3186. InfRefmsgid string `json:"inf_refmsgid"`
  3187. Infcode int64 `json:"infcode"`
  3188. Output struct {
  3189. Trtinfo struct {
  3190. PsnNo string `json:"psn_no"`
  3191. TrtChkType string `json:"trt_chk_type"`
  3192. FundPayType string `json:"fund_pay_type"`
  3193. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3194. Begndate string `json:"begndate"`
  3195. Enddate string `json:"enddate"`
  3196. TrtChkRslt string `json:"trt_chk_rslt"`
  3197. } `json:"trtinfo"`
  3198. } `json:"output"`
  3199. RefmsgTime string `json:"refmsg_time"`
  3200. RespondTime string `json:"respond_time"`
  3201. Signtype interface{} `json:"signtype"`
  3202. WarnMsg interface{} `json:"warn_msg"`
  3203. }
  3204. type Result2001Org10265 struct {
  3205. Cainfo interface{} `json:"cainfo"`
  3206. ErrMsg string `json:"err_msg"`
  3207. InfRefmsgid string `json:"inf_refmsgid"`
  3208. Infcode string `json:"infcode"`
  3209. Output struct {
  3210. Trtinfo struct {
  3211. PsnNo string `json:"psn_no"`
  3212. TrtChkType string `json:"trt_chk_type"`
  3213. FundPayType string `json:"fund_pay_type"`
  3214. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3215. Begndate string `json:"begndate"`
  3216. Enddate string `json:"enddate"`
  3217. TrtChkRslt string `json:"trt_chk_rslt"`
  3218. } `json:"trtinfo"`
  3219. } `json:"output"`
  3220. RefmsgTime string `json:"refmsg_time"`
  3221. RespondTime string `json:"respond_time"`
  3222. Signtype interface{} `json:"signtype"`
  3223. WarnMsg interface{} `json:"warn_msg"`
  3224. }
  3225. type ResultTwo struct {
  3226. ErrMsg string `json:"err_msg"`
  3227. InfRefmsgid string `json:"inf_refmsgid"`
  3228. Infcode int64 `json:"infcode"`
  3229. Output struct {
  3230. Baseinfo struct {
  3231. Age float64 `json:"age"`
  3232. Brdy string `json:"brdy"`
  3233. Certno string `json:"certno"`
  3234. Gend string `json:"gend"`
  3235. Naty string `json:"naty"`
  3236. PsnCertType string `json:"psn_cert_type"`
  3237. PsnName string `json:"psn_name"`
  3238. PsnNo string `json:"psn_no"`
  3239. } `json:"baseinfo"`
  3240. Idetinfo []interface{} `json:"idetinfo"`
  3241. Iinfo []struct {
  3242. Balc float64 `json:"balc"`
  3243. CvlservFlag string `json:"cvlserv_flag"`
  3244. EmpName string `json:"emp_name"`
  3245. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3246. Insutype string `json:"insutype"`
  3247. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3248. PausInsuDate string `json:"paus_insu_date"`
  3249. PsnInsuDate string `json:"psn_insu_date"`
  3250. PsnInsuStas string `json:"psn_insu_stas"`
  3251. PsnType string `json:"psn_type"`
  3252. } `json:"insuinfo"`
  3253. } `json:"output"`
  3254. RefmsgTime string `json:"refmsg_time"`
  3255. RespondTime string `json:"respond_time"`
  3256. Signtype interface{} `json:"signtype"`
  3257. WarnInfo interface{} `json:"warn_info"`
  3258. }
  3259. type ResultTwo10265 struct {
  3260. ErrMsg string `json:"err_msg"`
  3261. InfRefmsgid string `json:"inf_refmsgid"`
  3262. Infcode string `json:"infcode"`
  3263. Output struct {
  3264. Baseinfo struct {
  3265. Age float64 `json:"age"`
  3266. Brdy string `json:"brdy"`
  3267. Certno string `json:"certno"`
  3268. Gend string `json:"gend"`
  3269. Naty string `json:"naty"`
  3270. PsnCertType string `json:"psn_cert_type"`
  3271. PsnName string `json:"psn_name"`
  3272. PsnNo string `json:"psn_no"`
  3273. } `json:"baseinfo"`
  3274. Idetinfo []interface{} `json:"idetinfo"`
  3275. Iinfo []struct {
  3276. Balc float64 `json:"balc"`
  3277. CvlservFlag string `json:"cvlserv_flag"`
  3278. EmpName string `json:"emp_name"`
  3279. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3280. Insutype string `json:"insutype"`
  3281. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3282. PausInsuDate string `json:"paus_insu_date"`
  3283. PsnInsuDate string `json:"psn_insu_date"`
  3284. PsnInsuStas string `json:"psn_insu_stas"`
  3285. PsnType string `json:"psn_type"`
  3286. } `json:"insuinfo"`
  3287. } `json:"output"`
  3288. RefmsgTime string `json:"refmsg_time"`
  3289. RespondTime string `json:"respond_time"`
  3290. Signtype interface{} `json:"signtype"`
  3291. WarnInfo interface{} `json:"warn_info"`
  3292. }
  3293. type ResultThree struct {
  3294. Cainfo interface{} `json:"cainfo"`
  3295. ErrMsg string `json:"err_msg"`
  3296. InfRefmsgid string `json:"inf_refmsgid"`
  3297. Infcode int64 `json:"infcode"`
  3298. Output struct {
  3299. Data struct {
  3300. IptOtpNo string `json:"ipt_otp_no"`
  3301. MdtrtID string `json:"mdtrt_id"`
  3302. PsnNo string `json:"psn_no"`
  3303. } `json:"data"`
  3304. } `json:"output"`
  3305. RefmsgTime string `json:"refmsg_time"`
  3306. RespondTime string `json:"respond_time"`
  3307. Signtype interface{} `json:"signtype"`
  3308. WarnMsg interface{} `json:"warn_msg"`
  3309. }
  3310. type ResultThree10265 struct {
  3311. Cainfo interface{} `json:"cainfo"`
  3312. ErrMsg string `json:"err_msg"`
  3313. InfRefmsgid string `json:"inf_refmsgid"`
  3314. Infcode string `json:"infcode"`
  3315. Output struct {
  3316. Data struct {
  3317. IptOtpNo string `json:"ipt_otp_no"`
  3318. MdtrtID string `json:"mdtrt_id"`
  3319. PsnNo string `json:"psn_no"`
  3320. } `json:"data"`
  3321. } `json:"output"`
  3322. RefmsgTime string `json:"refmsg_time"`
  3323. RespondTime string `json:"respond_time"`
  3324. Signtype interface{} `json:"signtype"`
  3325. WarnMsg interface{} `json:"warn_msg"`
  3326. }
  3327. type ResultFour struct {
  3328. Cainfo string `json:"cainfo"`
  3329. ErrMsg string `json:"err_msg"`
  3330. InfRefmsgid string `json:"inf_refmsgid"`
  3331. Infcode int64 `json:"infcode"`
  3332. Output struct {
  3333. Result []struct {
  3334. BasMednFlag string `json:"bas_medn_flag"`
  3335. ChldMedcFlag string `json:"chld_medc_flag"`
  3336. ChrgitmLv string `json:"chrgitm_lv"`
  3337. Cnt float64 `json:"cnt"`
  3338. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3339. DrtReimFlag string `json:"drt_reim_flag"`
  3340. FeedetlSn string `json:"feedetl_sn"`
  3341. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3342. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3343. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3344. ListSpItemFlag string `json:"list_sp_item_flag"`
  3345. LmtUsedFlag string `json:"lmt_used_flag"`
  3346. MedChrgitmType string `json:"med_chrgitm_type"`
  3347. Memo string `json:"memo"`
  3348. OverlmtAmt float64 `json:"overlmt_amt"`
  3349. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3350. Pric float64 `json:"pric"`
  3351. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3352. SelfpayProp float64 `json:"selfpay_prop"`
  3353. } `json:"result"`
  3354. } `json:"output"`
  3355. RefmsgTime string `json:"refmsg_time"`
  3356. RespondTime string `json:"respond_time"`
  3357. Signtype string `json:"signtype"`
  3358. WarnMsg string `json:"warn_msg"`
  3359. }
  3360. type ResultFour10265 struct {
  3361. Cainfo string `json:"cainfo"`
  3362. ErrMsg string `json:"err_msg"`
  3363. InfRefmsgid string `json:"inf_refmsgid"`
  3364. Infcode string `json:"infcode"`
  3365. Output struct {
  3366. Result []struct {
  3367. BasMednFlag string `json:"bas_medn_flag"`
  3368. ChldMedcFlag string `json:"chld_medc_flag"`
  3369. ChrgitmLv string `json:"chrgitm_lv"`
  3370. Cnt float64 `json:"cnt"`
  3371. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3372. DrtReimFlag string `json:"drt_reim_flag"`
  3373. FeedetlSn string `json:"feedetl_sn"`
  3374. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3375. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3376. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3377. ListSpItemFlag string `json:"list_sp_item_flag"`
  3378. LmtUsedFlag string `json:"lmt_used_flag"`
  3379. MedChrgitmType string `json:"med_chrgitm_type"`
  3380. Memo string `json:"memo"`
  3381. OverlmtAmt float64 `json:"overlmt_amt"`
  3382. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3383. Pric float64 `json:"pric"`
  3384. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3385. SelfpayProp float64 `json:"selfpay_prop"`
  3386. } `json:"result"`
  3387. } `json:"output"`
  3388. RefmsgTime string `json:"refmsg_time"`
  3389. RespondTime string `json:"respond_time"`
  3390. Signtype string `json:"signtype"`
  3391. WarnMsg string `json:"warn_msg"`
  3392. }
  3393. type ResultFive struct {
  3394. Balc float64 `json:"balc"`
  3395. CvlservFlag string `json:"cvlserv_flag"`
  3396. EmpName string `json:"emp_name"`
  3397. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3398. Insutype string `json:"insutype"`
  3399. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3400. PausInsuDate string `json:"paus_insu_date"`
  3401. PsnInsuDate string `json:"psn_insu_date"`
  3402. PsnInsuStas string `json:"psn_insu_stas"`
  3403. PsnType string `json:"psn_type"`
  3404. }
  3405. type ResultSix struct {
  3406. Cainfo interface{} `json:"cainfo"`
  3407. ErrMsg string `json:"err_msg"`
  3408. InfRefmsgid string `json:"inf_refmsgid"`
  3409. Infcode int64 `json:"infcode"`
  3410. Output struct {
  3411. } `json:"output"`
  3412. RefmsgTime string `json:"refmsg_time"`
  3413. RespondTime string `json:"respond_time"`
  3414. Signtype interface{} `json:"signtype"`
  3415. WarnMsg interface{} `json:"warn_msg"`
  3416. }
  3417. type ResultSix10265 struct {
  3418. Cainfo interface{} `json:"cainfo"`
  3419. ErrMsg string `json:"err_msg"`
  3420. InfRefmsgid string `json:"inf_refmsgid"`
  3421. Infcode string `json:"infcode"`
  3422. Output struct {
  3423. } `json:"output"`
  3424. RefmsgTime string `json:"refmsg_time"`
  3425. RespondTime string `json:"respond_time"`
  3426. Signtype interface{} `json:"signtype"`
  3427. WarnMsg interface{} `json:"warn_msg"`
  3428. }
  3429. type ResultSeven struct {
  3430. Cainfo string `json:"cainfo"`
  3431. ErrMsg string `json:"err_msg"`
  3432. InfRefmsgid string `json:"inf_refmsgid"`
  3433. Infcode int64 `json:"infcode"`
  3434. Output struct {
  3435. Setldetail []interface{} `json:"setldetail"`
  3436. Setlinfo struct {
  3437. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3438. AcctPay float64 `json:"acct_pay"`
  3439. ActPayDedc float64 `json:"act_pay_dedc"`
  3440. Age float64 `json:"age"`
  3441. Balc float64 `json:"balc"`
  3442. Brdy string `json:"brdy"`
  3443. Certno string `json:"certno"`
  3444. ClrOptins string `json:"clr_optins"`
  3445. ClrType string `json:"clr_type"`
  3446. ClrWay string `json:"clr_way"`
  3447. CvlservFlag string `json:"cvlserv_flag"`
  3448. CvlservPay float64 `json:"cvlserv_pay"`
  3449. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3450. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3451. Gend string `json:"gend"`
  3452. HifesPay float64 `json:"hifes_pay"`
  3453. HifmiPay float64 `json:"hifmi_pay"`
  3454. HifpPay float64 `json:"hifp_pay"`
  3455. HospPartAmt float64 `json:"hosp_part_amt"`
  3456. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3457. Insutype string `json:"insutype"`
  3458. MafPay float64 `json:"maf_pay"`
  3459. MdtrtCertType string `json:"mdtrt_cert_type"`
  3460. HifobPay float64 `json:"hifob_pay"`
  3461. MdtrtID string `json:"mdtrt_id"`
  3462. MedType string `json:"med_type"`
  3463. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3464. MedinsSetlID string `json:"medins_setl_id"`
  3465. Naty string `json:"naty"`
  3466. OthPay float64 `json:"oth_pay"`
  3467. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3468. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3469. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3470. PsnCashPay float64 `json:"psn_cash_pay"`
  3471. PsnCertType string `json:"psn_cert_type"`
  3472. PsnName string `json:"psn_name"`
  3473. PsnNo string `json:"psn_no"`
  3474. PsnPartAmt float64 `json:"psn_part_amt"`
  3475. PsnType string `json:"psn_type"`
  3476. SetlID string `json:"setl_id"`
  3477. SetlTime string `json:"setl_time"`
  3478. } `json:"setlinfo"`
  3479. } `json:"output"`
  3480. RefmsgTime string `json:"refmsg_time"`
  3481. RespondTime string `json:"respond_time"`
  3482. Signtype interface{} `json:"signtype"`
  3483. WarnMsg interface{} `json:"warn_msg"`
  3484. }
  3485. type ResultSeven10265 struct {
  3486. Cainfo string `json:"cainfo"`
  3487. ErrMsg string `json:"err_msg"`
  3488. InfRefmsgid string `json:"inf_refmsgid"`
  3489. Infcode string `json:"infcode"`
  3490. Output struct {
  3491. Setldetail []interface{} `json:"setldetail"`
  3492. Setlinfo struct {
  3493. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3494. AcctPay float64 `json:"acct_pay"`
  3495. ActPayDedc float64 `json:"act_pay_dedc"`
  3496. Age float64 `json:"age"`
  3497. Balc float64 `json:"balc"`
  3498. Brdy string `json:"brdy"`
  3499. Certno string `json:"certno"`
  3500. ClrOptins string `json:"clr_optins"`
  3501. ClrType string `json:"clr_type"`
  3502. ClrWay string `json:"clr_way"`
  3503. CvlservFlag string `json:"cvlserv_flag"`
  3504. CvlservPay float64 `json:"cvlserv_pay"`
  3505. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3506. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3507. Gend string `json:"gend"`
  3508. HifesPay float64 `json:"hifes_pay"`
  3509. HifmiPay float64 `json:"hifmi_pay"`
  3510. HifpPay float64 `json:"hifp_pay"`
  3511. HospPartAmt float64 `json:"hosp_part_amt"`
  3512. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3513. Insutype string `json:"insutype"`
  3514. MafPay float64 `json:"maf_pay"`
  3515. MdtrtCertType string `json:"mdtrt_cert_type"`
  3516. HifobPay float64 `json:"hifob_pay"`
  3517. MdtrtID string `json:"mdtrt_id"`
  3518. MedType string `json:"med_type"`
  3519. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3520. MedinsSetlID string `json:"medins_setl_id"`
  3521. Naty string `json:"naty"`
  3522. OthPay float64 `json:"oth_pay"`
  3523. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3524. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3525. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3526. PsnCashPay float64 `json:"psn_cash_pay"`
  3527. PsnCertType string `json:"psn_cert_type"`
  3528. PsnName string `json:"psn_name"`
  3529. PsnNo string `json:"psn_no"`
  3530. PsnPartAmt float64 `json:"psn_part_amt"`
  3531. PsnType string `json:"psn_type"`
  3532. SetlID string `json:"setl_id"`
  3533. SetlTime string `json:"setl_time"`
  3534. } `json:"setlinfo"`
  3535. } `json:"output"`
  3536. RefmsgTime string `json:"refmsg_time"`
  3537. RespondTime string `json:"respond_time"`
  3538. Signtype interface{} `json:"signtype"`
  3539. WarnMsg interface{} `json:"warn_msg"`
  3540. }
  3541. type ResultEight struct {
  3542. Cainfo string `json:"cainfo"`
  3543. ErrMsg string `json:"err_msg"`
  3544. InfRefmsgid string `json:"inf_refmsgid"`
  3545. Infcode int64 `json:"infcode"`
  3546. Output struct {
  3547. Stmtinfo struct {
  3548. SetlOptins string `json:"setl_optins"`
  3549. StmtRslt string `json:"stmt_rslt"`
  3550. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3551. } `json:"stmtinfo"`
  3552. } `json:"output"`
  3553. RefmsgTime string `json:"refmsg_time"`
  3554. RespondTime string `json:"respond_time"`
  3555. Signtype interface{} `json:"signtype"`
  3556. WarnMsg interface{} `json:"warn_msg"`
  3557. }
  3558. type ResultEightFor10188 struct {
  3559. Cainfo string `json:"cainfo"`
  3560. ErrMsg string `json:"err_msg"`
  3561. InfRefmsgid string `json:"inf_refmsgid"`
  3562. Infcode string `json:"infcode"`
  3563. Output struct {
  3564. Stmtinfo struct {
  3565. SetlOptins string `json:"setl_optins"`
  3566. StmtRslt string `json:"stmt_rslt"`
  3567. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3568. } `json:"stmtinfo"`
  3569. } `json:"output"`
  3570. RefmsgTime string `json:"refmsg_time"`
  3571. RespondTime string `json:"respond_time"`
  3572. Signtype interface{} `json:"signtype"`
  3573. WarnMsg interface{} `json:"warn_msg"`
  3574. }
  3575. type ResultNine struct {
  3576. Cainfo string `json:"cainfo"`
  3577. ErrMsg string `json:"err_msg"`
  3578. InfRefmsgid string `json:"inf_refmsgid"`
  3579. Infcode int64 `json:"infcode"`
  3580. Output struct {
  3581. FileQuryNo string `json:"file_qury_no"`
  3582. } `json:"output"`
  3583. RefmsgTime string `json:"refmsg_time"`
  3584. RespondTime string `json:"respond_time"`
  3585. Signtype interface{} `json:"signtype"`
  3586. WarnMsg interface{} `json:"warn_msg"`
  3587. }
  3588. type ResultTen struct {
  3589. Cainfo string `json:"cainfo"`
  3590. ErrMsg string `json:"err_msg"`
  3591. InfRefmsgid string `json:"inf_refmsgid"`
  3592. Infcode int64 `json:"infcode"`
  3593. Output struct {
  3594. DldEndtime string `json:"dld_endtime"`
  3595. FileQuryNo string `json:"file_qury_no"`
  3596. Filename string `json:"filename"`
  3597. } `json:"output"`
  3598. RefmsgTime string `json:"refmsg_time"`
  3599. RespondTime string `json:"respond_time"`
  3600. Signtype interface{} `json:"signtype"`
  3601. WarnMsg interface{} `json:"warn_msg"`
  3602. }
  3603. //type Autogenerated struct {
  3604. // Output struct {
  3605. // Setlinfo struct {
  3606. // SetlTime string `json:"setl_time"`
  3607. // CvlservPay float64 `json:"cvlserv_pay"`
  3608. // Year string `json:"year"`
  3609. // MedType string `json:"med_type"`
  3610. // PsnPay float64 `json:"psn_pay"`
  3611. // OpterID string `json:"opter_id"`
  3612. // Begndate string `json:"begndate"`
  3613. // FlxempeFlag string `json:"flxempe_flag"`
  3614. // HifmiPay float64 `json:"hifmi_pay"`
  3615. // PsnNo string `json:"psn_no"`
  3616. // ActPayDedc float64 `json:"act_pay_dedc"`
  3617. // MedinsSetlID interface{} `json:"medins_setl_id"`
  3618. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3619. // ClrWay string `json:"clr_way"`
  3620. // OthPay float64 `json:"oth_pay"`
  3621. // Gend string `json:"gend"`
  3622. // MdtrtID string `json:"mdtrt_id"`
  3623. // AcctPay float64 `json:"acct_pay"`
  3624. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  3625. // Insutype string `json:"insutype"`
  3626. // Invono interface{} `json:"invono"`
  3627. // Enddate string `json:"enddate"`
  3628. // CashPayamt float64 `json:"cash_payamt"`
  3629. // PsnType string `json:"psn_type"`
  3630. // FixmedinsName string `json:"fixmedins_name"`
  3631. // HifpPay float64 `json:"hifp_pay"`
  3632. // NewFlag interface{} `json:"new_flag"`
  3633. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3634. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  3635. // PayLoc string `json:"pay_loc"`
  3636. // ClrType string `json:"clr_type"`
  3637. // RefdSetlFlag string `json:"refd_setl_flag"`
  3638. // CvlservFlag string `json:"cvlserv_flag"`
  3639. // EmpName string `json:"emp_name"`
  3640. // Brdy string `json:"brdy"`
  3641. // Naty string `json:"naty"`
  3642. // Certno string `json:"certno"`
  3643. // DiseCode string `json:"dise_code"`
  3644. // FixmedinsCode string `json:"fixmedins_code"`
  3645. // DedcHospLv string `json:"dedc_hosp_lv"`
  3646. // OpterName string `json:"opter_name"`
  3647. // Balc float64 `json:"balc"`
  3648. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3649. // PsnCertType string `json:"psn_cert_type"`
  3650. // HifobPay float64 `json:"hifob_pay"`
  3651. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  3652. // HifesPay float64 `json:"hifes_pay"`
  3653. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3654. // OptTime string `json:"opt_time"`
  3655. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3656. // SetlID string `json:"setl_id"`
  3657. // MafPay float64 `json:"maf_pay"`
  3658. // PsnName string `json:"psn_name"`
  3659. // InsuOptins interface{} `json:"insu_optins"`
  3660. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3661. // ClrOptins string `json:"clr_optins"`
  3662. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3663. // DiseName string `json:"dise_name"`
  3664. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3665. // Age float64 `json:"age"`
  3666. // DtrtCertType string `json:"dtrt_cert_type"`
  3667. // HospLv string `json:"hosp_lv"`
  3668. // } `json:"setlinfo"`
  3669. // Setldetail []struct {
  3670. // FundPayType string `json:"fund_pay_type"`
  3671. // FundPayamt float64 `json:"fund_payamt"`
  3672. // SetlProcInfo interface{} `json:"setl_proc_info"`
  3673. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  3674. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  3675. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  3676. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3677. // } `json:"setldetail"`
  3678. // } `json:"output"`
  3679. // Infcode int `json:"infcode"`
  3680. // WarnMsg interface{} `json:"warn_msg"`
  3681. // Cainfo interface{} `json:"cainfo"`
  3682. // ErrMsg interface{} `json:"err_msg"`
  3683. // RefmsgTime string `json:"refmsg_time"`
  3684. // Signtype interface{} `json:"signtype"`
  3685. // RespondTime string `json:"respond_time"`
  3686. // InfRefmsgid string `json:"inf_refmsgid"`
  3687. //}
  3688. type ResultEleven struct {
  3689. Cainfo string `json:"cainfo"`
  3690. ErrMsg string `json:"err_msg"`
  3691. InfRefmsgid string `json:"inf_refmsgid"`
  3692. Infcode int64 `json:"infcode"`
  3693. Output struct {
  3694. Setlinfo struct {
  3695. SetlTime string `json:"setl_time"`
  3696. CvlservPay float64 `json:"cvlserv_pay"`
  3697. Year string `json:"year"`
  3698. MedType string `json:"med_type"`
  3699. PsnPay float64 `json:"psn_pay"`
  3700. OpterID string `json:"opter_id"`
  3701. Begndate string `json:"begndate"`
  3702. FlxempeFlag string `json:"flxempe_flag"`
  3703. HifmiPay float64 `json:"hifmi_pay"`
  3704. PsnNo string `json:"psn_no"`
  3705. ActPayDedc float64 `json:"act_pay_dedc"`
  3706. MedinsSetlID interface{} `json:"medins_setl_id"`
  3707. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3708. ClrWay string `json:"clr_way"`
  3709. OthPay float64 `json:"oth_pay"`
  3710. Gend string `json:"gend"`
  3711. MdtrtID string `json:"mdtrt_id"`
  3712. AcctPay float64 `json:"acct_pay"`
  3713. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3714. Insutype string `json:"insutype"`
  3715. Invono interface{} `json:"invono"`
  3716. Enddate string `json:"enddate"`
  3717. CashPayamt float64 `json:"cash_payamt"`
  3718. PsnType string `json:"psn_type"`
  3719. FixmedinsName string `json:"fixmedins_name"`
  3720. HifpPay float64 `json:"hifp_pay"`
  3721. NewFlag interface{} `json:"new_flag"`
  3722. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3723. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3724. PayLoc string `json:"pay_loc"`
  3725. ClrType string `json:"clr_type"`
  3726. RefdSetlFlag string `json:"refd_setl_flag"`
  3727. CvlservFlag string `json:"cvlserv_flag"`
  3728. EmpName string `json:"emp_name"`
  3729. Brdy string `json:"brdy"`
  3730. Naty string `json:"naty"`
  3731. Certno string `json:"certno"`
  3732. DiseCode string `json:"dise_code"`
  3733. FixmedinsCode string `json:"fixmedins_code"`
  3734. DedcHospLv string `json:"dedc_hosp_lv"`
  3735. OpterName string `json:"opter_name"`
  3736. Balc float64 `json:"balc"`
  3737. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3738. PsnCertType string `json:"psn_cert_type"`
  3739. HifobPay float64 `json:"hifob_pay"`
  3740. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3741. HifesPay float64 `json:"hifes_pay"`
  3742. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3743. OptTime string `json:"opt_time"`
  3744. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3745. SetlID string `json:"setl_id"`
  3746. MafPay float64 `json:"maf_pay"`
  3747. PsnName string `json:"psn_name"`
  3748. InsuOptins interface{} `json:"insu_optins"`
  3749. PrefFundPay interface{} `json:"pref_fund_pay"`
  3750. ClrOptins string `json:"clr_optins"`
  3751. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3752. DiseName string `json:"dise_name"`
  3753. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3754. Age float64 `json:"age"`
  3755. DtrtCertType string `json:"dtrt_cert_type"`
  3756. HospLv string `json:"hosp_lv"`
  3757. } `json:"setlinfo"`
  3758. } `json:"output"`
  3759. RefmsgTime string `json:"refmsg_time"`
  3760. RespondTime string `json:"respond_time"`
  3761. Signtype interface{} `json:"signtype"`
  3762. WarnMsg interface{} `json:"warn_msg"`
  3763. }
  3764. type ResultEleven10265 struct {
  3765. Cainfo string `json:"cainfo"`
  3766. ErrMsg string `json:"err_msg"`
  3767. InfRefmsgid string `json:"inf_refmsgid"`
  3768. Infcode string `json:"infcode"`
  3769. Output struct {
  3770. Setlinfo struct {
  3771. SetlTime string `json:"setl_time"`
  3772. CvlservPay float64 `json:"cvlserv_pay"`
  3773. Year string `json:"year"`
  3774. MedType string `json:"med_type"`
  3775. PsnPay float64 `json:"psn_pay"`
  3776. OpterID string `json:"opter_id"`
  3777. Begndate string `json:"begndate"`
  3778. FlxempeFlag string `json:"flxempe_flag"`
  3779. HifmiPay float64 `json:"hifmi_pay"`
  3780. PsnNo string `json:"psn_no"`
  3781. ActPayDedc float64 `json:"act_pay_dedc"`
  3782. MedinsSetlID interface{} `json:"medins_setl_id"`
  3783. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3784. ClrWay string `json:"clr_way"`
  3785. OthPay float64 `json:"oth_pay"`
  3786. Gend string `json:"gend"`
  3787. MdtrtID string `json:"mdtrt_id"`
  3788. AcctPay float64 `json:"acct_pay"`
  3789. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3790. Insutype string `json:"insutype"`
  3791. Invono interface{} `json:"invono"`
  3792. Enddate string `json:"enddate"`
  3793. CashPayamt float64 `json:"cash_payamt"`
  3794. PsnType string `json:"psn_type"`
  3795. FixmedinsName string `json:"fixmedins_name"`
  3796. HifpPay float64 `json:"hifp_pay"`
  3797. NewFlag interface{} `json:"new_flag"`
  3798. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3799. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3800. PayLoc string `json:"pay_loc"`
  3801. ClrType string `json:"clr_type"`
  3802. RefdSetlFlag string `json:"refd_setl_flag"`
  3803. CvlservFlag string `json:"cvlserv_flag"`
  3804. EmpName string `json:"emp_name"`
  3805. Brdy string `json:"brdy"`
  3806. Naty string `json:"naty"`
  3807. Certno string `json:"certno"`
  3808. DiseCode string `json:"dise_code"`
  3809. FixmedinsCode string `json:"fixmedins_code"`
  3810. DedcHospLv string `json:"dedc_hosp_lv"`
  3811. OpterName string `json:"opter_name"`
  3812. Balc float64 `json:"balc"`
  3813. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3814. PsnCertType string `json:"psn_cert_type"`
  3815. HifobPay float64 `json:"hifob_pay"`
  3816. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3817. HifesPay float64 `json:"hifes_pay"`
  3818. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3819. OptTime string `json:"opt_time"`
  3820. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3821. SetlID string `json:"setl_id"`
  3822. MafPay float64 `json:"maf_pay"`
  3823. PsnName string `json:"psn_name"`
  3824. InsuOptins interface{} `json:"insu_optins"`
  3825. PrefFundPay interface{} `json:"pref_fund_pay"`
  3826. ClrOptins string `json:"clr_optins"`
  3827. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3828. DiseName string `json:"dise_name"`
  3829. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3830. Age float64 `json:"age"`
  3831. DtrtCertType string `json:"dtrt_cert_type"`
  3832. HospLv string `json:"hosp_lv"`
  3833. } `json:"setlinfo"`
  3834. } `json:"output"`
  3835. RefmsgTime string `json:"refmsg_time"`
  3836. RespondTime string `json:"respond_time"`
  3837. Signtype interface{} `json:"signtype"`
  3838. WarnMsg interface{} `json:"warn_msg"`
  3839. }
  3840. type ResultTwelve struct {
  3841. Cainfo string `json:"cainfo"`
  3842. ErrMsg string `json:"err_msg"`
  3843. InfRefmsgid string `json:"inf_refmsgid"`
  3844. Infcode int64 `json:"infcode"`
  3845. Output struct {
  3846. MdtrtId string `json:"mdtrt_id"`
  3847. ChrgBchno string `json:"chrg_bchno"`
  3848. PsnNo string `json:"psn_no"`
  3849. } `json:"output"`
  3850. RefmsgTime string `json:"refmsg_time"`
  3851. RespondTime string `json:"respond_time"`
  3852. Signtype interface{} `json:"signtype"`
  3853. WarnMsg interface{} `json:"warn_msg"`
  3854. }
  3855. type ResultThirteen struct {
  3856. ErrMsg string `json:"err_msg"`
  3857. InfRefmsgid string `json:"inf_refmsgid"`
  3858. Infcode int64 `json:"infcode"`
  3859. Output struct {
  3860. Result struct {
  3861. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3862. } `json:"result"`
  3863. } `json:"output"`
  3864. RefmsgTime string `json:"refmsg_time"`
  3865. RespondTime string `json:"respond_time"`
  3866. Signtype interface{} `json:"signtype"`
  3867. WarnInfo interface{} `json:"warn_info"`
  3868. }
  3869. type ResultThirteen10265 struct {
  3870. ErrMsg string `json:"err_msg"`
  3871. InfRefmsgid string `json:"inf_refmsgid"`
  3872. Infcode string `json:"infcode"`
  3873. Output struct {
  3874. Result struct {
  3875. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3876. } `json:"result"`
  3877. } `json:"output"`
  3878. RefmsgTime string `json:"refmsg_time"`
  3879. RespondTime string `json:"respond_time"`
  3880. Signtype interface{} `json:"signtype"`
  3881. WarnInfo interface{} `json:"warn_info"`
  3882. }
  3883. type ResultFourteen struct {
  3884. ErrMsg string `json:"err_msg"`
  3885. InfRefmsgid string `json:"inf_refmsgid"`
  3886. Infcode int64 `json:"infcode"`
  3887. Output struct {
  3888. } `json:"output"`
  3889. RefmsgTime string `json:"refmsg_time"`
  3890. RespondTime string `json:"respond_time"`
  3891. Signtype interface{} `json:"signtype"`
  3892. WarnInfo interface{} `json:"warn_info"`
  3893. }
  3894. type ResultFourteen10265 struct {
  3895. ErrMsg string `json:"err_msg"`
  3896. InfRefmsgid string `json:"inf_refmsgid"`
  3897. Infcode string `json:"infcode"`
  3898. Output struct {
  3899. } `json:"output"`
  3900. RefmsgTime string `json:"refmsg_time"`
  3901. RespondTime string `json:"respond_time"`
  3902. Signtype interface{} `json:"signtype"`
  3903. WarnInfo interface{} `json:"warn_info"`
  3904. }
  3905. type ResultSixteen struct {
  3906. Cainfo string `json:"cainfo"`
  3907. ErrMsg string `json:"err_msg"`
  3908. InfRefmsgid string `json:"inf_refmsgid"`
  3909. Infcode int64 `json:"infcode"`
  3910. Output struct {
  3911. Setldetail []interface{} `json:"setldetail"`
  3912. Setlinfo struct {
  3913. MdtrtID string `json:"mdtrt_id"`
  3914. SetlID string `json:"setl_id"`
  3915. ClrOptins string `json:"clr_optins"`
  3916. SetlTime string `json:"setl_time"`
  3917. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3918. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3919. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3920. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3921. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3922. ActPayDedc float64 `json:"act_pay_dedc"`
  3923. HifpPay float64 `json:"hifp_pay"`
  3924. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3925. Lfpay float64 `json:"selfpay"`
  3926. CvlservPay float64 `json:"cvlserv_pay"`
  3927. HifesPay float64 `json:"hifes_pay"`
  3928. HifmiPay float64 `json:"hifmi_pay"`
  3929. HifobPay float64 `json:"hifob_pay"`
  3930. MafPay float64 `json:"maf_pay"`
  3931. OthPay float64 `json:"oth_pay"`
  3932. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3933. PsnPartAmt float64 `json:"psn_part_amt"`
  3934. AcctPay float64 `json:"acct_pay"`
  3935. Balc float64 `json:"balc"`
  3936. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3937. HospPartAmt float64 `json:"hosp_part_amt"`
  3938. MedinsSetlID string `json:"medins_setl_id"`
  3939. PdnCashPay string `json:"pdn_cash_pay"`
  3940. } `json:"setlinfo"`
  3941. } `json:"output"`
  3942. RefmsgTime string `json:"refmsg_time"`
  3943. RespondTime string `json:"respond_time"`
  3944. Signtype interface{} `json:"signtype"`
  3945. WarnMsg interface{} `json:"warn_msg"`
  3946. }
  3947. type ResultSixteen10265 struct {
  3948. Cainfo string `json:"cainfo"`
  3949. ErrMsg string `json:"err_msg"`
  3950. InfRefmsgid string `json:"inf_refmsgid"`
  3951. Infcode string `json:"infcode"`
  3952. Output struct {
  3953. Setldetail []interface{} `json:"setldetail"`
  3954. Setlinfo struct {
  3955. MdtrtID string `json:"mdtrt_id"`
  3956. SetlID string `json:"setl_id"`
  3957. ClrOptins string `json:"clr_optins"`
  3958. SetlTime string `json:"setl_time"`
  3959. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3960. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3961. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3962. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3963. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3964. ActPayDedc float64 `json:"act_pay_dedc"`
  3965. HifpPay float64 `json:"hifp_pay"`
  3966. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3967. Lfpay float64 `json:"selfpay"`
  3968. CvlservPay float64 `json:"cvlserv_pay"`
  3969. HifesPay float64 `json:"hifes_pay"`
  3970. HifmiPay float64 `json:"hifmi_pay"`
  3971. HifobPay float64 `json:"hifob_pay"`
  3972. MafPay float64 `json:"maf_pay"`
  3973. OthPay float64 `json:"oth_pay"`
  3974. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3975. PsnPartAmt float64 `json:"psn_part_amt"`
  3976. AcctPay float64 `json:"acct_pay"`
  3977. Balc float64 `json:"balc"`
  3978. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3979. HospPartAmt float64 `json:"hosp_part_amt"`
  3980. MedinsSetlID string `json:"medins_setl_id"`
  3981. PdnCashPay string `json:"pdn_cash_pay"`
  3982. } `json:"setlinfo"`
  3983. } `json:"output"`
  3984. RefmsgTime string `json:"refmsg_time"`
  3985. RespondTime string `json:"respond_time"`
  3986. Signtype interface{} `json:"signtype"`
  3987. WarnMsg interface{} `json:"warn_msg"`
  3988. }
  3989. type ResultSeventeen struct {
  3990. ErrMsg string `json:"err_msg"`
  3991. InfRefmsgid string `json:"inf_refmsgid"`
  3992. Infcode int64 `json:"infcode"`
  3993. Output struct {
  3994. SetlListId string `json:"setl_list_id"`
  3995. } `json:"output"`
  3996. RefmsgTime string `json:"refmsg_time"`
  3997. RespondTime string `json:"respond_time"`
  3998. Signtype string `json:"signtype"`
  3999. WarnInfo string `json:"warn_info"`
  4000. }
  4001. type Result90991 struct {
  4002. ErrMsg string `json:"err_msg"`
  4003. InfRefmsgid string `json:"inf_refmsgid"`
  4004. Infcode int64 `json:"infcode"`
  4005. Output struct {
  4006. Result struct {
  4007. PsnNo string `json:"psn_no"`
  4008. CardStat string `json:"card_stat"`
  4009. Certno string `json:"certno"`
  4010. PsnName string `json:"psn_name"`
  4011. CheckStat string `json:"check_stat"`
  4012. SscnoCheckStat string `json:"sscno_check_stat"`
  4013. } `json:"result"`
  4014. } `json:"output"`
  4015. RefmsgTime string `json:"refmsg_time"`
  4016. RespondTime string `json:"respond_time"`
  4017. Signtype interface{} `json:"signtype"`
  4018. WarnInfo interface{} `json:"warn_info"`
  4019. }
  4020. type Result90100 struct {
  4021. ErrMsg string `json:"err_msg"`
  4022. InfRefmsgid string `json:"inf_refmsgid"`
  4023. Infcode int64 `json:"infcode"`
  4024. Output struct {
  4025. PoolareaNo string `json:"poolarea_no"`
  4026. PoolareaNoName string `json:"poolarea_no_name"`
  4027. Insutype string `json:"insutype"`
  4028. InsutypeName string `json:"insutype_name"`
  4029. ClctType string `json:"clct_type"`
  4030. ClctTypeName string `json:"clct_type_name"`
  4031. ClctFlag string `json:"clct_flag"`
  4032. ClctFlagName string `json:"clct_flag_name"`
  4033. AccrymBegn string `json:"accrym_begn"`
  4034. AccrymEnd string `json:"accrym_end"`
  4035. ClctTime string `json:"clct_time"`
  4036. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  4037. } `json:"output"`
  4038. RefmsgTime string `json:"refmsg_time"`
  4039. RespondTime string `json:"respond_time"`
  4040. Signtype interface{} `json:"signtype"`
  4041. WarnInfo interface{} `json:"warn_info"`
  4042. }
  4043. type Custom struct {
  4044. DetItemFeeSumamt string
  4045. Cut string
  4046. FeedetlSn string
  4047. Price string
  4048. MedListCodg string
  4049. Type int64
  4050. AdviceId int64
  4051. ProjectId int64
  4052. ItemId int64
  4053. }
  4054. type Result5301 struct {
  4055. ErrMsg string `json:"err_msg"`
  4056. InfRefmsgid string `json:"inf_refmsgid"`
  4057. Infcode int64 `json:"infcode"`
  4058. Output struct {
  4059. Result []struct {
  4060. OpspDiseCode string `json:"opsp_dise_code"`
  4061. OpspDiseName string `json:"opsp_dise_name"`
  4062. Begndate string `json:"begndate"`
  4063. Enddate string `json:"enddate"`
  4064. } `json:"feedetail"`
  4065. } `json:"output"`
  4066. RefmsgTime string `json:"refmsg_time"`
  4067. RespondTime string `json:"respond_time"`
  4068. Signtype interface{} `json:"signtype"`
  4069. WarnInfo interface{} `json:"warn_info"`
  4070. }
  4071. type Result5301For10265 struct {
  4072. ErrMsg string `json:"err_msg"`
  4073. InfRefmsgid string `json:"inf_refmsgid"`
  4074. Infcode string `json:"infcode"`
  4075. Output struct {
  4076. Result []struct {
  4077. OpspDiseCode string `json:"opsp_dise_code"`
  4078. OpspDiseName string `json:"opsp_dise_name"`
  4079. Begndate string `json:"begndate"`
  4080. Enddate string `json:"enddate"`
  4081. } `json:"feedetail"`
  4082. } `json:"output"`
  4083. RefmsgTime string `json:"refmsg_time"`
  4084. RespondTime string `json:"respond_time"`
  4085. Signtype interface{} `json:"signtype"`
  4086. WarnInfo interface{} `json:"warn_info"`
  4087. }
  4088. //获取个人信息----挂号-----上传就诊信息
  4089. func (c *HisApiController) GetRegisterInfo() {
  4090. id, _ := c.GetInt64("id")
  4091. record_time := c.GetString("record_time")
  4092. settlementValue, _ := c.GetInt64("settlement_value")
  4093. medical_insurance_card := c.GetString("medical_insurance_card")
  4094. name := c.GetString("name")
  4095. id_card_type, _ := c.GetInt64("id_card_type")
  4096. certificates, _ := c.GetInt64("certificates")
  4097. medical_care, _ := c.GetInt64("medical_care")
  4098. birthday := c.GetString("birthday")
  4099. id_card := c.GetString("id_card")
  4100. register_type, _ := c.GetInt64("register")
  4101. doctor, _ := c.GetInt64("doctor")
  4102. department, _ := c.GetInt64("department")
  4103. gender, _ := c.GetInt64("sex")
  4104. registration_fee, _ := c.GetFloat("registration_fee")
  4105. medical_expenses, _ := c.GetFloat("medical_expenses")
  4106. social_type, _ := c.GetInt64("social_type")
  4107. med_type := c.GetString("social_type")
  4108. admin_user_id, _ := c.GetInt64("admin_user_id")
  4109. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4110. timeLayout := "2006-01-02"
  4111. loc, _ := time.LoadLocation("Local")
  4112. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4113. birthUnix := birthdays.Unix()
  4114. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4115. if err != nil {
  4116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4117. return
  4118. }
  4119. recordDateTime := theTime.Unix()
  4120. adminInfo := c.GetAdminUserInfo()
  4121. var patient service.Patients
  4122. if id == 0 {
  4123. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4124. } else {
  4125. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4126. }
  4127. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4128. if patientPrescription.ID == 0 {
  4129. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4130. }
  4131. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4132. if patient.ID == 0 {
  4133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4134. return
  4135. }
  4136. if len(patient.IdCardNo) == 0 {
  4137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4138. return
  4139. }
  4140. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4141. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4142. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4143. //就诊结算未完成,不能进行二次挂号
  4144. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4145. if len(his) >= 1 {
  4146. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  4147. if len(his) >= 1 && order.ID == 0 {
  4148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  4149. return
  4150. }
  4151. }
  4152. //var register_log string
  4153. if config.IsOpen == 1 {
  4154. var res ResultTwo
  4155. var res10265 ResultTwo10265
  4156. var PsnNo string
  4157. var PsnCertType string
  4158. var Certno string
  4159. var PsnName string
  4160. var Gend string
  4161. var Naty string
  4162. var Brdy string
  4163. var Age float64
  4164. var infoStr string
  4165. var idetinfoStr string
  4166. var infocode int64
  4167. var verify_number string
  4168. fmt.Println(verify_number)
  4169. if miConfig.MdtrtareaAdmvs == "421300" {
  4170. psn_info, _ := service.GetPsnByPatientId(id)
  4171. PsnNo = psn_info.PsnNo
  4172. PsnCertType = psn_info.PsnCertType
  4173. Certno = psn_info.Certno
  4174. PsnName = psn_info.PsnName
  4175. Gend = psn_info.Gend
  4176. Naty = psn_info.Naty
  4177. Brdy = psn_info.Brdy
  4178. Age = psn_info.Age
  4179. infoStr = psn_info.Insuinfo
  4180. idetinfoStr = psn_info.Idetinfo
  4181. infocode = 0
  4182. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4183. psn_info, _ := service.GetPsnByPatientId(id)
  4184. PsnNo = psn_info.PsnNo
  4185. PsnCertType = psn_info.PsnCertType
  4186. Certno = psn_info.Certno
  4187. PsnName = psn_info.PsnName
  4188. Gend = psn_info.Gend
  4189. Naty = psn_info.Naty
  4190. Brdy = psn_info.Brdy
  4191. Age = psn_info.Age
  4192. infoStr = psn_info.Insuinfo
  4193. idetinfoStr = psn_info.Idetinfo
  4194. infocode = 0
  4195. verify_number = psn_info.VerifyNumber
  4196. } else {
  4197. var result string
  4198. var requestLog string
  4199. if miConfig.UserOrgId == 10138 {
  4200. result, requestLog = service.Gdyb1101D(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name, record_time)
  4201. } else {
  4202. 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)
  4203. }
  4204. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4205. if miConfig.Code == "H15049901371" {
  4206. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4207. utils.ErrorLog("解析失败:%v", err)
  4208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4209. return
  4210. }
  4211. res.ErrMsg = res10265.ErrMsg
  4212. res.Output = res10265.Output
  4213. res.InfRefmsgid = res10265.InfRefmsgid
  4214. } else {
  4215. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4216. utils.ErrorLog("解析失败:%v", err)
  4217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4218. return
  4219. }
  4220. }
  4221. PsnNo = res.Output.Baseinfo.PsnNo
  4222. PsnCertType = res.Output.Baseinfo.PsnCertType
  4223. Certno = res.Output.Baseinfo.Certno
  4224. PsnName = res.Output.Baseinfo.PsnName
  4225. Gend = res.Output.Baseinfo.Gend
  4226. Naty = res.Output.Baseinfo.Naty
  4227. Brdy = res.Output.Baseinfo.Brdy
  4228. Age = res.Output.Baseinfo.Age
  4229. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4230. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4231. infoStr = string(Iinfos)
  4232. idetinfoStr = string(Idetinfos)
  4233. if miConfig.Code == "H15049901371" {
  4234. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  4235. } else {
  4236. infocode = res.Infcode
  4237. }
  4238. }
  4239. if infocode == 0 {
  4240. his := models.VMHisPatient{
  4241. Name: name,
  4242. Gender: gender,
  4243. Birthday: birthUnix,
  4244. MedicalTreatmentType: medical_care,
  4245. IdType: certificates,
  4246. IdCardNo: id_card,
  4247. BalanceAccountsType: settlementValue,
  4248. SocialType: social_type,
  4249. MedicalInsuranceNumber: medical_insurance_card,
  4250. RegisterType: register_type,
  4251. RegisterCost: registration_fee,
  4252. TreatmentCost: medical_expenses,
  4253. Status: 1,
  4254. Ctime: time.Now().Unix(),
  4255. Mtime: time.Now().Unix(),
  4256. PsnNo: PsnNo,
  4257. PsnCertType: PsnCertType,
  4258. Certno: Certno,
  4259. PsnName: PsnName,
  4260. Gend: Gend,
  4261. Naty: Naty,
  4262. Brdy: Brdy,
  4263. Age: Age,
  4264. Iinfo: infoStr,
  4265. Idetinfo: idetinfoStr,
  4266. PatientId: patient.ID,
  4267. RecordDate: theTime.Unix(),
  4268. UserOrgId: adminInfo.CurrentOrgId,
  4269. AdminUserId: admin_user_id,
  4270. IsReturn: 1,
  4271. IdCardType: id_card_type,
  4272. Doctor: doctor,
  4273. Departments: department,
  4274. }
  4275. timestamp := time.Now().Unix()
  4276. tempTime := time.Unix(timestamp, 0)
  4277. timeFormat := tempTime.Format("20060102150405")
  4278. chrgBchno := rand.Intn(100000) + 10000
  4279. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4280. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  4281. department, _ := service.GetDepartMentDetail(department)
  4282. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  4283. IdCardNo := ""
  4284. if id_card_type == 1 {
  4285. // IdCardNo = medical_insurance_card
  4286. IdCardNo = patient.IdCardNo
  4287. } else {
  4288. IdCardNo = patient.IdCardNo
  4289. }
  4290. var rf []*ResultFive
  4291. json.Unmarshal([]byte(his.Iinfo), &rf)
  4292. var insutypes []*ResultFive
  4293. var insutype string
  4294. var insuplc_admdvs_temp string
  4295. var is390 int = 0
  4296. var is310 int = 0
  4297. for _, item := range rf {
  4298. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4299. insutypes = append(insutypes, item)
  4300. }
  4301. }
  4302. if len(insutypes) == 1 {
  4303. insutype = insutypes[0].Insutype
  4304. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4305. } else {
  4306. for _, i := range insutypes {
  4307. if i.Insutype == "390" {
  4308. is390 = 1
  4309. }
  4310. if i.Insutype == "310" {
  4311. is310 = 1
  4312. }
  4313. }
  4314. }
  4315. if is390 == 1 {
  4316. insutype = "390"
  4317. }
  4318. if is310 == 1 {
  4319. insutype = "310"
  4320. }
  4321. if len(insutypes) == 0 {
  4322. insutype = "310"
  4323. }
  4324. if len(insutypes) == 2 {
  4325. insutype = med_type
  4326. }
  4327. if len(med_type) > 0 {
  4328. insutype = med_type
  4329. }
  4330. //for _, item := range rf {
  4331. // if item.Insutype == insutype {
  4332. // insuplc_admdvs = item.InsuplcAdmdvs
  4333. // }
  4334. //}
  4335. var infocode int64
  4336. var resThree ResultThree
  4337. var resThree10265 ResultThree10265
  4338. if len(insuplc_admdvs) == 0 {
  4339. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  4340. } else {
  4341. insuplc_admdvs_temp = insuplc_admdvs
  4342. }
  4343. if miConfig.MdtrtareaAdmvs == "421300" {
  4344. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  4345. "&org_name=" + miConfig.OrgName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4346. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&doctor_name=" + doctor_info.UserName
  4347. resp, requestErr := http.Get(api)
  4348. if requestErr != nil {
  4349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4350. return
  4351. }
  4352. body, ioErr := ioutil.ReadAll(resp.Body)
  4353. if ioErr != nil {
  4354. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4356. return
  4357. }
  4358. var respJSON map[string]interface{}
  4359. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4360. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4362. return
  4363. }
  4364. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4365. result, _ := json.Marshal(respJSON)
  4366. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4367. utils.ErrorLog("解析失败:%v", err)
  4368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4369. return
  4370. }
  4371. infocode = resThree.Infcode
  4372. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4373. psn_info, _ := service.GetPsnByPatientId(id)
  4374. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4375. var cert_no string
  4376. if id_card_type == 3 {
  4377. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  4378. cert_no = IdCardNo
  4379. } else {
  4380. bas := strings.Split(psn_info.CardInfo, "|")
  4381. cert_no = bas[2]
  4382. }
  4383. var api string
  4384. if miConfig.MdtrtareaAdmvs == "320921" {
  4385. api = "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4386. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4387. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4388. } else {
  4389. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4390. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4391. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4392. }
  4393. resp, requestErr := http.Get(api)
  4394. if requestErr != nil {
  4395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4396. return
  4397. }
  4398. body, ioErr := ioutil.ReadAll(resp.Body)
  4399. if ioErr != nil {
  4400. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4402. return
  4403. }
  4404. var respJSON map[string]interface{}
  4405. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4406. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4408. return
  4409. }
  4410. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4411. result, _ := json.Marshal(respJSON)
  4412. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4413. utils.ErrorLog("解析失败:%v", err)
  4414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4415. return
  4416. }
  4417. resThree.ErrMsg = resThree10265.ErrMsg
  4418. resThree.Output = resThree10265.Output
  4419. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4420. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4421. } else {
  4422. result, requestLog := service.Gdyb2201A(res.Output.Baseinfo.PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_id, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, record_time)
  4423. saveLog(result, requestLog, "2201A", "挂号")
  4424. if miConfig.Code == "H15049901371" {
  4425. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4426. utils.ErrorLog("解析失败:%v", err)
  4427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4428. return
  4429. }
  4430. resThree.ErrMsg = resThree10265.ErrMsg
  4431. resThree.Output = resThree10265.Output
  4432. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4433. } else {
  4434. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4435. utils.ErrorLog("解析失败:%v", err)
  4436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4437. return
  4438. }
  4439. }
  4440. if miConfig.Code == "H15049901371" {
  4441. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4442. } else {
  4443. infocode = resThree.Infcode
  4444. }
  4445. }
  4446. if infocode != 0 {
  4447. adminUser := c.GetAdminUserInfo()
  4448. errlog := &models.HisOrderError{
  4449. UserOrgId: adminUser.CurrentOrgId,
  4450. Ctime: time.Now().Unix(),
  4451. Mtime: time.Now().Unix(),
  4452. ErrMsg: resThree.ErrMsg,
  4453. Status: 1,
  4454. PatientId: id,
  4455. RecordTime: recordDateTime,
  4456. Stage: 2,
  4457. }
  4458. service.CreateErrMsgLog(errlog)
  4459. c.ServeSuccessJSON(map[string]interface{}{
  4460. "failed_code": -10,
  4461. "msg": resThree.ErrMsg,
  4462. })
  4463. return
  4464. }
  4465. his.Number = resThree.Output.Data.MdtrtID
  4466. his.PsnNo = resThree.Output.Data.PsnNo
  4467. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  4468. his.IdCardNo = patient.IdCardNo
  4469. his.PhoneNumber = patient.Phone
  4470. his.UserOrgId = adminInfo.CurrentOrgId
  4471. his.Insutype = insutype
  4472. his.Ctime = time.Now().Unix()
  4473. his.Mtime = time.Now().Unix()
  4474. his.InsuplcAdmdvs = insuplc_admdvs_temp
  4475. his.Status = 1
  4476. service.UpdateHisPatientStatus(&his)
  4477. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  4478. c.ServeSuccessJSON(map[string]interface{}{
  4479. "his_info": his,
  4480. })
  4481. } else {
  4482. adminUser := c.GetAdminUserInfo()
  4483. errlog := &models.HisOrderError{
  4484. UserOrgId: adminUser.CurrentOrgId,
  4485. Ctime: time.Now().Unix(),
  4486. Mtime: time.Now().Unix(),
  4487. ErrMsg: res.ErrMsg,
  4488. Status: 1,
  4489. PatientId: id,
  4490. RecordTime: recordDateTime,
  4491. Stage: 1,
  4492. }
  4493. service.CreateErrMsgLog(errlog)
  4494. c.ServeSuccessJSON(map[string]interface{}{
  4495. "failed_code": -10,
  4496. "msg": res.ErrMsg,
  4497. })
  4498. return
  4499. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  4500. }
  4501. }
  4502. }
  4503. //上传明细----预结算----确认订单
  4504. func (c *HisApiController) GetUploadInfo() {
  4505. id, _ := c.GetInt64("id")
  4506. record_time := c.GetString("record_time")
  4507. his_patient_id, _ := c.GetInt64("his_patient_id")
  4508. order_id, _ := c.GetInt64("order_id")
  4509. pay_way, _ := c.GetInt64("pay_way")
  4510. pay_price, _ := c.GetFloat("pay_price")
  4511. pay_card_no := c.GetString("pay_card_no")
  4512. discount_price, _ := c.GetFloat("discount_price")
  4513. preferential_price, _ := c.GetFloat("preferential_price")
  4514. reality_price, _ := c.GetFloat("reality_price")
  4515. found_price, _ := c.GetFloat("found_price")
  4516. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  4517. private_price, _ := c.GetFloat("private_price")
  4518. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4519. admin_user_id, _ := c.GetInt64("admin_user_id")
  4520. fapiao_code := c.GetString("fapiao_code")
  4521. fapiao_number := c.GetString("fapiao_number")
  4522. diagnosis_id := c.GetString("diagnosis")
  4523. sick_type, _ := c.GetInt64("sick_type")
  4524. reg_type, _ := c.GetInt64("p_type")
  4525. begin_time := c.GetString("begin_time")
  4526. id_str := c.GetString("ids")
  4527. ids_arr := strings.Split(id_str, ",")
  4528. timeLayout := "2006-01-02"
  4529. loc, _ := time.LoadLocation("Local")
  4530. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4531. if err != nil {
  4532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4533. return
  4534. }
  4535. recordDateTime := theTime.Unix()
  4536. adminUser := c.GetAdminUserInfo()
  4537. var tempOrder models.HisOrder
  4538. tempOrder, _ = service.GetHisOrderByID(order_id)
  4539. var prescriptions []*models.HisPrescription
  4540. var start_time int64
  4541. var end_time int64
  4542. //if adminUser.CurrentOrgId == 10106{
  4543. // if len(fapiao_code) == 0{
  4544. // fapiao_code = "144072080589"
  4545. // }
  4546. // if len(fapiao_number) == 0{
  4547. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  4548. // if order.ID == 0{
  4549. // fapiao_number = "00001520"
  4550. // }else{
  4551. // //fapiao_code = "00001520"
  4552. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  4553. // var zero string
  4554. // if fpNumber >= 1000{
  4555. // zero = "0000" + strconv.Itoa(fpNumber)
  4556. // }else if fpNumber >= 10000{
  4557. // zero = "000" + strconv.Itoa(fpNumber)
  4558. // } else if fpNumber >= 100000{
  4559. // zero = "00" + strconv.Itoa(fpNumber)
  4560. // } else if fpNumber >= 1000000{
  4561. // zero = "0" + strconv.Itoa(fpNumber)
  4562. // }else {
  4563. // zero = strconv.Itoa(fpNumber)
  4564. // }
  4565. // fapiao_number = zero
  4566. // }
  4567. // }
  4568. //}
  4569. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4570. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4571. var patientPrescription models.HisPrescriptionInfo
  4572. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4573. if patientPrescription.ID == 0 {
  4574. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4575. }
  4576. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4577. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4578. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4579. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4580. var config []*models.HisXtDiagnoseConfig
  4581. for _, item := range diagnosis_ids {
  4582. id, _ := strconv.ParseInt(item, 10, 64)
  4583. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4584. config = append(config, &diagnosisConfig)
  4585. }
  4586. sickConfig, _ := service.FindSickById(sick_type)
  4587. //if tempOrder.ID == 0 {
  4588. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  4589. //}
  4590. if tempOrder.ID == 0 {
  4591. var result string
  4592. var requestLog string
  4593. var res2 ResultSix
  4594. var ressix10265 ResultSix10265
  4595. if miConfig.MdtrtareaAdmvs == "421300" {
  4596. data := make(map[string]interface{})
  4597. client := &http.Client{}
  4598. data["psn_no"] = his.PsnNo
  4599. data["mdtrt_id"] = his.Number
  4600. data["doctor"] = roles.UserName
  4601. data["department"] = department.Name
  4602. data["org_name"] = miConfig.OrgName
  4603. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4604. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4605. data["fixmedins_code"] = miConfig.Code
  4606. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4607. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4608. data["secret_key"] = miConfig.SecretKey
  4609. data["sick_code"] = sickConfig.CountryCode
  4610. data["sick_name"] = sickConfig.ClassName
  4611. data["dept"] = strconv.FormatInt(department.ID, 10)
  4612. data["config"] = config
  4613. data["begin_time"] = begin_time
  4614. bytesData, _ := json.Marshal(data)
  4615. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  4616. resp, _ := client.Do(req)
  4617. defer resp.Body.Close()
  4618. body, ioErr := ioutil.ReadAll(resp.Body)
  4619. if ioErr != nil {
  4620. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4622. return
  4623. }
  4624. var respJSON map[string]interface{}
  4625. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4626. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4628. return
  4629. }
  4630. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4631. userJSONBytes, _ := json.Marshal(respJSON)
  4632. fmt.Println("log")
  4633. fmt.Println(string(userJSONBytes))
  4634. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4635. utils.ErrorLog("解析失败:%v", err)
  4636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4637. return
  4638. }
  4639. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4640. //江苏地区国家医保医疗类别
  4641. //职工透析:医疗类别选特殊情况门诊9933
  4642. //居民血透门慢: 医疗类别选门诊慢病1402
  4643. //var med_type string
  4644. //if his.Insutype == "310" {
  4645. // if reg_type == 14 {
  4646. // med_type = "9933"
  4647. // } else if reg_type == 11 {
  4648. // med_type = "11"
  4649. //
  4650. // }
  4651. //} else if his.Insutype == "390" {
  4652. // if reg_type == 14 {
  4653. // med_type = "1402"
  4654. // } else if reg_type == 11 {
  4655. // med_type = "11"
  4656. // }
  4657. //}
  4658. data := make(map[string]interface{})
  4659. client := &http.Client{}
  4660. data["psn_no"] = his.PsnNo
  4661. data["mdtrt_id"] = his.Number
  4662. data["doctor"] = roles.UserName
  4663. data["department"] = department.Name
  4664. data["org_name"] = miConfig.OrgName
  4665. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4666. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4667. data["fixmedins_code"] = miConfig.Code
  4668. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4669. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4670. data["secret_key"] = miConfig.SecretKey
  4671. data["sick_code"] = sickConfig.CountryCode
  4672. data["sick_name"] = sickConfig.ClassName
  4673. data["url"] = miConfig.Url
  4674. data["ak"] = miConfig.AccessKey
  4675. data["begin_time"] = begin_time
  4676. data["cainfo"] = miConfig.Cainfo
  4677. data["dept"] = strconv.FormatInt(department.ID, 10)
  4678. data["config"] = config
  4679. bytesData, _ := json.Marshal(data)
  4680. var req *http.Request
  4681. if miConfig.MdtrtareaAdmvs == "320921" {
  4682. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4683. //api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  4684. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  4685. } else {
  4686. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4687. }
  4688. resp, _ := client.Do(req)
  4689. defer resp.Body.Close()
  4690. body, ioErr := ioutil.ReadAll(resp.Body)
  4691. if ioErr != nil {
  4692. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4694. return
  4695. }
  4696. var respJSON map[string]interface{}
  4697. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4698. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4700. return
  4701. }
  4702. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4703. userJSONBytes, _ := json.Marshal(respJSON)
  4704. fmt.Println("log")
  4705. fmt.Println(string(userJSONBytes))
  4706. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  4707. utils.ErrorLog("解析失败:%v", err)
  4708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4709. return
  4710. }
  4711. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4712. res2.Output = ressix10265.Output
  4713. res2.ErrMsg = ressix10265.ErrMsg
  4714. res2.Cainfo = ressix10265.Cainfo
  4715. res2.WarnMsg = ressix10265.WarnMsg
  4716. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4717. res2.Infcode = infocode
  4718. } else {
  4719. if miConfig.MdtrtareaAdmvs == "440781" { //
  4720. result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  4721. } else {
  4722. if miConfig.Code == "H15049901371" {
  4723. //赤峰地区国家医保医疗类别
  4724. //职工透析:医疗类别选特殊情况门诊990502
  4725. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4726. var med_type string
  4727. if his.Insutype == "390" {
  4728. if reg_type == 14 {
  4729. med_type = "9933"
  4730. } else if reg_type == 11 {
  4731. med_type = "11"
  4732. }
  4733. } else if his.Insutype == "310" {
  4734. if reg_type == 14 {
  4735. med_type = "990502"
  4736. } else if reg_type == 11 {
  4737. med_type = "11"
  4738. }
  4739. }
  4740. 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)
  4741. } else {
  4742. 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)
  4743. }
  4744. }
  4745. saveLog(result, requestLog, "2203", "上传就诊信息")
  4746. var respJSON2 map[string]interface{}
  4747. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4748. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4750. return
  4751. }
  4752. userJSONBytes2, _ := json.Marshal(respJSON2)
  4753. if miConfig.Code == "H15049901371" {
  4754. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  4755. utils.ErrorLog("解析失败:%v", err)
  4756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4757. return
  4758. }
  4759. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4760. res2.Output = ressix10265.Output
  4761. res2.ErrMsg = ressix10265.ErrMsg
  4762. res2.Cainfo = ressix10265.Cainfo
  4763. res2.WarnMsg = ressix10265.WarnMsg
  4764. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4765. res2.Infcode = infocode
  4766. } else {
  4767. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4768. utils.ErrorLog("解析失败:%v", err)
  4769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4770. return
  4771. }
  4772. }
  4773. }
  4774. if res2.Infcode != 0 {
  4775. adminUser := c.GetAdminUserInfo()
  4776. errlog := &models.HisOrderError{
  4777. UserOrgId: adminUser.CurrentOrgId,
  4778. Ctime: time.Now().Unix(),
  4779. Mtime: time.Now().Unix(),
  4780. ErrMsg: res2.ErrMsg,
  4781. Status: 1,
  4782. PatientId: id,
  4783. RecordTime: recordDateTime,
  4784. Stage: 3,
  4785. }
  4786. service.CreateErrMsgLog(errlog)
  4787. c.ServeSuccessJSON(map[string]interface{}{
  4788. "failed_code": -10,
  4789. "msg": res2.ErrMsg,
  4790. })
  4791. return
  4792. } else {
  4793. his.Diagnosis = diagnosis_id
  4794. his.SickType = sickConfig.ID
  4795. //var p_type int64
  4796. //if reg_type == 1111 || reg_type == 1112 {
  4797. // p_type = 11
  4798. //
  4799. //}
  4800. his.PType = fmt.Sprintf("%d", reg_type)
  4801. service.UpdateHisPatientThree(&his)
  4802. data := make(map[string]interface{})
  4803. if settle_accounts_type == 1 { //日结
  4804. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  4805. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  4806. } else {
  4807. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  4808. }
  4809. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  4810. data["pre"] = prescriptions
  4811. } else { //月结
  4812. start_time_str := c.GetString("start_time")
  4813. end_time_str := c.GetString("end_time")
  4814. timeLayout := "2006-01-02"
  4815. loc, _ := time.LoadLocation("Local")
  4816. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4817. if err != nil {
  4818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4819. return
  4820. }
  4821. recordStartTime := theStartTime.Unix()
  4822. start_time = recordStartTime
  4823. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4824. if err != nil {
  4825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4826. return
  4827. }
  4828. recordEndTime := theEndTime.Unix()
  4829. end_time = recordEndTime
  4830. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  4831. data["pre"] = prescriptions
  4832. }
  4833. timestamp := time.Now().Unix()
  4834. tempTime := time.Unix(timestamp, 0)
  4835. timeFormat := tempTime.Format("20060102150405")
  4836. chrgBchno := rand.Intn(100000) + 10000
  4837. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4838. strconv.FormatInt(his.PatientId, 10)
  4839. client := &http.Client{}
  4840. data["psn_no"] = his.PsnNo
  4841. data["mdtrt_id"] = his.Number
  4842. data["chrg_bchno"] = chrg_bchno
  4843. data["org_name"] = miConfig.OrgName
  4844. data["doctor"] = roles.UserName
  4845. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4846. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4847. data["fixmedins_code"] = miConfig.Code
  4848. //if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  4849. // data["dept_code"] = "15"
  4850. //} else {
  4851. data["dept_code"] = department.Number
  4852. //}
  4853. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4854. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4855. data["secret_key"] = miConfig.SecretKey
  4856. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  4857. data["url"] = miConfig.Url
  4858. data["ak"] = miConfig.AccessKey
  4859. data["new_doctor_name"] = patientPrescription.Doctor
  4860. data["diag_code"] = sickConfig.CountryCode
  4861. data["cainfo"] = miConfig.Cainfo
  4862. var ids []int64
  4863. for _, item := range prescriptions {
  4864. ids = append(ids, item.ID)
  4865. }
  4866. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4867. if config.IsOpen == 1 { //对接了医保,走医保流程
  4868. var res ResultFour
  4869. var resFour10265 ResultFour10265
  4870. if miConfig.MdtrtareaAdmvs == "421300" {
  4871. bytesData, _ := json.Marshal(data)
  4872. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  4873. resp, _ := client.Do(req)
  4874. defer resp.Body.Close()
  4875. body, ioErr := ioutil.ReadAll(resp.Body)
  4876. if ioErr != nil {
  4877. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4879. return
  4880. }
  4881. var respJSON map[string]interface{}
  4882. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4883. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4885. return
  4886. }
  4887. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4888. userJSONBytes, _ := json.Marshal(respJSON)
  4889. fmt.Println("log")
  4890. fmt.Println(string(userJSONBytes))
  4891. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4892. utils.ErrorLog("解析失败:%v", err)
  4893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4894. return
  4895. }
  4896. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4897. bytesData, _ := json.Marshal(data)
  4898. var req *http.Request
  4899. if miConfig.MdtrtareaAdmvs == "320921" {
  4900. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4901. } else {
  4902. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4903. }
  4904. resp, _ := client.Do(req)
  4905. defer resp.Body.Close()
  4906. body, ioErr := ioutil.ReadAll(resp.Body)
  4907. if ioErr != nil {
  4908. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4910. return
  4911. }
  4912. var respJSON map[string]interface{}
  4913. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4914. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4916. return
  4917. }
  4918. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4919. userJSONBytes, _ := json.Marshal(respJSON)
  4920. fmt.Println("log")
  4921. fmt.Println(string(userJSONBytes))
  4922. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4923. utils.ErrorLog("解析失败:%v", err)
  4924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4925. return
  4926. }
  4927. res.InfRefmsgid = resFour10265.InfRefmsgid
  4928. res.Output = resFour10265.Output
  4929. res.ErrMsg = resFour10265.ErrMsg
  4930. res.Cainfo = resFour10265.Cainfo
  4931. res.WarnMsg = resFour10265.WarnMsg
  4932. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4933. res.Infcode = infocode
  4934. } else {
  4935. if miConfig.Code == "H15049901371" {
  4936. 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)
  4937. var dat map[string]interface{}
  4938. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4939. fmt.Println(dat)
  4940. } else {
  4941. fmt.Println(err)
  4942. }
  4943. saveLog(result, request_log, "2204", "上传费用明细")
  4944. userJSONBytes, _ := json.Marshal(dat)
  4945. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4946. utils.ErrorLog("解析失败:%v", err)
  4947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4948. return
  4949. }
  4950. res.InfRefmsgid = resFour10265.InfRefmsgid
  4951. res.Output = resFour10265.Output
  4952. res.ErrMsg = resFour10265.ErrMsg
  4953. res.Cainfo = resFour10265.Cainfo
  4954. res.WarnMsg = resFour10265.WarnMsg
  4955. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4956. res.Infcode = infocode
  4957. } else {
  4958. 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)
  4959. var dat map[string]interface{}
  4960. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4961. fmt.Println(dat)
  4962. } else {
  4963. fmt.Println(err)
  4964. }
  4965. saveLog(result, request_log, "2204", "上传费用明细")
  4966. userJSONBytes, _ := json.Marshal(dat)
  4967. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4968. utils.ErrorLog("解析失败:%v", err)
  4969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4970. return
  4971. }
  4972. }
  4973. }
  4974. if res.Infcode == 0 {
  4975. order := &models.HisOrder{
  4976. UserOrgId: adminUser.CurrentOrgId,
  4977. HisPatientId: his.ID,
  4978. PatientId: his.PatientId,
  4979. SettleAccountsDate: recordDateTime,
  4980. MdtrtId: his.Number,
  4981. PsnNo: his.PsnNo,
  4982. MedType: strconv.FormatInt(reg_type, 10),
  4983. Ctime: time.Now().Unix(),
  4984. Mtime: time.Now().Unix(),
  4985. Status: 1,
  4986. Number: chrg_bchno,
  4987. Infcode: res.Infcode,
  4988. WarnMsg: res.WarnMsg,
  4989. Cainfo: res.Cainfo,
  4990. ErrMsg: res.ErrMsg,
  4991. RespondTime: res.RefmsgTime,
  4992. InfRefmsgid: res.InfRefmsgid,
  4993. OrderStatus: 1,
  4994. PayWay: pay_way,
  4995. PayPrice: pay_price,
  4996. PayCardNo: pay_card_no,
  4997. DiscountPrice: discount_price,
  4998. PreferentialPrice: preferential_price,
  4999. RealityPrice: reality_price,
  5000. FoundPrice: found_price,
  5001. MedicalInsurancePrice: medical_insurance_price,
  5002. PrivatePrice: private_price,
  5003. IsMedicineInsurance: 1,
  5004. SettleType: settle_accounts_type,
  5005. SettleStartTime: start_time,
  5006. SettleEndTime: end_time,
  5007. Creator: roles.AdminUserId,
  5008. Modify: roles.AdminUserId,
  5009. FaPiaoNumber: fapiao_number,
  5010. FaPiaoCode: fapiao_code,
  5011. PType: 2,
  5012. Diagnosis: diagnosis_id,
  5013. }
  5014. err = service.CreateOrder(order)
  5015. if err != nil {
  5016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5017. return
  5018. }
  5019. for _, item := range res.Output.Result {
  5020. temp := strings.Split(item.FeedetlSn, "-")
  5021. var advice_id int64 = 0
  5022. var project_id int64 = 0
  5023. var types int64 = 0
  5024. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5025. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5026. if temp[1] == "1" {
  5027. advice_id = id
  5028. project_id = 0
  5029. } else if temp[1] == "2" {
  5030. advice_id = 0
  5031. project_id = id
  5032. }
  5033. info := &models.HisOrderInfo{
  5034. OrderNumber: order.Number,
  5035. FeedetlSn: item.FeedetlSn,
  5036. UploadDate: time.Now().Unix(),
  5037. AdviceId: advice_id,
  5038. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5039. Cnt: item.Cnt,
  5040. Pric: float64(item.Pric),
  5041. PatientId: his.PatientId,
  5042. PricUplmtAmt: item.PricUplmtAmt,
  5043. SelfpayProp: item.SelfpayProp,
  5044. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5045. OverlmtAmt: item.OverlmtAmt,
  5046. PreselfpayAmt: item.PreselfpayAmt,
  5047. BasMednFlag: item.BasMednFlag,
  5048. MedChrgitmType: item.MedChrgitmType,
  5049. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5050. Status: 1,
  5051. Memo: item.Memo,
  5052. Mtime: time.Now().Unix(),
  5053. InscpScpAmt: item.InscpScpAmt,
  5054. DrtReimFlag: item.DrtReimFlag,
  5055. Ctime: time.Now().Unix(),
  5056. ListSpItemFlag: item.ListSpItemFlag,
  5057. ChldMedcFlag: item.ChldMedcFlag,
  5058. LmtUsedFlag: item.LmtUsedFlag,
  5059. ChrgitmLv: item.ChrgitmLv,
  5060. UserOrgId: adminUser.CurrentOrgId,
  5061. HisPatientId: his.ID,
  5062. OrderId: order.ID,
  5063. ProjectId: project_id,
  5064. Type: types,
  5065. }
  5066. service.CreateOrderInfo(info)
  5067. }
  5068. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5069. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5070. var total float64
  5071. for _, item := range prescriptions {
  5072. if item.Type == 1 { //药品
  5073. for _, subItem := range item.HisDoctorAdviceInfo {
  5074. total = total + (subItem.Price * subItem.PrescribingNumber)
  5075. }
  5076. }
  5077. if item.Type == 2 { //项目
  5078. for _, subItem := range item.HisPrescriptionProject {
  5079. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5080. total = total + (subItem.Price * cnt)
  5081. }
  5082. }
  5083. }
  5084. for _, item := range prescriptions {
  5085. for _, subItem := range item.HisAdditionalCharge {
  5086. total = total + (subItem.Price * float64(subItem.Count))
  5087. }
  5088. }
  5089. var allTotal string
  5090. if adminUser.CurrentOrgId == 9919 {
  5091. allTotal = fmt.Sprintf("%.4f", total)
  5092. } else {
  5093. allTotal = fmt.Sprintf("%.4f", total)
  5094. }
  5095. if res.Infcode == 0 {
  5096. var rf []*ResultFive
  5097. json.Unmarshal([]byte(his.Iinfo), &rf)
  5098. chrg_bchno := chrg_bchno
  5099. cert_no := his.Certno
  5100. var insutypes []string
  5101. var insutype string
  5102. var is390 int = 0
  5103. var is310 int = 0
  5104. for _, item := range rf {
  5105. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5106. insutypes = append(insutypes, item.Insutype)
  5107. }
  5108. }
  5109. if len(insutypes) == 1 {
  5110. insutype = insutypes[0]
  5111. } else {
  5112. for _, i := range insutypes {
  5113. if i == "390" {
  5114. is390 = 1
  5115. }
  5116. if i == "310" {
  5117. is310 = 1
  5118. }
  5119. }
  5120. }
  5121. if is390 == 1 {
  5122. insutype = "390"
  5123. }
  5124. if is310 == 1 {
  5125. insutype = "310"
  5126. }
  5127. if len(insutypes) == 0 {
  5128. insutype = "310"
  5129. }
  5130. if len(insutypes) == 2 {
  5131. insutype = strconv.FormatInt(his.SocialType, 10)
  5132. }
  5133. insutype = strconv.FormatInt(his.SocialType, 10)
  5134. //insutype = "390"
  5135. if his.IdCardType == 1 {
  5136. // cert_no = his.MedicalInsuranceNumber
  5137. cert_no = his.Certno
  5138. } else {
  5139. cert_no = his.Certno
  5140. }
  5141. var res ResultSeven
  5142. var resSeven10265 ResultSeven10265
  5143. var src_resquest string
  5144. var result2 string
  5145. var acct_used_flag string
  5146. fmt.Println("pay_way")
  5147. fmt.Println(pay_way)
  5148. fmt.Println("pay_way")
  5149. if pay_way == 4 {
  5150. acct_used_flag = "1"
  5151. } else {
  5152. acct_used_flag = "0"
  5153. }
  5154. if miConfig.MdtrtareaAdmvs == "421300" {
  5155. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5156. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5157. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5158. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5159. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5160. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5161. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5162. resp, requestErr := http.Get(api)
  5163. if requestErr != nil {
  5164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5165. return
  5166. }
  5167. body, ioErr := ioutil.ReadAll(resp.Body)
  5168. if ioErr != nil {
  5169. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5171. return
  5172. }
  5173. var respJSON map[string]interface{}
  5174. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5175. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5177. return
  5178. }
  5179. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5180. result, _ := json.Marshal(respJSON)
  5181. if miConfig.Code == "H15049901371" {
  5182. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5183. utils.ErrorLog("解析失败:%v", err)
  5184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5185. return
  5186. }
  5187. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5188. res.Output = resSeven10265.Output
  5189. res.ErrMsg = resSeven10265.ErrMsg
  5190. res.Cainfo = resSeven10265.Cainfo
  5191. res.WarnMsg = resSeven10265.WarnMsg
  5192. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5193. res.Infcode = infocode
  5194. } else {
  5195. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5196. utils.ErrorLog("解析失败:%v", err)
  5197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5198. return
  5199. }
  5200. }
  5201. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5202. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5203. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5204. //psn_info, _ := service.GetPsnByPatientId(id)
  5205. bas := strings.Split(psn_info.CardInfo, "|")
  5206. if his.IdCardType == 1 {
  5207. cert_no = bas[2]
  5208. } else if his.IdCardType == 3 {
  5209. cert_no = his.Certno
  5210. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  5211. } else {
  5212. cert_no = bas[1]
  5213. }
  5214. //江苏地区国家医保医疗类别
  5215. //职工透析:医疗类别选特殊情况门诊9933
  5216. //居民血透门慢: 医疗类别选门诊慢病1402
  5217. //var med_type string
  5218. //if his.Insutype == "310" {
  5219. // if reg_type == 14 {
  5220. // med_type = "9933"
  5221. // } else if reg_type == 11 {
  5222. // med_type = "11"
  5223. //
  5224. // }
  5225. //} else if his.Insutype == "390" {
  5226. // if reg_type == 14 {
  5227. // med_type = "1402"
  5228. // } else if reg_type == 11 {
  5229. // med_type = "11"
  5230. // }
  5231. //}
  5232. //psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5233. var api string
  5234. if miConfig.MdtrtareaAdmvs == "320921" {
  5235. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5236. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5237. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5238. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5239. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5240. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5241. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  5242. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5243. } else {
  5244. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5245. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5246. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5247. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5248. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5249. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5250. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5251. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  5252. }
  5253. resp, requestErr := http.Get(api)
  5254. if requestErr != nil {
  5255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5256. return
  5257. }
  5258. body, ioErr := ioutil.ReadAll(resp.Body)
  5259. if ioErr != nil {
  5260. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5262. return
  5263. }
  5264. var respJSON map[string]interface{}
  5265. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5266. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5268. return
  5269. }
  5270. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5271. result, _ := json.Marshal(respJSON)
  5272. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5273. utils.ErrorLog("解析失败:%v", err)
  5274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5275. return
  5276. }
  5277. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5278. res.Output = resSeven10265.Output
  5279. res.ErrMsg = resSeven10265.ErrMsg
  5280. res.Cainfo = resSeven10265.Cainfo
  5281. res.WarnMsg = resSeven10265.WarnMsg
  5282. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5283. res.Infcode = infocode
  5284. } else {
  5285. if miConfig.Code == "H15049901371" {
  5286. //赤峰地区国家医保医疗类别
  5287. //职工透析:医疗类别选特殊情况门诊990502
  5288. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5289. var med_type string
  5290. if his.Insutype == "390" {
  5291. if reg_type == 14 {
  5292. med_type = "9933"
  5293. } else if reg_type == 11 {
  5294. med_type = "11"
  5295. }
  5296. } else if his.Insutype == "310" {
  5297. if reg_type == 14 {
  5298. med_type = "990502"
  5299. } else if reg_type == 11 {
  5300. med_type = "11"
  5301. }
  5302. }
  5303. 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)
  5304. } else {
  5305. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  5306. }
  5307. //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)
  5308. var dat map[string]interface{}
  5309. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5310. fmt.Println(dat)
  5311. } else {
  5312. fmt.Println(err)
  5313. }
  5314. saveLog(result2, src_resquest, "2207", "结算")
  5315. userJSONBytes, _ := json.Marshal(dat)
  5316. if miConfig.Code == "H15049901371" {
  5317. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5318. utils.ErrorLog("解析失败:%v", err)
  5319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5320. return
  5321. }
  5322. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5323. res.Output = resSeven10265.Output
  5324. res.ErrMsg = resSeven10265.ErrMsg
  5325. res.Cainfo = resSeven10265.Cainfo
  5326. res.WarnMsg = resSeven10265.WarnMsg
  5327. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5328. res.Infcode = infocode
  5329. } else {
  5330. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5331. utils.ErrorLog("解析失败:%v", err)
  5332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5333. return
  5334. }
  5335. }
  5336. }
  5337. if res.Infcode != 0 {
  5338. errlog := &models.HisOrderError{
  5339. UserOrgId: adminUser.CurrentOrgId,
  5340. Ctime: time.Now().Unix(),
  5341. Mtime: time.Now().Unix(),
  5342. Number: chrg_bchno,
  5343. ErrMsg: res.ErrMsg,
  5344. Status: 1,
  5345. PatientId: id,
  5346. RecordTime: recordDateTime,
  5347. Stage: 6,
  5348. }
  5349. service.CreateErrMsgLog(errlog)
  5350. c.ServeSuccessJSON(map[string]interface{}{
  5351. "failed_code": -10,
  5352. "msg": res.ErrMsg,
  5353. })
  5354. return
  5355. } else {
  5356. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5357. order.OrderStatus = 2
  5358. order.Status = 1
  5359. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5360. order.SetlId = res.Output.Setlinfo.SetlID
  5361. order.PsnNo = res.Output.Setlinfo.PsnNo
  5362. order.PsnName = res.Output.Setlinfo.PsnName
  5363. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5364. order.Certno = res.Output.Setlinfo.Certno
  5365. order.Gend = res.Output.Setlinfo.Gend
  5366. order.Naty = res.Output.Setlinfo.Naty
  5367. order.Age = res.Output.Setlinfo.Age
  5368. order.Insutype = res.Output.Setlinfo.Insutype
  5369. order.PsnType = res.Output.Setlinfo.PsnType
  5370. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5371. order.SetlTime = res.Output.Setlinfo.SetlTime
  5372. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5373. if res.Output.Setlinfo.MedType == "140101" {
  5374. order.MedType = "14"
  5375. } else {
  5376. order.MedType = res.Output.Setlinfo.MedType
  5377. }
  5378. if reg_type == 1112 {
  5379. order.MedType = "1112"
  5380. }
  5381. if reg_type == 1111 {
  5382. order.MedType = "1111"
  5383. }
  5384. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5385. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5386. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5387. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5388. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5389. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5390. order.HifpPay = res.Output.Setlinfo.HifpPay
  5391. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5392. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5393. order.HifesPay = res.Output.Setlinfo.HifesPay
  5394. order.HifobPay = res.Output.Setlinfo.HifobPay
  5395. order.MafPay = res.Output.Setlinfo.MafPay
  5396. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5397. order.OthPay = res.Output.Setlinfo.OthPay
  5398. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5399. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5400. order.AcctPay = res.Output.Setlinfo.AcctPay
  5401. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5402. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5403. order.Balc = res.Output.Setlinfo.Balc
  5404. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5405. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5406. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5407. order.ClrType = res.Output.Setlinfo.ClrType
  5408. order.ClrWay = res.Output.Setlinfo.ClrWay
  5409. order.Creator = order.Creator
  5410. order.Modify = roles.AdminUserId
  5411. order.RequestLog = src_resquest
  5412. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5413. detailStr := string(setlDetail)
  5414. order.SetlDetail = detailStr
  5415. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5416. err = service.UpDateOrder(order)
  5417. if err == nil {
  5418. c.ServeSuccessJSON(map[string]interface{}{
  5419. "msg": "结算成功",
  5420. })
  5421. } else {
  5422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5423. return
  5424. }
  5425. }
  5426. } else {
  5427. adminUser := c.GetAdminUserInfo()
  5428. errlog := &models.HisOrderError{
  5429. UserOrgId: adminUser.CurrentOrgId,
  5430. Ctime: time.Now().Unix(),
  5431. Mtime: time.Now().Unix(),
  5432. ErrMsg: res.ErrMsg,
  5433. Status: 1,
  5434. PatientId: id,
  5435. RecordTime: recordDateTime,
  5436. Stage: 4,
  5437. }
  5438. service.CreateErrMsgLog(errlog)
  5439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5440. return
  5441. }
  5442. } else {
  5443. adminUser := c.GetAdminUserInfo()
  5444. errlog := &models.HisOrderError{
  5445. UserOrgId: adminUser.CurrentOrgId,
  5446. Ctime: time.Now().Unix(),
  5447. Mtime: time.Now().Unix(),
  5448. ErrMsg: res.ErrMsg,
  5449. Status: 1,
  5450. PatientId: id,
  5451. RecordTime: recordDateTime,
  5452. Stage: 4,
  5453. }
  5454. service.CreateErrMsgLog(errlog)
  5455. c.ServeSuccessJSON(map[string]interface{}{
  5456. "failed_code": -10,
  5457. "msg": res.ErrMsg,
  5458. })
  5459. return
  5460. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5461. //return
  5462. }
  5463. }
  5464. }
  5465. } else if tempOrder.ID > 0 {
  5466. if tempOrder.IsPre == 1 {
  5467. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  5468. var rf []*ResultFive
  5469. json.Unmarshal([]byte(his.Iinfo), &rf)
  5470. chrg_bchno := tempOrder.Number
  5471. cert_no := his.Certno
  5472. var insutypes []string
  5473. var insutype string
  5474. var is390 int = 0
  5475. var is310 int = 0
  5476. for _, item := range rf {
  5477. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5478. insutypes = append(insutypes, item.Insutype)
  5479. }
  5480. }
  5481. if len(insutypes) == 1 {
  5482. insutype = insutypes[0]
  5483. } else {
  5484. for _, i := range insutypes {
  5485. if i == "390" {
  5486. is390 = 1
  5487. }
  5488. if i == "310" {
  5489. is310 = 1
  5490. }
  5491. }
  5492. }
  5493. if is390 == 1 {
  5494. insutype = "390"
  5495. }
  5496. if is310 == 1 {
  5497. insutype = "310"
  5498. }
  5499. if len(insutypes) == 0 {
  5500. insutype = "310"
  5501. }
  5502. if len(insutypes) == 2 {
  5503. insutype = strconv.FormatInt(his.SocialType, 64)
  5504. }
  5505. //insutype = "390"
  5506. if his.IdCardType == 1 {
  5507. // cert_no = his.MedicalInsuranceNumber
  5508. cert_no = his.Certno
  5509. } else {
  5510. cert_no = his.Certno
  5511. }
  5512. var res ResultSeven
  5513. var resSeven10265 ResultSeven10265
  5514. var src_resquest string
  5515. var result2 string
  5516. var acct_used_flag string
  5517. fmt.Println("pay_way")
  5518. fmt.Println(pay_way)
  5519. fmt.Println("pay_way")
  5520. if pay_way == 4 {
  5521. acct_used_flag = "1"
  5522. } else {
  5523. acct_used_flag = "0"
  5524. }
  5525. if miConfig.MdtrtareaAdmvs == "421300" {
  5526. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5527. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5528. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5529. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5530. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5531. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5532. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5533. resp, requestErr := http.Get(api)
  5534. if requestErr != nil {
  5535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5536. return
  5537. }
  5538. body, ioErr := ioutil.ReadAll(resp.Body)
  5539. if ioErr != nil {
  5540. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5542. return
  5543. }
  5544. var respJSON map[string]interface{}
  5545. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5546. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5548. return
  5549. }
  5550. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5551. result, _ := json.Marshal(respJSON)
  5552. fmt.Println("log")
  5553. fmt.Println(string(result))
  5554. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5555. utils.ErrorLog("解析失败:%v", err)
  5556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5557. return
  5558. }
  5559. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5560. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5561. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5562. //psn_info, _ := service.GetPsnByPatientId(id)
  5563. bas := strings.Split(psn_info.CardInfo, "|")
  5564. if his.IdCardType == 1 {
  5565. cert_no = bas[2]
  5566. } else {
  5567. cert_no = bas[1]
  5568. }
  5569. //江苏地区国家医保医疗类别
  5570. //职工透析:医疗类别选特殊情况门诊9933
  5571. //居民血透门慢: 医疗类别选门诊慢病1402
  5572. //var med_type string
  5573. //if his.Insutype == "310" {
  5574. // if reg_type == 14 {
  5575. // med_type = "9933"
  5576. // } else if reg_type == 11 {
  5577. // med_type = "11"
  5578. //
  5579. // }
  5580. //} else if his.Insutype == "390" {
  5581. // if reg_type == 14 {
  5582. // med_type = "1402"
  5583. // } else if reg_type == 11 {
  5584. // med_type = "11"
  5585. // }
  5586. //}
  5587. var api string
  5588. if miConfig.MdtrtareaAdmvs == "320921" {
  5589. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5590. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5591. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5592. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5593. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5594. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5595. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  5596. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5597. } else {
  5598. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5599. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5600. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5601. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5602. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5603. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5604. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5605. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  5606. }
  5607. resp, requestErr := http.Get(api)
  5608. if requestErr != nil {
  5609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5610. return
  5611. }
  5612. body, ioErr := ioutil.ReadAll(resp.Body)
  5613. if ioErr != nil {
  5614. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5616. return
  5617. }
  5618. var respJSON map[string]interface{}
  5619. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5620. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5622. return
  5623. }
  5624. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5625. result, _ := json.Marshal(respJSON)
  5626. fmt.Println("log")
  5627. fmt.Println(string(result))
  5628. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5629. utils.ErrorLog("解析失败:%v", err)
  5630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5631. return
  5632. }
  5633. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5634. res.Output = resSeven10265.Output
  5635. res.ErrMsg = resSeven10265.ErrMsg
  5636. res.Cainfo = resSeven10265.Cainfo
  5637. res.WarnMsg = resSeven10265.WarnMsg
  5638. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5639. res.Infcode = infocode
  5640. } else {
  5641. var src_resquest string
  5642. if miConfig.Code == "H15049901371" {
  5643. //赤峰地区国家医保医疗类别
  5644. //职工透析:医疗类别选特殊情况门诊990502
  5645. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5646. var med_type string
  5647. if his.Insutype == "390" {
  5648. if reg_type == 14 {
  5649. med_type = "9933"
  5650. } else if reg_type == 11 {
  5651. med_type = "11"
  5652. }
  5653. } else if his.Insutype == "310" {
  5654. if reg_type == 14 {
  5655. med_type = "990502"
  5656. } else if reg_type == 11 {
  5657. med_type = "11"
  5658. }
  5659. }
  5660. 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)
  5661. } else {
  5662. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  5663. }
  5664. var dat map[string]interface{}
  5665. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5666. fmt.Println(dat)
  5667. } else {
  5668. fmt.Println(err)
  5669. }
  5670. saveLog(result2, src_resquest, "2207", "结算")
  5671. userJSONBytes, _ := json.Marshal(dat)
  5672. if miConfig.Code == "H15049901371" {
  5673. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5674. utils.ErrorLog("解析失败:%v", err)
  5675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5676. return
  5677. }
  5678. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5679. res.Output = resSeven10265.Output
  5680. res.ErrMsg = resSeven10265.ErrMsg
  5681. res.Cainfo = resSeven10265.Cainfo
  5682. res.WarnMsg = resSeven10265.WarnMsg
  5683. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5684. res.Infcode = infocode
  5685. } else {
  5686. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5687. utils.ErrorLog("解析失败:%v", err)
  5688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5689. return
  5690. }
  5691. }
  5692. }
  5693. if res.Infcode != 0 {
  5694. errlog := &models.HisOrderError{
  5695. UserOrgId: adminUser.CurrentOrgId,
  5696. Ctime: time.Now().Unix(),
  5697. Mtime: time.Now().Unix(),
  5698. Number: chrg_bchno,
  5699. ErrMsg: res.ErrMsg,
  5700. Status: 1,
  5701. PatientId: id,
  5702. RecordTime: recordDateTime,
  5703. Stage: 6,
  5704. }
  5705. service.CreateErrMsgLog(errlog)
  5706. c.ServeSuccessJSON(map[string]interface{}{
  5707. "failed_code": -10,
  5708. "msg": res.ErrMsg,
  5709. })
  5710. return
  5711. } else {
  5712. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5713. order.OrderStatus = 2
  5714. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5715. order.SetlId = res.Output.Setlinfo.SetlID
  5716. order.PsnNo = res.Output.Setlinfo.PsnNo
  5717. order.PsnName = res.Output.Setlinfo.PsnName
  5718. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5719. order.Certno = res.Output.Setlinfo.Certno
  5720. order.Gend = res.Output.Setlinfo.Gend
  5721. order.Naty = res.Output.Setlinfo.Naty
  5722. order.Age = res.Output.Setlinfo.Age
  5723. order.Insutype = res.Output.Setlinfo.Insutype
  5724. order.PsnType = res.Output.Setlinfo.PsnType
  5725. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5726. order.SetlTime = res.Output.Setlinfo.SetlTime
  5727. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5728. //order.MedType = res.Output.Setlinfo.MedType
  5729. if reg_type == 1112 {
  5730. order.MedType = "1112"
  5731. }
  5732. if reg_type == 1111 {
  5733. order.MedType = "1111"
  5734. }
  5735. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5736. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5737. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5738. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5739. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5740. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5741. order.HifpPay = res.Output.Setlinfo.HifpPay
  5742. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5743. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5744. order.HifesPay = res.Output.Setlinfo.HifesPay
  5745. order.HifobPay = res.Output.Setlinfo.HifobPay
  5746. order.MafPay = res.Output.Setlinfo.MafPay
  5747. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5748. order.OthPay = res.Output.Setlinfo.OthPay
  5749. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5750. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5751. order.AcctPay = res.Output.Setlinfo.AcctPay
  5752. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5753. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5754. order.Balc = res.Output.Setlinfo.Balc
  5755. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5756. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5757. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5758. order.ClrWay = res.Output.Setlinfo.ClrWay
  5759. order.Creator = order.Creator
  5760. order.Modify = roles.AdminUserId
  5761. order.RequestLog = src_resquest
  5762. order.Diagnosis = diagnosis_id
  5763. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5764. detailStr := string(setlDetail)
  5765. order.SetlDetail = detailStr
  5766. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5767. err = service.UpDateOrder(order)
  5768. if err == nil {
  5769. c.ServeSuccessJSON(map[string]interface{}{
  5770. "msg": "结算成功",
  5771. })
  5772. } else {
  5773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5774. return
  5775. }
  5776. }
  5777. }
  5778. }
  5779. }
  5780. //func (c *HisApiController) GetPreUploadInfo() {
  5781. // id, _ := c.GetInt64("id")
  5782. // record_time := c.GetString("record_time")
  5783. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5784. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5785. //
  5786. // timeLayout := "2006-01-02"
  5787. // loc, _ := time.LoadLocation("Local")
  5788. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5789. // if err != nil {
  5790. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5791. // return
  5792. // }
  5793. // recordDateTime := theTime.Unix()
  5794. // adminUser := c.GetAdminUserInfo()
  5795. //
  5796. // var prescriptions []*models.HisPrescription
  5797. //
  5798. // var start_time int64
  5799. // var end_time int64
  5800. //
  5801. // data := make(map[string]interface{})
  5802. // if settle_accounts_type == 1 { //日结
  5803. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  5804. // data["pre"] = prescriptions
  5805. //
  5806. // } else { //月结
  5807. // start_time_str := c.GetString("start_time")
  5808. // end_time_str := c.GetString("end_time")
  5809. // timeLayout := "2006-01-02"
  5810. // loc, _ := time.LoadLocation("Local")
  5811. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5812. // if err != nil {
  5813. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5814. // return
  5815. // }
  5816. // recordStartTime := theStartTime.Unix()
  5817. // start_time = recordStartTime
  5818. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5819. // if err != nil {
  5820. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5821. // return
  5822. // }
  5823. // recordEndTime := theEndTime.Unix()
  5824. // end_time = recordEndTime
  5825. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  5826. // data["pre"] = prescriptions
  5827. //
  5828. // }
  5829. //
  5830. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5831. //
  5832. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5833. // timestamp := time.Now().Unix()
  5834. // tempTime := time.Unix(timestamp, 0)
  5835. // timeFormat := tempTime.Format("20060102150405")
  5836. // chrgBchno := rand.Intn(100000) + 10000
  5837. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5838. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5839. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5840. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5841. // strconv.FormatInt(his.PatientId, 10)
  5842. // client := &http.Client{}
  5843. // data["psn_no"] = his.PsnNo
  5844. // data["mdtrt_id"] = his.Number
  5845. // data["chrg_bchno"] = chrg_bchno
  5846. // data["org_name"] = miConfig.OrgName
  5847. // data["doctor"] = roles.UserName
  5848. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5849. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5850. // data["fixmedins_code"] = miConfig.Code
  5851. // data["dept_code"] = department.Number
  5852. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5853. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5854. // data["secret_key"] = miConfig.SecretKey
  5855. // var ids []int64
  5856. //
  5857. // for _, item := range prescriptions {
  5858. // ids = append(ids, item.ID)
  5859. // }
  5860. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5861. // if config.IsOpen == 1 { //对接了医保,走医保流程
  5862. // bytesData, _ := json.Marshal(data)
  5863. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  5864. // resp, _ := client.Do(req)
  5865. // defer resp.Body.Close()
  5866. // body, ioErr := ioutil.ReadAll(resp.Body)
  5867. // if ioErr != nil {
  5868. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5869. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5870. // return
  5871. // }
  5872. // var respJSON map[string]interface{}
  5873. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5874. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5875. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5876. // return
  5877. // }
  5878. //
  5879. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5880. // userJSONBytes, _ := json.Marshal(respJSON)
  5881. // var res ResultFour
  5882. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5883. // utils.ErrorLog("解析失败:%v", err)
  5884. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5885. // return
  5886. // }
  5887. //
  5888. // if res.Infcode == 0 {
  5889. // order := &models.HisOrder{
  5890. // UserOrgId: adminUser.CurrentOrgId,
  5891. // HisPatientId: his.ID,
  5892. // PatientId: his.PatientId,
  5893. // SettleAccountsDate: recordDateTime,
  5894. // Ctime: time.Now().Unix(),
  5895. // Mtime: time.Now().Unix(),
  5896. // Status: 1,
  5897. // Number: chrg_bchno,
  5898. // Infcode: res.Infcode,
  5899. // WarnMsg: res.WarnMsg,
  5900. // Cainfo: res.Cainfo,
  5901. // ErrMsg: res.ErrMsg,
  5902. // RespondTime: res.RefmsgTime,
  5903. // InfRefmsgid: res.InfRefmsgid,
  5904. // OrderStatus: 1,
  5905. // IsMedicineInsurance: 1,
  5906. // SettleType: settle_accounts_type,
  5907. // SettleStartTime: start_time,
  5908. // SettleEndTime: end_time,
  5909. // Creator: roles.ID,
  5910. // Modify: roles.ID,
  5911. // PType: 2,
  5912. // }
  5913. // err = service.CreateOrder(order)
  5914. // if err != nil {
  5915. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5916. // return
  5917. // }
  5918. //
  5919. // for _, item := range res.Output.Result {
  5920. // temp := strings.Split(item.FeedetlSn, "-")
  5921. // var advice_id int64 = 0
  5922. // var project_id int64 = 0
  5923. // var types int64 = 0
  5924. //
  5925. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  5926. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  5927. //
  5928. // if temp[1] == "1" {
  5929. // advice_id = id
  5930. // project_id = 0
  5931. // } else if temp[1] == "2" {
  5932. // advice_id = 0
  5933. // project_id = id
  5934. // }
  5935. //
  5936. // info := &models.HisOrderInfo{
  5937. // OrderNumber: order.Number,
  5938. // FeedetlSn: item.FeedetlSn,
  5939. // UploadDate: time.Now().Unix(),
  5940. // AdviceId: advice_id,
  5941. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  5942. // Cnt: item.Cnt,
  5943. // Pric: float64(item.Pric),
  5944. // PatientId: his.PatientId,
  5945. // PricUplmtAmt: item.PricUplmtAmt,
  5946. // SelfpayProp: item.SelfpayProp,
  5947. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5948. // OverlmtAmt: item.OverlmtAmt,
  5949. // PreselfpayAmt: item.PreselfpayAmt,
  5950. // BasMednFlag: item.BasMednFlag,
  5951. // MedChrgitmType: item.MedChrgitmType,
  5952. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  5953. // Status: 1,
  5954. // Memo: item.Memo,
  5955. // Mtime: time.Now().Unix(),
  5956. // InscpScpAmt: item.InscpScpAmt,
  5957. // DrtReimFlag: item.DrtReimFlag,
  5958. // Ctime: time.Now().Unix(),
  5959. // ListSpItemFlag: item.ListSpItemFlag,
  5960. // ChldMedcFlag: item.ChldMedcFlag,
  5961. // LmtUsedFlag: item.LmtUsedFlag,
  5962. // ChrgitmLv: item.ChrgitmLv,
  5963. // UserOrgId: adminUser.CurrentOrgId,
  5964. // HisPatientId: his.ID,
  5965. // OrderId: order.ID,
  5966. // ProjectId: project_id,
  5967. // Type: types,
  5968. // }
  5969. // service.CreateOrderInfo(info)
  5970. //
  5971. // }
  5972. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5973. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  5974. //
  5975. // var total float64
  5976. // for _, item := range prescriptions {
  5977. // if item.Type == 1 { //药品
  5978. // for _, subItem := range item.HisDoctorAdviceInfo {
  5979. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5980. // }
  5981. // }
  5982. // if item.Type == 2 { //项目
  5983. // for _, subItem := range item.HisPrescriptionProject {
  5984. // total = total + (subItem.Price * float64(subItem.Count))
  5985. // }
  5986. // }
  5987. // }
  5988. //
  5989. // for _, item := range prescriptions {
  5990. // for _, subItem := range item.HisAdditionalCharge {
  5991. // total = total + (subItem.Price * float64(subItem.Count))
  5992. // }
  5993. // }
  5994. //
  5995. // allTotal := fmt.Sprintf("%.2f", total)
  5996. // if res.Infcode == 0 {
  5997. // var rf []*ResultFive
  5998. // json.Unmarshal([]byte(his.Iinfo), &rf)
  5999. // psn_no := his.PsnNo
  6000. // mdtrt_id := his.Number
  6001. // chrg_bchno := chrg_bchno
  6002. // cert_no := his.Certno
  6003. // insutype := rf[0].Insutype
  6004. //
  6005. // if his.IdCardType == 1 {
  6006. // cert_no = his.MedicalInsuranceNumber
  6007. //
  6008. // } else {
  6009. //
  6010. // cert_no = his.Certno
  6011. //
  6012. // }
  6013. //
  6014. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  6015. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  6016. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  6017. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  6018. // resp, requestErr := http.Get(api)
  6019. // if requestErr != nil {
  6020. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6021. // return
  6022. // }
  6023. // defer resp.Body.Close()
  6024. // body, ioErr := ioutil.ReadAll(resp.Body)
  6025. // if ioErr != nil {
  6026. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6027. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6028. // return
  6029. // }
  6030. // var respJSON map[string]interface{}
  6031. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6032. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6033. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6034. // return
  6035. // }
  6036. // fmt.Println(respJSON)
  6037. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6038. // userJSONBytes, _ := json.Marshal(respJSON)
  6039. // var res ResultSeven
  6040. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6041. // utils.ErrorLog("解析失败:%v", err)
  6042. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6043. // return
  6044. // }
  6045. // if res.Infcode != 0 {
  6046. // errlog := &models.HisOrderError{
  6047. // UserOrgId: adminUser.CurrentOrgId,
  6048. // Ctime: time.Now().Unix(),
  6049. // Mtime: time.Now().Unix(),
  6050. // Number: chrg_bchno,
  6051. // ErrMsg: res.ErrMsg,
  6052. // Status: 1,
  6053. // PatientId: id,
  6054. // RecordTime: recordDateTime,
  6055. // Stage: 7,
  6056. // }
  6057. // service.CreateErrMsgLog(errlog)
  6058. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6059. // return
  6060. // } else {
  6061. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6062. // order.OrderStatus = 1
  6063. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6064. // order.SetlId = res.Output.Setlinfo.SetlID
  6065. // order.PsnNo = res.Output.Setlinfo.PsnNo
  6066. // order.PsnName = res.Output.Setlinfo.PsnName
  6067. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6068. // order.Certno = res.Output.Setlinfo.Certno
  6069. // order.Gend = res.Output.Setlinfo.Gend
  6070. // order.Naty = res.Output.Setlinfo.Naty
  6071. // order.Age = res.Output.Setlinfo.Age
  6072. // order.Insutype = res.Output.Setlinfo.Insutype
  6073. // order.PsnType = res.Output.Setlinfo.PsnType
  6074. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6075. // order.SetlTime = res.Output.Setlinfo.SetlTime
  6076. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6077. // order.MedType = res.Output.Setlinfo.MedType
  6078. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6079. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6080. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6081. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6082. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6083. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6084. // order.HifpPay = res.Output.Setlinfo.HifpPay
  6085. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6086. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6087. // order.HifesPay = res.Output.Setlinfo.HifesPay
  6088. // order.HifobPay = res.Output.Setlinfo.HifobPay
  6089. // order.MafPay = res.Output.Setlinfo.MafPay
  6090. // order.OthPay = res.Output.Setlinfo.OthPay
  6091. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6092. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6093. // order.AcctPay = res.Output.Setlinfo.AcctPay
  6094. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6095. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6096. // order.Balc = res.Output.Setlinfo.Balc
  6097. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6098. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6099. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6100. // order.ClrWay = res.Output.Setlinfo.ClrWay
  6101. // order.Creator = order.Creator
  6102. // order.Modify = roles.ID
  6103. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6104. // detailStr := string(setlDetail)
  6105. // order.SetlDetail = detailStr
  6106. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6107. // err = service.UpDateOrder(order)
  6108. // if err == nil {
  6109. // c.ServeSuccessJSON(map[string]interface{}{
  6110. // "msg": "预结算成功",
  6111. // })
  6112. // } else {
  6113. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6114. // return
  6115. // }
  6116. // }
  6117. // } else {
  6118. // adminUser := c.GetAdminUserInfo()
  6119. // errlog := &models.HisOrderError{
  6120. // UserOrgId: adminUser.CurrentOrgId,
  6121. // Ctime: time.Now().Unix(),
  6122. // Mtime: time.Now().Unix(),
  6123. // ErrMsg: res.ErrMsg,
  6124. // Status: 1,
  6125. // PatientId: id,
  6126. // RecordTime: recordDateTime,
  6127. // Stage: 4,
  6128. // }
  6129. // service.CreateErrMsgLog(errlog)
  6130. //
  6131. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6132. // return
  6133. // }
  6134. // } else {
  6135. // adminUser := c.GetAdminUserInfo()
  6136. // errlog := &models.HisOrderError{
  6137. // UserOrgId: adminUser.CurrentOrgId,
  6138. // Ctime: time.Now().Unix(),
  6139. // Mtime: time.Now().Unix(),
  6140. // ErrMsg: res.ErrMsg,
  6141. // Status: 1,
  6142. // PatientId: id,
  6143. // RecordTime: recordDateTime,
  6144. // Stage: 4,
  6145. // }
  6146. // service.CreateErrMsgLog(errlog)
  6147. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6148. // return
  6149. // }
  6150. //
  6151. // } else {
  6152. // var total float64
  6153. // for _, item := range prescriptions {
  6154. // if item.Type == 1 { //药品
  6155. // for _, subItem := range item.HisDoctorAdviceInfo {
  6156. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6157. // }
  6158. // }
  6159. // if item.Type == 2 { //项目
  6160. // for _, subItem := range item.HisPrescriptionProject {
  6161. // total = total + (subItem.Price * float64(subItem.Count))
  6162. // }
  6163. // }
  6164. //
  6165. // for _, subItem := range item.HisAdditionalCharge {
  6166. // total = total + (subItem.Price * float64(subItem.Count))
  6167. // }
  6168. // }
  6169. //
  6170. // allTotal := fmt.Sprintf("%.2f", total)
  6171. // totals, _ := strconv.ParseFloat(allTotal, 64)
  6172. // order := &models.HisOrder{
  6173. // UserOrgId: adminUser.CurrentOrgId,
  6174. // HisPatientId: his.ID,
  6175. // PatientId: id,
  6176. // SettleAccountsDate: recordDateTime,
  6177. // Ctime: time.Now().Unix(),
  6178. // Mtime: time.Now().Unix(),
  6179. // Status: 1,
  6180. // OrderStatus: 2,
  6181. // Number: chrg_bchno,
  6182. // MedfeeSumamt: totals,
  6183. // }
  6184. // err = service.CreateOrder(order)
  6185. // if err != nil {
  6186. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6187. // return
  6188. // }
  6189. //
  6190. // var customs []*Custom
  6191. // for _, item := range prescriptions {
  6192. //
  6193. // if item.Type == 1 { //药品
  6194. // for _, subItem := range item.HisDoctorAdviceInfo {
  6195. // cus := &Custom{
  6196. // AdviceId: subItem.ID,
  6197. // ProjectId: 0,
  6198. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  6199. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  6200. // FeedetlSn: subItem.FeedetlSn,
  6201. // Price: fmt.Sprintf("%.2f", subItem.Price),
  6202. // MedListCodg: subItem.MedListCodg,
  6203. // Type: 1,
  6204. // }
  6205. // customs = append(customs, cus)
  6206. // }
  6207. // }
  6208. //
  6209. // if item.Type == 2 { //项目
  6210. // for _, subItem := range item.HisPrescriptionProject {
  6211. //
  6212. // cus := &Custom{
  6213. // AdviceId: 0,
  6214. // ProjectId: subItem.ID,
  6215. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  6216. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  6217. // FeedetlSn: subItem.FeedetlSn,
  6218. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  6219. // MedListCodg: subItem.MedListCodg,
  6220. // Type: 2,
  6221. // }
  6222. //
  6223. // customs = append(customs, cus)
  6224. // }
  6225. // }
  6226. //
  6227. // for _, item := range item.HisAdditionalCharge {
  6228. // cus := &Custom{
  6229. // ItemId: item.ID,
  6230. // AdviceId: 0,
  6231. // ProjectId: 0,
  6232. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  6233. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  6234. // FeedetlSn: item.FeedetlSn,
  6235. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  6236. // MedListCodg: item.XtHisAddtionConfig.Code,
  6237. // Type: 3,
  6238. // }
  6239. //
  6240. // customs = append(customs, cus)
  6241. // }
  6242. //
  6243. // }
  6244. //
  6245. // for _, item := range customs {
  6246. // var advice_id int64 = 0
  6247. // var project_id int64 = 0
  6248. // var item_id int64 = 0
  6249. //
  6250. // var types int64 = 0
  6251. //
  6252. // if item.Type == 1 {
  6253. // advice_id = item.AdviceId
  6254. // project_id = 0
  6255. // item_id = 0
  6256. // } else if item.Type == 2 {
  6257. // advice_id = 0
  6258. // item_id = 0
  6259. //
  6260. // project_id = item.ProjectId
  6261. // } else if item.Type == 3 {
  6262. // advice_id = 0
  6263. // item_id = item.ItemId
  6264. // project_id = 0
  6265. // }
  6266. //
  6267. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  6268. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  6269. // pric, _ := strconv.ParseFloat(item.Price, 32)
  6270. //
  6271. // info := &models.HisOrderInfo{
  6272. // OrderNumber: order.Number,
  6273. // UploadDate: time.Now().Unix(),
  6274. // AdviceId: advice_id,
  6275. // DetItemFeeSumamt: detItemFeeSumamt,
  6276. // Cnt: cut,
  6277. // Pric: pric,
  6278. // PatientId: id,
  6279. // Status: 1,
  6280. // Mtime: time.Now().Unix(),
  6281. // Ctime: time.Now().Unix(),
  6282. // UserOrgId: adminUser.CurrentOrgId,
  6283. // HisPatientId: his.ID,
  6284. // OrderId: order.ID,
  6285. // ProjectId: project_id,
  6286. // Type: types,
  6287. // ItemId: item_id,
  6288. // }
  6289. // service.CreateOrderInfo(info)
  6290. // }
  6291. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6292. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6293. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  6294. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6295. // if err == nil {
  6296. // c.ServeSuccessJSON(map[string]interface{}{
  6297. // "msg": "结算成功",
  6298. // })
  6299. // } else {
  6300. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6301. // return
  6302. // }
  6303. // }
  6304. //}
  6305. //上传明细-预结算-
  6306. func (c *HisApiController) GetPreUploadInfo() {
  6307. id, _ := c.GetInt64("id")
  6308. record_time := c.GetString("record_time")
  6309. his_patient_id, _ := c.GetInt64("his_patient_id")
  6310. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6311. admin_user_id, _ := c.GetInt64("admin_user_id")
  6312. diagnosis_id := c.GetString("diagnosis")
  6313. sick_type, _ := c.GetInt64("sick_type")
  6314. reg_type, _ := c.GetInt64("p_type")
  6315. begin_time := c.GetString("begin_time")
  6316. id_str := c.GetString("ids")
  6317. ids_arr := strings.Split(id_str, ",")
  6318. timeLayout := "2006-01-02"
  6319. loc, _ := time.LoadLocation("Local")
  6320. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6321. if err != nil {
  6322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6323. return
  6324. }
  6325. recordDateTime := theTime.Unix()
  6326. adminUser := c.GetAdminUserInfo()
  6327. diagnosis_ids := strings.Split(diagnosis_id, ",")
  6328. var config []*models.HisXtDiagnoseConfig
  6329. for _, item := range diagnosis_ids {
  6330. id, _ := strconv.ParseInt(item, 10, 64)
  6331. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6332. config = append(config, &diagnosisConfig)
  6333. }
  6334. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  6335. sickConfig, _ := service.FindSickById(sick_type)
  6336. var prescriptions []*models.HisPrescription
  6337. var start_time int64
  6338. var end_time int64
  6339. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6340. fmt.Println(his_patient_id)
  6341. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6342. timestamp := time.Now().Unix()
  6343. tempTime := time.Unix(timestamp, 0)
  6344. timeFormat := tempTime.Format("20060102150405")
  6345. chrgBchno := rand.Intn(100000) + 10000
  6346. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6347. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6348. var patientPrescription models.HisPrescriptionInfo
  6349. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6350. if patientPrescription.ID == 0 {
  6351. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6352. }
  6353. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6354. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6355. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6356. strconv.FormatInt(his.PatientId, 10)
  6357. var res2 ResultSix
  6358. var resSix10265 ResultSix10265
  6359. var time_stamp string
  6360. if miConfig.MdtrtareaAdmvs == "421300" {
  6361. data := make(map[string]interface{})
  6362. client := &http.Client{}
  6363. data["psn_no"] = his.PsnNo
  6364. data["mdtrt_id"] = his.Number
  6365. data["doctor"] = roles.UserName
  6366. data["department"] = department.Name
  6367. data["org_name"] = miConfig.OrgName
  6368. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6369. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6370. data["fixmedins_code"] = miConfig.Code
  6371. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6372. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6373. data["secret_key"] = miConfig.SecretKey
  6374. data["sick_code"] = sickConfig.CountryCode
  6375. data["sick_name"] = sickConfig.ClassName
  6376. data["begin_time"] = begin_time
  6377. data["dept"] = strconv.FormatInt(department.ID, 10)
  6378. data["config"] = config
  6379. fmt.Println(data)
  6380. bytesData, _ := json.Marshal(data)
  6381. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  6382. resp, _ := client.Do(req)
  6383. defer resp.Body.Close()
  6384. body, ioErr := ioutil.ReadAll(resp.Body)
  6385. if ioErr != nil {
  6386. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6388. return
  6389. }
  6390. var respJSON map[string]interface{}
  6391. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6392. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6394. return
  6395. }
  6396. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6397. userJSONBytes, _ := json.Marshal(respJSON)
  6398. fmt.Println("log")
  6399. fmt.Println(string(userJSONBytes))
  6400. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6401. utils.ErrorLog("解析失败:%v", err)
  6402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6403. return
  6404. }
  6405. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6406. //江苏地区国家医保医疗类别
  6407. //职工透析:医疗类别选特殊情况门诊9933
  6408. //居民血透门慢: 医疗类别选门诊慢病1402
  6409. //var med_type string
  6410. //if his.Insutype == "310" {
  6411. // if reg_type == 14 {
  6412. // med_type = "9933"
  6413. // } else if reg_type == 11 {
  6414. // med_type = "11"
  6415. //
  6416. // }
  6417. //} else if his.Insutype == "390" {
  6418. // if reg_type == 14 {
  6419. // med_type = "1402"
  6420. // } else if reg_type == 11 {
  6421. // med_type = "11"
  6422. // }
  6423. //}
  6424. data := make(map[string]interface{})
  6425. client := &http.Client{}
  6426. data["psn_no"] = his.PsnNo
  6427. data["mdtrt_id"] = his.Number
  6428. data["doctor"] = roles.UserName
  6429. data["department"] = department.Name
  6430. data["org_name"] = miConfig.OrgName
  6431. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6432. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6433. data["fixmedins_code"] = miConfig.Code
  6434. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6435. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6436. data["secret_key"] = miConfig.SecretKey
  6437. data["sick_code"] = sickConfig.CountryCode
  6438. data["sick_name"] = sickConfig.ClassName
  6439. data["begin_time"] = begin_time
  6440. data["dept"] = strconv.FormatInt(department.ID, 10)
  6441. data["config"] = config
  6442. data["url"] = miConfig.Url
  6443. data["ak"] = miConfig.AccessKey
  6444. data["cainfo"] = miConfig.Cainfo
  6445. bytesData, _ := json.Marshal(data)
  6446. var req *http.Request
  6447. if miConfig.MdtrtareaAdmvs == "320921" {
  6448. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6449. //api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  6450. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  6451. } else {
  6452. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6453. }
  6454. resp, _ := client.Do(req)
  6455. defer resp.Body.Close()
  6456. body, ioErr := ioutil.ReadAll(resp.Body)
  6457. if ioErr != nil {
  6458. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6460. return
  6461. }
  6462. var respJSON map[string]interface{}
  6463. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6464. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6466. return
  6467. }
  6468. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  6469. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  6470. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  6471. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6472. userJSONBytes, _ := json.Marshal(respJSON)
  6473. fmt.Println("log")
  6474. fmt.Println(string(userJSONBytes))
  6475. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6476. utils.ErrorLog("解析失败:%v", err)
  6477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6478. return
  6479. }
  6480. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6481. res2.Output = resSix10265.Output
  6482. res2.ErrMsg = resSix10265.ErrMsg
  6483. res2.Cainfo = resSix10265.Cainfo
  6484. res2.WarnMsg = resSix10265.WarnMsg
  6485. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6486. res2.Infcode = infocode
  6487. } else {
  6488. var result string
  6489. var requestLog string
  6490. if miConfig.MdtrtareaAdmvs == "440781" { //
  6491. 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)
  6492. } else {
  6493. if miConfig.Code == "H15049901371" {
  6494. //赤峰地区国家医保医疗类别
  6495. //职工透析:医疗类别选特殊情况门诊990502
  6496. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6497. var med_type string
  6498. if his.Insutype == "390" {
  6499. if reg_type == 14 {
  6500. med_type = "9933"
  6501. } else if reg_type == 11 {
  6502. med_type = "11"
  6503. }
  6504. } else if his.Insutype == "310" {
  6505. if reg_type == 14 {
  6506. med_type = "990502"
  6507. } else if reg_type == 11 {
  6508. med_type = "11"
  6509. }
  6510. }
  6511. 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)
  6512. } else {
  6513. 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)
  6514. }
  6515. saveLog(result, requestLog, "2203", "上传就诊信息")
  6516. var respJSON2 map[string]interface{}
  6517. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6518. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6520. return
  6521. }
  6522. userJSONBytes2, _ := json.Marshal(respJSON2)
  6523. if miConfig.Code == "H15049901371" {
  6524. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  6525. utils.ErrorLog("解析失败:%v", err)
  6526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6527. return
  6528. }
  6529. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6530. res2.Output = resSix10265.Output
  6531. res2.ErrMsg = resSix10265.ErrMsg
  6532. res2.Cainfo = resSix10265.Cainfo
  6533. res2.WarnMsg = resSix10265.WarnMsg
  6534. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6535. res2.Infcode = infocode
  6536. } else {
  6537. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  6538. utils.ErrorLog("解析失败:%v", err)
  6539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6540. return
  6541. }
  6542. }
  6543. }
  6544. }
  6545. if res2.Infcode != 0 {
  6546. adminUser := c.GetAdminUserInfo()
  6547. errlog := &models.HisOrderError{
  6548. UserOrgId: adminUser.CurrentOrgId,
  6549. Ctime: time.Now().Unix(),
  6550. Mtime: time.Now().Unix(),
  6551. ErrMsg: res2.ErrMsg,
  6552. Status: 1,
  6553. PatientId: id,
  6554. RecordTime: recordDateTime,
  6555. Stage: 3,
  6556. }
  6557. service.CreateErrMsgLog(errlog)
  6558. c.ServeSuccessJSON(map[string]interface{}{
  6559. "failed_code": -10,
  6560. "msg": res2.ErrMsg,
  6561. })
  6562. return
  6563. } else {
  6564. his.Diagnosis = diagnosis_id
  6565. his.SickType = sickConfig.ID
  6566. his.PType = fmt.Sprintf("%d", reg_type)
  6567. service.UpdateHisPatientThree(&his)
  6568. data := make(map[string]interface{})
  6569. if settle_accounts_type == 1 { //日结
  6570. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  6571. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  6572. } else {
  6573. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  6574. }
  6575. data["pre"] = prescriptions
  6576. } else { //月结
  6577. start_time_str := c.GetString("start_time")
  6578. end_time_str := c.GetString("end_time")
  6579. timeLayout := "2006-01-02"
  6580. loc, _ := time.LoadLocation("Local")
  6581. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6582. if err != nil {
  6583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6584. return
  6585. }
  6586. recordStartTime := theStartTime.Unix()
  6587. start_time = recordStartTime
  6588. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6589. if err != nil {
  6590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6591. return
  6592. }
  6593. recordEndTime := theEndTime.Unix()
  6594. end_time = recordEndTime
  6595. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  6596. data["pre"] = prescriptions
  6597. }
  6598. client := &http.Client{}
  6599. data["psn_no"] = his.PsnNo
  6600. data["mdtrt_id"] = his.Number
  6601. data["chrg_bchno"] = chrg_bchno
  6602. data["org_name"] = miConfig.OrgName
  6603. data["doctor"] = roles.UserName
  6604. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6605. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6606. data["fixmedins_code"] = miConfig.Code
  6607. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  6608. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  6609. data["dept_code"] = "15"
  6610. } else {
  6611. data["dept_code"] = department.Number
  6612. }
  6613. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6614. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6615. data["secret_key"] = miConfig.SecretKey
  6616. data["url"] = miConfig.Url
  6617. data["ak"] = miConfig.AccessKey
  6618. data["new_doctor_name"] = patientPrescription.Doctor
  6619. data["diag_code"] = sickConfig.CountryCode
  6620. data["time_stamp"] = time_stamp
  6621. data["cainfo"] = miConfig.Cainfo
  6622. var ids []int64
  6623. for _, item := range prescriptions {
  6624. ids = append(ids, item.ID)
  6625. }
  6626. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6627. if config.IsOpen == 1 { //对接了医保,走医保流程
  6628. var res ResultFour
  6629. var resFour10265 ResultFour10265
  6630. if miConfig.MdtrtareaAdmvs == "421300" {
  6631. bytesData, _ := json.Marshal(data)
  6632. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  6633. resp, _ := client.Do(req)
  6634. defer resp.Body.Close()
  6635. body, ioErr := ioutil.ReadAll(resp.Body)
  6636. if ioErr != nil {
  6637. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6639. return
  6640. }
  6641. var respJSON map[string]interface{}
  6642. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6643. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6645. return
  6646. }
  6647. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6648. userJSONBytes, _ := json.Marshal(respJSON)
  6649. fmt.Println("log")
  6650. fmt.Println(string(userJSONBytes))
  6651. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6652. utils.ErrorLog("解析失败:%v", err)
  6653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6654. return
  6655. }
  6656. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6657. bytesData, _ := json.Marshal(data)
  6658. var req *http.Request
  6659. if miConfig.MdtrtareaAdmvs == "320921" {
  6660. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6661. } else {
  6662. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6663. }
  6664. resp, _ := client.Do(req)
  6665. defer resp.Body.Close()
  6666. body, ioErr := ioutil.ReadAll(resp.Body)
  6667. if ioErr != nil {
  6668. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6670. return
  6671. }
  6672. var respJSON map[string]interface{}
  6673. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6674. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6676. return
  6677. }
  6678. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6679. userJSONBytes, _ := json.Marshal(respJSON)
  6680. fmt.Println("log")
  6681. fmt.Println(string(userJSONBytes))
  6682. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6683. utils.ErrorLog("解析失败:%v", err)
  6684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6685. return
  6686. }
  6687. res.InfRefmsgid = resFour10265.InfRefmsgid
  6688. res.Output = resFour10265.Output
  6689. res.ErrMsg = resFour10265.ErrMsg
  6690. res.Cainfo = resFour10265.Cainfo
  6691. res.WarnMsg = resFour10265.WarnMsg
  6692. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6693. res.Infcode = infocode
  6694. } else {
  6695. if miConfig.Code == "H15049901371" {
  6696. 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)
  6697. var dat map[string]interface{}
  6698. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6699. fmt.Println(dat)
  6700. } else {
  6701. fmt.Println(err)
  6702. }
  6703. saveLog(result, request_log, "2204", "上传费用明细")
  6704. userJSONBytes, _ := json.Marshal(dat)
  6705. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6706. utils.ErrorLog("解析失败:%v", err)
  6707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6708. return
  6709. }
  6710. res.InfRefmsgid = resFour10265.InfRefmsgid
  6711. res.Output = resFour10265.Output
  6712. res.ErrMsg = resFour10265.ErrMsg
  6713. res.Cainfo = resFour10265.Cainfo
  6714. res.WarnMsg = resFour10265.WarnMsg
  6715. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6716. res.Infcode = infocode
  6717. } else {
  6718. 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)
  6719. var dat map[string]interface{}
  6720. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6721. fmt.Println(dat)
  6722. } else {
  6723. fmt.Println(err)
  6724. }
  6725. saveLog(result, request_log, "2204", "上传费用明细")
  6726. userJSONBytes, _ := json.Marshal(dat)
  6727. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6728. utils.ErrorLog("解析失败:%v", err)
  6729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6730. return
  6731. }
  6732. }
  6733. }
  6734. if res.Infcode == 0 {
  6735. order := &models.HisOrder{
  6736. UserOrgId: adminUser.CurrentOrgId,
  6737. HisPatientId: his.ID,
  6738. PatientId: his.PatientId,
  6739. SettleAccountsDate: recordDateTime,
  6740. Ctime: time.Now().Unix(),
  6741. Mtime: time.Now().Unix(),
  6742. MdtrtId: his.Number,
  6743. PsnNo: his.PsnNo,
  6744. MedType: strconv.FormatInt(reg_type, 10),
  6745. Status: 1,
  6746. Number: chrg_bchno,
  6747. Infcode: res.Infcode,
  6748. WarnMsg: res.WarnMsg,
  6749. Cainfo: res.Cainfo,
  6750. ErrMsg: res.ErrMsg,
  6751. RespondTime: res.RefmsgTime,
  6752. InfRefmsgid: res.InfRefmsgid,
  6753. OrderStatus: 1,
  6754. IsMedicineInsurance: 1,
  6755. SettleType: settle_accounts_type,
  6756. SettleStartTime: start_time,
  6757. SettleEndTime: end_time,
  6758. Creator: roles.AdminUserId,
  6759. Modify: roles.AdminUserId,
  6760. PType: 2,
  6761. Diagnosis: diagnosis_id,
  6762. }
  6763. err = service.CreateOrder(order)
  6764. if err != nil {
  6765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6766. return
  6767. }
  6768. for _, item := range res.Output.Result {
  6769. temp := strings.Split(item.FeedetlSn, "-")
  6770. var advice_id int64 = 0
  6771. var project_id int64 = 0
  6772. var types int64 = 0
  6773. id, _ := strconv.ParseInt(temp[2], 10, 64)
  6774. types, _ = strconv.ParseInt(temp[1], 10, 64)
  6775. if temp[1] == "1" {
  6776. advice_id = id
  6777. project_id = 0
  6778. } else if temp[1] == "2" {
  6779. advice_id = 0
  6780. project_id = id
  6781. }
  6782. info := &models.HisOrderInfo{
  6783. OrderNumber: order.Number,
  6784. FeedetlSn: item.FeedetlSn,
  6785. UploadDate: time.Now().Unix(),
  6786. AdviceId: advice_id,
  6787. DetItemFeeSumamt: item.DetItemFeeSumamt,
  6788. Cnt: item.Cnt,
  6789. Pric: float64(item.Pric),
  6790. PatientId: his.PatientId,
  6791. PricUplmtAmt: item.PricUplmtAmt,
  6792. SelfpayProp: item.SelfpayProp,
  6793. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6794. OverlmtAmt: item.OverlmtAmt,
  6795. PreselfpayAmt: item.PreselfpayAmt,
  6796. BasMednFlag: item.BasMednFlag,
  6797. MedChrgitmType: item.MedChrgitmType,
  6798. HiNegoDrugFlag: item.HiNegoDrugFlag,
  6799. Status: 1,
  6800. Memo: item.Memo,
  6801. Mtime: time.Now().Unix(),
  6802. InscpScpAmt: item.InscpScpAmt,
  6803. DrtReimFlag: item.DrtReimFlag,
  6804. Ctime: time.Now().Unix(),
  6805. ListSpItemFlag: item.ListSpItemFlag,
  6806. ChldMedcFlag: item.ChldMedcFlag,
  6807. LmtUsedFlag: item.LmtUsedFlag,
  6808. ChrgitmLv: item.ChrgitmLv,
  6809. UserOrgId: adminUser.CurrentOrgId,
  6810. HisPatientId: his.ID,
  6811. OrderId: order.ID,
  6812. ProjectId: project_id,
  6813. Type: types,
  6814. }
  6815. service.CreateOrderInfo(info)
  6816. }
  6817. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6818. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  6819. var total float64
  6820. for _, item := range prescriptions {
  6821. if item.Type == 1 { //药品
  6822. for _, subItem := range item.HisDoctorAdviceInfo {
  6823. total = total + (subItem.Price * subItem.PrescribingNumber)
  6824. }
  6825. }
  6826. if item.Type == 2 { //项目
  6827. for _, subItem := range item.HisPrescriptionProject {
  6828. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6829. total = total + (subItem.Price * cnt)
  6830. }
  6831. }
  6832. }
  6833. for _, item := range prescriptions {
  6834. for _, subItem := range item.HisAdditionalCharge {
  6835. total = total + (subItem.Price * float64(subItem.Count))
  6836. }
  6837. }
  6838. allTotal := fmt.Sprintf("%.4f", total)
  6839. if res.Infcode == 0 {
  6840. var rf []*ResultFive
  6841. json.Unmarshal([]byte(his.Iinfo), &rf)
  6842. chrg_bchno := chrg_bchno
  6843. cert_no := his.Certno
  6844. var insutypes []string
  6845. var insutype string
  6846. var is390 int = 0
  6847. var is310 int = 0
  6848. for _, item := range rf {
  6849. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6850. insutypes = append(insutypes, item.Insutype)
  6851. }
  6852. }
  6853. if len(insutypes) == 1 {
  6854. insutype = insutypes[0]
  6855. } else {
  6856. for _, i := range insutypes {
  6857. if i == "390" {
  6858. is390 = 1
  6859. }
  6860. if i == "310" {
  6861. is310 = 1
  6862. }
  6863. }
  6864. }
  6865. if is390 == 1 {
  6866. insutype = "390"
  6867. }
  6868. if is310 == 1 {
  6869. insutype = "310"
  6870. }
  6871. if len(insutypes) == 0 {
  6872. insutype = "310"
  6873. }
  6874. if len(insutypes) == 2 {
  6875. insutype = strconv.FormatInt(his.SocialType, 64)
  6876. }
  6877. //insutype = "390"
  6878. if his.IdCardType == 1 {
  6879. cert_no = his.MedicalInsuranceNumber
  6880. } else {
  6881. cert_no = his.Certno
  6882. }
  6883. var res ResultSeven
  6884. var resSeven10265 ResultSeven10265
  6885. if miConfig.MdtrtareaAdmvs == "421300" {
  6886. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6887. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6888. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6889. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6890. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6891. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6892. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  6893. resp, requestErr := http.Get(api)
  6894. if requestErr != nil {
  6895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6896. return
  6897. }
  6898. body, ioErr := ioutil.ReadAll(resp.Body)
  6899. if ioErr != nil {
  6900. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6902. return
  6903. }
  6904. var respJSON map[string]interface{}
  6905. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6906. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6908. return
  6909. }
  6910. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6911. result, _ := json.Marshal(respJSON)
  6912. fmt.Println("log")
  6913. fmt.Println(string(result))
  6914. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6915. utils.ErrorLog("解析失败:%v", err)
  6916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6917. return
  6918. }
  6919. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6920. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6921. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6922. bas := strings.Split(psn_info.CardInfo, "|")
  6923. if his.IdCardType == 1 {
  6924. cert_no = bas[2]
  6925. } else {
  6926. cert_no = bas[1]
  6927. }
  6928. //江苏地区国家医保医疗类别
  6929. //职工透析:医疗类别选特殊情况门诊9933
  6930. //居民血透门慢: 医疗类别选门诊慢病1402
  6931. //var med_type string
  6932. //if his.Insutype == "310" {
  6933. // if reg_type == 14 {
  6934. // med_type = "9933"
  6935. // } else if reg_type == 11 {
  6936. // med_type = "11"
  6937. //
  6938. // }
  6939. //} else if his.Insutype == "390" {
  6940. // if reg_type == 14 {
  6941. // med_type = "1402"
  6942. // } else if reg_type == 11 {
  6943. // med_type = "11"
  6944. // }
  6945. //}
  6946. var api string
  6947. if miConfig.MdtrtareaAdmvs == "320921" {
  6948. api = "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6949. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6950. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6951. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6952. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6953. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6954. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + psn_info.VerifyNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6955. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6956. } else {
  6957. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6958. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6959. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6960. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6961. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6962. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6963. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6964. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + psn_info.VerifyNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6965. }
  6966. resp, requestErr := http.Get(api)
  6967. if requestErr != nil {
  6968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6969. return
  6970. }
  6971. body, ioErr := ioutil.ReadAll(resp.Body)
  6972. if ioErr != nil {
  6973. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6975. return
  6976. }
  6977. var respJSON map[string]interface{}
  6978. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6979. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6981. return
  6982. }
  6983. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6984. result, _ := json.Marshal(respJSON)
  6985. fmt.Println("log")
  6986. fmt.Println(string(result))
  6987. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6988. utils.ErrorLog("解析失败:%v", err)
  6989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6990. return
  6991. }
  6992. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6993. res.Output = resSeven10265.Output
  6994. res.ErrMsg = resSeven10265.ErrMsg
  6995. res.Cainfo = resSeven10265.Cainfo
  6996. res.WarnMsg = resSeven10265.WarnMsg
  6997. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6998. res.Infcode = infocode
  6999. } else {
  7000. var result string
  7001. var request_log string
  7002. if miConfig.Code == "H15049901371" {
  7003. //赤峰地区国家医保医疗类别
  7004. //职工透析:医疗类别选特殊情况门诊990502
  7005. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7006. var med_type string
  7007. if his.Insutype == "390" {
  7008. if reg_type == 14 {
  7009. med_type = "9933"
  7010. } else if reg_type == 11 {
  7011. med_type = "11"
  7012. }
  7013. } else if his.Insutype == "310" {
  7014. if reg_type == 14 {
  7015. med_type = "990502"
  7016. } else if reg_type == 11 {
  7017. med_type = "11"
  7018. }
  7019. }
  7020. 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)
  7021. } else {
  7022. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType)
  7023. }
  7024. var dat map[string]interface{}
  7025. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7026. fmt.Println(dat)
  7027. } else {
  7028. fmt.Println(err)
  7029. }
  7030. saveLog(result, request_log, "2206", "预结算")
  7031. //userJSONBytes, _ := json.Marshal(dat)
  7032. //
  7033. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7034. // utils.ErrorLog("解析失败:%v", err)
  7035. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7036. // return
  7037. //}
  7038. userJSONBytes, _ := json.Marshal(dat)
  7039. if miConfig.Code == "H15049901371" {
  7040. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7041. utils.ErrorLog("解析失败:%v", err)
  7042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7043. return
  7044. }
  7045. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7046. res.Output = resSeven10265.Output
  7047. res.ErrMsg = resSeven10265.ErrMsg
  7048. res.Cainfo = resSeven10265.Cainfo
  7049. res.WarnMsg = resSeven10265.WarnMsg
  7050. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7051. res.Infcode = infocode
  7052. } else {
  7053. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7054. utils.ErrorLog("解析失败:%v", err)
  7055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7056. return
  7057. }
  7058. }
  7059. }
  7060. if res.Infcode != 0 {
  7061. errlog := &models.HisOrderError{
  7062. UserOrgId: adminUser.CurrentOrgId,
  7063. Ctime: time.Now().Unix(),
  7064. Mtime: time.Now().Unix(),
  7065. Number: chrg_bchno,
  7066. ErrMsg: res.ErrMsg,
  7067. Status: 1,
  7068. PatientId: id,
  7069. RecordTime: recordDateTime,
  7070. Stage: 20,
  7071. }
  7072. service.CreateErrMsgLog(errlog)
  7073. c.ServeSuccessJSON(map[string]interface{}{
  7074. "failed_code": -10,
  7075. "msg": res.ErrMsg,
  7076. })
  7077. return
  7078. } else {
  7079. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7080. order.OrderStatus = 1
  7081. order.IsPre = 1
  7082. order.Status = 1
  7083. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7084. order.SetlId = res.Output.Setlinfo.SetlID
  7085. order.PsnNo = res.Output.Setlinfo.PsnNo
  7086. order.PsnName = res.Output.Setlinfo.PsnName
  7087. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7088. order.Certno = res.Output.Setlinfo.Certno
  7089. order.Gend = res.Output.Setlinfo.Gend
  7090. order.Naty = res.Output.Setlinfo.Naty
  7091. order.Age = res.Output.Setlinfo.Age
  7092. order.Insutype = res.Output.Setlinfo.Insutype
  7093. order.PsnType = res.Output.Setlinfo.PsnType
  7094. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7095. order.SetlTime = res.Output.Setlinfo.SetlTime
  7096. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7097. if res.Output.Setlinfo.MedType == "140101" {
  7098. order.MedType = "14"
  7099. } else {
  7100. order.MedType = res.Output.Setlinfo.MedType
  7101. }
  7102. if reg_type == 1112 {
  7103. order.MedType = "1112"
  7104. }
  7105. if reg_type == 1111 {
  7106. order.MedType = "1111"
  7107. }
  7108. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7109. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7110. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7111. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7112. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7113. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7114. order.HifpPay = res.Output.Setlinfo.HifpPay
  7115. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7116. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7117. order.HifesPay = res.Output.Setlinfo.HifesPay
  7118. order.HifobPay = res.Output.Setlinfo.HifobPay
  7119. order.MafPay = res.Output.Setlinfo.MafPay
  7120. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  7121. order.OthPay = res.Output.Setlinfo.OthPay
  7122. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7123. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7124. order.AcctPay = res.Output.Setlinfo.AcctPay
  7125. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7126. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7127. order.Balc = res.Output.Setlinfo.Balc
  7128. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7129. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7130. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7131. order.ClrWay = res.Output.Setlinfo.ClrWay
  7132. order.Creator = order.Creator
  7133. order.Modify = roles.AdminUserId
  7134. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7135. detailStr := string(setlDetail)
  7136. order.SetlDetail = detailStr
  7137. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7138. err = service.UpDateOrder(order)
  7139. if err == nil {
  7140. c.ServeSuccessJSON(map[string]interface{}{
  7141. "msg": "预结算成功",
  7142. })
  7143. } else {
  7144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7145. return
  7146. }
  7147. }
  7148. } else {
  7149. adminUser := c.GetAdminUserInfo()
  7150. errlog := &models.HisOrderError{
  7151. UserOrgId: adminUser.CurrentOrgId,
  7152. Ctime: time.Now().Unix(),
  7153. Mtime: time.Now().Unix(),
  7154. ErrMsg: res.ErrMsg,
  7155. Status: 1,
  7156. PatientId: id,
  7157. RecordTime: recordDateTime,
  7158. Stage: 4,
  7159. }
  7160. service.CreateErrMsgLog(errlog)
  7161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7162. return
  7163. }
  7164. } else {
  7165. adminUser := c.GetAdminUserInfo()
  7166. errlog := &models.HisOrderError{
  7167. UserOrgId: adminUser.CurrentOrgId,
  7168. Ctime: time.Now().Unix(),
  7169. Mtime: time.Now().Unix(),
  7170. ErrMsg: res.ErrMsg,
  7171. Status: 1,
  7172. PatientId: id,
  7173. RecordTime: recordDateTime,
  7174. Stage: 4,
  7175. }
  7176. service.CreateErrMsgLog(errlog)
  7177. c.ServeSuccessJSON(map[string]interface{}{
  7178. "failed_code": -10,
  7179. "msg": res.ErrMsg,
  7180. })
  7181. return
  7182. }
  7183. }
  7184. }
  7185. }
  7186. //func (c *HisApiController) GetSettleInfo() {
  7187. // id, _ := c.GetInt64("id")
  7188. // order_id, _ := c.GetInt64("order_id")
  7189. //
  7190. // record_time := c.GetString("record_time")
  7191. // pay_way, _ := c.GetInt64("pay_way")
  7192. // pay_price, _ := c.GetFloat("pay_price")
  7193. // pay_card_no := c.GetString("pay_card_no")
  7194. // discount_price, _ := c.GetFloat("discount_price")
  7195. // preferential_price, _ := c.GetFloat("preferential_price")
  7196. // reality_price, _ := c.GetFloat("reality_price")
  7197. // found_price, _ := c.GetFloat("found_price")
  7198. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  7199. // private_price, _ := c.GetFloat("private_price")
  7200. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7201. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7202. //
  7203. // timeLayout := "2006-01-02"
  7204. // loc, _ := time.LoadLocation("Local")
  7205. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7206. // if err != nil {
  7207. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7208. // return
  7209. // }
  7210. // recordDateTime := theTime.Unix()
  7211. // adminUser := c.GetAdminUserInfo()
  7212. //
  7213. // var prescriptions []*models.HisPrescription
  7214. //
  7215. // data := make(map[string]interface{})
  7216. // if settle_accounts_type == 1 { //日结
  7217. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  7218. // data["pre"] = prescriptions
  7219. //
  7220. // } else { //月结
  7221. // start_time_str := c.GetString("start_time")
  7222. // end_time_str := c.GetString("end_time")
  7223. // timeLayout := "2006-01-02"
  7224. // loc, _ := time.LoadLocation("Local")
  7225. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7226. // if err != nil {
  7227. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7228. // return
  7229. // }
  7230. // recordStartTime := theStartTime.Unix()
  7231. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7232. // if err != nil {
  7233. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7234. // return
  7235. // }
  7236. // recordEndTime := theEndTime.Unix()
  7237. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  7238. // data["pre"] = prescriptions
  7239. //
  7240. // }
  7241. //
  7242. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7243. //
  7244. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7245. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7246. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7247. // strconv.FormatInt(his.PatientId, 10)
  7248. //
  7249. // order_src, _ := service.GetHisOrderByID(order_id)
  7250. //
  7251. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7252. // if config.IsOpen == 1 { //对接了医保,走医保流程
  7253. //
  7254. // var total float64
  7255. // for _, item := range prescriptions {
  7256. // if item.Type == 1 { //药品
  7257. // for _, subItem := range item.HisDoctorAdviceInfo {
  7258. // total = total + (subItem.Price * subItem.PrescribingNumber)
  7259. // }
  7260. // }
  7261. // if item.Type == 2 { //项目
  7262. // for _, subItem := range item.HisPrescriptionProject {
  7263. // total = total + (subItem.Price * float64(subItem.Count))
  7264. // }
  7265. // }
  7266. // }
  7267. //
  7268. // for _, item := range prescriptions {
  7269. // for _, subItem := range item.HisAdditionalCharge {
  7270. // total = total + (subItem.Price * float64(subItem.Count))
  7271. // }
  7272. // }
  7273. //
  7274. // allTotal := fmt.Sprintf("%.2f", total)
  7275. // var rf []*ResultFive
  7276. // json.Unmarshal([]byte(his.Iinfo), &rf)
  7277. // psn_no := order_src.PsnNo
  7278. // mdtrt_id := order_src.MdtrtId
  7279. // chrg_bchno := order_src.Number
  7280. // cert_no := order_src.Certno
  7281. // insutype := rf[0].Insutype
  7282. //
  7283. // if his.IdCardType == 1 {
  7284. // cert_no = his.MedicalInsuranceNumber
  7285. // } else {
  7286. // cert_no = his.Certno
  7287. // }
  7288. //
  7289. // 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)
  7290. // var dat map[string]interface{}
  7291. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7292. // fmt.Println(dat)
  7293. // } else {
  7294. // fmt.Println(err)
  7295. // }
  7296. //
  7297. // userJSONBytes, _ := json.Marshal(dat)
  7298. //
  7299. //
  7300. //
  7301. // var res ResultSeven
  7302. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7303. // utils.ErrorLog("解析失败:%v", err)
  7304. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7305. // return
  7306. // }
  7307. // if res.Infcode == -1 {
  7308. // errlog := &models.HisOrderError{
  7309. // UserOrgId: adminUser.CurrentOrgId,
  7310. // Ctime: time.Now().Unix(),
  7311. // Mtime: time.Now().Unix(),
  7312. // Number: chrg_bchno,
  7313. // ErrMsg: res.ErrMsg,
  7314. // Status: 1,
  7315. // PatientId: id,
  7316. // RecordTime: recordDateTime,
  7317. // Stage: 6,
  7318. // }
  7319. // service.CreateErrMsgLog(errlog)
  7320. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7321. // return
  7322. // } else {
  7323. // order_src.OrderStatus = 2
  7324. // order_src.PayWay = pay_way
  7325. // order_src.PayPrice = pay_price
  7326. // order_src.PayCardNo = pay_card_no
  7327. // order_src.DiscountPrice = discount_price
  7328. // order_src.PreferentialPrice = preferential_price
  7329. // order_src.RealityPrice = reality_price
  7330. // order_src.FoundPrice = found_price
  7331. // order_src.MedicalInsurancePrice = medical_insurance_price
  7332. // order_src.PrivatePrice = private_price
  7333. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  7334. // order_src.SetlId = res.Output.Setlinfo.SetlID
  7335. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  7336. // order_src.PsnName = res.Output.Setlinfo.PsnName
  7337. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  7338. // order_src.Certno = res.Output.Setlinfo.Certno
  7339. // order_src.Gend = res.Output.Setlinfo.Gend
  7340. // order_src.Naty = res.Output.Setlinfo.Naty
  7341. // order_src.Age = res.Output.Setlinfo.Age
  7342. // order_src.Insutype = res.Output.Setlinfo.Insutype
  7343. // order_src.PsnType = res.Output.Setlinfo.PsnType
  7344. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7345. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  7346. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7347. // order_src.MedType = res.Output.Setlinfo.MedType
  7348. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7349. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7350. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7351. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7352. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7353. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7354. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  7355. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  7356. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7357. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  7358. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  7359. // order_src.MafPay = res.Output.Setlinfo.MafPay
  7360. // order_src.OthPay = res.Output.Setlinfo.OthPay
  7361. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7362. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7363. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  7364. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7365. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7366. // order_src.Balc = res.Output.Setlinfo.Balc
  7367. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7368. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7369. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  7370. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  7371. // order_src.Creator = order_src.Creator
  7372. // order_src.Modify = roles.ID
  7373. // order_src.RequestLog = src_resquest
  7374. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7375. // detailStr := string(setlDetail)
  7376. // order_src.SetlDetail = detailStr
  7377. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7378. // err = service.UpDateOrder(order_src)
  7379. //
  7380. // if err == nil {
  7381. // c.ServeSuccessJSON(map[string]interface{}{
  7382. // "msg": "结算成功",
  7383. // })
  7384. // } else {
  7385. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7386. // return
  7387. // }
  7388. // }
  7389. // }
  7390. //}
  7391. //退款
  7392. func (c *HisApiController) Refund() {
  7393. order_id, _ := c.GetInt64("order_id")
  7394. admin_user_id, _ := c.GetInt64("admin_user_id")
  7395. adminUser := c.GetAdminUserInfo()
  7396. var order models.HisOrder
  7397. order, _ = service.GetHisOrderByID(order_id)
  7398. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7399. if order.ID == 0 {
  7400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7401. return
  7402. }
  7403. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7404. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7405. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7406. if config.IsOpen == 1 { //对接了医保,走医保流程
  7407. var res ResultSixteen
  7408. var resSixteen10265 ResultSixteen10265
  7409. var src_resquest string
  7410. var result string
  7411. if miConfig.MdtrtareaAdmvs == "421300" {
  7412. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  7413. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7414. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7415. resp3, requestErr3 := http.Get(api3)
  7416. if requestErr3 != nil {
  7417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7418. return
  7419. }
  7420. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7421. if ioErr3 != nil {
  7422. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7424. return
  7425. }
  7426. var respJSON3 map[string]interface{}
  7427. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7428. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7430. return
  7431. }
  7432. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7433. userJSONBytes3, _ := json.Marshal(respJSON3)
  7434. fmt.Println("log")
  7435. fmt.Println(string(userJSONBytes3))
  7436. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  7437. utils.ErrorLog("解析失败:%v", err)
  7438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7439. return
  7440. }
  7441. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7442. var api3 string
  7443. if miConfig.MdtrtareaAdmvs == "320921" {
  7444. api3 = "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7445. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7446. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7447. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7448. } else {
  7449. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7450. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7451. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7452. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7453. }
  7454. resp3, requestErr3 := http.Get(api3)
  7455. if requestErr3 != nil {
  7456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7457. return
  7458. }
  7459. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7460. if ioErr3 != nil {
  7461. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7463. return
  7464. }
  7465. var respJSON3 map[string]interface{}
  7466. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7467. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7469. return
  7470. }
  7471. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7472. userJSONBytes3, _ := json.Marshal(respJSON3)
  7473. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  7474. utils.ErrorLog("解析失败:%v", err)
  7475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7476. return
  7477. }
  7478. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7479. res.Output = resSixteen10265.Output
  7480. res.ErrMsg = resSixteen10265.ErrMsg
  7481. res.Cainfo = resSixteen10265.Cainfo
  7482. res.WarnMsg = resSixteen10265.WarnMsg
  7483. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7484. res.Infcode = infocode
  7485. } else {
  7486. if miConfig.Code == "H15049901371" {
  7487. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7488. var dat map[string]interface{}
  7489. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7490. fmt.Println(dat)
  7491. } else {
  7492. fmt.Println(err)
  7493. }
  7494. saveLog(result, src_resquest, "2208", "退费")
  7495. userJSONBytes, _ := json.Marshal(dat)
  7496. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  7497. utils.ErrorLog("解析失败:%v", err)
  7498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7499. return
  7500. }
  7501. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7502. res.Output = resSixteen10265.Output
  7503. res.ErrMsg = resSixteen10265.ErrMsg
  7504. res.Cainfo = resSixteen10265.Cainfo
  7505. res.WarnMsg = resSixteen10265.WarnMsg
  7506. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7507. res.Infcode = infocode
  7508. } else {
  7509. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7510. var dat map[string]interface{}
  7511. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7512. fmt.Println(dat)
  7513. } else {
  7514. fmt.Println(err)
  7515. }
  7516. saveLog(result, src_resquest, "2208", "退费")
  7517. userJSONBytes, _ := json.Marshal(dat)
  7518. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7519. utils.ErrorLog("解析失败:%v", err)
  7520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7521. return
  7522. }
  7523. }
  7524. }
  7525. if res.Infcode == 0 {
  7526. var res2 ResultSix
  7527. var resSix10265 ResultSix10265
  7528. if miConfig.MdtrtareaAdmvs == "421300" {
  7529. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7530. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7531. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7532. resp3, requestErr3 := http.Get(api3)
  7533. if requestErr3 != nil {
  7534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7535. return
  7536. }
  7537. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7538. if ioErr3 != nil {
  7539. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7541. return
  7542. }
  7543. var respJSON3 map[string]interface{}
  7544. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7545. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7547. return
  7548. }
  7549. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7550. userJSONBytes3, _ := json.Marshal(respJSON3)
  7551. fmt.Println("log")
  7552. fmt.Println(string(userJSONBytes3))
  7553. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7554. utils.ErrorLog("解析失败:%v", err)
  7555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7556. return
  7557. }
  7558. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7559. var api3 string
  7560. if miConfig.MdtrtareaAdmvs == "320921" {
  7561. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7562. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7563. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7564. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7565. } else {
  7566. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7567. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7568. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7569. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7570. }
  7571. resp3, requestErr3 := http.Get(api3)
  7572. if requestErr3 != nil {
  7573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7574. return
  7575. }
  7576. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7577. if ioErr3 != nil {
  7578. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7580. return
  7581. }
  7582. var respJSON3 map[string]interface{}
  7583. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7584. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7586. return
  7587. }
  7588. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7589. userJSONBytes3, _ := json.Marshal(respJSON3)
  7590. fmt.Println("log")
  7591. fmt.Println(string(userJSONBytes3))
  7592. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7593. utils.ErrorLog("解析失败:%v", err)
  7594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7595. return
  7596. }
  7597. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7598. res2.Output = resSix10265.Output
  7599. res2.ErrMsg = resSix10265.ErrMsg
  7600. res2.Cainfo = resSix10265.Cainfo
  7601. res2.WarnMsg = resSix10265.WarnMsg
  7602. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7603. res2.Infcode = infocode
  7604. } else {
  7605. if miConfig.Code == "H15049901371" {
  7606. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7607. var dat map[string]interface{}
  7608. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7609. fmt.Println(dat)
  7610. } else {
  7611. fmt.Println(err)
  7612. }
  7613. saveLog(result2, src_request, "2205", "撤销明细")
  7614. userJSONBytes, _ := json.Marshal(dat)
  7615. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7616. utils.ErrorLog("解析失败:%v", err)
  7617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7618. return
  7619. }
  7620. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7621. res2.Output = resSix10265.Output
  7622. res2.ErrMsg = resSix10265.ErrMsg
  7623. res2.Cainfo = resSix10265.Cainfo
  7624. res2.WarnMsg = resSix10265.WarnMsg
  7625. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7626. res2.Infcode = infocode
  7627. } else {
  7628. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7629. var dat map[string]interface{}
  7630. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7631. fmt.Println(dat)
  7632. } else {
  7633. fmt.Println(err)
  7634. }
  7635. saveLog(result2, src_request, "2205", "撤销明细")
  7636. userJSONBytes, _ := json.Marshal(dat)
  7637. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7638. utils.ErrorLog("解析失败:%v", err)
  7639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7640. return
  7641. }
  7642. }
  7643. }
  7644. if res2.Infcode == 0 {
  7645. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  7646. if err == nil {
  7647. c.ServeSuccessJSON(map[string]interface{}{
  7648. "msg": "退费成功",
  7649. })
  7650. } else {
  7651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7652. return
  7653. }
  7654. } else {
  7655. c.ServeSuccessJSON(map[string]interface{}{
  7656. "code": -10,
  7657. "msg": res2.ErrMsg,
  7658. })
  7659. }
  7660. } else {
  7661. c.ServeSuccessJSON(map[string]interface{}{
  7662. "code": -10,
  7663. "msg": res.ErrMsg,
  7664. })
  7665. }
  7666. }
  7667. }
  7668. func (c *HisApiController) RefundNumber() {
  7669. record_time := c.GetString("record_time")
  7670. //patient_id, _ := c.GetInt64("patient_id")
  7671. admin_user_id, _ := c.GetInt64("admin_user_id")
  7672. his_patient_id, _ := c.GetInt64("id")
  7673. timeLayout := "2006-01-02"
  7674. loc, _ := time.LoadLocation("Local")
  7675. adminUser := c.GetAdminUserInfo()
  7676. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7677. fmt.Println(err)
  7678. if err != nil {
  7679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7680. return
  7681. }
  7682. recordDateTime := theTime.Unix()
  7683. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7684. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  7685. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7686. //order, _ := service.GetHisOrderByID(order_id)
  7687. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7688. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7689. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7690. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  7691. if count > 0 {
  7692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  7693. return
  7694. }
  7695. if config.IsOpen == 1 { //对接了医保,走医保流程
  7696. var res2 ResultSix
  7697. var resSix10265 ResultSix10265
  7698. if miConfig.MdtrtareaAdmvs == "421300" {
  7699. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  7700. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7701. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7702. resp3, requestErr3 := http.Get(api3)
  7703. if requestErr3 != nil {
  7704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7705. return
  7706. }
  7707. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7708. if ioErr3 != nil {
  7709. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7711. return
  7712. }
  7713. var respJSON3 map[string]interface{}
  7714. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7715. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7717. return
  7718. }
  7719. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7720. userJSONBytes3, _ := json.Marshal(respJSON3)
  7721. fmt.Println("log")
  7722. fmt.Println(string(userJSONBytes3))
  7723. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7724. utils.ErrorLog("解析失败:%v", err)
  7725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7726. return
  7727. }
  7728. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7729. var api3 string
  7730. if miConfig.MdtrtareaAdmvs == "320921" {
  7731. api3 = "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  7732. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7733. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7734. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7735. } else {
  7736. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7737. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  7738. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7739. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7740. }
  7741. resp3, requestErr3 := http.Get(api3)
  7742. if requestErr3 != nil {
  7743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7744. return
  7745. }
  7746. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7747. if ioErr3 != nil {
  7748. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7750. return
  7751. }
  7752. var respJSON3 map[string]interface{}
  7753. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7754. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7756. return
  7757. }
  7758. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7759. userJSONBytes3, _ := json.Marshal(respJSON3)
  7760. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7761. utils.ErrorLog("解析失败:%v", err)
  7762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7763. return
  7764. }
  7765. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7766. res2.Output = resSix10265.Output
  7767. res2.ErrMsg = resSix10265.ErrMsg
  7768. res2.Cainfo = resSix10265.Cainfo
  7769. res2.WarnMsg = resSix10265.WarnMsg
  7770. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7771. res2.Infcode = infocode
  7772. } else {
  7773. var api3 string
  7774. if miConfig.Code == "H15049901371" {
  7775. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7776. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7777. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7778. } else {
  7779. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7780. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7781. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7782. }
  7783. resp3, requestErr3 := http.Get(api3)
  7784. if requestErr3 != nil {
  7785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7786. return
  7787. }
  7788. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7789. if ioErr3 != nil {
  7790. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7792. return
  7793. }
  7794. var respJSON3 map[string]interface{}
  7795. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7796. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7798. return
  7799. }
  7800. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7801. userJSONBytes3, _ := json.Marshal(respJSON3)
  7802. if miConfig.Code == "H15049901371" {
  7803. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7804. utils.ErrorLog("解析失败:%v", err)
  7805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7806. return
  7807. }
  7808. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7809. res2.Output = resSix10265.Output
  7810. res2.ErrMsg = resSix10265.ErrMsg
  7811. res2.Cainfo = resSix10265.Cainfo
  7812. res2.WarnMsg = resSix10265.WarnMsg
  7813. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7814. res2.Infcode = infocode
  7815. } else {
  7816. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7817. utils.ErrorLog("解析失败:%v", err)
  7818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7819. return
  7820. }
  7821. }
  7822. }
  7823. if res2.Infcode == 0 {
  7824. if err == nil {
  7825. c.ServeSuccessJSON(map[string]interface{}{
  7826. "msg": "退号成功",
  7827. })
  7828. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  7829. } else {
  7830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7831. return
  7832. }
  7833. } else {
  7834. c.ServeSuccessJSON(map[string]interface{}{
  7835. "code": -10,
  7836. "msg": res2.ErrMsg,
  7837. })
  7838. }
  7839. } else {
  7840. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  7841. //if err == nil {
  7842. // c.ServeSuccessJSON(map[string]interface{}{
  7843. // "msg": "退费成功",
  7844. // })
  7845. //} else {
  7846. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7847. // return
  7848. //}
  7849. }
  7850. }
  7851. func (c *HisApiController) RefundDetail() {
  7852. order_id, _ := c.GetInt64("order_id")
  7853. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7854. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7855. number := c.GetString("number")
  7856. record_time := c.GetString("record_time")
  7857. patient_id, _ := c.GetInt64("patient_id")
  7858. //med_type, _ := c.GetInt64("med_type")
  7859. timeLayout := "2006-01-02"
  7860. loc, _ := time.LoadLocation("Local")
  7861. adminUser := c.GetAdminUserInfo()
  7862. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7863. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7864. fmt.Println(err)
  7865. if err != nil {
  7866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7867. return
  7868. }
  7869. recordDateTime := theTime.Unix()
  7870. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7871. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7872. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7873. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7874. var order models.HisOrder
  7875. order, _ = service.GetHisOrderByID(order_id)
  7876. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7877. if config.IsOpen == 1 { //对接了医保,走医保流程
  7878. var res2 ResultSix
  7879. if miConfig.MdtrtareaAdmvs == "421300" {
  7880. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7881. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7882. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7883. resp3, requestErr3 := http.Get(api3)
  7884. if requestErr3 != nil {
  7885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7886. return
  7887. }
  7888. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7889. if ioErr3 != nil {
  7890. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7892. return
  7893. }
  7894. var respJSON3 map[string]interface{}
  7895. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7896. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7898. return
  7899. }
  7900. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7901. userJSONBytes3, _ := json.Marshal(respJSON3)
  7902. fmt.Println("log")
  7903. fmt.Println(string(userJSONBytes3))
  7904. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7905. utils.ErrorLog("解析失败:%v", err)
  7906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7907. return
  7908. }
  7909. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7910. if err == nil {
  7911. c.ServeSuccessJSON(map[string]interface{}{
  7912. "msg": "撤销明细成功",
  7913. })
  7914. return
  7915. } else {
  7916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7917. return
  7918. }
  7919. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7920. var resSix10265 ResultSix10265
  7921. var api3 string
  7922. if miConfig.MdtrtareaAdmvs == "320921" {
  7923. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7924. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7925. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7926. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7927. } else {
  7928. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7929. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7930. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7931. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7932. }
  7933. resp3, requestErr3 := http.Get(api3)
  7934. if requestErr3 != nil {
  7935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7936. return
  7937. }
  7938. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7939. if ioErr3 != nil {
  7940. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7942. return
  7943. }
  7944. var respJSON3 map[string]interface{}
  7945. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7946. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7948. return
  7949. }
  7950. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7951. userJSONBytes3, _ := json.Marshal(respJSON3)
  7952. fmt.Println("log")
  7953. fmt.Println(string(userJSONBytes3))
  7954. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7955. utils.ErrorLog("解析失败:%v", err)
  7956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7957. return
  7958. }
  7959. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7960. res2.Output = resSix10265.Output
  7961. res2.ErrMsg = resSix10265.ErrMsg
  7962. res2.Cainfo = resSix10265.Cainfo
  7963. res2.WarnMsg = resSix10265.WarnMsg
  7964. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7965. res2.Infcode = infocode
  7966. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7967. if err == nil {
  7968. c.ServeSuccessJSON(map[string]interface{}{
  7969. "msg": "撤销明细成功",
  7970. })
  7971. return
  7972. } else {
  7973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7974. return
  7975. }
  7976. } else {
  7977. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  7978. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7979. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7980. resp2, requestErr2 := http.Get(api2)
  7981. if requestErr2 != nil {
  7982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7983. return
  7984. }
  7985. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7986. if ioErr2 != nil {
  7987. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7989. return
  7990. }
  7991. var respJSON2 map[string]interface{}
  7992. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  7993. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7995. return
  7996. }
  7997. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7998. if err == nil {
  7999. c.ServeSuccessJSON(map[string]interface{}{
  8000. "msg": "撤销明细成功",
  8001. })
  8002. return
  8003. } else {
  8004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8005. return
  8006. }
  8007. }
  8008. } else {
  8009. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8010. if err == nil {
  8011. c.ServeSuccessJSON(map[string]interface{}{
  8012. "msg": "退费成功",
  8013. })
  8014. } else {
  8015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8016. return
  8017. }
  8018. }
  8019. }
  8020. //对账
  8021. func (c *HisApiController) GetCheckAccount() {
  8022. start_time := c.GetString("start_time")
  8023. end_time := c.GetString("end_time")
  8024. insutype := c.GetString("insutype")
  8025. clr_type := c.GetString("clr_type")
  8026. clr_org := c.GetString("clr_optins")
  8027. admin_user_id, _ := c.GetInt64("admin_user_id")
  8028. adminUser := c.GetAdminUserInfo()
  8029. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8030. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8031. if len(clr_org) == 0 {
  8032. clr_org = miConfig.MdtrtareaAdmvs
  8033. }
  8034. timeLayout := "2006-01-02"
  8035. loc, _ := time.LoadLocation("Local")
  8036. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8037. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8038. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_org, clr_type)
  8039. fixmedins_setl_cnt := int64(len(orders))
  8040. var medfee_sumamt float64
  8041. var acct_pay float64
  8042. var fund_pay_sumamt float64
  8043. for _, item := range orders {
  8044. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8045. acct_pay = acct_pay + item.AcctPay
  8046. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8047. }
  8048. var user_name string
  8049. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8050. if role.ID == 0 {
  8051. user_name = "xxx"
  8052. } else {
  8053. user_name = role.UserName
  8054. }
  8055. var res ResultEight
  8056. var res10188 ResultEightFor10188
  8057. if config.IsOpen == 1 {
  8058. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8059. api := "http://192.168.3.111:9532/" + "jsyb/3201?" +
  8060. "insutype=" + insutype +
  8061. "&clr_type=" + "11" +
  8062. "&setl_optins=" + clr_org +
  8063. "&stmt_begndate=" + start_time +
  8064. "&stm_enddate=" + end_time +
  8065. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8066. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8067. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8068. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8069. "&fixmedins_code=" + miConfig.Code +
  8070. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8071. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8072. "&secret_key=" + miConfig.SecretKey +
  8073. "&org_name=" + miConfig.OrgName +
  8074. "&doctor=" + user_name +
  8075. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8076. fmt.Println(api)
  8077. resp, requestErr := http.Get(api)
  8078. if requestErr != nil {
  8079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8080. return
  8081. }
  8082. body, ioErr := ioutil.ReadAll(resp.Body)
  8083. fmt.Println(body)
  8084. if ioErr != nil {
  8085. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8087. return
  8088. }
  8089. var respJSON map[string]interface{}
  8090. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8091. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8093. return
  8094. }
  8095. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8096. userJSONBytes, _ := json.Marshal(respJSON)
  8097. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8098. utils.ErrorLog("解析失败:%v", err)
  8099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8100. return
  8101. }
  8102. res.InfRefmsgid = res10188.InfRefmsgid
  8103. res.Output = res10188.Output
  8104. res.ErrMsg = res10188.ErrMsg
  8105. res.Cainfo = res10188.Cainfo
  8106. res.WarnMsg = res10188.WarnMsg
  8107. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8108. res.Infcode = infocode
  8109. } else {
  8110. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8111. "insutype=" + insutype +
  8112. "&clr_type=" + clr_type +
  8113. "&setl_optins=" + clr_org +
  8114. "&stmt_begndate=" + start_time +
  8115. "&stm_enddate=" + end_time +
  8116. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8117. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8118. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8119. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8120. "&fixmedins_code=" + miConfig.Code +
  8121. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8122. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8123. "&secret_key=" + miConfig.SecretKey +
  8124. "&org_name=" + miConfig.OrgName +
  8125. "&doctor=" + user_name
  8126. fmt.Println(api)
  8127. resp, requestErr := http.Get(api)
  8128. if requestErr != nil {
  8129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8130. return
  8131. }
  8132. body, ioErr := ioutil.ReadAll(resp.Body)
  8133. fmt.Println(body)
  8134. if ioErr != nil {
  8135. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8137. return
  8138. }
  8139. var respJSON map[string]interface{}
  8140. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8141. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8143. return
  8144. }
  8145. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8146. userJSONBytes, _ := json.Marshal(respJSON)
  8147. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8148. utils.ErrorLog("解析失败:%v", err)
  8149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8150. return
  8151. }
  8152. }
  8153. if res.Infcode == 0 {
  8154. if res.Output.Stmtinfo.StmtRslt == "0" {
  8155. micc := &models.MedicalInsuranceCostCompare{
  8156. StartTime: startime.Unix(),
  8157. EndTime: endtime.Unix(),
  8158. Insutype: insutype,
  8159. CheckType: 1,
  8160. Num: fixmedins_setl_cnt,
  8161. Mtime: time.Now().Unix(),
  8162. Status: 1,
  8163. UserOrgId: adminUser.CurrentOrgId,
  8164. CostTotal: medfee_sumamt,
  8165. FuncTotal: fund_pay_sumamt,
  8166. PsnPay: acct_pay,
  8167. Creator: admin_user_id,
  8168. Ctime: time.Now().Unix(),
  8169. ClrType: clr_type,
  8170. }
  8171. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  8172. if err == nil {
  8173. c.ServeSuccessJSON(map[string]interface{}{
  8174. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8175. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8176. })
  8177. } else {
  8178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8179. }
  8180. } else {
  8181. c.ServeSuccessJSON(map[string]interface{}{
  8182. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8183. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8184. })
  8185. }
  8186. } else {
  8187. c.ServeSuccessJSON(map[string]interface{}{
  8188. "code": -10,
  8189. "msg": res.ErrMsg,
  8190. })
  8191. }
  8192. }
  8193. }
  8194. func (c *HisApiController) Check310() {
  8195. adminUser := c.GetAdminUserInfo()
  8196. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8197. var user_name string
  8198. user_name = "高慧裕"
  8199. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8200. "insutype=" + "310" +
  8201. "&clr_type=" + "" +
  8202. "&setl_optins=" + "441202" +
  8203. "&stmt_begndate=" + "2022-03-01" +
  8204. "&stm_enddate=" + "2022-03-31" +
  8205. "&medfee_sumamt=" + "194930.12" +
  8206. "&fund_pay_sumamt=" + "188741.46" +
  8207. "&acct_pay=" + "0" +
  8208. "&fixmedins_setl_cnt=" + "452" +
  8209. "&fixmedins_code=" + miConfig.Code +
  8210. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8211. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8212. "&secret_key=" + miConfig.SecretKey +
  8213. "&org_name=" + miConfig.OrgName +
  8214. "&doctor=" + user_name
  8215. fmt.Println(api)
  8216. resp, requestErr := http.Get(api)
  8217. if requestErr != nil {
  8218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8219. return
  8220. }
  8221. body, ioErr := ioutil.ReadAll(resp.Body)
  8222. fmt.Println(body)
  8223. if ioErr != nil {
  8224. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8226. return
  8227. }
  8228. var respJSON map[string]interface{}
  8229. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8230. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8232. return
  8233. }
  8234. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8235. userJSONBytes, _ := json.Marshal(respJSON)
  8236. var res ResultEight
  8237. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8238. utils.ErrorLog("解析失败:%v", err)
  8239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8240. return
  8241. }
  8242. }
  8243. func (c *HisApiController) Check390() {
  8244. adminUser := c.GetAdminUserInfo()
  8245. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8246. var user_name string
  8247. user_name = "高慧裕"
  8248. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8249. "insutype=" + "390" +
  8250. "&clr_type=" + "" +
  8251. "&setl_optins=" + "441202" +
  8252. "&stmt_begndate=" + "2022-03-01" +
  8253. "&stm_enddate=" + "2022-03-31" +
  8254. "&medfee_sumamt=" + "1068448.89" +
  8255. "&fund_pay_sumamt=" + "1014677.62" +
  8256. "&acct_pay=" + "0" +
  8257. "&fixmedins_setl_cnt=" + "1950" +
  8258. "&fixmedins_code=" + miConfig.Code +
  8259. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8260. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8261. "&secret_key=" + miConfig.SecretKey +
  8262. "&org_name=" + miConfig.OrgName +
  8263. "&doctor=" + user_name
  8264. fmt.Println(api)
  8265. resp, requestErr := http.Get(api)
  8266. if requestErr != nil {
  8267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8268. return
  8269. }
  8270. body, ioErr := ioutil.ReadAll(resp.Body)
  8271. fmt.Println(body)
  8272. if ioErr != nil {
  8273. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8275. return
  8276. }
  8277. var respJSON map[string]interface{}
  8278. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8279. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8281. return
  8282. }
  8283. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8284. userJSONBytes, _ := json.Marshal(respJSON)
  8285. var res ResultEight
  8286. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8287. utils.ErrorLog("解析失败:%v", err)
  8288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8289. return
  8290. }
  8291. }
  8292. //对账明细
  8293. func (c *HisApiController) GetCheckDetailAccount() {
  8294. start_time := c.GetString("start_time")
  8295. end_time := c.GetString("end_time")
  8296. admin_user_id, _ := c.GetInt64("admin_user_id")
  8297. adminUser := c.GetAdminUserInfo()
  8298. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8299. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8300. timeLayout := "2006-01-02"
  8301. loc, _ := time.LoadLocation("Local")
  8302. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8303. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8304. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  8305. Mkdir(miConfig.OrgName)
  8306. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  8307. file_name := file + ".txt"
  8308. zip_name := file + ".zip"
  8309. zip_path := miConfig.OrgName + "/" + zip_name
  8310. file_path := miConfig.OrgName + "/" + file_name
  8311. decimal.DivisionPrecision = 2
  8312. var medfee_sumamt float64
  8313. var psn_cash_pay float64
  8314. var fund_pay_sumamt float64
  8315. fixmedins_setl_cnt := int64(len(orders))
  8316. for _, item := range orders {
  8317. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8318. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  8319. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8320. }
  8321. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  8322. defer f.Close()
  8323. if err != nil {
  8324. fmt.Println(err.Error())
  8325. } else {
  8326. for _, item := range orders {
  8327. var refd_setl_flag string
  8328. if item.OrderStatus == 2 {
  8329. refd_setl_flag = "0"
  8330. var str string
  8331. str = item.SetlId + " " +
  8332. item.MdtrtId + " " +
  8333. item.PsnNo + " " +
  8334. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8335. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8336. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  8337. _, err = f.Write([]byte(str))
  8338. }
  8339. if item.OrderStatus == 3 {
  8340. var str string
  8341. str = item.SetlId + " " +
  8342. item.MdtrtId + " " +
  8343. item.PsnNo + " " +
  8344. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8345. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8346. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  8347. _, err = f.Write([]byte(str))
  8348. var str2 string
  8349. str2 = item.SetlId + " " +
  8350. item.MdtrtId + " " +
  8351. item.PsnNo + " " +
  8352. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  8353. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  8354. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  8355. _, err = f.Write([]byte(str2))
  8356. }
  8357. }
  8358. }
  8359. Zip(file_path, zip_path)
  8360. fmt.Println(ReadFile(zip_path))
  8361. fmt.Println(string(ReadFile(zip_path)))
  8362. if config.IsOpen == 1 {
  8363. var user_name string
  8364. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8365. if role.ID == 0 {
  8366. user_name = "管理员"
  8367. } else {
  8368. user_name = role.UserName
  8369. }
  8370. baseParams := models.BaseParams{
  8371. SecretKey: miConfig.SecretKey,
  8372. FixmedinsCode: miConfig.Code,
  8373. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8374. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8375. OrgName: miConfig.OrgName,
  8376. Doctor: user_name,
  8377. }
  8378. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  8379. var dat map[string]interface{}
  8380. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8381. fmt.Println(dat)
  8382. } else {
  8383. fmt.Println(err)
  8384. }
  8385. userJSONBytes, _ := json.Marshal(dat)
  8386. var res ResultNine
  8387. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8388. utils.ErrorLog("解析失败:%v", err)
  8389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8390. return
  8391. }
  8392. if res.Infcode == 0 {
  8393. fileNo := res.Output.FileQuryNo
  8394. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  8395. "file_qury_no=" + fileNo +
  8396. "&setl_optins=" + "定点医保中心" +
  8397. "&stmt_begndate=" + start_time +
  8398. "&stm_enddate=" + end_time +
  8399. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8400. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8401. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  8402. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8403. "&fixmedins_code=" + miConfig.Code +
  8404. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8405. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8406. "&secret_key=" + miConfig.SecretKey +
  8407. "&org_name=" + miConfig.OrgName +
  8408. "&doctor=" + user_name
  8409. resp, requestErr := http.Get(api)
  8410. if requestErr != nil {
  8411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8412. return
  8413. }
  8414. body, ioErr := ioutil.ReadAll(resp.Body)
  8415. if ioErr != nil {
  8416. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8418. return
  8419. }
  8420. var respJSON map[string]interface{}
  8421. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8422. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8424. return
  8425. }
  8426. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8427. userJSONBytes, _ := json.Marshal(respJSON)
  8428. var res ResultTen
  8429. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8430. utils.ErrorLog("解析失败:%v", err)
  8431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8432. return
  8433. }
  8434. if res.Infcode == 0 {
  8435. service.Gdyb9102(baseParams, zip_name, fileNo)
  8436. micc := &models.MedicalInsuranceCostCompare{
  8437. StartTime: startime.Unix(),
  8438. EndTime: endtime.Unix(),
  8439. Insutype: "0",
  8440. CheckType: 2,
  8441. Num: fixmedins_setl_cnt,
  8442. Mtime: time.Now().Unix(),
  8443. Status: 1,
  8444. UserOrgId: adminUser.CurrentOrgId,
  8445. CostTotal: medfee_sumamt,
  8446. FuncTotal: fund_pay_sumamt,
  8447. PsnPay: psn_cash_pay,
  8448. Creator: admin_user_id,
  8449. Ctime: time.Now().Unix(),
  8450. }
  8451. service.CreateMedicalInsuranceCostCompareRecord(micc)
  8452. c.ServeSuccessJSON(map[string]interface{}{
  8453. "msg": "明细对账成功",
  8454. })
  8455. }
  8456. } else {
  8457. }
  8458. }
  8459. }
  8460. type CustomOrderInfo struct {
  8461. Name string
  8462. Spec string
  8463. Unit string
  8464. Count float64
  8465. Price float64
  8466. Total float64
  8467. }
  8468. func (c *HisApiController) GetSettleAccounts() {
  8469. //id, _ := c.GetInt64("id")
  8470. //record_time := c.GetString("record_time")
  8471. order_id, _ := c.GetInt64("order_id")
  8472. admin_user_id, _ := c.GetInt64("admin_user_id")
  8473. //timeLayout := "2006-01-02"
  8474. //loc, _ := time.LoadLocation("Local")
  8475. //
  8476. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8477. //if err != nil {
  8478. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8479. // return
  8480. //}
  8481. //recordDateTime := theTime.Unix()
  8482. adminUser := c.GetAdminUserInfo()
  8483. order, _ := service.GetHisOrderByID(order_id)
  8484. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8485. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  8486. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8487. orderInfos = append(orderInfos, orderInfos_two...)
  8488. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8489. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  8490. var diagnosis_ids []string
  8491. if his.ID > 0 {
  8492. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  8493. } else {
  8494. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  8495. }
  8496. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  8497. var dia_config []*models.HisXtDiagnoseConfig
  8498. var name string
  8499. for _, item := range diagnosis_ids {
  8500. id, _ := strconv.ParseInt(item, 10, 64)
  8501. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8502. dia_config = append(dia_config, &diagnosisConfig)
  8503. if len(name) == 0 {
  8504. name = diagnosisConfig.ClassName
  8505. } else {
  8506. name = name + "," + diagnosisConfig.ClassName
  8507. }
  8508. }
  8509. var bedCostTotal float64 = 0 //床位总费
  8510. var bedCostSelfTotal float64 = 0 //床位自费
  8511. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  8512. var operationCostTotal float64 = 0 //手术费
  8513. var operationCostSelfTotal float64 = 0 //手术费
  8514. var operationCostPartSelfTotal float64 = 0 //手术费
  8515. var otherCostTotal float64 = 0 //其他费用
  8516. var otherCostSelfTotal float64 = 0 //其他费用
  8517. var otherCostPartSelfTotal float64 = 0 //其他费用
  8518. var materialCostTotal float64 = 0 //材料费
  8519. var materialCostSelfTotal float64 = 0 //材料费
  8520. var materialCostPartSelfTotal float64 = 0 //材料费
  8521. var westernMedicineCostTotal float64 = 0 //西药费
  8522. var westernMedicineCostSelfTotal float64 = 0 //西药费
  8523. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  8524. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  8525. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  8526. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  8527. var checkCostTotal float64 = 0 //检查费
  8528. var checkCostSelfTotal float64 = 0 //检查费
  8529. var checkCostPartSelfTotal float64 = 0 //检查费
  8530. var laboratoryCostTotal float64 = 0 //化验费
  8531. var laboratoryCostSelfTotal float64 = 0 //化验费
  8532. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  8533. var treatCostTotal float64 = 0 //治疗费用
  8534. var treatCostSelfTotal float64 = 0 //治疗费用
  8535. var treatCostPartSelfTotal float64 = 0 //治疗费用
  8536. decimal.DivisionPrecision = 2
  8537. for _, item := range orderInfos {
  8538. if item.MedChrgitmType == "01" { //床位费
  8539. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8540. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8541. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8542. }
  8543. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  8544. if item.MedChrgitmType == "03" { //检查费
  8545. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8546. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8547. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8548. }
  8549. } else {
  8550. if item.MedChrgitmType == "03" { //检查费
  8551. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8552. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8553. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8554. }
  8555. }
  8556. if item.MedChrgitmType == "04" { //化验费
  8557. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8558. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8559. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8560. }
  8561. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  8562. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8563. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8564. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8565. }
  8566. if item.MedChrgitmType == "06" { //手术费
  8567. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8568. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8569. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8570. }
  8571. if item.MedChrgitmType == "08" { //材料费
  8572. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8573. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8574. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8575. }
  8576. if item.MedChrgitmType == "09" { //西药费
  8577. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8578. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8579. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8580. }
  8581. if item.MedChrgitmType == "11" { //中成费
  8582. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8583. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8584. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8585. }
  8586. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  8587. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8588. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8589. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8590. }
  8591. }
  8592. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8593. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8594. var user_name string
  8595. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8596. if role.ID == 0 {
  8597. user_name = "管理员"
  8598. } else {
  8599. user_name = role.UserName
  8600. }
  8601. baseParams := models.BaseParams{
  8602. SecretKey: miConfig.SecretKey,
  8603. FixmedinsCode: miConfig.Code,
  8604. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8605. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8606. OrgName: miConfig.OrgName,
  8607. Doctor: user_name,
  8608. }
  8609. businessParams := models.BusinessParams{
  8610. PsnNo: order.PsnNo,
  8611. MdtrtId: order.MdtrtId,
  8612. SetlId: order.SetlId,
  8613. }
  8614. var res ResultEleven
  8615. var resEleven10265 ResultEleven10265
  8616. if config.IsOpen == 1 {
  8617. if miConfig.MdtrtareaAdmvs == "421300" {
  8618. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8619. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8620. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8621. resp, requestErr := http.Get(api)
  8622. if requestErr != nil {
  8623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8624. return
  8625. }
  8626. body, ioErr := ioutil.ReadAll(resp.Body)
  8627. if ioErr != nil {
  8628. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8630. return
  8631. }
  8632. var respJSON map[string]interface{}
  8633. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8634. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8636. return
  8637. }
  8638. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8639. result, _ := json.Marshal(respJSON)
  8640. fmt.Println("log")
  8641. fmt.Println(string(result))
  8642. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8643. utils.ErrorLog("解析失败:%v", err)
  8644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8645. return
  8646. }
  8647. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8648. var api string
  8649. if miConfig.MdtrtareaAdmvs == "320921" {
  8650. api = "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8651. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8652. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8653. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8654. } else {
  8655. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8656. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8657. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8658. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8659. }
  8660. resp, requestErr := http.Get(api)
  8661. if requestErr != nil {
  8662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8663. return
  8664. }
  8665. body, ioErr := ioutil.ReadAll(resp.Body)
  8666. if ioErr != nil {
  8667. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8669. return
  8670. }
  8671. var respJSON map[string]interface{}
  8672. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8673. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8675. return
  8676. }
  8677. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8678. result, _ := json.Marshal(respJSON)
  8679. fmt.Println("log")
  8680. fmt.Println(string(result))
  8681. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  8682. utils.ErrorLog("解析失败:%v", err)
  8683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8684. return
  8685. }
  8686. res.InfRefmsgid = resEleven10265.InfRefmsgid
  8687. res.Output = resEleven10265.Output
  8688. res.ErrMsg = resEleven10265.ErrMsg
  8689. res.Cainfo = resEleven10265.Cainfo
  8690. res.WarnMsg = resEleven10265.WarnMsg
  8691. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  8692. res.Infcode = infocode
  8693. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8694. fmt.Println("~~~~~~~")
  8695. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8696. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8697. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8698. resp, requestErr := http.Get(api)
  8699. if requestErr != nil {
  8700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8701. return
  8702. }
  8703. body, ioErr := ioutil.ReadAll(resp.Body)
  8704. if ioErr != nil {
  8705. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8707. return
  8708. }
  8709. var respJSON map[string]interface{}
  8710. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8711. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8713. return
  8714. }
  8715. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8716. result, _ := json.Marshal(respJSON)
  8717. fmt.Println("log")
  8718. fmt.Println(string(result))
  8719. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  8720. utils.ErrorLog("解析失败:%v", err)
  8721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8722. return
  8723. }
  8724. res.InfRefmsgid = resEleven10265.InfRefmsgid
  8725. res.Output = resEleven10265.Output
  8726. res.ErrMsg = resEleven10265.ErrMsg
  8727. res.Cainfo = resEleven10265.Cainfo
  8728. res.WarnMsg = resEleven10265.WarnMsg
  8729. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  8730. res.Infcode = infocode
  8731. } else {
  8732. result := service.Gdyb5203(baseParams, businessParams)
  8733. var dat map[string]interface{}
  8734. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8735. fmt.Println(dat)
  8736. } else {
  8737. fmt.Println(err)
  8738. }
  8739. userJSONBytes, _ := json.Marshal(dat)
  8740. if miConfig.Code == "H15049901371" {
  8741. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  8742. utils.ErrorLog("解析失败:%v", err)
  8743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8744. return
  8745. }
  8746. res.InfRefmsgid = resEleven10265.InfRefmsgid
  8747. res.Output = resEleven10265.Output
  8748. res.ErrMsg = resEleven10265.ErrMsg
  8749. res.Cainfo = resEleven10265.Cainfo
  8750. res.WarnMsg = resEleven10265.WarnMsg
  8751. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  8752. res.Infcode = infocode
  8753. } else {
  8754. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8755. utils.ErrorLog("解析失败:%v", err)
  8756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8757. return
  8758. }
  8759. }
  8760. }
  8761. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8762. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  8763. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  8764. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  8765. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  8766. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8767. var doctor_name string
  8768. if roles.ID == 0 {
  8769. doctor_name = "管理员"
  8770. } else {
  8771. doctor_name = roles.UserName
  8772. }
  8773. yiliao_leibie := ""
  8774. switch order.MedType {
  8775. case "11":
  8776. yiliao_leibie = "普通门诊"
  8777. break
  8778. case "12":
  8779. yiliao_leibie = "门诊挂号"
  8780. break
  8781. case "13":
  8782. yiliao_leibie = "急诊"
  8783. break
  8784. case "14":
  8785. yiliao_leibie = "门诊特殊病"
  8786. break
  8787. case "15":
  8788. yiliao_leibie = "门诊统筹"
  8789. break
  8790. case "16":
  8791. yiliao_leibie = "门诊慢性病"
  8792. break
  8793. case "21":
  8794. yiliao_leibie = "普通住院"
  8795. break
  8796. }
  8797. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8798. if res.Infcode == 0 {
  8799. c.ServeSuccessJSON(map[string]interface{}{
  8800. "diagnosis": name,
  8801. "order_infos": orderInfos,
  8802. "number": order.MdtrtId,
  8803. "date": order.SettleAccountsDate,
  8804. "charge_admin": charge_admin,
  8805. "printor_admin": printor_admin,
  8806. "info": res.Output.Setlinfo,
  8807. "order": order,
  8808. "bedCostTotal": bedCostTotal,
  8809. "bedCostSelfTotal": bedCostSelfTotal,
  8810. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  8811. "operationCostTotal": operationCostTotal,
  8812. "operationCostSelfTotal": operationCostSelfTotal,
  8813. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  8814. "otherCostTotal": otherCostTotal,
  8815. "otherCostSelfTotal": otherCostSelfTotal,
  8816. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  8817. "materialCostTotal": materialCostTotal,
  8818. "materialCostSelfTotal": materialCostSelfTotal,
  8819. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  8820. "westernMedicineCostTotal": westernMedicineCostTotal,
  8821. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  8822. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  8823. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  8824. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  8825. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  8826. "checkCostTotal": checkCostTotal,
  8827. "checkCostSelfTotal": checkCostSelfTotal,
  8828. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  8829. "laboratoryCostTotal": laboratoryCostTotal,
  8830. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  8831. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  8832. "treatCostTotal": treatCostTotal,
  8833. "treatCostSelfTotal": treatCostSelfTotal,
  8834. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  8835. "doctor_info": doctor_info,
  8836. "doctor_code": adminRole_two.DoctorCode,
  8837. "doctor_name": doctor_name,
  8838. "health_card_no": order.PsnNo,
  8839. "department": departments.Name,
  8840. "yiliao_leibie": yiliao_leibie,
  8841. "after_money": order.AccountPrice,
  8842. "patient": patient,
  8843. "org_name": miConfig.OrgName,
  8844. "org_code": miConfig.Code,
  8845. "order_number": order.Number,
  8846. "his_hospital": his_hospital,
  8847. "his": his,
  8848. "dia_config": dia_config,
  8849. //"check_order_info": cus_slice,
  8850. })
  8851. }
  8852. }
  8853. }
  8854. func (c *HisApiController) CheckTreatment() {
  8855. patient_id, _ := c.GetInt64("patient_id")
  8856. id_card_no := c.GetString("id_card_no")
  8857. insutype := c.GetString("insutype")
  8858. med_type := c.GetString("med_type")
  8859. admin_user_id, _ := c.GetInt64("admin_user_id")
  8860. adminUser := c.GetAdminUserInfo()
  8861. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8862. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8863. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8864. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8865. if miConfig.MdtrtareaAdmvs == "421300" {
  8866. var res ResultTwo
  8867. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  8868. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8869. "&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)
  8870. resp, requestErr := http.Get(api)
  8871. if requestErr != nil {
  8872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8873. return
  8874. }
  8875. body, ioErr := ioutil.ReadAll(resp.Body)
  8876. if ioErr != nil {
  8877. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8879. return
  8880. }
  8881. var respJSON map[string]interface{}
  8882. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8883. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8885. return
  8886. }
  8887. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8888. result, _ := json.Marshal(respJSON)
  8889. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8890. utils.ErrorLog("解析失败:%v", err)
  8891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8892. return
  8893. }
  8894. if res.Infcode == 0 {
  8895. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  8896. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8897. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  8898. resp, requestErr := http.Get(api)
  8899. if requestErr != nil {
  8900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8901. return
  8902. }
  8903. body, ioErr := ioutil.ReadAll(resp.Body)
  8904. if ioErr != nil {
  8905. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8907. return
  8908. }
  8909. var respJSON map[string]interface{}
  8910. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8911. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8913. return
  8914. }
  8915. var res Result2001
  8916. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8917. result2, _ := json.Marshal(respJSON)
  8918. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  8919. utils.ErrorLog("解析失败:%v", err)
  8920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8921. return
  8922. }
  8923. if res.Infcode == 0 {
  8924. c.ServeSuccessJSON(map[string]interface{}{
  8925. "msg": res.Output.Trtinfo,
  8926. })
  8927. }
  8928. } else {
  8929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8930. return
  8931. }
  8932. } else {
  8933. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  8934. var dat map[string]interface{}
  8935. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8936. fmt.Println(dat)
  8937. } else {
  8938. fmt.Println(err)
  8939. }
  8940. userJSONBytes, _ := json.Marshal(dat)
  8941. var res ResultTwo
  8942. var res10265 ResultTwo10265
  8943. if miConfig.Code == "H15049901371" {
  8944. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8945. utils.ErrorLog("解析失败:%v", err)
  8946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8947. return
  8948. }
  8949. res.ErrMsg = res10265.ErrMsg
  8950. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8951. res.Infcode = infocode
  8952. res.Output = res10265.Output
  8953. res.InfRefmsgid = res10265.InfRefmsgid
  8954. } else {
  8955. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8956. utils.ErrorLog("解析失败:%v", err)
  8957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8958. return
  8959. }
  8960. }
  8961. var user_name string
  8962. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  8963. if role.ID == 0 {
  8964. user_name = "xxx"
  8965. } else {
  8966. user_name = role.UserName
  8967. }
  8968. baseParams := models.BaseParams{
  8969. SecretKey: miConfig.SecretKey,
  8970. FixmedinsCode: miConfig.Code,
  8971. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8972. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8973. OrgName: miConfig.OrgName,
  8974. Doctor: user_name,
  8975. }
  8976. if config.IsOpen == 1 {
  8977. if miConfig.Code == "H15049901371" {
  8978. if med_type == "14" {
  8979. if insutype == "390" {
  8980. med_type = "9933"
  8981. } else if insutype == "310" {
  8982. med_type = "990502"
  8983. }
  8984. } else if med_type == "11" {
  8985. med_type = "11"
  8986. }
  8987. }
  8988. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  8989. var dat map[string]interface{}
  8990. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8991. fmt.Println(dat)
  8992. } else {
  8993. fmt.Println(err)
  8994. }
  8995. var res Result2001
  8996. var res10265 Result2001Org10265
  8997. if miConfig.Code == "H15049901371" {
  8998. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8999. utils.ErrorLog("解析失败:%v", err)
  9000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9001. return
  9002. }
  9003. res.ErrMsg = res10265.ErrMsg
  9004. res.Output = res10265.Output
  9005. res.InfRefmsgid = res10265.InfRefmsgid
  9006. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9007. res.Infcode = infocode
  9008. } else {
  9009. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9010. utils.ErrorLog("解析失败:%v", err)
  9011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9012. return
  9013. }
  9014. }
  9015. if res.Infcode == 0 {
  9016. c.ServeSuccessJSON(map[string]interface{}{
  9017. "msg": res.Output.Trtinfo,
  9018. })
  9019. }
  9020. }
  9021. }
  9022. }
  9023. //func (c *HisApiController) PutRecord() {
  9024. // id, _ := c.GetInt64("id")
  9025. // record_time := c.GetString("record_time")
  9026. // timeLayout := "2006-01-02"
  9027. // loc, _ := time.LoadLocation("Local")
  9028. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9029. // if err != nil {
  9030. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9031. // return
  9032. // }
  9033. // recordDateTime := theTime.Unix()
  9034. //
  9035. // adminInfo := c.GetAdminUserInfo()
  9036. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  9037. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9038. //
  9039. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9040. //
  9041. // fmt.Println(miConfig.SecretKey)
  9042. //
  9043. // if patient == nil {
  9044. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9045. // return
  9046. // }
  9047. // if len(patient.IdCardNo) == 0 {
  9048. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  9049. // return
  9050. // }
  9051. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  9052. // if config.IsOpen == 1 {
  9053. // 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
  9054. // resp, requestErr := http.Get(api)
  9055. // if requestErr != nil {
  9056. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9057. // return
  9058. // }
  9059. // defer resp.Body.Close()
  9060. // body, ioErr := ioutil.ReadAll(resp.Body)
  9061. // if ioErr != nil {
  9062. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9063. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9064. // return
  9065. // }
  9066. // var respJSON map[string]interface{}
  9067. //
  9068. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9069. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9070. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9071. // return
  9072. // }
  9073. //
  9074. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9075. // userJSONBytes, _ := json.Marshal(userJSON)
  9076. // var res ResultTwo
  9077. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9078. // utils.ErrorLog("解析失败:%v", err)
  9079. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9080. // return
  9081. // }
  9082. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9083. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9084. // infoStr := string(Iinfos)
  9085. // idetinfoStr := string(Idetinfos)
  9086. //
  9087. // if res.Infcode == 0 {
  9088. // his := models.VMHisPatient{
  9089. // Status: 1,
  9090. // Ctime: time.Now().Unix(),
  9091. // Mtime: time.Now().Unix(),
  9092. // PsnNo: res.Output.Baseinfo.PsnNo,
  9093. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  9094. // Certno: res.Output.Baseinfo.Certno,
  9095. // PsnName: res.Output.Baseinfo.PsnName,
  9096. // Gend: res.Output.Baseinfo.Gend,
  9097. // Naty: res.Output.Baseinfo.Naty,
  9098. // Brdy: res.Output.Baseinfo.Brdy,
  9099. // Age: res.Output.Baseinfo.Age,
  9100. // Iinfo: infoStr,
  9101. // Idetinfo: idetinfoStr,
  9102. // PatientId: patient.ID,
  9103. // RecordDate: theTime.Unix(),
  9104. // UserOrgId: adminInfo.CurrentOrgId,
  9105. // AdminUserId: adminInfo.AdminUser.Id,
  9106. // IsReturn: 1,
  9107. // }
  9108. //
  9109. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  9110. // //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")
  9111. // //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")
  9112. //
  9113. // //var dat map[string]interface{}
  9114. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9115. // // fmt.Println(dat)
  9116. // //} else {
  9117. // // fmt.Println(err)
  9118. // //}
  9119. //
  9120. // var dat2 map[string]interface{}
  9121. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9122. // fmt.Println(dat2)
  9123. // } else {
  9124. // fmt.Println(err)
  9125. // }
  9126. //
  9127. // } else {
  9128. // adminUser := c.GetAdminUserInfo()
  9129. // errlog := &models.HisOrderError{
  9130. // UserOrgId: adminUser.CurrentOrgId,
  9131. // Ctime: time.Now().Unix(),
  9132. // Mtime: time.Now().Unix(),
  9133. // ErrMsg: res.ErrMsg,
  9134. // Status: 1,
  9135. // PatientId: id,
  9136. // RecordTime: recordDateTime,
  9137. // Stage: 1,
  9138. // }
  9139. // service.CreateErrMsgLog(errlog)
  9140. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  9141. // return
  9142. // }
  9143. // }
  9144. //
  9145. //}
  9146. //func (c *HisApiController) GetUploadDiag() {
  9147. // id, _ := c.GetInt64("id")
  9148. // record_time := c.GetString("record_time")
  9149. //
  9150. // diagnosis_id, _ := c.GetInt64("diagnosis")
  9151. // sick_type, _ := c.GetInt64("sick_type")
  9152. // reg_type, _ := c.GetInt64("reg_type")
  9153. //
  9154. // timeLayout := "2006-01-02"
  9155. // loc, _ := time.LoadLocation("Local")
  9156. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9157. // if err != nil {
  9158. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9159. // return
  9160. // }
  9161. //
  9162. // var patientPrescription models.HisPrescriptionInfo
  9163. // recordDateTime := theTime.Unix()
  9164. // adminInfo := c.GetAdminUserInfo()
  9165. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9166. //
  9167. // if patientPrescription.ID == 0 {
  9168. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9169. // }
  9170. //
  9171. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9172. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9173. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9174. // sickConfig, _ := service.FindSickById(sick_type)
  9175. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9176. //
  9177. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  9178. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  9179. // "&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 +
  9180. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  9181. // resp2, requestErr2 := http.Get(api2)
  9182. // if requestErr2 != nil {
  9183. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9184. // return
  9185. // }
  9186. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  9187. // if ioErr2 != nil {
  9188. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  9189. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9190. // return
  9191. // }
  9192. // var respJSON2 map[string]interface{}
  9193. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  9194. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9195. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9196. // return
  9197. // }
  9198. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9199. // userJSONBytes2, _ := json.Marshal(respJSON2)
  9200. //
  9201. // var res2 ResultSix
  9202. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9203. // utils.ErrorLog("解析失败:%v", err)
  9204. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9205. // return
  9206. // }
  9207. // if res2.Infcode != 0 {
  9208. // adminUser := c.GetAdminUserInfo()
  9209. // errlog := &models.HisOrderError{
  9210. // UserOrgId: adminUser.CurrentOrgId,
  9211. // Ctime: time.Now().Unix(),
  9212. // Mtime: time.Now().Unix(),
  9213. // ErrMsg: res2.ErrMsg,
  9214. // Status: 1,
  9215. // PatientId: id,
  9216. // RecordTime: recordDateTime,
  9217. // Stage: 3,
  9218. // }
  9219. // service.CreateErrMsgLog(errlog)
  9220. //
  9221. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  9222. // return
  9223. // }
  9224. //
  9225. // c.ServeSuccessJSON(map[string]interface{}{
  9226. // "msg": "上传成功",
  9227. // })
  9228. //
  9229. //}
  9230. type QueryResult struct {
  9231. ID int64
  9232. Name string
  9233. Code string
  9234. List_type_code string
  9235. }
  9236. func (c *HisApiController) GetCheckCode() {
  9237. ids_str := c.GetString("ids")
  9238. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9239. ids_arr := strings.Split(ids_str, ",")
  9240. var queryResult []QueryResult
  9241. ids := make([]int64, 0)
  9242. for _, item := range ids_arr {
  9243. id, _ := strconv.ParseInt(item, 10, 64)
  9244. ids = append(ids, id)
  9245. }
  9246. if record_type == 1 {
  9247. drugs, _ := service.GetBatchDrugList(ids)
  9248. for _, item := range drugs {
  9249. result := QueryResult{
  9250. ID: item.ID,
  9251. Name: item.DrugName,
  9252. Code: item.MedicalInsuranceNumber,
  9253. List_type_code: "101",
  9254. }
  9255. queryResult = append(queryResult, result)
  9256. }
  9257. } else if record_type == 2 {
  9258. goods, _ := service.GetBatchGoodInformationList(ids)
  9259. for _, item := range goods {
  9260. result := QueryResult{
  9261. ID: item.ID,
  9262. Name: item.GoodName,
  9263. Code: item.MedicalInsuranceNumber,
  9264. List_type_code: "301",
  9265. }
  9266. queryResult = append(queryResult, result)
  9267. }
  9268. } else if record_type == 3 {
  9269. projects, _ := service.GetBathchMyPorjecgList(ids)
  9270. for _, item := range projects {
  9271. result := QueryResult{
  9272. ID: item.ID,
  9273. Name: item.ProjectName,
  9274. Code: item.MedicalCode,
  9275. List_type_code: "201",
  9276. }
  9277. queryResult = append(queryResult, result)
  9278. }
  9279. }
  9280. admin_user_id, _ := c.GetInt64("admin_user_id")
  9281. adminUser := c.GetAdminUserInfo()
  9282. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9283. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9284. var user_name string
  9285. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9286. if role.ID == 0 {
  9287. user_name = "xxx"
  9288. } else {
  9289. user_name = role.UserName
  9290. }
  9291. baseParams := &models.BaseParams{
  9292. SecretKey: miConfig.SecretKey,
  9293. FixmedinsCode: miConfig.Code,
  9294. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9295. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9296. OrgName: miConfig.OrgName,
  9297. Doctor: user_name,
  9298. }
  9299. if config.IsOpen == 1 {
  9300. for _, item := range queryResult {
  9301. var result string
  9302. if record_type == 1 {
  9303. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9304. } else if record_type == 2 {
  9305. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9306. } else if record_type == 3 {
  9307. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9308. }
  9309. var dat map[string]interface{}
  9310. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9311. fmt.Println(dat)
  9312. } else {
  9313. fmt.Println(err)
  9314. }
  9315. userJSONBytes, _ := json.Marshal(dat)
  9316. var res ResultSix
  9317. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9318. utils.ErrorLog("解析失败:%v", err)
  9319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9320. return
  9321. }
  9322. if res.Infcode == 0 {
  9323. if record_type == 1 {
  9324. service.UpdateBaseDrugById(item.ID)
  9325. } else if record_type == 2 {
  9326. service.UpdateGoodInformaitonByDetail(item.ID)
  9327. } else if record_type == 3 {
  9328. service.UpdateProjectById(item.ID)
  9329. }
  9330. c.ServeSuccessJSON(map[string]interface{}{
  9331. "failed_code": 0,
  9332. "msg": "目录对照成功",
  9333. })
  9334. } else {
  9335. c.ServeSuccessJSON(map[string]interface{}{
  9336. "failed_code": -10,
  9337. "msg": res.ErrMsg,
  9338. })
  9339. }
  9340. }
  9341. }
  9342. }
  9343. func (c *HisApiController) UnCheckCode() {
  9344. ids_str := c.GetString("ids")
  9345. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9346. admin_user_id, _ := c.GetInt64("admin_user_id")
  9347. ids_arr := strings.Split(ids_str, ",")
  9348. var queryResult []QueryResult
  9349. ids := make([]int64, 0)
  9350. for _, item := range ids_arr {
  9351. id, _ := strconv.ParseInt(item, 10, 64)
  9352. ids = append(ids, id)
  9353. }
  9354. if record_type == 1 {
  9355. drugs, _ := service.GetBatchDrugList(ids)
  9356. for _, item := range drugs {
  9357. result := QueryResult{
  9358. ID: item.ID,
  9359. Name: item.DrugName,
  9360. Code: item.MedicalInsuranceNumber,
  9361. List_type_code: "101",
  9362. }
  9363. queryResult = append(queryResult, result)
  9364. }
  9365. } else if record_type == 2 {
  9366. goods, _ := service.GetBatchGoodInformationList(ids)
  9367. for _, item := range goods {
  9368. result := QueryResult{
  9369. ID: item.ID,
  9370. Name: item.GoodName,
  9371. Code: item.MedicalInsuranceNumber,
  9372. List_type_code: "301",
  9373. }
  9374. queryResult = append(queryResult, result)
  9375. }
  9376. } else if record_type == 3 {
  9377. projects, _ := service.GetBathchMyPorjecgList(ids)
  9378. for _, item := range projects {
  9379. result := QueryResult{
  9380. ID: item.ID,
  9381. Name: item.ProjectName,
  9382. Code: item.MedicalCode,
  9383. List_type_code: "201",
  9384. }
  9385. queryResult = append(queryResult, result)
  9386. }
  9387. }
  9388. adminUser := c.GetAdminUserInfo()
  9389. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9390. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9391. var user_name string
  9392. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9393. if role.ID == 0 {
  9394. user_name = "xxx"
  9395. } else {
  9396. user_name = role.UserName
  9397. }
  9398. baseParams := &models.BaseParams{
  9399. SecretKey: miConfig.SecretKey,
  9400. FixmedinsCode: miConfig.Code,
  9401. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9402. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9403. OrgName: miConfig.OrgName,
  9404. Doctor: user_name,
  9405. }
  9406. if config.IsOpen == 1 {
  9407. for _, item := range queryResult {
  9408. var result string
  9409. if record_type == 1 {
  9410. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9411. } else if record_type == 2 {
  9412. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9413. } else if record_type == 3 {
  9414. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9415. }
  9416. var dat2 map[string]interface{}
  9417. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  9418. fmt.Println(dat2)
  9419. } else {
  9420. fmt.Println(err)
  9421. }
  9422. userJSONBytes, _ := json.Marshal(dat2)
  9423. var res ResultSix
  9424. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9425. utils.ErrorLog("解析失败:%v", err)
  9426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9427. return
  9428. }
  9429. if res.Infcode == 0 {
  9430. if record_type == 1 {
  9431. service.UpdateDrugByIdDetail(item.ID)
  9432. } else if record_type == 2 {
  9433. service.UpdateGoodInfoById(item.ID)
  9434. } else if record_type == 3 {
  9435. service.UpdateMyProjectById(item.ID)
  9436. }
  9437. c.ServeSuccessJSON(map[string]interface{}{
  9438. "failed_code": 0,
  9439. "msg": "撤销目录对照成功",
  9440. })
  9441. } else {
  9442. c.ServeSuccessJSON(map[string]interface{}{
  9443. "failed_code": -10,
  9444. "msg": res.ErrMsg,
  9445. })
  9446. }
  9447. }
  9448. }
  9449. }
  9450. func (c *HisApiController) GetPatientInfo() {
  9451. id_card_no := c.GetString("id_card_no")
  9452. admin_user_id, _ := c.GetInt64("admin_user_id")
  9453. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  9454. if patient.ID == 0 {
  9455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9456. return
  9457. }
  9458. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9459. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9460. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  9461. if config.IsOpen == 1 {
  9462. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9463. var dat map[string]interface{}
  9464. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9465. fmt.Println(dat)
  9466. } else {
  9467. fmt.Println(err)
  9468. }
  9469. userJSONBytes, _ := json.Marshal(dat)
  9470. var res ResultTwo
  9471. var res10265 ResultTwo10265
  9472. if miConfig.Code == "H15049901371" {
  9473. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9474. utils.ErrorLog("解析失败:%v", err)
  9475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9476. return
  9477. }
  9478. res.ErrMsg = res10265.ErrMsg
  9479. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9480. res.Infcode = infocode
  9481. res.Output = res10265.Output
  9482. res.InfRefmsgid = res10265.InfRefmsgid
  9483. } else {
  9484. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9485. utils.ErrorLog("解析失败:%v", err)
  9486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9487. return
  9488. }
  9489. }
  9490. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9491. // utils.ErrorLog("解析失败:%v", err)
  9492. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9493. // return
  9494. //}
  9495. if res.Infcode != 0 {
  9496. c.ServeSuccessJSON(map[string]interface{}{
  9497. "failed_code": -10,
  9498. "msg": res.ErrMsg,
  9499. })
  9500. } else {
  9501. c.ServeSuccessJSON(map[string]interface{}{
  9502. "failed_code": 0,
  9503. "info": res,
  9504. })
  9505. }
  9506. }
  9507. }
  9508. func (c *HisApiController) PsnPutOnRecord() {
  9509. record_type, _ := c.GetInt64("type")
  9510. patient_id, _ := c.GetInt64("patient_id")
  9511. admin_user_id, _ := c.GetInt64("admin_user_id")
  9512. start_time := c.GetString("start_time")
  9513. end_time := c.GetString("end_time")
  9514. adminUser := c.GetAdminUserInfo()
  9515. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9516. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9517. var patients []*models.Patients
  9518. if record_type == 1 { //全部备案
  9519. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  9520. patients = append(patients, patient...)
  9521. } else { //单个备案
  9522. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9523. patients = append(patients, patient)
  9524. }
  9525. var user_name string
  9526. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9527. if role.ID == 0 {
  9528. user_name = "xxx"
  9529. } else {
  9530. user_name = role.UserName
  9531. }
  9532. if config.IsOpen == 1 {
  9533. for _, item := range patients {
  9534. 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
  9535. resp, requestErr := http.Get(api)
  9536. if requestErr != nil {
  9537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9538. return
  9539. }
  9540. defer resp.Body.Close()
  9541. body, ioErr := ioutil.ReadAll(resp.Body)
  9542. if ioErr != nil {
  9543. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9545. return
  9546. }
  9547. var respJSON map[string]interface{}
  9548. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9549. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9551. return
  9552. }
  9553. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9554. userJSONBytes, _ := json.Marshal(userJSON)
  9555. var res ResultTwo
  9556. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9557. utils.ErrorLog("解析失败:%v", err)
  9558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9559. return
  9560. }
  9561. if res.Infcode == 0 {
  9562. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  9563. var dat map[string]interface{}
  9564. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9565. fmt.Println(dat)
  9566. } else {
  9567. fmt.Println(err)
  9568. }
  9569. userJSONBytes, _ := json.Marshal(dat)
  9570. var res2 ResultThirteen
  9571. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9572. utils.ErrorLog("解析失败:%v", err)
  9573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9574. return
  9575. }
  9576. if res2.Infcode == 0 {
  9577. psnResult := &models.GdybPsnRecord{
  9578. UserOrgId: adminUser.CurrentOrgId,
  9579. PatientId: item.ID,
  9580. PsnNo: res.Output.Baseinfo.PsnNo,
  9581. Ctime: time.Now().Unix(),
  9582. Mtime: time.Now().Unix(),
  9583. Status: 1,
  9584. IsCancel: 1,
  9585. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  9586. }
  9587. service.CreatePsnRecord(psnResult)
  9588. } else {
  9589. c.ServeSuccessJSON(map[string]interface{}{
  9590. "failed_code": -10,
  9591. "msg": res2.ErrMsg,
  9592. })
  9593. return
  9594. }
  9595. }
  9596. }
  9597. }
  9598. }
  9599. func (c *HisApiController) PsnUnPutOnRecord() {
  9600. id, _ := c.GetInt64("id")
  9601. //record_type, _ := c.GetInt64("type")
  9602. admin_user_id, _ := c.GetInt64("admin_user_id")
  9603. adminUser := c.GetAdminUserInfo()
  9604. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9605. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9606. var user_name string
  9607. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9608. if role.ID == 0 {
  9609. user_name = "xxx"
  9610. } else {
  9611. user_name = role.UserName
  9612. }
  9613. psn_record, _ := service.GetPsnRecordById(id)
  9614. if psn_record.ID == 0 {
  9615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  9616. return
  9617. }
  9618. if config.IsOpen == 1 {
  9619. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  9620. var dat map[string]interface{}
  9621. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9622. fmt.Println(dat)
  9623. } else {
  9624. fmt.Println(err)
  9625. }
  9626. userJSONBytes, _ := json.Marshal(dat)
  9627. var res ResultFourteen
  9628. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9629. utils.ErrorLog("解析失败:%v", err)
  9630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9631. return
  9632. }
  9633. if res.Infcode == 0 {
  9634. psn_record.IsCancel = 2
  9635. service.CreatePsnRecord(&psn_record)
  9636. } else {
  9637. c.ServeSuccessJSON(map[string]interface{}{
  9638. "failed_code": -10,
  9639. "msg": res.ErrMsg,
  9640. })
  9641. return
  9642. }
  9643. }
  9644. }
  9645. func (c *HisApiController) PsnPutNCDSOnRecord() {
  9646. patient_id, _ := c.GetInt64("patient_id")
  9647. insutype_two := c.GetString("insutype")
  9648. psn_no := c.GetString("psn_no")
  9649. doctor_id, _ := c.GetInt64("doctor_id")
  9650. sick_id, _ := c.GetInt64("sick_id")
  9651. department_id, _ := c.GetInt64("department_id")
  9652. start_time := c.GetString("start_time")
  9653. end_time := c.GetString("end_time")
  9654. check_time := c.GetString("check_time")
  9655. adminUser := c.GetAdminUserInfo()
  9656. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9657. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9658. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9659. sick, _ := service.FindSickById(sick_id)
  9660. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  9661. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  9662. var res ResultTwo
  9663. var res10265 ResultTwo10265
  9664. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9665. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  9666. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  9667. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  9668. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(3, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(1, 10) + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  9669. resp, requestErr := http.Get(api)
  9670. if requestErr != nil {
  9671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9672. return
  9673. }
  9674. body, ioErr := ioutil.ReadAll(resp.Body)
  9675. if ioErr != nil {
  9676. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9678. return
  9679. }
  9680. var respJSON map[string]interface{}
  9681. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9682. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9684. return
  9685. }
  9686. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9687. result, _ := json.Marshal(respJSON)
  9688. fmt.Println("log")
  9689. fmt.Println(string(result))
  9690. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9691. utils.ErrorLog("解析失败:%v", err)
  9692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9693. return
  9694. }
  9695. res.ErrMsg = res10265.ErrMsg
  9696. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9697. res.Infcode = infocode
  9698. res.Output = res10265.Output
  9699. res.InfRefmsgid = res10265.InfRefmsgid
  9700. } else {
  9701. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  9702. if miConfig.Code == "H15049901371" {
  9703. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9704. utils.ErrorLog("解析失败:%v", err)
  9705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9706. return
  9707. }
  9708. res.ErrMsg = res10265.ErrMsg
  9709. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9710. res.Infcode = infocode
  9711. res.Output = res10265.Output
  9712. res.InfRefmsgid = res10265.InfRefmsgid
  9713. } else {
  9714. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9715. utils.ErrorLog("解析失败:%v", err)
  9716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9717. return
  9718. }
  9719. }
  9720. }
  9721. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9722. infoStr := string(Iinfos)
  9723. var rf []*ResultFive
  9724. json.Unmarshal([]byte(infoStr), &rf)
  9725. var insuplc_admdvs string
  9726. var insutype string
  9727. var is390 int = 0
  9728. var is310 int = 0
  9729. var insutypes []*ResultFive
  9730. for _, item := range rf {
  9731. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9732. insutypes = append(insutypes, item)
  9733. }
  9734. }
  9735. if len(insutypes) == 1 {
  9736. insutype = insutypes[0].Insutype
  9737. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9738. } else {
  9739. for _, i := range insutypes {
  9740. if i.Insutype == "390" {
  9741. is390 = 1
  9742. }
  9743. if i.Insutype == "310" {
  9744. is310 = 1
  9745. }
  9746. }
  9747. }
  9748. if is390 == 1 {
  9749. insutype = "390"
  9750. }
  9751. if is310 == 1 {
  9752. insutype = "310"
  9753. }
  9754. if len(insutypes) == 2 {
  9755. insutype = insutype_two
  9756. }
  9757. if len(insutypes) == 0 {
  9758. insutype = "310"
  9759. }
  9760. insutype = insutype_two
  9761. fmt.Println(insutype)
  9762. for _, item := range rf {
  9763. fmt.Println(item.Insutype)
  9764. fmt.Println(insutype)
  9765. if item.Insutype == insutype {
  9766. fmt.Println(item.Insutype)
  9767. fmt.Println(insutype)
  9768. insuplc_admdvs = item.InsuplcAdmdvs
  9769. }
  9770. }
  9771. fmt.Println(insuplc_admdvs)
  9772. var res2 ResultThirteen
  9773. var res10265_2 ResultThirteen10265
  9774. if config.IsOpen == 1 {
  9775. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9776. } else {
  9777. 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)
  9778. var dat map[string]interface{}
  9779. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9780. fmt.Println(dat)
  9781. } else {
  9782. fmt.Println(err)
  9783. }
  9784. userJSONBytes, _ := json.Marshal(dat)
  9785. if miConfig.Code == "H15049901371" {
  9786. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  9787. utils.ErrorLog("解析失败:%v", err)
  9788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9789. return
  9790. }
  9791. res2.ErrMsg = res10265_2.ErrMsg
  9792. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  9793. res2.Infcode = infocode
  9794. res2.Output = res10265_2.Output
  9795. res2.InfRefmsgid = res10265_2.InfRefmsgid
  9796. } else {
  9797. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9798. utils.ErrorLog("解析失败:%v", err)
  9799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9800. return
  9801. }
  9802. }
  9803. }
  9804. if res2.Infcode == 0 {
  9805. psnResult := &models.GdybPsnNcdsRecord{
  9806. UserOrgId: adminUser.CurrentOrgId,
  9807. PatientId: patient.ID,
  9808. PsnNo: psn_no,
  9809. DoctorId: doctor.AdminUserId,
  9810. DepartmentId: department_id,
  9811. SickType: sick_id,
  9812. Insutype: insutype,
  9813. Ctime: time.Now().Unix(),
  9814. Mtime: time.Now().Unix(),
  9815. Status: 1,
  9816. IsCancel: 1,
  9817. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  9818. }
  9819. service.CreatePsnNCDSRecord(psnResult)
  9820. c.ServeSuccessJSON(map[string]interface{}{
  9821. "failed_code": 0,
  9822. "msg": "备案成功",
  9823. "result": psnResult,
  9824. })
  9825. } else {
  9826. c.ServeSuccessJSON(map[string]interface{}{
  9827. "failed_code": -10,
  9828. "msg": res2.ErrMsg,
  9829. })
  9830. return
  9831. }
  9832. }
  9833. }
  9834. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  9835. id, _ := c.GetInt64("id")
  9836. admin_user_id, _ := c.GetInt64("admin_user_id")
  9837. adminUser := c.GetAdminUserInfo()
  9838. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9839. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9840. //config, _ := service.Ge(adminUser.CurrentOrgId)
  9841. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  9842. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9843. //var user_name string
  9844. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9845. //if role.ID == 0 {
  9846. // user_name = "xxx"
  9847. //} else {
  9848. // user_name = role.UserName
  9849. //}
  9850. psn_record, _ := service.GetPsnNCDSRecordById(id)
  9851. if psn_record.ID == 0 {
  9852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  9853. return
  9854. }
  9855. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  9856. var res ResultTwo
  9857. var res10265 ResultTwo10265
  9858. if miConfig.Code == "H15049901371" {
  9859. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9860. utils.ErrorLog("解析失败:%v", err)
  9861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9862. return
  9863. }
  9864. res.ErrMsg = res10265.ErrMsg
  9865. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9866. res.Infcode = infocode
  9867. res.Output = res10265.Output
  9868. res.InfRefmsgid = res10265.InfRefmsgid
  9869. } else {
  9870. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9871. utils.ErrorLog("解析失败:%v", err)
  9872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9873. return
  9874. }
  9875. }
  9876. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9877. infoStr := string(Iinfos)
  9878. var rf []*ResultFive
  9879. json.Unmarshal([]byte(infoStr), &rf)
  9880. var insuplc_admdvs string
  9881. var insutype string
  9882. var is390 int = 0
  9883. var is310 int = 0
  9884. var insutypes []*ResultFive
  9885. for _, item := range rf {
  9886. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9887. insutypes = append(insutypes, item)
  9888. }
  9889. }
  9890. if len(insutypes) == 1 {
  9891. insutype = insutypes[0].Insutype
  9892. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9893. } else {
  9894. for _, i := range insutypes {
  9895. if i.Insutype == "390" {
  9896. is390 = 1
  9897. }
  9898. if i.Insutype == "310" {
  9899. is310 = 1
  9900. }
  9901. }
  9902. }
  9903. if is390 == 1 {
  9904. insutype = "390"
  9905. }
  9906. if is310 == 1 {
  9907. insutype = "310"
  9908. }
  9909. if len(insutypes) == 0 {
  9910. insutype = "310"
  9911. }
  9912. insutype = psn_record.Insutype
  9913. for _, item := range rf {
  9914. if item.Insutype == insutype {
  9915. insuplc_admdvs = item.InsuplcAdmdvs
  9916. }
  9917. }
  9918. if config.IsOpen == 1 {
  9919. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  9920. var dat map[string]interface{}
  9921. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9922. fmt.Println(dat)
  9923. } else {
  9924. fmt.Println(err)
  9925. }
  9926. userJSONBytes, _ := json.Marshal(dat)
  9927. var res ResultFourteen
  9928. var res10265 ResultFourteen10265
  9929. if miConfig.Code == "H15049901371" {
  9930. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9931. utils.ErrorLog("解析失败:%v", err)
  9932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9933. return
  9934. }
  9935. res.ErrMsg = res10265.ErrMsg
  9936. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9937. res.Infcode = infocode
  9938. res.Output = res10265.Output
  9939. res.InfRefmsgid = res10265.InfRefmsgid
  9940. } else {
  9941. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9942. utils.ErrorLog("解析失败:%v", err)
  9943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9944. return
  9945. }
  9946. }
  9947. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9948. // utils.ErrorLog("解析失败:%v", err)
  9949. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9950. // return
  9951. //}
  9952. if res.Infcode == 0 {
  9953. psn_record.IsCancel = 2
  9954. service.CreatePsnNCDSRecord(&psn_record)
  9955. c.ServeSuccessJSON(map[string]interface{}{
  9956. "failed_code": 0,
  9957. "msg": "撤销备案成功",
  9958. })
  9959. } else {
  9960. c.ServeSuccessJSON(map[string]interface{}{
  9961. "failed_code": -10,
  9962. "msg": res.ErrMsg,
  9963. })
  9964. return
  9965. }
  9966. }
  9967. }
  9968. func (c *HisApiController) TestTest() {
  9969. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  9970. fmt.Println(patient.Iinfo)
  9971. }
  9972. type CustomData struct {
  9973. MsgId string
  9974. PsnNo string
  9975. Info string
  9976. }
  9977. func (c *HisApiController) ReversalData() {
  9978. var customData []*CustomData
  9979. custom := &CustomData{
  9980. MsgId: "H44022900158202103301714472004",
  9981. PsnNo: "44020000001101329945",
  9982. Info: "2207",
  9983. }
  9984. customData = append(customData, custom)
  9985. custom1 := &CustomData{
  9986. MsgId: "H4402290015820210330172057803",
  9987. PsnNo: "44020000001101161813",
  9988. Info: "2207",
  9989. }
  9990. customData = append(customData, custom1)
  9991. custom2 := &CustomData{
  9992. MsgId: "H44022900158202103301705198813",
  9993. PsnNo: "44190000133097375417",
  9994. Info: "2207",
  9995. }
  9996. customData = append(customData, custom2)
  9997. custom3 := &CustomData{
  9998. MsgId: "H44022900158202103301715524756",
  9999. PsnNo: "44020000001100187221",
  10000. Info: "2207",
  10001. }
  10002. customData = append(customData, custom3)
  10003. custom4 := &CustomData{
  10004. MsgId: "H44022900158202103301730376224",
  10005. PsnNo: "44020000001101959155",
  10006. Info: "2207",
  10007. }
  10008. customData = append(customData, custom4)
  10009. custom5 := &CustomData{
  10010. MsgId: "H44022900158202103301748008725",
  10011. PsnNo: "44020000001104246641",
  10012. Info: "2207",
  10013. }
  10014. customData = append(customData, custom5)
  10015. custom6 := &CustomData{
  10016. MsgId: "H44022900158202103301718096755",
  10017. PsnNo: "44020000001102211860",
  10018. Info: "2207",
  10019. }
  10020. customData = append(customData, custom6)
  10021. custom7 := &CustomData{
  10022. MsgId: "H44022900158202103301736551640",
  10023. PsnNo: "44020000001102687718",
  10024. Info: "2207",
  10025. }
  10026. customData = append(customData, custom7)
  10027. custom8 := &CustomData{
  10028. MsgId: "H44022900158202103301743097676",
  10029. PsnNo: "44020000001102127785",
  10030. Info: "2207",
  10031. }
  10032. customData = append(customData, custom8)
  10033. custom9 := &CustomData{
  10034. MsgId: "H44022900158202103301712304203",
  10035. PsnNo: "44020000001101518097",
  10036. Info: "2207",
  10037. }
  10038. customData = append(customData, custom9)
  10039. custom10 := &CustomData{
  10040. MsgId: "H44022900158202103301738448785",
  10041. PsnNo: "44020000001100500813",
  10042. Info: "2207",
  10043. }
  10044. customData = append(customData, custom10)
  10045. custom11 := &CustomData{
  10046. MsgId: "H44022900158202103301732455843",
  10047. PsnNo: "44020000001102690557",
  10048. Info: "2207",
  10049. }
  10050. customData = append(customData, custom11)
  10051. custom12 := &CustomData{
  10052. MsgId: "H44022900158202103301745421708",
  10053. PsnNo: "44020000001102211928",
  10054. Info: "2207",
  10055. }
  10056. customData = append(customData, custom12)
  10057. custom1212 := &CustomData{
  10058. MsgId: "H440229001582021033017351627",
  10059. PsnNo: "44020000001102481733",
  10060. Info: "2207",
  10061. }
  10062. customData = append(customData, custom1212)
  10063. custom13 := &CustomData{
  10064. MsgId: "H44022900158202103301740327951",
  10065. PsnNo: "44020000001103174866",
  10066. Info: "2207",
  10067. }
  10068. customData = append(customData, custom13)
  10069. custom14 := &CustomData{
  10070. MsgId: "H4402290015820210330174922668",
  10071. PsnNo: "44020000001102927272",
  10072. Info: "2207",
  10073. }
  10074. customData = append(customData, custom14)
  10075. custom15 := &CustomData{
  10076. MsgId: "H44022900158202103301752362273",
  10077. PsnNo: "44020000001102942890",
  10078. Info: "2207",
  10079. }
  10080. customData = append(customData, custom15)
  10081. custom16 := &CustomData{
  10082. MsgId: "H44022900158202103301751082917",
  10083. PsnNo: "44020000001101662162",
  10084. Info: "2207",
  10085. }
  10086. customData = append(customData, custom16)
  10087. custom17 := &CustomData{
  10088. MsgId: "H44022900158202103301754147728",
  10089. PsnNo: "44020000000229014511",
  10090. Info: "2207",
  10091. }
  10092. customData = append(customData, custom17)
  10093. adminUser := c.GetAdminUserInfo()
  10094. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10095. for _, item := range customData {
  10096. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10097. fmt.Println(result)
  10098. }
  10099. }
  10100. func (c *HisApiController) GetAllopatry() {
  10101. year := c.GetString("year")
  10102. month := c.GetString("month")
  10103. admin_user_id, _ := c.GetInt64("admin_user_id")
  10104. adminUser := c.GetAdminUserInfo()
  10105. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10106. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10107. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10108. var dat map[string]interface{}
  10109. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10110. fmt.Println(dat)
  10111. } else {
  10112. fmt.Println(err)
  10113. }
  10114. userJSONBytes, _ := json.Marshal(dat)
  10115. var res models.Result9001
  10116. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10117. utils.ErrorLog("解析失败:%v", err)
  10118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10119. return
  10120. }
  10121. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10122. var dat2 map[string]interface{}
  10123. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10124. fmt.Println(dat)
  10125. } else {
  10126. fmt.Println(err)
  10127. }
  10128. userJSONBytes2, _ := json.Marshal(dat2)
  10129. var res2 models.Result3260
  10130. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10131. utils.ErrorLog("解析失败:%v", err)
  10132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10133. return
  10134. }
  10135. if res2.Infcode == 0 {
  10136. c.ServeSuccessJSON(map[string]interface{}{
  10137. "list": res2.Output.Data,
  10138. })
  10139. return
  10140. } else {
  10141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10142. return
  10143. }
  10144. }
  10145. func (c *HisApiController) ComfirmAllopatry() {
  10146. year := c.GetString("year")
  10147. month := c.GetString("month")
  10148. admin_user_id, _ := c.GetInt64("admin_user_id")
  10149. adminUser := c.GetAdminUserInfo()
  10150. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10151. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10152. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10153. var dat map[string]interface{}
  10154. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10155. fmt.Println(dat)
  10156. } else {
  10157. fmt.Println(err)
  10158. }
  10159. userJSONBytes, _ := json.Marshal(dat)
  10160. var res models.Result9001
  10161. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10162. utils.ErrorLog("解析失败:%v", err)
  10163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10164. return
  10165. }
  10166. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10167. var dat2 map[string]interface{}
  10168. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10169. fmt.Println(dat)
  10170. } else {
  10171. fmt.Println(err)
  10172. }
  10173. userJSONBytes2, _ := json.Marshal(dat2)
  10174. var res2 models.Result3260
  10175. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10176. utils.ErrorLog("解析失败:%v", err)
  10177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10178. return
  10179. }
  10180. if res2.Infcode == 0 {
  10181. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  10182. var dat map[string]interface{}
  10183. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10184. fmt.Println(dat)
  10185. } else {
  10186. fmt.Println(err)
  10187. }
  10188. userJSONBytes, _ := json.Marshal(dat)
  10189. var res3 models.Result3261
  10190. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  10191. utils.ErrorLog("解析失败:%v", err)
  10192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10193. return
  10194. }
  10195. if res3.Infcode == 0 {
  10196. record := &models.HisYidiClearRecord{
  10197. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10198. Ctime: time.Now().Unix(),
  10199. Mtime: time.Now().Unix(),
  10200. Status: 1,
  10201. MsgId: msgId,
  10202. }
  10203. service.SaveClearRecord(record)
  10204. c.ServeSuccessJSON(map[string]interface{}{
  10205. "msg": "提取成功",
  10206. })
  10207. }
  10208. }
  10209. }
  10210. func (c *HisApiController) RefundAllopatry() {
  10211. year := c.GetString("year")
  10212. month := c.GetString("month")
  10213. id, _ := c.GetInt64("id")
  10214. admin_user_id, _ := c.GetInt64("admin_user_id")
  10215. adminUser := c.GetAdminUserInfo()
  10216. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10217. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10218. record, _ := service.GetClearRecordById(id)
  10219. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  10220. var dat map[string]interface{}
  10221. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10222. fmt.Println(dat)
  10223. } else {
  10224. fmt.Println(err)
  10225. }
  10226. userJSONBytes, _ := json.Marshal(dat)
  10227. var empty ResultFourteen
  10228. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  10229. utils.ErrorLog("解析失败:%v", err)
  10230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10231. return
  10232. }
  10233. if empty.Infcode == 0 {
  10234. c.ServeSuccessJSON(map[string]interface{}{
  10235. "msg": "撤销成功",
  10236. })
  10237. return
  10238. }
  10239. }
  10240. func (c *HisApiController) ReversalOtherData() {
  10241. var customData []*CustomData
  10242. custom := &CustomData{
  10243. MsgId: "H44022900158202103301714472004",
  10244. PsnNo: "44020000001101329945",
  10245. Info: "2208",
  10246. }
  10247. customData = append(customData, custom)
  10248. custom1 := &CustomData{
  10249. MsgId: "H4402290015820210330172057803",
  10250. PsnNo: "44020000001101161813",
  10251. Info: "2208",
  10252. }
  10253. customData = append(customData, custom1)
  10254. custom2 := &CustomData{
  10255. MsgId: "H44022900158202103301705198813",
  10256. PsnNo: "44190000133097375417",
  10257. Info: "2208",
  10258. }
  10259. customData = append(customData, custom2)
  10260. custom3 := &CustomData{
  10261. MsgId: "H44022900158202103301715524756",
  10262. PsnNo: "44020000001100187221",
  10263. Info: "2208",
  10264. }
  10265. customData = append(customData, custom3)
  10266. custom4 := &CustomData{
  10267. MsgId: "H44022900158202103301730376224",
  10268. PsnNo: "44020000001101959155",
  10269. Info: "2208",
  10270. }
  10271. customData = append(customData, custom4)
  10272. custom5 := &CustomData{
  10273. MsgId: "H44022900158202103301748008725",
  10274. PsnNo: "44020000001104246641",
  10275. Info: "2208",
  10276. }
  10277. customData = append(customData, custom5)
  10278. custom6 := &CustomData{
  10279. MsgId: "H44022900158202103301718096755",
  10280. PsnNo: "44020000001102211860",
  10281. Info: "2208",
  10282. }
  10283. customData = append(customData, custom6)
  10284. custom7 := &CustomData{
  10285. MsgId: "H44022900158202103301736551640",
  10286. PsnNo: "44020000001102687718",
  10287. Info: "2208",
  10288. }
  10289. customData = append(customData, custom7)
  10290. custom8 := &CustomData{
  10291. MsgId: "H44022900158202103301743097676",
  10292. PsnNo: "44020000001102127785",
  10293. Info: "2208",
  10294. }
  10295. customData = append(customData, custom8)
  10296. custom9 := &CustomData{
  10297. MsgId: "H44022900158202103301712304203",
  10298. PsnNo: "44020000001101518097",
  10299. Info: "2208",
  10300. }
  10301. customData = append(customData, custom9)
  10302. custom10 := &CustomData{
  10303. MsgId: "H44022900158202103301738448785",
  10304. PsnNo: "44020000001100500813",
  10305. Info: "2208",
  10306. }
  10307. customData = append(customData, custom10)
  10308. custom11 := &CustomData{
  10309. MsgId: "H44022900158202103301732455843",
  10310. PsnNo: "44020000001102690557",
  10311. Info: "2208",
  10312. }
  10313. customData = append(customData, custom11)
  10314. custom12 := &CustomData{
  10315. MsgId: "H44022900158202103301745421708",
  10316. PsnNo: "44020000001102211928",
  10317. Info: "2208",
  10318. }
  10319. customData = append(customData, custom12)
  10320. custom1212 := &CustomData{
  10321. MsgId: "H440229001582021033017351627",
  10322. PsnNo: "44020000001102481733",
  10323. Info: "2208",
  10324. }
  10325. customData = append(customData, custom1212)
  10326. custom13 := &CustomData{
  10327. MsgId: "H44022900158202103301740327951",
  10328. PsnNo: "44020000001103174866",
  10329. Info: "2208",
  10330. }
  10331. customData = append(customData, custom13)
  10332. custom14 := &CustomData{
  10333. MsgId: "H4402290015820210330174922668",
  10334. PsnNo: "44020000001102927272",
  10335. Info: "2208",
  10336. }
  10337. customData = append(customData, custom14)
  10338. custom15 := &CustomData{
  10339. MsgId: "H44022900158202103301752362273",
  10340. PsnNo: "44020000001102942890",
  10341. Info: "2208",
  10342. }
  10343. customData = append(customData, custom15)
  10344. custom16 := &CustomData{
  10345. MsgId: "H44022900158202103301751082917",
  10346. PsnNo: "44020000001101662162",
  10347. Info: "2208",
  10348. }
  10349. customData = append(customData, custom16)
  10350. custom17 := &CustomData{
  10351. MsgId: "H44022900158202103301754147728",
  10352. PsnNo: "44020000000229014511",
  10353. Info: "2208",
  10354. }
  10355. customData = append(customData, custom17)
  10356. adminUser := c.GetAdminUserInfo()
  10357. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10358. for _, item := range customData {
  10359. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10360. fmt.Println(result)
  10361. }
  10362. }
  10363. func PathExists(path string) (bool, error) {
  10364. _, err := os.Stat(path)
  10365. if err == nil {
  10366. return true, nil
  10367. }
  10368. if os.IsNotExist(err) {
  10369. return false, nil
  10370. }
  10371. return false, err
  10372. }
  10373. //创建文件夹
  10374. func Mkdir(dir string) {
  10375. // 创建文件夹
  10376. exist, err := PathExists(dir)
  10377. if err != nil {
  10378. fmt.Println(err.Error())
  10379. } else {
  10380. if exist {
  10381. fmt.Println(dir + "文件夹已存在!")
  10382. } else {
  10383. // 文件夹名称,权限
  10384. err := os.Mkdir(dir, os.ModePerm)
  10385. if err != nil {
  10386. fmt.Println(dir+"文件夹创建失败:", err.Error())
  10387. } else {
  10388. fmt.Println(dir + "文件夹创建成功!")
  10389. }
  10390. }
  10391. }
  10392. }
  10393. //压缩文件
  10394. func Zip(srcFile string, destZip string) error {
  10395. zipfile, err := os.Create(destZip)
  10396. if err != nil {
  10397. return err
  10398. }
  10399. defer zipfile.Close()
  10400. archive := zip.NewWriter(zipfile)
  10401. defer archive.Close()
  10402. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  10403. if err != nil {
  10404. return err
  10405. }
  10406. header, err := zip.FileInfoHeader(info)
  10407. if err != nil {
  10408. return err
  10409. }
  10410. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  10411. // header.Name = path
  10412. if info.IsDir() {
  10413. header.Name += "/"
  10414. } else {
  10415. header.Method = zip.Deflate
  10416. }
  10417. writer, err := archive.CreateHeader(header)
  10418. if err != nil {
  10419. return err
  10420. }
  10421. if !info.IsDir() {
  10422. file, err := os.Open(path)
  10423. if err != nil {
  10424. return err
  10425. }
  10426. defer file.Close()
  10427. _, err = io.Copy(writer, file)
  10428. }
  10429. return err
  10430. })
  10431. return err
  10432. }
  10433. func ReadFile(filePath string) []byte {
  10434. f, err := os.Open(filePath)
  10435. if err != nil {
  10436. fmt.Println("read file fail", err)
  10437. return nil
  10438. }
  10439. defer f.Close()
  10440. fd, err := ioutil.ReadAll(f)
  10441. if err != nil {
  10442. fmt.Println("read to fd fail", err)
  10443. return nil
  10444. }
  10445. return fd
  10446. }
  10447. func saveLog(result string, request string, infno string, desc string) {
  10448. org_id, _ := beego.AppConfig.Int64("org_id")
  10449. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  10450. dir := miConfig.OrgName + "日志"
  10451. utils.Mkdir(dir)
  10452. month := time.Unix(1557042972, 0).Format("1")
  10453. year := time.Now().Format("2006")
  10454. month = time.Now().Format("01")
  10455. day := time.Now().Format("02")
  10456. hour := time.Now().Format("15")
  10457. min := time.Now().Format("04")
  10458. sec := time.Now().Format("05")
  10459. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  10460. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  10461. file_name := file + ".txt"
  10462. file_path := miConfig.OrgName + "日志" + "/" + file_name
  10463. exist, _ := utils.PathExists(file_path)
  10464. if exist { //存在
  10465. fmt.Println("存在")
  10466. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  10467. if err != nil {
  10468. fmt.Println("read fail")
  10469. }
  10470. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  10471. n, _ := f.Seek(0, 2)
  10472. _, err = f.WriteAt([]byte(content), n)
  10473. } else { //不存在
  10474. fmt.Println("文件不存在,创建文件")
  10475. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  10476. defer f.Close()
  10477. if err != nil {
  10478. } else {
  10479. _, err = f.Write([]byte("记录日志"))
  10480. }
  10481. }
  10482. }
  10483. type Charset string
  10484. const (
  10485. UTF8 = Charset("UTF-8")
  10486. GB18030 = Charset("GB18030")
  10487. )
  10488. func ConvertToString(src string, srcCode string, tagCode string) string {
  10489. srcCoder := mahonia.NewDecoder(srcCode)
  10490. srcResult := srcCoder.ConvertString(src)
  10491. tagCoder := mahonia.NewDecoder(tagCode)
  10492. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  10493. result := string(cdata)
  10494. return result
  10495. }