new_his_api_controller.go 452KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362
  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/shopspring/decimal"
  15. "io"
  16. "io/ioutil"
  17. "math/rand"
  18. "net/http"
  19. "os"
  20. "path/filepath"
  21. "strconv"
  22. "strings"
  23. "syscall"
  24. "time"
  25. "unsafe"
  26. )
  27. type HisApiController struct {
  28. controllers.BaseAuthAPIController
  29. }
  30. func NewHisManagerApiRegistRouters() {
  31. //挂号
  32. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  33. //上传就诊信息-上传明细-结算
  34. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  35. //查询
  36. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  37. //对总账
  38. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  39. //对明细
  40. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  41. //退费,退明细
  42. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  43. //退号
  44. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  45. //退明细
  46. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  47. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  48. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  49. //beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  50. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  51. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  52. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  53. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  54. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  55. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  56. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  57. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  58. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  59. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  60. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  61. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  62. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  63. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  64. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  65. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  66. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  67. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  68. beego.Router("/api/check", &HisApiController{}, "get:Check")
  69. beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  70. beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  71. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  72. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  73. beego.Router("/9002", &HisApiController{}, "get:Get9002")
  74. beego.Router("/2505", &HisApiController{}, "get:Get2505")
  75. beego.Router("/2503", &HisApiController{}, "get:Get2503")
  76. beego.Router("/5301", &HisApiController{}, "get:Get5301")
  77. beego.Router("/2504", &HisApiController{}, "get:Get2504")
  78. beego.Router("/1160", &HisApiController{}, "get:Get1160")
  79. beego.Router("/2001", &HisApiController{}, "get:Get2001")
  80. // beego.Router("/api/gzpatient/get", &HisApiController{}, "get:GetGZPatientInfo")
  81. beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  82. }
  83. // func (c *HisApiController) GetGZPatientInfo() {
  84. // id_card_no := c.GetString("id_card_no")
  85. // admin_user_id, _ := c.GetInt64("admin_user_id")
  86. // patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  87. // if patient.ID == 0 {
  88. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  89. // return
  90. // }
  91. // role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  92. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  93. // config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  94. // var result string
  95. // var request_log string
  96. // var result_log string
  97. // result, request_log, result_log = service.ZHGdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig. MdtrtareaAdmvs, miConfig.SecretKey, 2, "", 1, patient.Name)
  98. // var dat map[string]interface{}
  99. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  100. // fmt.Println(dat)
  101. // } else {
  102. // fmt.Println(err)
  103. // }
  104. // userJSONBytes, _ := json.Marshal(dat)
  105. // var res ResultTwo
  106. // var resTwo10265 ResultTwo10265
  107. // if miConfig.Code == "H15049901371" {
  108. // if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  109. // utils.ErrorLog("解析失败:%v", err)
  110. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  111. // return
  112. // }
  113. // Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  114. // res.Infcode = Infcode
  115. // res.ErrMsg = resTwo10265.ErrMsg
  116. // res.Output = resTwo10265.Output
  117. // res.InfRefmsgid = resTwo10265.InfRefmsgid
  118. // res.RespondTime = resTwo10265.RespondTime
  119. // res.WarnInfo = resTwo10265.WarnInfo
  120. // } else {
  121. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  122. // utils.ErrorLog("解析失败:%v", err)
  123. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  124. // return
  125. // }
  126. // }
  127. // var insutypes []string
  128. // var insutype string
  129. // var is390 int = 0
  130. // var is310 int = 0
  131. // for _, item := range res.Output.Iinfo {
  132. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  133. // insutypes = append(insutypes, item.Insutype)
  134. // }
  135. // }
  136. // if len(insutypes) == 1 {
  137. // insutype = insutypes[0]
  138. // } else {
  139. // for _, i := range insutypes {
  140. // if i == "390" {
  141. // is390 = 1
  142. // }
  143. // if i == "310" {
  144. // is310 = 1
  145. // }
  146. // }
  147. // }
  148. // if is390 == 1 {
  149. // insutype = "390"
  150. // }
  151. // if is310 == 1 {
  152. // insutype = "310"
  153. // }
  154. // if len(insutypes) == 0 {
  155. // insutype = "310"
  156. // }
  157. // if res.Infcode != 0 {
  158. // c.ServeSuccessJSON(map[string]interface{}{
  159. // "failed_code": -10,
  160. // "msg": res.ErrMsg,
  161. // })
  162. // } else {
  163. // c.ServeSuccessJSON(map[string]interface{}{
  164. // "failed_code": 0,
  165. // "info": res,
  166. // "insutype": insutype,
  167. // })
  168. // }
  169. // }
  170. func (c *HisApiController) Get9002() {
  171. adminUser := c.GetAdminUserInfo()
  172. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  173. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  174. service.Gdyb9002(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  175. }
  176. func (c *HisApiController) Get2001() {
  177. adminUser := c.GetAdminUserInfo()
  178. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  179. baseParams := models.BaseParams{
  180. SecretKey: "h1hEqxQm12ryULCgPKolkid8S9hZFu6M",
  181. FixmedinsCode: miConfig.Code,
  182. InsuplcAdmdvs: "441599",
  183. MdtrtareaAdmvs: "440100",
  184. OrgName: miConfig.OrgName,
  185. Doctor: "1111",
  186. }
  187. service.Gdyb2001(baseParams, "441500CS000000301426", "310", "11")
  188. }
  189. func (c *HisApiController) Get1160() {
  190. adminUser := c.GetAdminUserInfo()
  191. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  192. baseParams := models.BaseParams{
  193. SecretKey: "h1hEqxQm12ryULCgPKolkid8S9hZFu6M",
  194. FixmedinsCode: miConfig.Code,
  195. InsuplcAdmdvs: "440100",
  196. MdtrtareaAdmvs: "440100",
  197. OrgName: miConfig.OrgName,
  198. Doctor: "1111",
  199. }
  200. service.Gdyb1160(baseParams, "441500CS000000301426", "310", "14")
  201. }
  202. func (c *HisApiController) Get2504() {
  203. adminUser := c.GetAdminUserInfo()
  204. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  205. result := service.Gdyb2504("441500CS000000301426", miConfig.OrgName, "admin", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "20220629626617")
  206. fmt.Println(result)
  207. }
  208. func (c *HisApiController) Get5301() {
  209. adminUser := c.GetAdminUserInfo()
  210. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  211. result := service.Gdyb5301("44010000003501822495", miConfig.OrgName, "admin", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  212. fmt.Println(result)
  213. }
  214. func (c *HisApiController) Get2505() {
  215. adminUser := c.GetAdminUserInfo()
  216. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  217. result := service.Gdyb2505("44010000003501822495", "admin", miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "2022-01-01 12:35:39", "2022-12-30 12:35:39")
  218. fmt.Println(result)
  219. }
  220. func (c *HisApiController) Get2503() {
  221. adminUser := c.GetAdminUserInfo()
  222. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  223. result := service.Gdyb2503ForGz("441500CS000000301426", "310", miConfig.OrgName, "方军", miConfig.Code, "1", "441599", miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "慢性肾功能不全(血液治疗)", "M07803", "2022-01-01 12:35:39", "2022-12-30 12:35:39", "2022-06-28 00:00:00")
  224. fmt.Println(result)
  225. }
  226. func (c *HisApiController) Get9001() {
  227. adminUser := c.GetAdminUserInfo()
  228. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  229. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  230. result, inputLog := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  231. var dat map[string]interface{}
  232. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  233. fmt.Println(dat)
  234. } else {
  235. fmt.Println(err)
  236. }
  237. userJSONBytes, _ := json.Marshal(dat)
  238. var res models.Result9001
  239. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  240. utils.ErrorLog("解析失败:%v", err)
  241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  242. return
  243. }
  244. if res.Infcode == 0 {
  245. sign := models.HisSignIn{
  246. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  247. SignNo: res.Output.Result.SignNo,
  248. SignTime: res.Output.Result.SignTime,
  249. Ctime: time.Now().Unix(),
  250. Mtime: time.Now().Unix(),
  251. Status: 1,
  252. InputLog: inputLog,
  253. OutputLog: result,
  254. FixmedinsCode: miConfig.Code,
  255. }
  256. err := service.CreateSignIn(&sign)
  257. if err == nil {
  258. c.ServeSuccessJSON(map[string]interface{}{
  259. "msg": "签到成功",
  260. })
  261. }
  262. }
  263. }
  264. func (c *HisApiController) Check3101() {
  265. patient_id, _ := c.GetInt64("patient_id")
  266. his_patient_id, _ := c.GetInt64("his_patient_id")
  267. admin_user_id, _ := c.GetInt64("admin_user_id")
  268. adminUser := c.GetAdminUserInfo()
  269. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  270. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  271. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  272. record_time := c.GetString("record_time")
  273. trig_scen := c.GetString("trig_scen")
  274. timeLayout := "2006-01-02"
  275. loc, _ := time.LoadLocation("Local")
  276. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  277. if err != nil {
  278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  279. return
  280. }
  281. recordDateTime := theTime.Unix()
  282. var patientPrescription models.HisPrescriptionInfo
  283. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  284. if patientPrescription.ID == 0 {
  285. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  286. }
  287. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  288. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  289. //
  290. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  291. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  292. var pp models.PublicParams
  293. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  294. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  295. pp.FixmedinsName = miConfig.OrgName
  296. pp.FixmedinsCode = miConfig.Code
  297. pp.RequestUrl = miConfig.Url
  298. pp.Cainfo = miConfig.Cainfo
  299. pp.SecretKey = miConfig.SecretKey
  300. pp.AccessKey = miConfig.AccessKey
  301. pp.OpterName = roles.UserName
  302. var config []*models.HisXtDiagnoseConfig
  303. for _, item := range diagnosis_ids {
  304. id, _ := strconv.ParseInt(item, 10, 64)
  305. diagnosisConfig, _ := service.FindDiagnoseById(id)
  306. config = append(config, &diagnosisConfig)
  307. }
  308. var pd models.PatientDtos
  309. pd.PatnID = his.PsnNo
  310. pd.PatnName = his.Name
  311. pd.Gend = his.Gend
  312. pd.Brdy = his.Brdy
  313. pd.Poolarea = his.InsuplcAdmdvs
  314. pd.CurrMdtrtID = his.Number
  315. var fed models.FsiEncounterDtos
  316. fed.MdtrtID = his.Number
  317. fed.MedinsID = miConfig.Code
  318. fed.MedinsName = miConfig.OrgName
  319. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  320. fed.MedMdtrtType = "1"
  321. fed.MedinsType = "1"
  322. fed.MedinsLv = "11"
  323. tm := time.Unix(his.RecordDate, 0)
  324. s_tm := tm.Format("2006-01-02 15:04:05")
  325. fed.AdmDate = s_tm
  326. fed.DscgDate = s_tm
  327. fed.DscgMainDiseCodg = config[0].CountryCode
  328. fed.DscgMainDiseName = config[0].CountryContentName
  329. //诊断信息
  330. var fdds []*models.FsiDiagnoseDtos
  331. for index, item := range config {
  332. if index == 0 {
  333. var fdd models.FsiDiagnoseDtos
  334. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  335. fdd.InoutDiseType = "1"
  336. fdd.MaindiseFlag = "1"
  337. fdd.DiseDate = s_tm
  338. fdd.DiasSrtNo = "1"
  339. fdd.DiseName = item.CountryContentName
  340. fdd.DiseCodg = item.CountryCode
  341. fdds = append(fdds, &fdd)
  342. } else {
  343. var fdd models.FsiDiagnoseDtos
  344. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  345. fdd.InoutDiseType = "1"
  346. fdd.MaindiseFlag = "1"
  347. fdd.DiseDate = s_tm
  348. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  349. fdd.DiseName = item.CountryContentName
  350. fdd.DiseCodg = item.CountryCode
  351. fdds = append(fdds, &fdd)
  352. }
  353. }
  354. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  355. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  356. fed.AdmDeptName = department.Name
  357. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  358. fed.DscgDeptName = department.Name
  359. fed.MedMdtrtType = "1"
  360. fed.MedType = "11"
  361. //if his.Insutype == "390" {
  362. // fed.MedType = "1402"
  363. //} else {
  364. // fed.MedType = "9933"
  365. //}
  366. var orders []*models.FsiOrderDtos
  367. if trig_scen == "2" {
  368. //处方医嘱信息
  369. for _, item := range prescriptions {
  370. for _, subItem := range item.HisDoctorAdviceInfo {
  371. var order models.FsiOrderDtos
  372. order.RxID = strconv.FormatInt(item.ID, 10)
  373. order.Rxno = strconv.FormatInt(item.ID, 10)
  374. order.LongDrordFlag = "0"
  375. order.HilistType = "1"
  376. order.ChrgType = "1"
  377. order.DrordBhvr = "-"
  378. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  379. order.HosplistName = subItem.BaseDrugLib.DrugName
  380. order.HilistLv = "1"
  381. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  382. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  383. order.HosplistName = subItem.BaseDrugLib.DrugName
  384. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  385. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  386. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  387. order.OwnpayAmt = ""
  388. order.SelfpayAmt = ""
  389. order.Spec = ""
  390. order.SpecUnt = ""
  391. order.DrordBegnDate = s_tm
  392. order.DrordStopDate = ""
  393. order.DrordDrCodg = "1"
  394. order.DrordDeptName = department.Name
  395. order.DrordDrCodg = "1"
  396. order.DrordDrName = doctor_info.UserName
  397. order.DrordDrProfttl = ""
  398. order.CurrDrordFlag = "1"
  399. orders = append(orders, &order)
  400. }
  401. for _, subItem := range item.HisPrescriptionProject {
  402. if subItem.Type == 2 {
  403. var order models.FsiOrderDtos
  404. order.RxID = strconv.FormatInt(item.ID, 10)
  405. order.Rxno = strconv.FormatInt(item.ID, 10)
  406. order.LongDrordFlag = "0"
  407. order.HilistType = "1"
  408. order.ChrgType = "1"
  409. order.DrordBhvr = "-"
  410. order.HilistCode = subItem.HisProject.MedicalCode
  411. order.HosplistName = subItem.HisProject.ProjectName
  412. order.HilistLv = "1"
  413. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  414. order.HosplistCode = subItem.HisProject.MedicalCode
  415. order.HosplistName = subItem.HisProject.ProjectName
  416. order.Cnt = subItem.Count
  417. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  418. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  419. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  420. order.OwnpayAmt = ""
  421. order.SelfpayAmt = ""
  422. order.Spec = ""
  423. order.SpecUnt = ""
  424. order.DrordBegnDate = s_tm
  425. order.DrordStopDate = ""
  426. order.DrordDrCodg = "1"
  427. order.DrordDeptName = department.Name
  428. order.DrordDrCodg = "1"
  429. order.DrordDrName = doctor_info.UserName
  430. order.DrordDrProfttl = ""
  431. order.CurrDrordFlag = "1"
  432. orders = append(orders, &order)
  433. }
  434. if subItem.Type == 3 {
  435. var order models.FsiOrderDtos
  436. order.RxID = strconv.FormatInt(item.ID, 10)
  437. order.Rxno = strconv.FormatInt(item.ID, 10)
  438. order.LongDrordFlag = "0"
  439. order.HilistType = "1"
  440. order.ChrgType = "1"
  441. order.DrordBhvr = "-"
  442. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  443. order.HosplistName = subItem.GoodInfo.GoodName
  444. order.HilistLv = "1"
  445. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  446. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  447. order.HosplistName = subItem.GoodInfo.GoodName
  448. order.Cnt = subItem.Count
  449. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  450. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  451. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  452. order.OwnpayAmt = ""
  453. order.SelfpayAmt = ""
  454. order.Spec = ""
  455. order.SpecUnt = ""
  456. order.DrordBegnDate = s_tm
  457. order.DrordStopDate = ""
  458. order.DrordDrCodg = "1"
  459. order.DrordDeptName = department.Name
  460. order.DrordDrCodg = "1"
  461. order.DrordDrName = doctor_info.UserName
  462. order.DrordDrProfttl = ""
  463. order.CurrDrordFlag = "1"
  464. orders = append(orders, &order)
  465. }
  466. }
  467. }
  468. //处方医嘱信息
  469. }
  470. fed.MatnStas = "0"
  471. fed.MedfeeSumamt = "0"
  472. fed.OwnpayAmt = "0"
  473. fed.SelfpayAmt = "0"
  474. fed.AcctPayamt = "0"
  475. fed.MaAmt = "0"
  476. fed.HifpPayamt = "0"
  477. fed.SetlTotlnum = "1"
  478. fed.Insutype = his.Insutype
  479. fed.ReimFlag = "0"
  480. fed.OutSetlFlag = "0"
  481. var fopd []*models.FsiOperationDtosData
  482. data := make(map[string]interface{})
  483. data["fed"] = fed
  484. data["fdd"] = fdds
  485. data["fod"] = orders
  486. data["pd"] = pd
  487. data["pp"] = pp
  488. data["fopd"] = fopd
  489. data["trig_scen"] = trig_scen
  490. fmt.Println(data)
  491. fmt.Println(fed)
  492. fmt.Println(fdds)
  493. fmt.Println(orders)
  494. fmt.Println(pd)
  495. fmt.Println(pp)
  496. fmt.Println(fopd)
  497. client := &http.Client{}
  498. bytesData, _ := json.Marshal(data)
  499. var req *http.Request
  500. if miConfig.MdtrtareaAdmvs == "320921" {
  501. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  502. } else {
  503. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  504. }
  505. resp, _ := client.Do(req)
  506. defer resp.Body.Close()
  507. body, ioErr := ioutil.ReadAll(resp.Body)
  508. if ioErr != nil {
  509. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  511. return
  512. }
  513. var respJSON map[string]interface{}
  514. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  515. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  517. return
  518. }
  519. //手术操作集合
  520. //手术操作集合
  521. }
  522. func (c *HisApiController) Check3102() {
  523. patient_id, _ := c.GetInt64("patient_id")
  524. order_id, _ := c.GetInt64("order_id")
  525. his_patient_id, _ := c.GetInt64("his_patient_id")
  526. admin_user_id, _ := c.GetInt64("admin_user_id")
  527. trig_scen := c.GetString("trig_scen")
  528. adminUser := c.GetAdminUserInfo()
  529. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  530. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  531. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  532. record_time := c.GetString("record_time")
  533. order, _ := service.GetHisOrderByID(order_id)
  534. timeLayout := "2006-01-02"
  535. loc, _ := time.LoadLocation("Local")
  536. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  537. if err != nil {
  538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  539. return
  540. }
  541. recordDateTime := theTime.Unix()
  542. var patientPrescription models.HisPrescriptionInfo
  543. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  544. if patientPrescription.ID == 0 {
  545. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  546. }
  547. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  548. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  549. //
  550. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  551. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  552. var pp models.PublicParams
  553. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  554. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  555. pp.FixmedinsName = miConfig.OrgName
  556. pp.FixmedinsCode = miConfig.Code
  557. pp.RequestUrl = miConfig.Url
  558. pp.Cainfo = miConfig.Cainfo
  559. pp.SecretKey = miConfig.SecretKey
  560. pp.AccessKey = miConfig.AccessKey
  561. pp.OpterName = roles.UserName
  562. var config []*models.HisXtDiagnoseConfig
  563. for _, item := range diagnosis_ids {
  564. id, _ := strconv.ParseInt(item, 10, 64)
  565. diagnosisConfig, _ := service.FindDiagnoseById(id)
  566. config = append(config, &diagnosisConfig)
  567. }
  568. var pd models.PatientDtos
  569. pd.PatnID = his.PsnNo
  570. pd.PatnName = his.Name
  571. pd.Gend = his.Gend
  572. pd.Brdy = his.Brdy
  573. pd.Poolarea = his.InsuplcAdmdvs
  574. pd.CurrMdtrtID = his.Number
  575. var fed models.FsiEncounterDtos
  576. fed.MdtrtID = his.Number
  577. fed.MedinsID = miConfig.Code
  578. fed.MedinsName = miConfig.OrgName
  579. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  580. fed.MedMdtrtType = "1"
  581. fed.MedinsType = "1"
  582. fed.MedinsLv = "11"
  583. tm := time.Unix(his.RecordDate, 0)
  584. s_tm := tm.Format("2006-01-02 15:04:05")
  585. fed.AdmDate = s_tm
  586. fed.DscgDate = s_tm
  587. fed.DscgMainDiseCodg = config[0].CountryCode
  588. fed.DscgMainDiseName = config[0].CountryContentName
  589. //诊断信息
  590. var fdds []*models.FsiDiagnoseDtos
  591. for index, item := range config {
  592. if index == 0 {
  593. var fdd models.FsiDiagnoseDtos
  594. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  595. fdd.InoutDiseType = "1"
  596. fdd.MaindiseFlag = "1"
  597. fdd.DiseDate = s_tm
  598. fdd.DiasSrtNo = "1"
  599. fdd.DiseName = item.CountryContentName
  600. fdd.DiseCodg = item.CountryCode
  601. fdds = append(fdds, &fdd)
  602. } else {
  603. var fdd models.FsiDiagnoseDtos
  604. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  605. fdd.InoutDiseType = "1"
  606. fdd.MaindiseFlag = "1"
  607. fdd.DiseDate = s_tm
  608. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  609. fdd.DiseName = item.CountryContentName
  610. fdd.DiseCodg = item.CountryCode
  611. fdds = append(fdds, &fdd)
  612. }
  613. }
  614. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  615. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  616. fed.AdmDeptName = department.Name
  617. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  618. fed.DscgDeptName = department.Name
  619. fed.MedType = order.MedType
  620. //处方医嘱信息
  621. var orders []*models.FsiOrderDtos
  622. //for _, item := range prescriptions {
  623. // for _, subItem := range item.HisDoctorAdviceInfo {
  624. // var order models.FsiOrderDtos
  625. // order.RxID = strconv.FormatInt(item.ID, 10)
  626. // order.Rxno = strconv.FormatInt(item.ID, 10)
  627. // order.LongDrordFlag = "0"
  628. // order.HilistType = "1"
  629. // order.ChrgType = "1"
  630. // order.DrordBhvr = "-"
  631. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  632. // order.HosplistName = subItem.BaseDrugLib.DrugName
  633. // order.HilistLv = "1"
  634. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  635. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  636. // order.HosplistName = subItem.BaseDrugLib.DrugName
  637. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  638. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  639. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  640. // order.OwnpayAmt = ""
  641. // order.SelfpayAmt = ""
  642. // order.Spec = ""
  643. // order.SpecUnt = ""
  644. // order.DrordBegnDate = s_tm
  645. // order.DrordStopDate = ""
  646. // order.DrordDrCodg = "1"
  647. // order.DrordDeptName = department.Name
  648. // order.DrordDrCodg = "1"
  649. // order.DrordDrName = doctor_info.UserName
  650. // order.DrordDrProfttl = ""
  651. // order.CurrDrordFlag = "1"
  652. // orders = append(orders, &order)
  653. // }
  654. // for _, subItem := range item.HisPrescriptionProject {
  655. // if subItem.Type == 2 {
  656. // var order models.FsiOrderDtos
  657. // order.RxID = strconv.FormatInt(item.ID, 10)
  658. // order.Rxno = strconv.FormatInt(item.ID, 10)
  659. // order.LongDrordFlag = "0"
  660. // order.HilistType = "1"
  661. // order.ChrgType = "1"
  662. // order.DrordBhvr = "-"
  663. // order.HilistCode = subItem.HisProject.MedicalCode
  664. // order.HosplistName = subItem.HisProject.ProjectName
  665. // order.HilistLv = "1"
  666. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  667. // order.HosplistCode = subItem.HisProject.MedicalCode
  668. // order.HosplistName = subItem.HisProject.ProjectName
  669. // order.Cnt = subItem.Count
  670. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  671. //
  672. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  673. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  674. // order.OwnpayAmt = ""
  675. // order.SelfpayAmt = ""
  676. // order.Spec = ""
  677. // order.SpecUnt = ""
  678. // order.DrordBegnDate = s_tm
  679. // order.DrordStopDate = ""
  680. // order.DrordDrCodg = "1"
  681. // order.DrordDeptName = department.Name
  682. // order.DrordDrCodg = "1"
  683. // order.DrordDrName = doctor_info.UserName
  684. // order.DrordDrProfttl = ""
  685. // order.CurrDrordFlag = "1"
  686. // orders = append(orders, &order)
  687. //
  688. // }
  689. // if subItem.Type == 3 {
  690. //
  691. // var order models.FsiOrderDtos
  692. // order.RxID = strconv.FormatInt(item.ID, 10)
  693. // order.Rxno = strconv.FormatInt(item.ID, 10)
  694. // order.LongDrordFlag = "0"
  695. // order.HilistType = "1"
  696. // order.ChrgType = "1"
  697. // order.DrordBhvr = "-"
  698. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  699. // order.HosplistName = subItem.GoodInfo.GoodName
  700. // order.HilistLv = "1"
  701. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  702. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  703. // order.HosplistName = subItem.GoodInfo.GoodName
  704. // order.Cnt = subItem.Count
  705. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  706. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  707. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  708. // order.OwnpayAmt = ""
  709. // order.SelfpayAmt = ""
  710. // order.Spec = ""
  711. // order.SpecUnt = ""
  712. // order.DrordBegnDate = s_tm
  713. // order.DrordStopDate = ""
  714. // order.DrordDrCodg = "1"
  715. // order.DrordDeptName = department.Name
  716. // order.DrordDrCodg = "1"
  717. // order.DrordDrName = doctor_info.UserName
  718. // order.DrordDrProfttl = ""
  719. // order.CurrDrordFlag = "1"
  720. // orders = append(orders, &order)
  721. //
  722. // }
  723. // }
  724. //}
  725. for _, item := range prescriptions {
  726. for _, subItem := range item.HisDoctorAdviceInfo {
  727. var order models.FsiOrderDtos
  728. order.RxID = strconv.FormatInt(item.ID, 10)
  729. order.Rxno = strconv.FormatInt(item.ID, 10)
  730. order.LongDrordFlag = "0"
  731. order.HilistType = "1"
  732. order.ChrgType = "1"
  733. order.DrordBhvr = "-"
  734. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  735. order.HosplistName = subItem.BaseDrugLib.DrugName
  736. order.HilistLv = "1"
  737. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  738. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  739. order.HosplistName = subItem.BaseDrugLib.DrugName
  740. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  741. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  742. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  743. order.OwnpayAmt = ""
  744. order.SelfpayAmt = ""
  745. order.Spec = ""
  746. order.SpecUnt = ""
  747. order.DrordBegnDate = s_tm
  748. order.DrordStopDate = ""
  749. order.DrordDrCodg = "1"
  750. order.DrordDeptName = department.Name
  751. order.DrordDrCodg = "1"
  752. order.DrordDrName = doctor_info.UserName
  753. order.DrordDrProfttl = ""
  754. order.CurrDrordFlag = "1"
  755. orders = append(orders, &order)
  756. }
  757. for _, subItem := range item.HisPrescriptionProject {
  758. if subItem.Type == 2 {
  759. var order models.FsiOrderDtos
  760. order.RxID = strconv.FormatInt(item.ID, 10)
  761. order.Rxno = strconv.FormatInt(item.ID, 10)
  762. order.LongDrordFlag = "0"
  763. order.HilistType = "1"
  764. order.ChrgType = "1"
  765. order.DrordBhvr = "-"
  766. order.HilistCode = subItem.HisProject.MedicalCode
  767. order.HosplistName = subItem.HisProject.ProjectName
  768. order.HilistLv = "1"
  769. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  770. order.HosplistCode = subItem.HisProject.MedicalCode
  771. order.HosplistName = subItem.HisProject.ProjectName
  772. order.Cnt = subItem.Count
  773. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  774. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  775. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  776. order.OwnpayAmt = ""
  777. order.SelfpayAmt = ""
  778. order.Spec = ""
  779. order.SpecUnt = ""
  780. order.DrordBegnDate = s_tm
  781. order.DrordStopDate = ""
  782. order.DrordDrCodg = "1"
  783. order.DrordDeptName = department.Name
  784. order.DrordDrCodg = "1"
  785. order.DrordDrName = doctor_info.UserName
  786. order.DrordDrProfttl = ""
  787. order.CurrDrordFlag = "1"
  788. orders = append(orders, &order)
  789. }
  790. if subItem.Type == 3 {
  791. var order models.FsiOrderDtos
  792. order.RxID = strconv.FormatInt(item.ID, 10)
  793. order.Rxno = strconv.FormatInt(item.ID, 10)
  794. order.LongDrordFlag = "0"
  795. order.HilistType = "1"
  796. order.ChrgType = "1"
  797. order.DrordBhvr = "-"
  798. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  799. order.HosplistName = subItem.GoodInfo.GoodName
  800. order.HilistLv = "1"
  801. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  802. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  803. order.HosplistName = subItem.GoodInfo.GoodName
  804. order.Cnt = subItem.Count
  805. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  806. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  807. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  808. order.OwnpayAmt = ""
  809. order.SelfpayAmt = ""
  810. order.Spec = ""
  811. order.SpecUnt = ""
  812. order.DrordBegnDate = s_tm
  813. order.DrordStopDate = ""
  814. order.DrordDrCodg = "1"
  815. order.DrordDeptName = department.Name
  816. order.DrordDrCodg = "1"
  817. order.DrordDrName = doctor_info.UserName
  818. order.DrordDrProfttl = ""
  819. order.CurrDrordFlag = "1"
  820. orders = append(orders, &order)
  821. }
  822. }
  823. }
  824. //处方医嘱信息
  825. fed.MatnStas = "0"
  826. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  827. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  828. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  829. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  830. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  831. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  832. fed.SetlTotlnum = "1"
  833. fed.Insutype = his.Insutype
  834. fed.ReimFlag = "0"
  835. fed.OutSetlFlag = "0"
  836. var fopd []*models.FsiOperationDtosData
  837. data := make(map[string]interface{})
  838. data["fed"] = fed
  839. data["fdd"] = fdds
  840. data["fod"] = orders
  841. data["pd"] = pd
  842. data["pp"] = pp
  843. data["fopd"] = fopd
  844. data["trig_scen"] = trig_scen
  845. client := &http.Client{}
  846. bytesData, _ := json.Marshal(data)
  847. var req *http.Request
  848. if miConfig.MdtrtareaAdmvs == "320921" {
  849. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  850. } else {
  851. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  852. }
  853. resp, _ := client.Do(req)
  854. defer resp.Body.Close()
  855. body, ioErr := ioutil.ReadAll(resp.Body)
  856. if ioErr != nil {
  857. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  859. return
  860. }
  861. var respJSON map[string]interface{}
  862. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  863. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  865. return
  866. }
  867. //手术操作集合
  868. //手术操作集合
  869. }
  870. func (c *HisApiController) Check() {
  871. psn_no := c.GetString("psn_no")
  872. in := c.GetString("in")
  873. mt := c.GetString("mt")
  874. baseParams := models.BaseParams{
  875. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  876. FixmedinsCode: "H15049901371",
  877. InsuplcAdmdvs: "150499",
  878. MdtrtareaAdmvs: "150499",
  879. OrgName: "赤峰费森血液透析中心",
  880. Doctor: "1111",
  881. }
  882. service.Gdyb2001(baseParams, psn_no, in, mt)
  883. }
  884. func (c *HisApiController) GetPsnNcdsInfo() {
  885. admin_user_id, _ := c.GetInt64("admin_user_id")
  886. patient_id, _ := c.GetInt64("patient_id")
  887. id, _ := c.GetInt64("id")
  888. adminUser := c.GetAdminUserInfo()
  889. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  890. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  891. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  892. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  893. psn_record, _ := service.GetPsnNCDSRecordById(id)
  894. //
  895. //if psn_record.ID == 0 {
  896. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  897. // return
  898. //}
  899. var res Result5301
  900. var res10265 Result5301For10265
  901. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  902. psn_info, _ := service.GetPsnByPatientId(patient_id)
  903. var api string
  904. if miConfig.MdtrtareaAdmvs == "320921" {
  905. 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 +
  906. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  907. } else {
  908. 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 +
  909. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  910. }
  911. resp, requestErr := http.Get(api)
  912. if requestErr != nil {
  913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  914. return
  915. }
  916. body, ioErr := ioutil.ReadAll(resp.Body)
  917. if ioErr != nil {
  918. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  920. return
  921. }
  922. var respJSON map[string]interface{}
  923. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  924. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  926. return
  927. }
  928. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  929. result, _ := json.Marshal(respJSON)
  930. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  931. utils.ErrorLog("解析失败:%v", err)
  932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  933. return
  934. }
  935. res.ErrMsg = res10265.ErrMsg
  936. res.Output = res10265.Output
  937. res.InfRefmsgid = res10265.InfRefmsgid
  938. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  939. res.Infcode = infocode
  940. } else {
  941. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  942. var dat map[string]interface{}
  943. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  944. fmt.Println(dat)
  945. } else {
  946. fmt.Println(err)
  947. }
  948. userJSONBytes, _ := json.Marshal(dat)
  949. if miConfig.Code == "H15049901371" {
  950. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  951. utils.ErrorLog("解析失败:%v", err)
  952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  953. return
  954. }
  955. res.InfRefmsgid = res10265.InfRefmsgid
  956. res.Output = res10265.Output
  957. res.ErrMsg = res10265.ErrMsg
  958. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  959. res.Infcode = infocode
  960. } else {
  961. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  962. utils.ErrorLog("解析失败:%v", err)
  963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  964. return
  965. }
  966. }
  967. }
  968. if res.Infcode == 0 {
  969. c.ServeSuccessJSON(map[string]interface{}{
  970. "result": res.Output.Result,
  971. })
  972. }
  973. }
  974. func (c *HisApiController) CheckInsutype() {
  975. his_patient_id, _ := c.GetInt64("his_patient_id")
  976. admin_user_id, _ := c.GetInt64("admin_user_id")
  977. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  978. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  979. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  980. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  981. var dat map[string]interface{}
  982. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  983. fmt.Println(dat)
  984. } else {
  985. fmt.Println(err)
  986. }
  987. userJSONBytes, _ := json.Marshal(dat)
  988. var res Result90100
  989. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  990. utils.ErrorLog("解析失败:%v", err)
  991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  992. return
  993. }
  994. if res.Infcode != 0 {
  995. c.ServeSuccessJSON(map[string]interface{}{
  996. "failed_code": -10,
  997. "msg": res.ErrMsg,
  998. })
  999. return
  1000. } else {
  1001. fmt.Println(res)
  1002. }
  1003. }
  1004. func (c *HisApiController) CheckCardPWD() {
  1005. card_pwd := c.GetString("card_pwd")
  1006. his_patient_id, _ := c.GetInt64("his_patient_id")
  1007. admin_user_id, _ := c.GetInt64("admin_user_id")
  1008. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1009. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1010. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1011. psn, _ := service.GetPsnByPatientId(his.PatientId)
  1012. bas := strings.Split(psn.CardInfo, "|")
  1013. basNumber := bas[2]
  1014. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  1015. var dat map[string]interface{}
  1016. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1017. fmt.Println(dat)
  1018. } else {
  1019. fmt.Println(err)
  1020. }
  1021. userJSONBytes, _ := json.Marshal(dat)
  1022. var res Result90991
  1023. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1024. utils.ErrorLog("解析失败:%v", err)
  1025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1026. return
  1027. }
  1028. if res.Infcode != 0 {
  1029. c.ServeSuccessJSON(map[string]interface{}{
  1030. "failed_code": -10,
  1031. "msg": res.ErrMsg,
  1032. })
  1033. return
  1034. } else {
  1035. fmt.Println(res.Output.Result.CardStat)
  1036. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  1037. var msg string
  1038. switch res.Output.Result.CardStat {
  1039. case "00":
  1040. msg = "未激活"
  1041. break
  1042. case "10":
  1043. msg = "激活"
  1044. break
  1045. case "20":
  1046. msg = "窗口挂失"
  1047. break
  1048. case "21":
  1049. msg = "电话挂失"
  1050. break
  1051. case "22":
  1052. msg = "单位网上申报挂失"
  1053. break
  1054. case "23":
  1055. msg = "保健办挂失"
  1056. break
  1057. case "24":
  1058. msg = "个人网上挂失"
  1059. break
  1060. case "25":
  1061. msg = "网上服务大厅挂失"
  1062. break
  1063. case "30":
  1064. msg = "注销"
  1065. break
  1066. case "40":
  1067. msg = "回收"
  1068. break
  1069. case "99":
  1070. msg = "制卡中(无效卡)"
  1071. break
  1072. }
  1073. c.ServeSuccessJSON(map[string]interface{}{
  1074. "failed_code": -10,
  1075. "msg": msg,
  1076. })
  1077. return
  1078. } else {
  1079. c.ServeSuccessJSON(map[string]interface{}{
  1080. "msg": "校验成功",
  1081. })
  1082. return
  1083. }
  1084. }
  1085. }
  1086. func (c *HisApiController) CheckCardPWDTwo() {
  1087. //card_pwd := c.GetString("card_pwd")
  1088. //his_patient_id, _ := c.GetInt64("his_patient_id")
  1089. admin_user_id, _ := c.GetInt64("admin_user_id")
  1090. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1091. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1092. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  1093. var dat map[string]interface{}
  1094. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1095. fmt.Println(dat)
  1096. } else {
  1097. fmt.Println(err)
  1098. }
  1099. userJSONBytes, _ := json.Marshal(dat)
  1100. var res Result90991
  1101. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1102. utils.ErrorLog("解析失败:%v", err)
  1103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1104. return
  1105. }
  1106. if res.Infcode != 0 {
  1107. c.ServeSuccessJSON(map[string]interface{}{
  1108. "failed_code": -10,
  1109. "msg": res.ErrMsg,
  1110. })
  1111. return
  1112. } else {
  1113. if res.Output.Result.SscnoCheckStat == "0" {
  1114. var msg string
  1115. switch res.Output.Result.CardStat {
  1116. case "00":
  1117. msg = "未激活"
  1118. break
  1119. case "10":
  1120. msg = "激活"
  1121. break
  1122. case "20":
  1123. msg = "窗口挂失"
  1124. break
  1125. case "21":
  1126. msg = "电话挂失"
  1127. break
  1128. case "22":
  1129. msg = "单位网上申报挂失"
  1130. break
  1131. case "23":
  1132. msg = "保健办挂失"
  1133. break
  1134. case "24":
  1135. msg = "个人网上挂失"
  1136. break
  1137. case "25":
  1138. msg = "网上服务大厅挂失"
  1139. break
  1140. case "30":
  1141. msg = "注销"
  1142. break
  1143. case "40":
  1144. msg = "回收"
  1145. break
  1146. case "99":
  1147. msg = "制卡中(无效卡)"
  1148. break
  1149. }
  1150. c.ServeSuccessJSON(map[string]interface{}{
  1151. "failed_code": -10,
  1152. "msg": msg,
  1153. })
  1154. return
  1155. } else {
  1156. c.ServeSuccessJSON(map[string]interface{}{
  1157. "msg": "校验成功",
  1158. })
  1159. return
  1160. }
  1161. }
  1162. }
  1163. //func (c *HisApiController) ReadCard() {
  1164. // id_card_type, _ := c.GetInt64("id_card_type")
  1165. // admin_user_id, _ := c.GetInt64("admin_user_id")
  1166. // certificates, _ := c.GetInt64("certificates")
  1167. // fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  1168. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1169. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1170. //
  1171. // switch id_card_type {
  1172. // case 1:
  1173. // if miConfig.MdtrtareaAdmvs == "421300" {
  1174. // var res ResultTwo
  1175. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  1176. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  1177. // "&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)
  1178. //
  1179. // resp, requestErr := http.Get(api)
  1180. // if requestErr != nil {
  1181. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1182. // return
  1183. // }
  1184. //
  1185. // body, ioErr := ioutil.ReadAll(resp.Body)
  1186. // if ioErr != nil {
  1187. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1188. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1189. // return
  1190. // }
  1191. // var respJSON map[string]interface{}
  1192. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1193. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1194. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1195. // return
  1196. // }
  1197. //
  1198. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1199. // result, _ := json.Marshal(respJSON)
  1200. // fmt.Println("log")
  1201. // fmt.Println(string(result))
  1202. //
  1203. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  1204. // utils.ErrorLog("解析失败:%v", err)
  1205. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1206. // return
  1207. // }
  1208. //
  1209. // if res.Infcode == 0 {
  1210. // patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1211. // if err == gorm.ErrRecordNotFound {
  1212. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1213. // return
  1214. // } else if err != nil {
  1215. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1216. // return
  1217. //
  1218. // } else {
  1219. //
  1220. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1221. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1222. // infoStr := string(Iinfos)
  1223. // idetinfoStr := string(Idetinfos)
  1224. // psn := &models.HisPsn{
  1225. // PsnNo: res.Output.Baseinfo.PsnNo,
  1226. // Age: res.Output.Baseinfo.Age,
  1227. // PatientId: patient.ID,
  1228. // Certno: res.Output.Baseinfo.Certno,
  1229. // Brdy: res.Output.Baseinfo.Brdy,
  1230. // Gend: res.Output.Baseinfo.Gend,
  1231. // Naty: res.Output.Baseinfo.Naty,
  1232. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  1233. // PsnName: res.Output.Baseinfo.PsnName,
  1234. // Idetinfo: idetinfoStr,
  1235. // Insuinfo: infoStr,
  1236. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1237. // }
  1238. // service.CreateHisPsn(psn)
  1239. //
  1240. // c.ServeSuccessJSON(map[string]interface{}{
  1241. // "patient": patient,
  1242. // "number": res.Output.Baseinfo.Certno,
  1243. // })
  1244. // }
  1245. // } else {
  1246. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1247. // return
  1248. // }
  1249. //
  1250. // } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1251. // var api string
  1252. // if miConfig.MdtrtareaAdmvs == "320921" {
  1253. // 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 +
  1254. // "&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
  1255. // fmt.Println(api)
  1256. // } else {
  1257. // 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 +
  1258. // "&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)
  1259. // }
  1260. //
  1261. // resp, requestErr := http.Get(api)
  1262. // if requestErr != nil {
  1263. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1264. // return
  1265. // }
  1266. //
  1267. // body, ioErr := ioutil.ReadAll(resp.Body)
  1268. // if ioErr != nil {
  1269. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1270. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1271. // return
  1272. // }
  1273. // var respJSON map[string]interface{}
  1274. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1275. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1276. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1277. // return
  1278. // }
  1279. // var status string
  1280. // status = respJSON["data"].(map[string]interface{})["status"].(string)
  1281. // card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1282. // //console.log()
  1283. // fmt.Println("type===")
  1284. //
  1285. // fmt.Println(card_type)
  1286. //
  1287. // var token string
  1288. // var res ResultTwo //1101结果
  1289. // var res10265 ResultTwo10265 //1101结果
  1290. // var card_info string //卡信息
  1291. // var busi_card_info string
  1292. //
  1293. // card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1294. // busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1295. //
  1296. // if status == "0" { //读卡成功
  1297. // if card_type == "1" {
  1298. //
  1299. // respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1300. // result, _ := json.Marshal(respJSON)
  1301. //
  1302. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1303. // utils.ErrorLog("解析失败:%v", err)
  1304. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1305. // return
  1306. // }
  1307. // res.ErrMsg = res10265.ErrMsg
  1308. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1309. // res.Infcode = infocode
  1310. // res.Output = res10265.Output
  1311. // res.InfRefmsgid = res10265.InfRefmsgid
  1312. //
  1313. // } else {
  1314. // //var card_info string //卡信息
  1315. // //var busi_card_info string
  1316. //
  1317. // token = respJSON["data"].(map[string]interface{})["token"].(string)
  1318. // //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1319. //
  1320. // //fmt.Println(card_info)
  1321. // //fmt.Println(busi_card_info)
  1322. //
  1323. // respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1324. // result, _ := json.Marshal(respJSON)
  1325. //
  1326. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1327. // utils.ErrorLog("解析失败:%v", err)
  1328. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1329. // return
  1330. // }
  1331. // res.ErrMsg = res10265.ErrMsg
  1332. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1333. // res.Infcode = infocode
  1334. // res.Output = res10265.Output
  1335. // res.InfRefmsgid = res10265.InfRefmsgid
  1336. //
  1337. // }
  1338. //
  1339. // if res.Infcode == 0 {
  1340. // patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1341. // if err == gorm.ErrRecordNotFound {
  1342. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1343. // return
  1344. // } else if err != nil {
  1345. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1346. // return
  1347. //
  1348. // } else {
  1349. //
  1350. // if card_type == "1" {
  1351. // bas := strings.Split(card_info, "|")
  1352. // basNumber := bas[2]
  1353. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1354. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1355. // infoStr := string(Iinfos)
  1356. // idetinfoStr := string(Idetinfos)
  1357. // psn := &models.HisPsn{
  1358. // PsnNo: res.Output.Baseinfo.PsnNo,
  1359. // Age: res.Output.Baseinfo.Age,
  1360. // PatientId: patient.ID,
  1361. // Certno: res.Output.Baseinfo.Certno,
  1362. // Brdy: res.Output.Baseinfo.Brdy,
  1363. // Gend: res.Output.Baseinfo.Gend,
  1364. // Naty: res.Output.Baseinfo.Naty,
  1365. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  1366. // PsnName: res.Output.Baseinfo.PsnName,
  1367. // Idetinfo: idetinfoStr,
  1368. // Insuinfo: infoStr,
  1369. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1370. // CardInfo: card_info,
  1371. // VerifyNumber: busi_card_info,
  1372. // }
  1373. // service.CreateHisPsn(psn)
  1374. //
  1375. // var rf []*ResultFive
  1376. // json.Unmarshal([]byte(infoStr), &rf)
  1377. //
  1378. // var insutypes []*ResultFive
  1379. // var insutype string
  1380. // var is390 int = 0
  1381. // var is310 int = 0
  1382. //
  1383. // for _, item := range rf {
  1384. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1385. // insutypes = append(insutypes, item)
  1386. // }
  1387. // }
  1388. //
  1389. // if len(insutypes) == 1 {
  1390. // insutype = insutypes[0].Insutype
  1391. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1392. // } else {
  1393. // for _, i := range insutypes {
  1394. // if i.Insutype == "390" {
  1395. // is390 = 1
  1396. // }
  1397. //
  1398. // if i.Insutype == "310" {
  1399. // is310 = 1
  1400. // }
  1401. // }
  1402. // }
  1403. // if is390 == 1 {
  1404. // insutype = "390"
  1405. // }
  1406. //
  1407. // if is310 == 1 {
  1408. // insutype = "310"
  1409. // }
  1410. //
  1411. // if len(insutypes) == 0 {
  1412. // insutype = "310"
  1413. // }
  1414. //
  1415. // c.ServeSuccessJSON(map[string]interface{}{
  1416. // "patient": patient,
  1417. // "number": basNumber,
  1418. // "insutype": insutype,
  1419. // })
  1420. // } else {
  1421. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1422. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1423. // infoStr := string(Iinfos)
  1424. // idetinfoStr := string(Idetinfos)
  1425. // psn := &models.HisPsn{
  1426. // PsnNo: res.Output.Baseinfo.PsnNo,
  1427. // Age: res.Output.Baseinfo.Age,
  1428. // PatientId: patient.ID,
  1429. // Certno: res.Output.Baseinfo.Certno,
  1430. // Brdy: res.Output.Baseinfo.Brdy,
  1431. // Gend: res.Output.Baseinfo.Gend,
  1432. // Naty: res.Output.Baseinfo.Naty,
  1433. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  1434. // PsnName: res.Output.Baseinfo.PsnName,
  1435. // Idetinfo: idetinfoStr,
  1436. // Insuinfo: infoStr,
  1437. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1438. // CardInfo: card_info,
  1439. // VerifyNumber: token,
  1440. // }
  1441. // service.CreateHisPsn(psn)
  1442. // c.ServeSuccessJSON(map[string]interface{}{
  1443. // "patient": patient,
  1444. // "number": token,
  1445. // })
  1446. // }
  1447. // }
  1448. // } else {
  1449. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1450. // return
  1451. // }
  1452. // } else { //读卡失败
  1453. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1454. // return
  1455. //
  1456. // }
  1457. //
  1458. // } else {
  1459. // if initFlag == 0 {
  1460. // c.TestGetBasBaseInit()
  1461. // }
  1462. // basStr := c.GetBasBaseInfo()
  1463. // if len(basStr) == 0 {
  1464. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1465. // return
  1466. // }
  1467. // fmt.Println(basStr)
  1468. // bas := strings.Split(basStr, "|")
  1469. // basNumber := bas[1]
  1470. // fmt.Println(basNumber)
  1471. // card_sn := bas[3]
  1472. // fmt.Println(card_sn)
  1473. // result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1474. // var dat map[string]interface{}
  1475. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1476. // fmt.Println(dat)
  1477. // } else {
  1478. // fmt.Println(err)
  1479. // }
  1480. //
  1481. // userJSONBytes, _ := json.Marshal(dat)
  1482. // var res ResultTwo
  1483. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1484. // utils.ErrorLog("解析失败:%v", err)
  1485. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1486. // return
  1487. // }
  1488. //
  1489. // if res.Infcode == 0 {
  1490. // patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1491. // if err == gorm.ErrRecordNotFound {
  1492. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1493. // return
  1494. // } else if err != nil {
  1495. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1496. // return
  1497. //
  1498. // } else {
  1499. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1500. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1501. // infoStr := string(Iinfos)
  1502. // idetinfoStr := string(Idetinfos)
  1503. // psn := &models.HisPsn{
  1504. // PsnNo: res.Output.Baseinfo.PsnNo,
  1505. // Age: res.Output.Baseinfo.Age,
  1506. // PatientId: patient.ID,
  1507. // Certno: res.Output.Baseinfo.Certno,
  1508. // Brdy: res.Output.Baseinfo.Brdy,
  1509. // Gend: res.Output.Baseinfo.Gend,
  1510. // Naty: res.Output.Baseinfo.Naty,
  1511. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  1512. // PsnName: res.Output.Baseinfo.PsnName,
  1513. // Idetinfo: idetinfoStr,
  1514. // Insuinfo: infoStr,
  1515. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1516. // CardInfo: basStr,
  1517. // VerifyNumber: "",
  1518. // }
  1519. // service.CreateHisPsn(psn)
  1520. //
  1521. // c.ServeSuccessJSON(map[string]interface{}{
  1522. // "patient": patient,
  1523. // "number": basNumber,
  1524. // })
  1525. // }
  1526. // } else {
  1527. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1528. // return
  1529. // }
  1530. // break
  1531. // }
  1532. // case 2:
  1533. // SFZStr := c.GetSFZBaseInfo()
  1534. // id_card_str := strings.Split(SFZStr, "^")
  1535. // id_card_number := id_card_str[0]
  1536. // card_sn := ""
  1537. // result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1538. // var dat map[string]interface{}
  1539. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1540. // fmt.Println(dat)
  1541. // } else {
  1542. // fmt.Println(err)
  1543. // }
  1544. //
  1545. // userJSONBytes, _ := json.Marshal(dat)
  1546. // var res ResultTwo
  1547. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1548. // utils.ErrorLog("解析失败:%v", err)
  1549. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1550. // return
  1551. // }
  1552. //
  1553. // if res.Infcode == 0 {
  1554. // patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1555. // if err == gorm.ErrRecordNotFound {
  1556. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1557. // return
  1558. // } else if err != nil {
  1559. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1560. // return
  1561. //
  1562. // } else {
  1563. // c.ServeSuccessJSON(map[string]interface{}{
  1564. // "patient": patient,
  1565. // "number": id_card_number,
  1566. // })
  1567. // }
  1568. // } else {
  1569. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1570. // return
  1571. // }
  1572. //
  1573. // break
  1574. // case 3:
  1575. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1576. // var api string
  1577. // if miConfig.MdtrtareaAdmvs == "320921" {
  1578. // 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 +
  1579. // "&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
  1580. // fmt.Println(api)
  1581. //
  1582. // } else {
  1583. // 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 +
  1584. // "&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)
  1585. // }
  1586. //
  1587. // resp, requestErr := http.Get(api)
  1588. // if requestErr != nil {
  1589. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1590. // return
  1591. // }
  1592. //
  1593. // body, ioErr := ioutil.ReadAll(resp.Body)
  1594. // if ioErr != nil {
  1595. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1596. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1597. // return
  1598. // }
  1599. // var respJSON map[string]interface{}
  1600. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1601. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1602. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1603. // return
  1604. // }
  1605. // var status string
  1606. // status = respJSON["data"].(map[string]interface{})["status"].(string)
  1607. // card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1608. //
  1609. // var token string
  1610. // var res ResultTwo //1101结果
  1611. // var res10265 ResultTwo10265 //1101结果
  1612. // var card_info string //卡信息
  1613. // var busi_card_info string
  1614. //
  1615. // //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1616. // busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1617. //
  1618. // if status == "0" { //读卡成功
  1619. // if card_type == "1" {
  1620. //
  1621. // respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1622. // result, _ := json.Marshal(respJSON)
  1623. //
  1624. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1625. // utils.ErrorLog("解析失败:%v", err)
  1626. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1627. // return
  1628. // }
  1629. // res.ErrMsg = res10265.ErrMsg
  1630. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1631. // res.Infcode = infocode
  1632. // res.Output = res10265.Output
  1633. // res.InfRefmsgid = res10265.InfRefmsgid
  1634. //
  1635. // } else {
  1636. // //var card_info string //卡信息
  1637. // //var busi_card_info string
  1638. //
  1639. // token = respJSON["data"].(map[string]interface{})["token"].(string)
  1640. // //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1641. //
  1642. // //fmt.Println(card_info)
  1643. // //fmt.Println(busi_card_info)
  1644. //
  1645. // respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1646. // result, _ := json.Marshal(respJSON)
  1647. //
  1648. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1649. // utils.ErrorLog("解析失败:%v", err)
  1650. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1651. // return
  1652. // }
  1653. // res.ErrMsg = res10265.ErrMsg
  1654. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1655. // res.Infcode = infocode
  1656. // res.Output = res10265.Output
  1657. // res.InfRefmsgid = res10265.InfRefmsgid
  1658. //
  1659. // }
  1660. //
  1661. // if res.Infcode == 0 {
  1662. // patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1663. // if err == gorm.ErrRecordNotFound {
  1664. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1665. // return
  1666. // } else if err != nil {
  1667. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1668. // return
  1669. //
  1670. // } else {
  1671. //
  1672. // if card_type == "1" {
  1673. // bas := strings.Split(card_info, "|")
  1674. // basNumber := bas[2]
  1675. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1676. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1677. // infoStr := string(Iinfos)
  1678. // idetinfoStr := string(Idetinfos)
  1679. // psn := &models.HisPsn{
  1680. // PsnNo: res.Output.Baseinfo.PsnNo,
  1681. // Age: res.Output.Baseinfo.Age,
  1682. // PatientId: patient.ID,
  1683. // Certno: res.Output.Baseinfo.Certno,
  1684. // Brdy: res.Output.Baseinfo.Brdy,
  1685. // Gend: res.Output.Baseinfo.Gend,
  1686. // Naty: res.Output.Baseinfo.Naty,
  1687. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  1688. // PsnName: res.Output.Baseinfo.PsnName,
  1689. // Idetinfo: idetinfoStr,
  1690. // Insuinfo: infoStr,
  1691. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1692. // CardInfo: card_info,
  1693. // VerifyNumber: busi_card_info,
  1694. // }
  1695. //
  1696. // service.CreateHisPsn(psn)
  1697. // c.ServeSuccessJSON(map[string]interface{}{
  1698. // "patient": patient,
  1699. // "number": basNumber,
  1700. // })
  1701. // } else {
  1702. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1703. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1704. // infoStr := string(Iinfos)
  1705. // idetinfoStr := string(Idetinfos)
  1706. // psn := &models.HisPsn{
  1707. // PsnNo: res.Output.Baseinfo.PsnNo,
  1708. // Age: res.Output.Baseinfo.Age,
  1709. // PatientId: patient.ID,
  1710. // Certno: res.Output.Baseinfo.Certno,
  1711. // Brdy: res.Output.Baseinfo.Brdy,
  1712. // Gend: res.Output.Baseinfo.Gend,
  1713. // Naty: res.Output.Baseinfo.Naty,
  1714. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  1715. // PsnName: res.Output.Baseinfo.PsnName,
  1716. // Idetinfo: idetinfoStr,
  1717. // Insuinfo: infoStr,
  1718. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1719. // CardInfo: card_info,
  1720. // VerifyNumber: token,
  1721. // }
  1722. // service.CreateHisPsn(psn)
  1723. // var rf []*ResultFive
  1724. // json.Unmarshal([]byte(infoStr), &rf)
  1725. // var insutypes []*ResultFive
  1726. // var insutype string
  1727. // var is390 int = 0
  1728. // var is310 int = 0
  1729. //
  1730. // for _, item := range rf {
  1731. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1732. // insutypes = append(insutypes, item)
  1733. // }
  1734. // }
  1735. //
  1736. // if len(insutypes) == 1 {
  1737. // insutype = insutypes[0].Insutype
  1738. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1739. // } else {
  1740. // for _, i := range insutypes {
  1741. // if i.Insutype == "390" {
  1742. // is390 = 1
  1743. // }
  1744. //
  1745. // if i.Insutype == "310" {
  1746. // is310 = 1
  1747. // }
  1748. // }
  1749. // }
  1750. //
  1751. // if is390 == 1 {
  1752. // insutype = "390"
  1753. // }
  1754. //
  1755. // if is310 == 1 {
  1756. // insutype = "310"
  1757. // }
  1758. //
  1759. // if len(insutypes) == 0 {
  1760. // insutype = "310"
  1761. // }
  1762. // c.ServeSuccessJSON(map[string]interface{}{
  1763. // "patient": patient,
  1764. // "number": token,
  1765. // "insutype": insutype,
  1766. // })
  1767. // }
  1768. // }
  1769. // } else {
  1770. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1771. // return
  1772. // }
  1773. // } else { //读卡失败
  1774. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1775. // return
  1776. //
  1777. // }
  1778. //
  1779. // }
  1780. //
  1781. // break
  1782. // case 4:
  1783. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1784. // var api string
  1785. // if miConfig.MdtrtareaAdmvs == "320921" {
  1786. // 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 +
  1787. // "&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
  1788. // fmt.Println(api)
  1789. //
  1790. // } else {
  1791. // 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 +
  1792. // "&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)
  1793. // }
  1794. //
  1795. // resp, requestErr := http.Get(api)
  1796. // if requestErr != nil {
  1797. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1798. // return
  1799. // }
  1800. //
  1801. // body, ioErr := ioutil.ReadAll(resp.Body)
  1802. // if ioErr != nil {
  1803. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1804. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1805. // return
  1806. // }
  1807. // var respJSON map[string]interface{}
  1808. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1809. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1810. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1811. // return
  1812. // }
  1813. // var status string
  1814. // status = respJSON["data"].(map[string]interface{})["status"].(string)
  1815. // //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1816. //
  1817. // var token string
  1818. // var res ResultTwo //1101结果
  1819. // var res10265 ResultTwo10265 //1101结果
  1820. //
  1821. // if status == "0" { //读卡成功
  1822. // var card_info string //卡信息
  1823. // var busi_card_info string
  1824. //
  1825. // token = respJSON["data"].(map[string]interface{})["token"].(string)
  1826. // busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1827. // card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1828. //
  1829. // fmt.Println(card_info)
  1830. // fmt.Println(busi_card_info)
  1831. //
  1832. // respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1833. // result, _ := json.Marshal(respJSON)
  1834. //
  1835. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1836. // utils.ErrorLog("解析失败:%v", err)
  1837. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1838. // return
  1839. // }
  1840. // res.ErrMsg = res10265.ErrMsg
  1841. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1842. // res.Infcode = infocode
  1843. // res.Output = res10265.Output
  1844. // res.InfRefmsgid = res10265.InfRefmsgid
  1845. //
  1846. // if res.Infcode == 0 {
  1847. // patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1848. // if err == gorm.ErrRecordNotFound {
  1849. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1850. // return
  1851. // } else if err != nil {
  1852. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1853. // return
  1854. //
  1855. // } else {
  1856. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1857. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1858. // infoStr := string(Iinfos)
  1859. // idetinfoStr := string(Idetinfos)
  1860. // psn := &models.HisPsn{
  1861. // PsnNo: res.Output.Baseinfo.PsnNo,
  1862. // Age: res.Output.Baseinfo.Age,
  1863. // PatientId: patient.ID,
  1864. // Certno: res.Output.Baseinfo.Certno,
  1865. // Brdy: res.Output.Baseinfo.Brdy,
  1866. // Gend: res.Output.Baseinfo.Gend,
  1867. // Naty: res.Output.Baseinfo.Naty,
  1868. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  1869. // PsnName: res.Output.Baseinfo.PsnName,
  1870. // Idetinfo: idetinfoStr,
  1871. // Insuinfo: infoStr,
  1872. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1873. // CardInfo: card_info,
  1874. // VerifyNumber: token,
  1875. // }
  1876. // service.CreateHisPsn(psn)
  1877. // c.ServeSuccessJSON(map[string]interface{}{
  1878. // "patient": patient,
  1879. // "number": token,
  1880. // })
  1881. // }
  1882. // } else {
  1883. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1884. // return
  1885. // }
  1886. // } else { //读卡失败
  1887. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1888. // return
  1889. // }
  1890. // }
  1891. // break
  1892. // }
  1893. //}
  1894. var initFlag int64 = 0
  1895. //func (c *HisApiController) TestGetBasBaseInit() {
  1896. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  1897. // Iinit := DllDef.MustFindProc("Init")
  1898. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1899. //
  1900. // ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  1901. // if ret != 0 {
  1902. // fmt.Println("SSCard的报错原因:", err)
  1903. // fmt.Println("SSCard的运算结果为:", ret)
  1904. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1905. // return
  1906. // }
  1907. //
  1908. // result := int(ret)
  1909. // fmt.Println("SSCard的运算结果为1:", result)
  1910. // initFlag = 1
  1911. // return
  1912. //}
  1913. //func (c *HisApiController) GetSFZBaseInfo() string {
  1914. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  1915. // readCard := DllDef.MustFindProc("ReadSFZ")
  1916. // if readCard == nil {
  1917. // fmt.Println("readcard is nil")
  1918. // readCard = DllDef.MustFindProc("ReadSFZ")
  1919. // }
  1920. //
  1921. // str := make([]byte, 256)
  1922. // str1 := make([]byte, 256)
  1923. // r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1924. //
  1925. // fmt.Println(r)
  1926. // return string(str)
  1927. //}
  1928. //func (c *HisApiController) GetBasBaseInfo() string {
  1929. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  1930. // readCard := DllDef.MustFindProc("ReadCardBas")
  1931. // if readCard == nil {
  1932. // fmt.Println("readcard is nil")
  1933. // readCard = DllDef.MustFindProc("ReadCardBas")
  1934. // }
  1935. // str := make([]byte, 1024)
  1936. // str1 := make([]byte, 1024)
  1937. // ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  1938. // fmt.Println(string(str1))
  1939. // fmt.Println(string(str))
  1940. // fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1941. // fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1942. // if ret2 != 0 {
  1943. // return ""
  1944. // }
  1945. // return string(str)
  1946. //}
  1947. type CustomFundPay struct {
  1948. FundPayType string `json:"fund_pay_type"`
  1949. FundPayamt float64 `json:"fund_payamt"`
  1950. }
  1951. func (c *HisApiController) GetSettleList() {
  1952. order_id, _ := c.GetInt64("order_id")
  1953. admin_user_id, _ := c.GetInt64("admin_user_id")
  1954. order, _ := service.GetHisOrderByIDTwo(order_id)
  1955. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1956. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1957. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1958. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1959. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1960. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1961. if order.ID == 0 {
  1962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1963. return
  1964. }
  1965. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1966. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1967. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1968. fmt.Println(count)
  1969. var zero string
  1970. number := count + 1
  1971. if number >= 1000 {
  1972. zero = "0000" + strconv.FormatInt(number, 10)
  1973. } else if number >= 10000 {
  1974. zero = "000" + strconv.FormatInt(number, 10)
  1975. } else if number >= 100000 {
  1976. zero = "00" + strconv.FormatInt(number, 10)
  1977. } else if number >= 1000000 {
  1978. zero = "0" + strconv.FormatInt(number, 10)
  1979. } else {
  1980. zero = strconv.FormatInt(number, 10)
  1981. }
  1982. fmt.Println(zero)
  1983. struct4101 := service.Struct4101{
  1984. PsnNo: order.PsnNo,
  1985. MdtrtId: order.MdtrtId,
  1986. SetlId: order.SetlId,
  1987. PsnName: order.PsnName,
  1988. Gend: order.Gend,
  1989. Brdy: his.Brdy,
  1990. Age: his.Age,
  1991. Naty: order.Naty,
  1992. PatnCertType: "01",
  1993. Certno: order.Certno,
  1994. Prfs: "90",
  1995. ConerName: roles[0].UserName,
  1996. PatnRlts: "99",
  1997. ConerAddr: miConfig.OrgName,
  1998. ConerTel: admin.Mobile,
  1999. HiType: order.Insutype,
  2000. Insuplc: miConfig.InsuplcAdmdvs,
  2001. MaindiagFlag: "1",
  2002. BillCode: last_order.FaPiaoCode,
  2003. BillNo: zero,
  2004. BizSn: order.Number,
  2005. PsnSelfPay: order.PsnPartAmt,
  2006. PsnOwnPay: order.PsnPartAmt,
  2007. AcctPay: order.AcctPay,
  2008. PsnCashpay: order.PsnCashPay,
  2009. HiPaymtd: "1",
  2010. Hsorg: miConfig.InsuplcAdmdvs,
  2011. HsorgOpter: miConfig.InsuplcAdmdvs,
  2012. MedinsFillPsn: curRoles.UserName,
  2013. MedinsFillDept: depart.Name,
  2014. IptMedType: "2",
  2015. }
  2016. struct4101.SetlBegnDate = order.SetlTime
  2017. struct4101.SetlEndDate = order.SetlTime
  2018. time_arr := strings.Split(order.SetlTime, " ")
  2019. struct4101.AdmTime = time_arr[0]
  2020. struct4101.AdmEndTime = time_arr[0]
  2021. var rf []CustomFundPay
  2022. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2023. var tempFunPays []service.CustomStruct
  2024. for _, item := range rf {
  2025. var tempFunPay service.CustomStruct
  2026. // v1, _ := strconv.ParseFloat(item.FundPayamt, 64)
  2027. tempFunPay.FundPayamt = item.FundPayamt
  2028. tempFunPay.FundPayType = item.FundPayType
  2029. tempFunPays = append(tempFunPays, tempFunPay)
  2030. }
  2031. struct4101.CustomStruct = tempFunPays
  2032. fmt.Println("111111111")
  2033. fmt.Println(tempFunPays)
  2034. fmt.Println(struct4101.CustomStruct)
  2035. var tempDiaginfos []service.DiaginfoStructTwo
  2036. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2037. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2038. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  2039. var config []*models.HisXtDiagnoseConfig
  2040. for _, item := range diagnosis_ids {
  2041. id, _ := strconv.ParseInt(item, 10, 64)
  2042. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2043. config = append(config, &diagnosisConfig)
  2044. }
  2045. for index, item := range config {
  2046. if index == 0 {
  2047. var tempDiaginfo service.DiaginfoStructTwo
  2048. tempDiaginfo.DiagCode = item.CountryCode
  2049. tempDiaginfo.DiagName = item.CountryContentName
  2050. tempDiaginfo.DiagType = "1"
  2051. tempDiaginfo.MaindiagFlag = "1"
  2052. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2053. } else {
  2054. var tempDiaginfo service.DiaginfoStructTwo
  2055. tempDiaginfo.DiagCode = item.CountryCode
  2056. tempDiaginfo.DiagName = item.CountryContentName
  2057. tempDiaginfo.DiagType = "2"
  2058. tempDiaginfo.MaindiagFlag = "0"
  2059. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2060. }
  2061. }
  2062. struct4101.Diseinfo = tempDiaginfos
  2063. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2064. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2065. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2066. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  2067. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  2068. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2069. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2070. var iteminfo service.IteminfoStruct
  2071. var bedCostTotal float64 = 0 //床位总费
  2072. var bedCostSelfTotal float64 = 0 //床位自费
  2073. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2074. var operationCostTotal float64 = 0 //手术费
  2075. var operationCostSelfTotal float64 = 0 //手术费
  2076. var operationCostPartSelfTotal float64 = 0 //手术费
  2077. var otherCostTotal float64 = 0 //其他费用
  2078. var otherCostSelfTotal float64 = 0 //其他费用
  2079. var otherCostPartSelfTotal float64 = 0 //其他费用
  2080. var materialCostTotal float64 = 0 //材料费
  2081. var materialCostSelfTotal float64 = 0 //材料费
  2082. var materialCostPartSelfTotal float64 = 0 //材料费
  2083. var westernMedicineCostTotal float64 = 0 //西药费
  2084. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2085. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2086. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2087. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2088. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2089. var checkCostTotal float64 = 0 //检查费
  2090. var checkCostSelfTotal float64 = 0 //检查费
  2091. var checkCostPartSelfTotal float64 = 0 //检查费
  2092. var laboratoryCostTotal float64 = 0 //化验费
  2093. var laboratoryCostSelfTotal float64 = 0 //化验费
  2094. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2095. var treatCostTotal float64 = 0 //治疗费用
  2096. var treatCostSelfTotal float64 = 0 //治疗费用
  2097. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2098. decimal.DivisionPrecision = 2
  2099. var bed_fulamt_ownpay_amt float64 = 0
  2100. var operation_fulamt_ownpay_amt float64 = 0
  2101. var other_fulamt_ownpay_amt float64 = 0
  2102. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2103. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2104. var check_fulamt_ownpay_amt float64 = 0
  2105. var material_fulamt_ownpay_amt float64 = 0
  2106. var laboratory_fulamt_ownpay_amt float64 = 0
  2107. var treat_fulamt_ownpay_amt float64 = 0
  2108. var bed_claa_sunmfee float64 = 0
  2109. var bed_clab_amt float64 = 0
  2110. var bed_other_amt float64 = 0
  2111. var operation_claa_sunmfee float64 = 0
  2112. var operation_clab_amt float64 = 0
  2113. var operation_other_amt float64 = 0
  2114. var other_claa_sunmfee float64 = 0
  2115. var other_clab_amt float64 = 0
  2116. var other_other_amt float64 = 0
  2117. var westernMedicine_claa_sunmfee float64 = 0
  2118. var westernMedicine_clab_amt float64 = 0
  2119. var westernMedicine_other_amt float64 = 0
  2120. var chineseTraditional_claa_sunmfee float64 = 0
  2121. var chineseTraditional_clab_amt float64 = 0
  2122. var chineseTraditional_other_amt float64 = 0
  2123. var check_claa_sunmfee float64 = 0
  2124. var check_clab_amt float64 = 0
  2125. var check_other_amt float64 = 0
  2126. var material_claa_sunmfee float64 = 0
  2127. var material_clab_amt float64 = 0
  2128. var material_other_amt float64 = 0
  2129. var laboratory_claa_sunmfee float64 = 0
  2130. var laboratory_clab_amt float64 = 0
  2131. var laboratory_other_amt float64 = 0
  2132. var treat_claa_sunmfee float64 = 0
  2133. var treat_clab_amt float64 = 0
  2134. var treat_other_amt float64 = 0
  2135. for _, item := range order.HisOrderInfo {
  2136. if item.MedChrgitmType == "01" { //床位费
  2137. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2138. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2139. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2140. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2141. if item.ChrgitmLv == "1" {
  2142. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2143. }
  2144. if item.ChrgitmLv == "2" {
  2145. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2146. }
  2147. if item.ChrgitmLv == "3" {
  2148. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2149. }
  2150. }
  2151. if item.MedChrgitmType == "03" { //检查费
  2152. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2153. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2154. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2155. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2156. if item.ChrgitmLv == "1" {
  2157. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2158. }
  2159. if item.ChrgitmLv == "2" {
  2160. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2161. }
  2162. if item.ChrgitmLv == "3" {
  2163. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2164. }
  2165. }
  2166. if item.MedChrgitmType == "04" { //化验费
  2167. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2168. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2169. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2170. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2171. if item.ChrgitmLv == "1" {
  2172. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2173. }
  2174. if item.ChrgitmLv == "2" {
  2175. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2176. }
  2177. if item.ChrgitmLv == "3" {
  2178. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2179. }
  2180. }
  2181. if item.MedChrgitmType == "05" { //治疗费
  2182. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2183. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2184. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2185. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2186. if item.ChrgitmLv == "1" {
  2187. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2188. }
  2189. if item.ChrgitmLv == "2" {
  2190. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2191. }
  2192. if item.ChrgitmLv == "3" {
  2193. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2194. }
  2195. }
  2196. if item.MedChrgitmType == "06" { //手术费
  2197. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2198. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2199. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2200. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2201. if item.ChrgitmLv == "1" {
  2202. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2203. }
  2204. if item.ChrgitmLv == "2" {
  2205. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2206. }
  2207. if item.ChrgitmLv == "3" {
  2208. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2209. }
  2210. }
  2211. if item.MedChrgitmType == "08" { //材料费
  2212. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2213. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2214. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2215. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2216. if item.ChrgitmLv == "1" {
  2217. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2218. }
  2219. if item.ChrgitmLv == "2" {
  2220. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2221. }
  2222. if item.ChrgitmLv == "3" {
  2223. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2224. }
  2225. }
  2226. if item.MedChrgitmType == "09" { //西药费
  2227. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2228. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2229. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2230. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2231. if item.ChrgitmLv == "1" {
  2232. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2233. }
  2234. if item.ChrgitmLv == "2" {
  2235. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2236. }
  2237. if item.ChrgitmLv == "3" {
  2238. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2239. }
  2240. }
  2241. if item.MedChrgitmType == "11" { //中成费
  2242. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2243. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2244. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2245. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2246. if item.ChrgitmLv == "1" {
  2247. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2248. }
  2249. if item.ChrgitmLv == "2" {
  2250. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2251. }
  2252. if item.ChrgitmLv == "3" {
  2253. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2254. }
  2255. }
  2256. if item.MedChrgitmType == "14" { //其他费
  2257. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2258. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2259. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2260. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2261. if item.ChrgitmLv == "1" {
  2262. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2263. }
  2264. if item.ChrgitmLv == "2" {
  2265. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2266. }
  2267. if item.ChrgitmLv == "3" {
  2268. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2269. }
  2270. }
  2271. }
  2272. var iteminfoStructs []service.IteminfoStruct
  2273. if bedCostTotal != 0 {
  2274. iteminfo.MedChrgitm = "01"
  2275. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2276. iteminfo.Amt = bedCostTotal
  2277. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2278. iteminfo.ClabAmt = bed_clab_amt
  2279. iteminfo.OthAmt = bed_other_amt
  2280. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2281. }
  2282. if checkCostTotal != 0 {
  2283. iteminfo.MedChrgitm = "03"
  2284. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2285. iteminfo.Amt = checkCostTotal
  2286. iteminfo.ClaaSumfee = check_claa_sunmfee
  2287. iteminfo.ClabAmt = check_clab_amt
  2288. iteminfo.OthAmt = check_other_amt
  2289. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2290. }
  2291. if laboratoryCostTotal != 0 {
  2292. iteminfo.MedChrgitm = "04"
  2293. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2294. iteminfo.Amt = laboratoryCostTotal
  2295. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2296. iteminfo.ClabAmt = laboratory_clab_amt
  2297. iteminfo.OthAmt = laboratory_other_amt
  2298. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2299. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2300. }
  2301. if treatCostTotal != 0 {
  2302. iteminfo.MedChrgitm = "05"
  2303. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2304. iteminfo.Amt = treatCostTotal
  2305. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2306. iteminfo.ClabAmt = treat_clab_amt
  2307. iteminfo.OthAmt = treat_other_amt
  2308. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2309. //(struct4101.IteminfoStruct, iteminfo)
  2310. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2311. }
  2312. if operationCostTotal != 0 {
  2313. iteminfo.MedChrgitm = "06"
  2314. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2315. iteminfo.Amt = operationCostTotal
  2316. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2317. iteminfo.ClabAmt = operation_clab_amt
  2318. iteminfo.OthAmt = operation_other_amt
  2319. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2320. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2321. }
  2322. if materialCostTotal != 0 {
  2323. iteminfo.MedChrgitm = "08"
  2324. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2325. iteminfo.Amt = materialCostTotal
  2326. iteminfo.ClaaSumfee = material_claa_sunmfee
  2327. iteminfo.ClabAmt = material_clab_amt
  2328. iteminfo.OthAmt = material_other_amt
  2329. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2330. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2331. }
  2332. if westernMedicineCostTotal != 0 {
  2333. iteminfo.MedChrgitm = "09"
  2334. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2335. iteminfo.Amt = westernMedicineCostTotal
  2336. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2337. iteminfo.ClabAmt = westernMedicine_clab_amt
  2338. iteminfo.OthAmt = westernMedicine_other_amt
  2339. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2340. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2341. }
  2342. if chineseTraditionalMedicineCostTotal != 0 {
  2343. iteminfo.MedChrgitm = "11"
  2344. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2345. iteminfo.Amt = westernMedicineCostTotal
  2346. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2347. iteminfo.ClabAmt = westernMedicine_clab_amt
  2348. iteminfo.OthAmt = westernMedicine_other_amt
  2349. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2350. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2351. }
  2352. if otherCostTotal != 0 {
  2353. iteminfo.MedChrgitm = "14"
  2354. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2355. iteminfo.Amt = otherCostTotal
  2356. iteminfo.ClaaSumfee = other_claa_sunmfee
  2357. iteminfo.ClabAmt = other_clab_amt
  2358. iteminfo.OthAmt = other_other_amt
  2359. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2360. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2361. }
  2362. struct4101.IteminfoStruct = iteminfoStructs
  2363. struct4101.Ntly = "中国"
  2364. struct4101.AdmCaty = "A03.06"
  2365. var res ResultSeventeen
  2366. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2367. var resOther ResultSeventeenOther
  2368. var pp models.PublicParams
  2369. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2370. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2371. pp.FixmedinsName = miConfig.OrgName
  2372. pp.FixmedinsCode = miConfig.Code
  2373. pp.RequestUrl = miConfig.Url
  2374. pp.Cainfo = miConfig.Cainfo
  2375. pp.SecretKey = miConfig.SecretKey
  2376. pp.AccessKey = miConfig.AccessKey
  2377. pp.OpterName = curRoles.UserName
  2378. client := &http.Client{}
  2379. var req *http.Request
  2380. data := make(map[string]interface{})
  2381. data["struct4101"] = struct4101
  2382. data["pp"] = pp
  2383. bytesData, _ := json.Marshal(data)
  2384. if miConfig.MdtrtareaAdmvs == "320921" {
  2385. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2386. } else {
  2387. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2388. }
  2389. resp, _ := client.Do(req)
  2390. defer resp.Body.Close()
  2391. body, ioErr := ioutil.ReadAll(resp.Body)
  2392. if ioErr != nil {
  2393. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2395. return
  2396. }
  2397. var respJSON map[string]interface{}
  2398. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2399. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2401. return
  2402. }
  2403. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2404. userJSONBytes, _ := json.Marshal(respJSON)
  2405. fmt.Println("log")
  2406. fmt.Println(string(userJSONBytes))
  2407. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  2408. utils.ErrorLog("解析失败:%v", err)
  2409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2410. return
  2411. }
  2412. res.InfRefmsgid = resOther.InfRefmsgid
  2413. res.Output = resOther.Output
  2414. res.ErrMsg = resOther.ErrMsg
  2415. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  2416. res.Infcode = infocode
  2417. } else {
  2418. result := service.Gdyb4101ForGZ(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2419. var dat map[string]interface{}
  2420. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2421. fmt.Println(dat)
  2422. } else {
  2423. fmt.Println(err)
  2424. }
  2425. userJSONBytes, _ := json.Marshal(dat)
  2426. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2427. utils.ErrorLog("解析失败:%v", err)
  2428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2429. return
  2430. }
  2431. }
  2432. if res.Infcode != 0 {
  2433. c.ServeSuccessJSON(map[string]interface{}{
  2434. "failed_code": -10,
  2435. "msg": res.ErrMsg,
  2436. })
  2437. return
  2438. } else {
  2439. order.FaPiaoNumber = zero
  2440. order.FaPiaoCode = last_order.FaPiaoCode
  2441. service.UpdateOrder(order)
  2442. hisFundSettleListResult := &models.HisFundSettleListResult{
  2443. Number: res.Output.SetlListId,
  2444. Status: 1,
  2445. Ctime: time.Now().Unix(),
  2446. Mtime: time.Now().Unix(),
  2447. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2448. IsUpload: 1,
  2449. OrderId: order_id,
  2450. }
  2451. service.CreateUploadRecord(hisFundSettleListResult)
  2452. c.ServeSuccessJSON(map[string]interface{}{
  2453. "msg": "上传成功",
  2454. "result": hisFundSettleListResult,
  2455. })
  2456. return
  2457. }
  2458. }
  2459. func (c *HisApiController) GetSettleListHospital() {
  2460. order_id, _ := c.GetInt64("order_id")
  2461. admin_user_id, _ := c.GetInt64("admin_user_id")
  2462. order, _ := service.GetHisOrderByIDTwo(order_id)
  2463. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2464. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2465. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2466. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2467. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2468. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2469. if order.ID == 0 {
  2470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2471. return
  2472. }
  2473. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  2474. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  2475. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  2476. fmt.Println(count)
  2477. var zero string
  2478. number := count + 1
  2479. if number >= 1000 {
  2480. zero = "0000" + strconv.FormatInt(number, 10)
  2481. } else if number >= 10000 {
  2482. zero = "000" + strconv.FormatInt(number, 10)
  2483. } else if number >= 100000 {
  2484. zero = "00" + strconv.FormatInt(number, 10)
  2485. } else if number >= 1000000 {
  2486. zero = "0" + strconv.FormatInt(number, 10)
  2487. } else {
  2488. zero = strconv.FormatInt(number, 10)
  2489. }
  2490. fmt.Println(zero)
  2491. struct4101 := service.Struct4101{
  2492. PsnNo: order.PsnNo,
  2493. MdtrtId: order.MdtrtId,
  2494. SetlId: order.SetlId,
  2495. PsnName: order.PsnName,
  2496. Gend: order.Gend,
  2497. Brdy: his.Brdy,
  2498. Age: int64(order.Age),
  2499. Naty: order.Naty,
  2500. PatnCertType: "01",
  2501. Certno: order.Certno,
  2502. Prfs: "90",
  2503. ConerName: roles[0].UserName,
  2504. PatnRlts: "99",
  2505. ConerAddr: miConfig.OrgName,
  2506. ConerTel: admin.Mobile,
  2507. HiType: order.Insutype,
  2508. Insuplc: miConfig.InsuplcAdmdvs,
  2509. MaindiagFlag: "1",
  2510. BillCode: last_order.FaPiaoCode,
  2511. BillNo: zero,
  2512. BizSn: order.Number,
  2513. PsnSelfPay: order.PsnPartAmt,
  2514. PsnOwnPay: order.PsnPartAmt,
  2515. AcctPay: order.AcctPay,
  2516. PsnCashpay: order.PsnCashPay,
  2517. HiPaymtd: "1",
  2518. Hsorg: miConfig.InsuplcAdmdvs,
  2519. HsorgOpter: miConfig.InsuplcAdmdvs,
  2520. MedinsFillPsn: curRoles.UserName,
  2521. MedinsFillDept: depart.Name,
  2522. IptMedType: "2",
  2523. AdmTime: his.InHosptialTime,
  2524. AdmEndTime: his.OutHosptialTime,
  2525. }
  2526. struct4101.SetlBegnDate = order.SetlTime
  2527. struct4101.SetlEndDate = order.SetlTime
  2528. var rf []CustomFundPay
  2529. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2530. var tempFunPays []service.CustomStruct
  2531. for _, item := range rf {
  2532. var tempFunPay service.CustomStruct
  2533. tempFunPay.FundPayamt = item.FundPayamt
  2534. tempFunPay.FundPayType = item.FundPayType
  2535. tempFunPays = append(tempFunPays, tempFunPay)
  2536. }
  2537. fmt.Println("111111111")
  2538. fmt.Println(tempFunPays)
  2539. struct4101.CustomStruct = tempFunPays
  2540. fmt.Println(struct4101.CustomStruct)
  2541. var tempDiaginfos []service.DiaginfoStructTwo
  2542. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2543. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2544. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2545. var config []*models.HisXtDiagnoseConfig
  2546. for _, item := range diagnosis_ids {
  2547. id, _ := strconv.ParseInt(item, 10, 64)
  2548. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2549. config = append(config, &diagnosisConfig)
  2550. }
  2551. for index, item := range config {
  2552. if index == 0 {
  2553. var tempDiaginfo service.DiaginfoStructTwo
  2554. tempDiaginfo.DiagCode = item.CountryCode
  2555. tempDiaginfo.DiagName = item.CountryContentName
  2556. tempDiaginfo.DiagType = "1"
  2557. tempDiaginfo.MaindiagFlag = "1"
  2558. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2559. } else {
  2560. var tempDiaginfo service.DiaginfoStructTwo
  2561. tempDiaginfo.DiagCode = item.CountryCode
  2562. tempDiaginfo.DiagName = item.CountryContentName
  2563. tempDiaginfo.DiagType = "2"
  2564. tempDiaginfo.MaindiagFlag = "0"
  2565. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2566. }
  2567. }
  2568. struct4101.Diseinfo = tempDiaginfos
  2569. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2570. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2571. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2572. tempOpspdiseinfo2.OprnOprtCode = ""
  2573. tempOpspdiseinfo2.OprnOprtName = ""
  2574. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2575. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2576. var iteminfo service.IteminfoStruct
  2577. var bedCostTotal float64 = 0 //床位总费
  2578. var bedCostSelfTotal float64 = 0 //床位自费
  2579. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2580. var operationCostTotal float64 = 0 //手术费
  2581. var operationCostSelfTotal float64 = 0 //手术费
  2582. var operationCostPartSelfTotal float64 = 0 //手术费
  2583. var otherCostTotal float64 = 0 //其他费用
  2584. var otherCostSelfTotal float64 = 0 //其他费用
  2585. var otherCostPartSelfTotal float64 = 0 //其他费用
  2586. var materialCostTotal float64 = 0 //材料费
  2587. var materialCostSelfTotal float64 = 0 //材料费
  2588. var materialCostPartSelfTotal float64 = 0 //材料费
  2589. var westernMedicineCostTotal float64 = 0 //西药费
  2590. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2591. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2592. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2593. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2594. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2595. var checkCostTotal float64 = 0 //检查费
  2596. var checkCostSelfTotal float64 = 0 //检查费
  2597. var checkCostPartSelfTotal float64 = 0 //检查费
  2598. var laboratoryCostTotal float64 = 0 //化验费
  2599. var laboratoryCostSelfTotal float64 = 0 //化验费
  2600. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2601. var treatCostTotal float64 = 0 //治疗费用
  2602. var treatCostSelfTotal float64 = 0 //治疗费用
  2603. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2604. decimal.DivisionPrecision = 2
  2605. var bed_fulamt_ownpay_amt float64 = 0
  2606. var operation_fulamt_ownpay_amt float64 = 0
  2607. var other_fulamt_ownpay_amt float64 = 0
  2608. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2609. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2610. var check_fulamt_ownpay_amt float64 = 0
  2611. var material_fulamt_ownpay_amt float64 = 0
  2612. var laboratory_fulamt_ownpay_amt float64 = 0
  2613. var treat_fulamt_ownpay_amt float64 = 0
  2614. var bed_claa_sunmfee float64 = 0
  2615. var bed_clab_amt float64 = 0
  2616. var bed_other_amt float64 = 0
  2617. var operation_claa_sunmfee float64 = 0
  2618. var operation_clab_amt float64 = 0
  2619. var operation_other_amt float64 = 0
  2620. var other_claa_sunmfee float64 = 0
  2621. var other_clab_amt float64 = 0
  2622. var other_other_amt float64 = 0
  2623. var westernMedicine_claa_sunmfee float64 = 0
  2624. var westernMedicine_clab_amt float64 = 0
  2625. var westernMedicine_other_amt float64 = 0
  2626. var chineseTraditional_claa_sunmfee float64 = 0
  2627. var chineseTraditional_clab_amt float64 = 0
  2628. var chineseTraditional_other_amt float64 = 0
  2629. var check_claa_sunmfee float64 = 0
  2630. var check_clab_amt float64 = 0
  2631. var check_other_amt float64 = 0
  2632. var material_claa_sunmfee float64 = 0
  2633. var material_clab_amt float64 = 0
  2634. var material_other_amt float64 = 0
  2635. var laboratory_claa_sunmfee float64 = 0
  2636. var laboratory_clab_amt float64 = 0
  2637. var laboratory_other_amt float64 = 0
  2638. var treat_claa_sunmfee float64 = 0
  2639. var treat_clab_amt float64 = 0
  2640. var treat_other_amt float64 = 0
  2641. for _, item := range order.HisOrderInfo {
  2642. if item.MedChrgitmType == "01" { //床位费
  2643. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2644. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2645. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2646. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2647. if item.ChrgitmLv == "1" {
  2648. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2649. }
  2650. if item.ChrgitmLv == "2" {
  2651. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2652. }
  2653. if item.ChrgitmLv == "3" {
  2654. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2655. }
  2656. }
  2657. if item.MedChrgitmType == "03" { //检查费
  2658. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2659. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2660. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2661. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2662. if item.ChrgitmLv == "1" {
  2663. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2664. }
  2665. if item.ChrgitmLv == "2" {
  2666. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2667. }
  2668. if item.ChrgitmLv == "3" {
  2669. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2670. }
  2671. }
  2672. if item.MedChrgitmType == "04" { //化验费
  2673. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2674. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2675. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2676. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2677. if item.ChrgitmLv == "1" {
  2678. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2679. }
  2680. if item.ChrgitmLv == "2" {
  2681. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2682. }
  2683. if item.ChrgitmLv == "3" {
  2684. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2685. }
  2686. }
  2687. if item.MedChrgitmType == "05" { //治疗费
  2688. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2689. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2690. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2691. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2692. if item.ChrgitmLv == "1" {
  2693. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2694. }
  2695. if item.ChrgitmLv == "2" {
  2696. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2697. }
  2698. if item.ChrgitmLv == "3" {
  2699. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2700. }
  2701. }
  2702. if item.MedChrgitmType == "06" { //手术费
  2703. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2704. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2705. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2706. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2707. if item.ChrgitmLv == "1" {
  2708. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2709. }
  2710. if item.ChrgitmLv == "2" {
  2711. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2712. }
  2713. if item.ChrgitmLv == "3" {
  2714. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2715. }
  2716. }
  2717. if item.MedChrgitmType == "08" { //材料费
  2718. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2719. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2720. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2721. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2722. if item.ChrgitmLv == "1" {
  2723. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2724. }
  2725. if item.ChrgitmLv == "2" {
  2726. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2727. }
  2728. if item.ChrgitmLv == "3" {
  2729. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2730. }
  2731. }
  2732. if item.MedChrgitmType == "09" { //西药费
  2733. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2734. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2735. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2736. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2737. if item.ChrgitmLv == "1" {
  2738. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2739. }
  2740. if item.ChrgitmLv == "2" {
  2741. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2742. }
  2743. if item.ChrgitmLv == "3" {
  2744. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2745. }
  2746. }
  2747. if item.MedChrgitmType == "11" { //中成费
  2748. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2749. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2750. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2751. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2752. if item.ChrgitmLv == "1" {
  2753. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2754. }
  2755. if item.ChrgitmLv == "2" {
  2756. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2757. }
  2758. if item.ChrgitmLv == "3" {
  2759. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2760. }
  2761. }
  2762. if item.MedChrgitmType == "14" { //其他费
  2763. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2764. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2765. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2766. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2767. if item.ChrgitmLv == "1" {
  2768. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2769. }
  2770. if item.ChrgitmLv == "2" {
  2771. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2772. }
  2773. if item.ChrgitmLv == "3" {
  2774. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2775. }
  2776. }
  2777. }
  2778. var iteminfoStructs []service.IteminfoStruct
  2779. if bedCostTotal != 0 {
  2780. iteminfo.MedChrgitm = "01"
  2781. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2782. iteminfo.Amt = bedCostTotal
  2783. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2784. iteminfo.ClabAmt = bed_clab_amt
  2785. iteminfo.OthAmt = bed_other_amt
  2786. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2787. }
  2788. if checkCostTotal != 0 {
  2789. iteminfo.MedChrgitm = "03"
  2790. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2791. iteminfo.Amt = checkCostTotal
  2792. iteminfo.ClaaSumfee = check_claa_sunmfee
  2793. iteminfo.ClabAmt = check_clab_amt
  2794. iteminfo.OthAmt = check_other_amt
  2795. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2796. }
  2797. if laboratoryCostTotal != 0 {
  2798. iteminfo.MedChrgitm = "04"
  2799. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2800. iteminfo.Amt = laboratoryCostTotal
  2801. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2802. iteminfo.ClabAmt = laboratory_clab_amt
  2803. iteminfo.OthAmt = laboratory_other_amt
  2804. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2805. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2806. }
  2807. if treatCostTotal != 0 {
  2808. iteminfo.MedChrgitm = "05"
  2809. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2810. iteminfo.Amt = treatCostTotal
  2811. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2812. iteminfo.ClabAmt = treat_clab_amt
  2813. iteminfo.OthAmt = treat_other_amt
  2814. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2815. //(struct4101.IteminfoStruct, iteminfo)
  2816. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2817. }
  2818. if operationCostTotal != 0 {
  2819. iteminfo.MedChrgitm = "06"
  2820. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2821. iteminfo.Amt = operationCostTotal
  2822. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2823. iteminfo.ClabAmt = operation_clab_amt
  2824. iteminfo.OthAmt = operation_other_amt
  2825. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2826. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2827. }
  2828. if materialCostTotal != 0 {
  2829. iteminfo.MedChrgitm = "08"
  2830. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2831. iteminfo.Amt = materialCostTotal
  2832. iteminfo.ClaaSumfee = material_claa_sunmfee
  2833. iteminfo.ClabAmt = material_clab_amt
  2834. iteminfo.OthAmt = material_other_amt
  2835. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2836. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2837. }
  2838. if westernMedicineCostTotal != 0 {
  2839. iteminfo.MedChrgitm = "09"
  2840. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2841. iteminfo.Amt = westernMedicineCostTotal
  2842. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2843. iteminfo.ClabAmt = westernMedicine_clab_amt
  2844. iteminfo.OthAmt = westernMedicine_other_amt
  2845. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2846. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2847. }
  2848. if chineseTraditionalMedicineCostTotal != 0 {
  2849. iteminfo.MedChrgitm = "11"
  2850. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2851. iteminfo.Amt = westernMedicineCostTotal
  2852. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2853. iteminfo.ClabAmt = westernMedicine_clab_amt
  2854. iteminfo.OthAmt = westernMedicine_other_amt
  2855. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2856. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2857. }
  2858. if otherCostTotal != 0 {
  2859. iteminfo.MedChrgitm = "14"
  2860. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2861. iteminfo.Amt = otherCostTotal
  2862. iteminfo.ClaaSumfee = other_claa_sunmfee
  2863. iteminfo.ClabAmt = other_clab_amt
  2864. iteminfo.OthAmt = other_other_amt
  2865. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2866. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2867. }
  2868. struct4101.IteminfoStruct = iteminfoStructs
  2869. struct4101.Ntly = "中国"
  2870. struct4101.AdmCaty = "A03.06"
  2871. fmt.Println("111111111")
  2872. fmt.Println(tempFunPays)
  2873. struct4101.CustomStruct = tempFunPays
  2874. fmt.Println(struct4101.CustomStruct)
  2875. result := service.Gdyb4101ForGZ(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2876. fmt.Println(result)
  2877. var dat map[string]interface{}
  2878. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2879. fmt.Println(dat)
  2880. } else {
  2881. fmt.Println(err)
  2882. }
  2883. userJSONBytes, _ := json.Marshal(dat)
  2884. var res ResultSeventeen
  2885. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2886. utils.ErrorLog("解析失败:%v", err)
  2887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2888. return
  2889. }
  2890. if res.Infcode != 0 {
  2891. c.ServeSuccessJSON(map[string]interface{}{
  2892. "failed_code": -10,
  2893. "msg": res.ErrMsg,
  2894. })
  2895. return
  2896. } else {
  2897. order.FaPiaoNumber = zero
  2898. order.FaPiaoCode = last_order.FaPiaoCode
  2899. service.UpdateOrder(order)
  2900. hisFundSettleListResult := &models.HisFundSettleListResult{
  2901. Number: res.Output.SetlListId,
  2902. Status: 1,
  2903. Ctime: time.Now().Unix(),
  2904. Mtime: time.Now().Unix(),
  2905. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2906. IsUpload: 1,
  2907. OrderId: order_id,
  2908. }
  2909. service.CreateUploadRecord(hisFundSettleListResult)
  2910. c.ServeSuccessJSON(map[string]interface{}{
  2911. "msg": "上传成功",
  2912. "result": hisFundSettleListResult,
  2913. })
  2914. return
  2915. }
  2916. }
  2917. func (c *HisApiController) GetBatchSettleList() {
  2918. orders, _ := service.GetAllHisOrder(10106)
  2919. for _, item := range orders {
  2920. order_id := item.ID
  2921. order, _ := service.GetHisOrderByIDTwo(order_id)
  2922. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2923. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2924. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2925. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  2926. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2927. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2928. if order.ID == 0 {
  2929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2930. return
  2931. }
  2932. if his.BalanceAccountsType == 2 {
  2933. continue
  2934. }
  2935. struct4101 := service.Struct4101{
  2936. PsnNo: order.PsnNo,
  2937. MdtrtId: order.MdtrtId,
  2938. SetlId: order.SetlId,
  2939. PsnName: order.PsnName,
  2940. Gend: order.Gend,
  2941. Brdy: his.Brdy,
  2942. Age: his.Age,
  2943. Naty: order.Naty,
  2944. PatnCertType: "01",
  2945. Certno: order.Certno,
  2946. Prfs: "90",
  2947. ConerName: roles[0].UserName,
  2948. PatnRlts: "99",
  2949. ConerAddr: miConfig.OrgName,
  2950. ConerTel: admin.Mobile,
  2951. HiType: order.Insutype,
  2952. Insuplc: his.InsuplcAdmdvs,
  2953. MaindiagFlag: "1",
  2954. BillCode: order.FaPiaoCode,
  2955. BillNo: order.FaPiaoNumber,
  2956. BizSn: order.Number,
  2957. PsnSelfPay: order.PsnPartAmt,
  2958. PsnOwnPay: order.PsnPartAmt,
  2959. AcctPay: order.AcctPay,
  2960. PsnCashpay: order.PsnCashPay,
  2961. HiPaymtd: "1",
  2962. Hsorg: his.InsuplcAdmdvs,
  2963. HsorgOpter: his.InsuplcAdmdvs,
  2964. MedinsFillPsn: curRoles.UserName,
  2965. MedinsFillDept: depart.Name,
  2966. IptMedType: "2",
  2967. }
  2968. struct4101.SetlBegnDate = order.SetlTime
  2969. struct4101.SetlEndDate = order.SetlTime
  2970. //if order.SettleType == 1 {
  2971. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  2972. // dateStr := t.Format("2006-01-02")
  2973. // struct4101.SetlBegnDate = dateStr
  2974. // struct4101.SetlEndDate = dateStr
  2975. //} else {
  2976. // t := time.Unix(int64(order.SettleStartTime), 0)
  2977. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  2978. // dateStartStr := t.Format("2006-01-02")
  2979. // dateEndStr := t2.Format("2006-01-02")
  2980. // struct4101.SetlBegnDate = dateStartStr
  2981. // struct4101.SetlEndDate = dateEndStr
  2982. //}
  2983. var rf []CustomFundPay
  2984. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2985. var tempFunPays []service.CustomStruct
  2986. var tempFunPay610100 service.CustomStruct
  2987. for _, item := range rf {
  2988. if item.FundPayType == "610100" {
  2989. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  2990. tempFunPay610100.FundPayType = item.FundPayType
  2991. } else {
  2992. var tempFunPay service.CustomStruct
  2993. tempFunPay.FundPayamt = item.FundPayamt
  2994. tempFunPay.FundPayType = item.FundPayType
  2995. tempFunPays = append(tempFunPays, tempFunPay)
  2996. }
  2997. }
  2998. tempFunPays = append(tempFunPays, tempFunPay610100)
  2999. struct4101.CustomStruct = tempFunPays
  3000. var tempDiaginfos []service.DiaginfoStructTwo
  3001. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  3002. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  3003. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3004. var config []*models.HisXtDiagnoseConfig
  3005. for _, item := range diagnosis_ids {
  3006. id, _ := strconv.ParseInt(item, 10, 64)
  3007. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3008. config = append(config, &diagnosisConfig)
  3009. }
  3010. for index, item := range config {
  3011. if index == 0 {
  3012. var tempDiaginfo service.DiaginfoStructTwo
  3013. tempDiaginfo.DiagCode = item.CountryCode
  3014. tempDiaginfo.DiagName = item.CountryContentName
  3015. tempDiaginfo.DiagType = "1"
  3016. tempDiaginfo.MaindiagFlag = "1"
  3017. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3018. } else {
  3019. var tempDiaginfo service.DiaginfoStructTwo
  3020. tempDiaginfo.DiagCode = item.CountryCode
  3021. tempDiaginfo.DiagName = item.CountryContentName
  3022. tempDiaginfo.DiagType = "2"
  3023. tempDiaginfo.MaindiagFlag = "0"
  3024. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3025. }
  3026. }
  3027. struct4101.Diseinfo = tempDiaginfos
  3028. sickConfigTwo, _ := service.FindSickById(his.SickType)
  3029. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  3030. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  3031. tempOpspdiseinfo2.OprnOprtCode = ""
  3032. tempOpspdiseinfo2.OprnOprtName = ""
  3033. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  3034. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  3035. var iteminfo service.IteminfoStruct
  3036. var bedCostTotal float64 = 0 //床位总费
  3037. var bedCostSelfTotal float64 = 0 //床位自费
  3038. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  3039. var examineCostTotal float64 = 0 //诊查总费
  3040. var examineCostSelfTotal float64 = 0 //诊查自费
  3041. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  3042. var nursingCostTotal float64 = 0 //护理总费
  3043. var nursingCostSelfTotal float64 = 0 //护理自费
  3044. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  3045. var chineseMedicineCostTotal float64 = 0 //中成药
  3046. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  3047. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  3048. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  3049. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  3050. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  3051. var registerCostTotal float64 = 0 //一般诊疗费
  3052. var registerCostSelfTotal float64 = 0 //一般诊疗费
  3053. var registerPartSelfTotal float64 = 0 //一般诊疗费
  3054. var operationCostTotal float64 = 0 //手术费
  3055. var operationCostSelfTotal float64 = 0 //手术费
  3056. var operationCostPartSelfTotal float64 = 0 //手术费
  3057. var otherCostTotal float64 = 0 //其他费用
  3058. var otherCostSelfTotal float64 = 0 //其他费用
  3059. var otherCostPartSelfTotal float64 = 0 //其他费用
  3060. var materialCostTotal float64 = 0 //材料费
  3061. var materialCostSelfTotal float64 = 0 //材料费
  3062. var materialCostPartSelfTotal float64 = 0 //材料费
  3063. var westernMedicineCostTotal float64 = 0 //西药费
  3064. var westernMedicineCostSelfTotal float64 = 0 //西药费
  3065. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  3066. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  3067. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  3068. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  3069. var checkCostTotal float64 = 0 //检查费
  3070. var checkCostSelfTotal float64 = 0 //检查费
  3071. var checkCostPartSelfTotal float64 = 0 //检查费
  3072. var laboratoryCostTotal float64 = 0 //化验费
  3073. var laboratoryCostSelfTotal float64 = 0 //化验费
  3074. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  3075. var treatCostTotal float64 = 0 //治疗费用
  3076. var treatCostSelfTotal float64 = 0 //治疗费用
  3077. var treatCostPartSelfTotal float64 = 0 //治疗费用
  3078. decimal.DivisionPrecision = 2
  3079. var bed_fulamt_ownpay_amt float64 = 0
  3080. var examine_fulamt_ownpay_amt float64 = 0
  3081. var nursing_fulamt_ownpay_amt float64 = 0
  3082. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  3083. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  3084. var register_fulamt_ownpay_amt float64 = 0
  3085. var operation_fulamt_ownpay_amt float64 = 0
  3086. var other_fulamt_ownpay_amt float64 = 0
  3087. var westernMedicine_fulamt_ownpay_amt float64 = 0
  3088. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  3089. var check_fulamt_ownpay_amt float64 = 0
  3090. var material_fulamt_ownpay_amt float64 = 0
  3091. var laboratory_fulamt_ownpay_amt float64 = 0
  3092. var treat_fulamt_ownpay_amt float64 = 0
  3093. var bed_claa_sunmfee float64 = 0
  3094. var bed_clab_amt float64 = 0
  3095. var bed_other_amt float64 = 0
  3096. var examine_claa_sunmfee float64 = 0
  3097. var examine_clab_amt float64 = 0
  3098. var examine_other_amt float64 = 0
  3099. var nursing_claa_sunmfee float64 = 0
  3100. var nursing_clab_amt float64 = 0
  3101. var nursing_other_amt float64 = 0
  3102. var chinese_medicine_claa_sunmfee float64 = 0
  3103. var chinese_medicine_clab_amt float64 = 0
  3104. var chinese_medicine_other_amt float64 = 0
  3105. var commonly_treatment_claa_sunmfee float64 = 0
  3106. var commonly_treatment_clab_amt float64 = 0
  3107. var commonly_treatment_other_amt float64 = 0
  3108. var operation_claa_sunmfee float64 = 0
  3109. var operation_clab_amt float64 = 0
  3110. var operation_other_amt float64 = 0
  3111. var other_claa_sunmfee float64 = 0
  3112. var other_clab_amt float64 = 0
  3113. var other_other_amt float64 = 0
  3114. var westernMedicine_claa_sunmfee float64 = 0
  3115. var westernMedicine_clab_amt float64 = 0
  3116. var westernMedicine_other_amt float64 = 0
  3117. var chineseTraditional_claa_sunmfee float64 = 0
  3118. var chineseTraditional_clab_amt float64 = 0
  3119. var chineseTraditional_other_amt float64 = 0
  3120. var check_claa_sunmfee float64 = 0
  3121. var check_clab_amt float64 = 0
  3122. var check_other_amt float64 = 0
  3123. var material_claa_sunmfee float64 = 0
  3124. var material_clab_amt float64 = 0
  3125. var material_other_amt float64 = 0
  3126. var laboratory_claa_sunmfee float64 = 0
  3127. var laboratory_clab_amt float64 = 0
  3128. var laboratory_other_amt float64 = 0
  3129. var treat_claa_sunmfee float64 = 0
  3130. var treat_clab_amt float64 = 0
  3131. var treat_other_amt float64 = 0
  3132. var register_claa_sunmfee float64 = 0
  3133. var register_clab_amt float64 = 0
  3134. var register_other_amt float64 = 0
  3135. for _, item := range order.HisOrderInfo {
  3136. if item.MedChrgitmType == "01" { //床位费
  3137. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3138. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3139. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3140. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3141. if item.ChrgitmLv == "1" {
  3142. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3143. }
  3144. if item.ChrgitmLv == "2" {
  3145. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3146. }
  3147. if item.ChrgitmLv == "3" {
  3148. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3149. }
  3150. }
  3151. if item.MedChrgitmType == "02" { //诊查
  3152. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3153. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3154. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3155. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3156. if item.ChrgitmLv == "1" {
  3157. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3158. }
  3159. if item.ChrgitmLv == "2" {
  3160. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3161. }
  3162. if item.ChrgitmLv == "3" {
  3163. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3164. }
  3165. }
  3166. if item.MedChrgitmType == "03" { //检查费
  3167. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3168. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3169. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3170. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3171. if item.ChrgitmLv == "1" {
  3172. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3173. }
  3174. if item.ChrgitmLv == "2" {
  3175. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3176. }
  3177. if item.ChrgitmLv == "3" {
  3178. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3179. }
  3180. }
  3181. if item.MedChrgitmType == "04" { //化验费
  3182. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3183. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3184. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3185. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3186. if item.ChrgitmLv == "1" {
  3187. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3188. }
  3189. if item.ChrgitmLv == "2" {
  3190. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3191. }
  3192. if item.ChrgitmLv == "3" {
  3193. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3194. }
  3195. }
  3196. if item.MedChrgitmType == "05" { //治疗费
  3197. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3198. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3199. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3200. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3201. if item.ChrgitmLv == "1" {
  3202. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3203. }
  3204. if item.ChrgitmLv == "2" {
  3205. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3206. }
  3207. if item.ChrgitmLv == "3" {
  3208. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3209. }
  3210. }
  3211. if item.MedChrgitmType == "06" { //手术费
  3212. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3213. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3214. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3215. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3216. if item.ChrgitmLv == "1" {
  3217. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3218. }
  3219. if item.ChrgitmLv == "2" {
  3220. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3221. }
  3222. if item.ChrgitmLv == "3" {
  3223. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3224. }
  3225. }
  3226. if item.MedChrgitmType == "07" { //手术费
  3227. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3228. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3229. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3230. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3231. if item.ChrgitmLv == "1" {
  3232. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3233. }
  3234. if item.ChrgitmLv == "2" {
  3235. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3236. }
  3237. if item.ChrgitmLv == "3" {
  3238. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3239. }
  3240. }
  3241. if item.MedChrgitmType == "08" { //材料费
  3242. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3243. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3244. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3245. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3246. if item.ChrgitmLv == "1" {
  3247. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3248. }
  3249. if item.ChrgitmLv == "2" {
  3250. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3251. }
  3252. if item.ChrgitmLv == "3" {
  3253. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3254. }
  3255. }
  3256. if item.MedChrgitmType == "09" { //西药费
  3257. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3258. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3259. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3260. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3261. if item.ChrgitmLv == "1" {
  3262. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3263. }
  3264. if item.ChrgitmLv == "2" {
  3265. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3266. }
  3267. if item.ChrgitmLv == "3" {
  3268. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3269. }
  3270. }
  3271. if item.MedChrgitmType == "10" { //中药饮片
  3272. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3273. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3274. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3275. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3276. if item.ChrgitmLv == "1" {
  3277. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3278. }
  3279. if item.ChrgitmLv == "2" {
  3280. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3281. }
  3282. if item.ChrgitmLv == "3" {
  3283. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3284. }
  3285. }
  3286. if item.MedChrgitmType == "11" { //中成费
  3287. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3288. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3289. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3290. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3291. if item.ChrgitmLv == "1" {
  3292. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3293. }
  3294. if item.ChrgitmLv == "2" {
  3295. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3296. }
  3297. if item.ChrgitmLv == "3" {
  3298. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3299. }
  3300. }
  3301. if item.MedChrgitmType == "12" { //中成费
  3302. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3303. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3304. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3305. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3306. if item.ChrgitmLv == "1" {
  3307. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3308. }
  3309. if item.ChrgitmLv == "2" {
  3310. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3311. }
  3312. if item.ChrgitmLv == "3" {
  3313. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3314. }
  3315. }
  3316. if item.MedChrgitmType == "13" { //中成费
  3317. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3318. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3319. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3320. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3321. if item.ChrgitmLv == "1" {
  3322. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3323. }
  3324. if item.ChrgitmLv == "2" {
  3325. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3326. }
  3327. if item.ChrgitmLv == "3" {
  3328. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3329. }
  3330. }
  3331. if item.MedChrgitmType == "14" { //其他费
  3332. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3333. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3334. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3335. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3336. if item.ChrgitmLv == "1" {
  3337. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3338. }
  3339. if item.ChrgitmLv == "2" {
  3340. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3341. }
  3342. if item.ChrgitmLv == "3" {
  3343. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3344. }
  3345. }
  3346. }
  3347. var iteminfoStructs []service.IteminfoStruct
  3348. if bedCostTotal != 0 {
  3349. iteminfo.MedChrgitm = "01"
  3350. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3351. iteminfo.Amt = bedCostTotal
  3352. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3353. iteminfo.ClabAmt = bed_clab_amt
  3354. iteminfo.OthAmt = bed_other_amt
  3355. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3356. }
  3357. if examineCostTotal != 0 {
  3358. iteminfo.MedChrgitm = "02"
  3359. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  3360. iteminfo.Amt = examineCostTotal
  3361. iteminfo.ClaaSumfee = examine_claa_sunmfee
  3362. iteminfo.ClabAmt = examine_clab_amt
  3363. iteminfo.OthAmt = examine_other_amt
  3364. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3365. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3366. }
  3367. if checkCostTotal != 0 {
  3368. iteminfo.MedChrgitm = "03"
  3369. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3370. iteminfo.Amt = checkCostTotal
  3371. iteminfo.ClaaSumfee = check_claa_sunmfee
  3372. iteminfo.ClabAmt = check_clab_amt
  3373. iteminfo.OthAmt = check_other_amt
  3374. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3375. }
  3376. if laboratoryCostTotal != 0 {
  3377. iteminfo.MedChrgitm = "04"
  3378. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3379. iteminfo.Amt = laboratoryCostTotal
  3380. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3381. iteminfo.ClabAmt = laboratory_clab_amt
  3382. iteminfo.OthAmt = laboratory_other_amt
  3383. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3384. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3385. }
  3386. if treatCostTotal != 0 {
  3387. iteminfo.MedChrgitm = "05"
  3388. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3389. iteminfo.Amt = treatCostTotal
  3390. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3391. iteminfo.ClabAmt = treat_clab_amt
  3392. iteminfo.OthAmt = treat_other_amt
  3393. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3394. //(struct4101.IteminfoStruct, iteminfo)
  3395. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3396. }
  3397. if operationCostTotal != 0 {
  3398. iteminfo.MedChrgitm = "06"
  3399. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3400. iteminfo.Amt = operationCostTotal
  3401. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3402. iteminfo.ClabAmt = operation_clab_amt
  3403. iteminfo.OthAmt = operation_other_amt
  3404. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3405. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3406. }
  3407. if nursingCostTotal != 0 {
  3408. iteminfo.MedChrgitm = "07"
  3409. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  3410. iteminfo.Amt = nursingCostTotal
  3411. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  3412. iteminfo.ClabAmt = nursing_clab_amt
  3413. iteminfo.OthAmt = nursing_other_amt
  3414. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3415. }
  3416. if materialCostTotal != 0 {
  3417. iteminfo.MedChrgitm = "08"
  3418. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3419. iteminfo.Amt = materialCostTotal
  3420. iteminfo.ClaaSumfee = material_claa_sunmfee
  3421. iteminfo.ClabAmt = material_clab_amt
  3422. iteminfo.OthAmt = material_other_amt
  3423. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3424. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3425. }
  3426. if westernMedicineCostTotal != 0 {
  3427. iteminfo.MedChrgitm = "09"
  3428. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3429. iteminfo.Amt = westernMedicineCostTotal
  3430. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3431. iteminfo.ClabAmt = westernMedicine_clab_amt
  3432. iteminfo.OthAmt = westernMedicine_other_amt
  3433. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3434. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3435. }
  3436. if chineseMedicineCostTotal != 0 {
  3437. iteminfo.MedChrgitm = "10"
  3438. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  3439. iteminfo.Amt = chineseMedicineCostTotal
  3440. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  3441. iteminfo.ClabAmt = chinese_medicine_clab_amt
  3442. iteminfo.OthAmt = chinese_medicine_other_amt
  3443. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3444. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3445. }
  3446. if chineseTraditionalMedicineCostTotal != 0 {
  3447. iteminfo.MedChrgitm = "11"
  3448. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3449. iteminfo.Amt = westernMedicineCostTotal
  3450. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3451. iteminfo.ClabAmt = westernMedicine_clab_amt
  3452. iteminfo.OthAmt = westernMedicine_other_amt
  3453. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3454. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3455. }
  3456. if commonlyTreatmentCostTotal != 0 {
  3457. iteminfo.MedChrgitm = "12"
  3458. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  3459. iteminfo.Amt = commonlyTreatmentCostTotal
  3460. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  3461. iteminfo.ClabAmt = commonly_treatment_clab_amt
  3462. iteminfo.OthAmt = commonly_treatment_other_amt
  3463. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3464. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3465. }
  3466. if registerCostTotal != 0 {
  3467. iteminfo.MedChrgitm = "13"
  3468. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  3469. iteminfo.Amt = registerCostTotal
  3470. iteminfo.ClaaSumfee = register_claa_sunmfee
  3471. iteminfo.ClabAmt = register_clab_amt
  3472. iteminfo.OthAmt = register_other_amt
  3473. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3474. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3475. }
  3476. if otherCostTotal != 0 {
  3477. iteminfo.MedChrgitm = "14"
  3478. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3479. iteminfo.Amt = otherCostTotal
  3480. iteminfo.ClaaSumfee = other_claa_sunmfee
  3481. iteminfo.ClabAmt = other_clab_amt
  3482. iteminfo.OthAmt = other_other_amt
  3483. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3484. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3485. }
  3486. struct4101.IteminfoStruct = iteminfoStructs
  3487. struct4101.Ntly = "中国"
  3488. struct4101.AdmCaty = "A03.06"
  3489. result := service.Gdyb4101ForGZ(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  3490. fmt.Println(result)
  3491. var dat map[string]interface{}
  3492. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3493. fmt.Println(dat)
  3494. } else {
  3495. fmt.Println(err)
  3496. }
  3497. userJSONBytes, _ := json.Marshal(dat)
  3498. var res ResultSeventeen
  3499. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3500. utils.ErrorLog("解析失败:%v", err)
  3501. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3502. adminUser := c.GetAdminUserInfo()
  3503. errlog := &models.HisOrderError{
  3504. UserOrgId: adminUser.CurrentOrgId,
  3505. Ctime: time.Now().Unix(),
  3506. Mtime: time.Now().Unix(),
  3507. ErrMsg: res.ErrMsg + "解析失败",
  3508. Status: 1,
  3509. PatientId: order_id,
  3510. Stage: 10106,
  3511. }
  3512. service.CreateErrMsgLog(errlog)
  3513. continue
  3514. }
  3515. if res.Infcode != 0 {
  3516. adminUser := c.GetAdminUserInfo()
  3517. errlog := &models.HisOrderError{
  3518. UserOrgId: adminUser.CurrentOrgId,
  3519. Ctime: time.Now().Unix(),
  3520. Mtime: time.Now().Unix(),
  3521. ErrMsg: res.ErrMsg,
  3522. Status: 1,
  3523. PatientId: order_id,
  3524. Stage: 10106,
  3525. }
  3526. service.CreateErrMsgLog(errlog)
  3527. continue
  3528. } else {
  3529. hisFundSettleListResult := &models.HisFundSettleListResult{
  3530. Number: res.Output.SetlListId,
  3531. Status: 1,
  3532. Ctime: time.Now().Unix(),
  3533. Mtime: time.Now().Unix(),
  3534. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3535. IsUpload: 1,
  3536. OrderId: order_id,
  3537. }
  3538. service.CreateUploadRecord(hisFundSettleListResult)
  3539. continue
  3540. }
  3541. }
  3542. }
  3543. func (c *HisApiController) GetOrgInfo() {
  3544. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  3545. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  3546. }
  3547. func (c *HisApiController) GetHisPatientInfo() {
  3548. medical_insurance_card := c.GetString("medical_insurance_card")
  3549. id_card_type, _ := c.GetInt64("id_card_type")
  3550. id_card := c.GetString("id_card")
  3551. adminInfo := c.GetAdminUserInfo()
  3552. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3553. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3554. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  3555. IdCardNo := ""
  3556. if id_card_type == 1 {
  3557. IdCardNo = medical_insurance_card
  3558. } else if id_card_type == 2 {
  3559. IdCardNo = id_card
  3560. }
  3561. if config.IsOpen == 1 {
  3562. 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
  3563. resp, requestErr := http.Get(api)
  3564. if requestErr != nil {
  3565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3566. return
  3567. }
  3568. defer resp.Body.Close()
  3569. body, ioErr := ioutil.ReadAll(resp.Body)
  3570. if ioErr != nil {
  3571. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3573. return
  3574. }
  3575. var respJSON map[string]interface{}
  3576. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3577. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3579. return
  3580. }
  3581. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3582. userJSONBytes, _ := json.Marshal(userJSON)
  3583. var res ResultTwo
  3584. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3585. utils.ErrorLog("解析失败:%v", err)
  3586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3587. return
  3588. }
  3589. Iinfos, _ := json.Marshal(res.Output[0].Iinfo)
  3590. Idetinfos, _ := json.Marshal(res.Output[0].Idetinfo)
  3591. infoStr := string(Iinfos)
  3592. idetinfoStr := string(Idetinfos)
  3593. if res.Infcode == 0 {
  3594. his := models.VMHisPatient{
  3595. Status: 1,
  3596. Ctime: time.Now().Unix(),
  3597. Mtime: time.Now().Unix(),
  3598. PsnNo: res.Output[0].Baseinfo.PsnNo,
  3599. PsnCertType: res.Output[0].Baseinfo.PsnCertType,
  3600. Certno: res.Output[0].Baseinfo.Certno,
  3601. PsnName: res.Output[0].Baseinfo.PsnName,
  3602. Gend: res.Output[0].Baseinfo.Gend,
  3603. Naty: res.Output[0].Baseinfo.Naty,
  3604. Brdy: res.Output[0].Baseinfo.Brdy,
  3605. Age: res.Output[0].Baseinfo.Age,
  3606. Iinfo: infoStr,
  3607. Idetinfo: idetinfoStr,
  3608. UserOrgId: adminInfo.CurrentOrgId,
  3609. IsReturn: 1,
  3610. IdCardType: id_card_type,
  3611. }
  3612. c.ServeSuccessJSON(map[string]interface{}{
  3613. "info": his,
  3614. })
  3615. } else {
  3616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3617. return
  3618. }
  3619. }
  3620. }
  3621. //func GetBasBaseInfo() (jsonStr string, err error) {
  3622. //
  3623. // handle := syscall.NewLazyDLL("SSCard.dll")
  3624. // add := handle.NewProc("ReadCardBas")
  3625. // str := make([]byte, 1024)
  3626. // str1 := make([]byte, 1024)
  3627. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3628. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3629. //
  3630. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3631. //
  3632. // fmt.Println("> Add(4,5)的结果为:", ret)
  3633. // handle.Release()
  3634. //
  3635. // return "", nil
  3636. //
  3637. //}
  3638. //func GetQRBaseInfo() (jsonStr string, err error) {
  3639. // handle := syscall.LoadDLL("SSCard.dll")
  3640. // ReadCardBas := handle.FindProc("GetQRBase")
  3641. //
  3642. // str := make([]byte, 256)
  3643. // str1 := make([]byte, 256)
  3644. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3645. //
  3646. // fmt.Println(string(str))
  3647. // fmt.Println(r)
  3648. // return string(str), nil
  3649. //}
  3650. //func CardInit() int {
  3651. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  3652. // add := DllTestDef.MustFindProc("Init")
  3653. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3654. // if err != nil {
  3655. // fmt.Println("SSCard的运算结果为:", ret)
  3656. // }
  3657. // result := int(ret)
  3658. // return result
  3659. //}
  3660. //func CardInit() int {
  3661. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3662. // if err != nil {
  3663. // fmt.Println("SSCard的运算结果为:", ret)
  3664. // }
  3665. // fmt.Println(err)
  3666. // result := int(ret)
  3667. // return result
  3668. //}
  3669. func IntPtr(n int) uintptr {
  3670. return uintptr(n)
  3671. }
  3672. func StrPtr(s string) uintptr {
  3673. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3674. }
  3675. type Result2001 struct {
  3676. Cainfo interface{} `json:"cainfo"`
  3677. ErrMsg string `json:"err_msg"`
  3678. InfRefmsgid string `json:"inf_refmsgid"`
  3679. Infcode int64 `json:"infcode"`
  3680. Output struct {
  3681. Trtinfo struct {
  3682. PsnNo string `json:"psn_no"`
  3683. TrtChkType string `json:"trt_chk_type"`
  3684. FundPayType string `json:"fund_pay_type"`
  3685. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3686. Begndate string `json:"begndate"`
  3687. Enddate string `json:"enddate"`
  3688. TrtChkRslt string `json:"trt_chk_rslt"`
  3689. } `json:"trtinfo"`
  3690. } `json:"output"`
  3691. RefmsgTime string `json:"refmsg_time"`
  3692. RespondTime string `json:"respond_time"`
  3693. Signtype interface{} `json:"signtype"`
  3694. WarnMsg interface{} `json:"warn_msg"`
  3695. }
  3696. type Result2001Org10265 struct {
  3697. Cainfo interface{} `json:"cainfo"`
  3698. ErrMsg string `json:"err_msg"`
  3699. InfRefmsgid string `json:"inf_refmsgid"`
  3700. Infcode string `json:"infcode"`
  3701. Output struct {
  3702. Trtinfo struct {
  3703. PsnNo string `json:"psn_no"`
  3704. TrtChkType string `json:"trt_chk_type"`
  3705. FundPayType string `json:"fund_pay_type"`
  3706. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3707. Begndate string `json:"begndate"`
  3708. Enddate string `json:"enddate"`
  3709. TrtChkRslt string `json:"trt_chk_rslt"`
  3710. } `json:"trtinfo"`
  3711. } `json:"output"`
  3712. RefmsgTime string `json:"refmsg_time"`
  3713. RespondTime string `json:"respond_time"`
  3714. Signtype interface{} `json:"signtype"`
  3715. WarnMsg interface{} `json:"warn_msg"`
  3716. }
  3717. type ResultTwo struct {
  3718. ErrMsg string `json:"err_msg"`
  3719. InfRefmsgid string `json:"inf_refmsgid"`
  3720. Infcode int64 `json:"infcode"`
  3721. Output []struct {
  3722. Baseinfo struct {
  3723. Age float64 `json:"age"`
  3724. Brdy string `json:"brdy"`
  3725. Certno string `json:"certno"`
  3726. Gend string `json:"gend"`
  3727. Naty string `json:"naty"`
  3728. PsnCertType string `json:"psn_cert_type"`
  3729. PsnName string `json:"psn_name"`
  3730. PsnNo string `json:"psn_no"`
  3731. } `json:"baseinfo"`
  3732. Idetinfo []interface{} `json:"idetinfo"`
  3733. Iinfo []struct {
  3734. Balc float64 `json:"balc"`
  3735. CvlservFlag string `json:"cvlserv_flag"`
  3736. EmpName string `json:"emp_name"`
  3737. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3738. Insutype string `json:"insutype"`
  3739. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3740. PausInsuDate string `json:"paus_insu_date"`
  3741. PsnInsuDate string `json:"psn_insu_date"`
  3742. PsnInsuStas string `json:"psn_insu_stas"`
  3743. PsnType string `json:"psn_type"`
  3744. } `json:"insuinfo"`
  3745. } `json:"output"`
  3746. RefmsgTime string `json:"refmsg_time"`
  3747. RespondTime string `json:"respond_time"`
  3748. Signtype interface{} `json:"signtype"`
  3749. WarnInfo interface{} `json:"warn_info"`
  3750. }
  3751. type ResultTwo10265 struct {
  3752. ErrMsg string `json:"err_msg"`
  3753. InfRefmsgid string `json:"inf_refmsgid"`
  3754. Infcode string `json:"infcode"`
  3755. Output struct {
  3756. Baseinfo struct {
  3757. Age float64 `json:"age"`
  3758. Brdy string `json:"brdy"`
  3759. Certno string `json:"certno"`
  3760. Gend string `json:"gend"`
  3761. Naty string `json:"naty"`
  3762. PsnCertType string `json:"psn_cert_type"`
  3763. PsnName string `json:"psn_name"`
  3764. PsnNo string `json:"psn_no"`
  3765. } `json:"baseinfo"`
  3766. Idetinfo []interface{} `json:"idetinfo"`
  3767. Iinfo []struct {
  3768. Balc float64 `json:"balc"`
  3769. CvlservFlag string `json:"cvlserv_flag"`
  3770. EmpName string `json:"emp_name"`
  3771. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3772. Insutype string `json:"insutype"`
  3773. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3774. PausInsuDate string `json:"paus_insu_date"`
  3775. PsnInsuDate string `json:"psn_insu_date"`
  3776. PsnInsuStas string `json:"psn_insu_stas"`
  3777. PsnType string `json:"psn_type"`
  3778. } `json:"insuinfo"`
  3779. } `json:"output"`
  3780. RefmsgTime string `json:"refmsg_time"`
  3781. RespondTime string `json:"respond_time"`
  3782. Signtype interface{} `json:"signtype"`
  3783. WarnInfo interface{} `json:"warn_info"`
  3784. }
  3785. type ResultThree struct {
  3786. Cainfo interface{} `json:"cainfo"`
  3787. ErrMsg string `json:"err_msg"`
  3788. InfRefmsgid string `json:"inf_refmsgid"`
  3789. Infcode int64 `json:"infcode"`
  3790. Output struct {
  3791. Data struct {
  3792. IptOtpNo string `json:"ipt_otp_no"`
  3793. MdtrtID string `json:"mdtrt_id"`
  3794. PsnNo string `json:"psn_no"`
  3795. } `json:"data"`
  3796. } `json:"output"`
  3797. RefmsgTime string `json:"refmsg_time"`
  3798. RespondTime string `json:"respond_time"`
  3799. Signtype interface{} `json:"signtype"`
  3800. WarnMsg interface{} `json:"warn_msg"`
  3801. }
  3802. type ResultThree10265 struct {
  3803. Cainfo interface{} `json:"cainfo"`
  3804. ErrMsg string `json:"err_msg"`
  3805. InfRefmsgid string `json:"inf_refmsgid"`
  3806. Infcode string `json:"infcode"`
  3807. Output struct {
  3808. Data struct {
  3809. IptOtpNo string `json:"ipt_otp_no"`
  3810. MdtrtID string `json:"mdtrt_id"`
  3811. PsnNo string `json:"psn_no"`
  3812. } `json:"data"`
  3813. } `json:"output"`
  3814. RefmsgTime string `json:"refmsg_time"`
  3815. RespondTime string `json:"respond_time"`
  3816. Signtype interface{} `json:"signtype"`
  3817. WarnMsg interface{} `json:"warn_msg"`
  3818. }
  3819. type ResultFour struct {
  3820. Cainfo string `json:"cainfo"`
  3821. ErrMsg string `json:"err_msg"`
  3822. InfRefmsgid string `json:"inf_refmsgid"`
  3823. Infcode int64 `json:"infcode"`
  3824. Output struct {
  3825. Result []struct {
  3826. BasMednFlag string `json:"bas_medn_flag"`
  3827. ChldMedcFlag string `json:"chld_medc_flag"`
  3828. ChrgitmLv string `json:"chrgitm_lv"`
  3829. Cnt float64 `json:"cnt"`
  3830. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3831. DrtReimFlag string `json:"drt_reim_flag"`
  3832. FeedetlSn string `json:"feedetl_sn"`
  3833. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3834. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3835. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3836. ListSpItemFlag string `json:"list_sp_item_flag"`
  3837. LmtUsedFlag string `json:"lmt_used_flag"`
  3838. MedChrgitmType string `json:"med_chrgitm_type"`
  3839. Memo string `json:"memo"`
  3840. OverlmtAmt float64 `json:"overlmt_amt"`
  3841. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3842. Pric float64 `json:"pric"`
  3843. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3844. SelfpayProp float64 `json:"selfpay_prop"`
  3845. } `json:"result"`
  3846. } `json:"output"`
  3847. RefmsgTime string `json:"refmsg_time"`
  3848. RespondTime string `json:"respond_time"`
  3849. Signtype string `json:"signtype"`
  3850. WarnMsg string `json:"warn_msg"`
  3851. }
  3852. type ResultFour10265 struct {
  3853. Cainfo string `json:"cainfo"`
  3854. ErrMsg string `json:"err_msg"`
  3855. InfRefmsgid string `json:"inf_refmsgid"`
  3856. Infcode string `json:"infcode"`
  3857. Output struct {
  3858. Result []struct {
  3859. BasMednFlag string `json:"bas_medn_flag"`
  3860. ChldMedcFlag string `json:"chld_medc_flag"`
  3861. ChrgitmLv string `json:"chrgitm_lv"`
  3862. Cnt float64 `json:"cnt"`
  3863. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3864. DrtReimFlag string `json:"drt_reim_flag"`
  3865. FeedetlSn string `json:"feedetl_sn"`
  3866. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3867. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3868. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3869. ListSpItemFlag string `json:"list_sp_item_flag"`
  3870. LmtUsedFlag string `json:"lmt_used_flag"`
  3871. MedChrgitmType string `json:"med_chrgitm_type"`
  3872. Memo string `json:"memo"`
  3873. OverlmtAmt float64 `json:"overlmt_amt"`
  3874. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3875. Pric float64 `json:"pric"`
  3876. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3877. SelfpayProp float64 `json:"selfpay_prop"`
  3878. } `json:"result"`
  3879. } `json:"output"`
  3880. RefmsgTime string `json:"refmsg_time"`
  3881. RespondTime string `json:"respond_time"`
  3882. Signtype string `json:"signtype"`
  3883. WarnMsg string `json:"warn_msg"`
  3884. }
  3885. type ResultFive struct {
  3886. Balc float64 `json:"balc"`
  3887. CvlservFlag string `json:"cvlserv_flag"`
  3888. EmpName string `json:"emp_name"`
  3889. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3890. Insutype string `json:"insutype"`
  3891. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3892. PausInsuDate string `json:"paus_insu_date"`
  3893. PsnInsuDate string `json:"psn_insu_date"`
  3894. PsnInsuStas string `json:"psn_insu_stas"`
  3895. PsnType string `json:"psn_type"`
  3896. }
  3897. type ResultSix struct {
  3898. Cainfo interface{} `json:"cainfo"`
  3899. ErrMsg string `json:"err_msg"`
  3900. InfRefmsgid string `json:"inf_refmsgid"`
  3901. Infcode int64 `json:"infcode"`
  3902. RefmsgTime string `json:"refmsg_time"`
  3903. RespondTime string `json:"respond_time"`
  3904. Signtype interface{} `json:"signtype"`
  3905. WarnMsg interface{} `json:"warn_msg"`
  3906. }
  3907. type ResultSix10265 struct {
  3908. Cainfo interface{} `json:"cainfo"`
  3909. ErrMsg string `json:"err_msg"`
  3910. InfRefmsgid string `json:"inf_refmsgid"`
  3911. Infcode string `json:"infcode"`
  3912. Output struct {
  3913. } `json:"output"`
  3914. RefmsgTime string `json:"refmsg_time"`
  3915. RespondTime string `json:"respond_time"`
  3916. Signtype interface{} `json:"signtype"`
  3917. WarnMsg interface{} `json:"warn_msg"`
  3918. }
  3919. type ResultSeven struct {
  3920. Cainfo string `json:"cainfo"`
  3921. ErrMsg string `json:"err_msg"`
  3922. InfRefmsgid string `json:"inf_refmsgid"`
  3923. Infcode int64 `json:"infcode"`
  3924. Output struct {
  3925. Setldetail []interface{} `json:"setldetail"`
  3926. Setlinfo struct {
  3927. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3928. AcctPay float64 `json:"acct_pay"`
  3929. ActPayDedc float64 `json:"act_pay_dedc"`
  3930. Age float64 `json:"age"`
  3931. Balc float64 `json:"balc"`
  3932. Brdy string `json:"brdy"`
  3933. Certno string `json:"certno"`
  3934. ClrOptins string `json:"clr_optins"`
  3935. ClrType string `json:"clr_type"`
  3936. ClrWay string `json:"clr_way"`
  3937. CvlservFlag string `json:"cvlserv_flag"`
  3938. CvlservPay float64 `json:"cvlserv_pay"`
  3939. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3940. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3941. Gend string `json:"gend"`
  3942. HifesPay float64 `json:"hifes_pay"`
  3943. HifmiPay float64 `json:"hifmi_pay"`
  3944. HifpPay float64 `json:"hifp_pay"`
  3945. HospPartAmt float64 `json:"hosp_part_amt"`
  3946. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3947. Insutype string `json:"insutype"`
  3948. MafPay float64 `json:"maf_pay"`
  3949. MdtrtCertType string `json:"mdtrt_cert_type"`
  3950. HifobPay float64 `json:"hifob_pay"`
  3951. MdtrtID string `json:"mdtrt_id"`
  3952. MedType string `json:"med_type"`
  3953. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3954. MedinsSetlID string `json:"medins_setl_id"`
  3955. Naty string `json:"naty"`
  3956. OthPay float64 `json:"oth_pay"`
  3957. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3958. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3959. PsnCashPay float64 `json:"psn_cash_pay"`
  3960. PsnCertType string `json:"psn_cert_type"`
  3961. PsnName string `json:"psn_name"`
  3962. PsnNo string `json:"psn_no"`
  3963. PsnPartAmt float64 `json:"psn_part_amt"`
  3964. PsnType string `json:"psn_type"`
  3965. SetlID string `json:"setl_id"`
  3966. SetlTime string `json:"setl_time"`
  3967. } `json:"setlinfo"`
  3968. } `json:"output"`
  3969. RefmsgTime string `json:"refmsg_time"`
  3970. RespondTime string `json:"respond_time"`
  3971. Signtype interface{} `json:"signtype"`
  3972. WarnMsg interface{} `json:"warn_msg"`
  3973. }
  3974. type ResultSeven10265 struct {
  3975. Cainfo string `json:"cainfo"`
  3976. ErrMsg string `json:"err_msg"`
  3977. InfRefmsgid string `json:"inf_refmsgid"`
  3978. Infcode string `json:"infcode"`
  3979. Output struct {
  3980. Setldetail []interface{} `json:"setldetail"`
  3981. Setlinfo struct {
  3982. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3983. AcctPay float64 `json:"acct_pay"`
  3984. ActPayDedc float64 `json:"act_pay_dedc"`
  3985. Age float64 `json:"age"`
  3986. Balc float64 `json:"balc"`
  3987. Brdy string `json:"brdy"`
  3988. Certno string `json:"certno"`
  3989. ClrOptins string `json:"clr_optins"`
  3990. ClrType string `json:"clr_type"`
  3991. ClrWay string `json:"clr_way"`
  3992. CvlservFlag string `json:"cvlserv_flag"`
  3993. CvlservPay float64 `json:"cvlserv_pay"`
  3994. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3995. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3996. Gend string `json:"gend"`
  3997. HifesPay float64 `json:"hifes_pay"`
  3998. HifmiPay float64 `json:"hifmi_pay"`
  3999. HifpPay float64 `json:"hifp_pay"`
  4000. HospPartAmt float64 `json:"hosp_part_amt"`
  4001. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4002. Insutype string `json:"insutype"`
  4003. MafPay float64 `json:"maf_pay"`
  4004. MdtrtCertType string `json:"mdtrt_cert_type"`
  4005. HifobPay float64 `json:"hifob_pay"`
  4006. MdtrtID string `json:"mdtrt_id"`
  4007. MedType string `json:"med_type"`
  4008. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4009. MedinsSetlID string `json:"medins_setl_id"`
  4010. Naty string `json:"naty"`
  4011. OthPay float64 `json:"oth_pay"`
  4012. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4013. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4014. PsnCashPay float64 `json:"psn_cash_pay"`
  4015. PsnCertType string `json:"psn_cert_type"`
  4016. PsnName string `json:"psn_name"`
  4017. PsnNo string `json:"psn_no"`
  4018. PsnPartAmt float64 `json:"psn_part_amt"`
  4019. PsnType string `json:"psn_type"`
  4020. SetlID string `json:"setl_id"`
  4021. SetlTime string `json:"setl_time"`
  4022. } `json:"setlinfo"`
  4023. } `json:"output"`
  4024. RefmsgTime string `json:"refmsg_time"`
  4025. RespondTime string `json:"respond_time"`
  4026. Signtype interface{} `json:"signtype"`
  4027. WarnMsg interface{} `json:"warn_msg"`
  4028. }
  4029. type ResultEight struct {
  4030. Cainfo string `json:"cainfo"`
  4031. ErrMsg string `json:"err_msg"`
  4032. InfRefmsgid string `json:"inf_refmsgid"`
  4033. Infcode int64 `json:"infcode"`
  4034. Output struct {
  4035. Stmtinfo struct {
  4036. SetlOptins string `json:"setl_optins"`
  4037. StmtRslt string `json:"stmt_rslt"`
  4038. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  4039. } `json:"stmtinfo"`
  4040. } `json:"output"`
  4041. RefmsgTime string `json:"refmsg_time"`
  4042. RespondTime string `json:"respond_time"`
  4043. Signtype interface{} `json:"signtype"`
  4044. WarnMsg interface{} `json:"warn_msg"`
  4045. }
  4046. type ResultEightFor10188 struct {
  4047. Cainfo string `json:"cainfo"`
  4048. ErrMsg string `json:"err_msg"`
  4049. InfRefmsgid string `json:"inf_refmsgid"`
  4050. Infcode string `json:"infcode"`
  4051. Output struct {
  4052. Stmtinfo struct {
  4053. SetlOptins string `json:"setl_optins"`
  4054. StmtRslt string `json:"stmt_rslt"`
  4055. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  4056. } `json:"stmtinfo"`
  4057. } `json:"output"`
  4058. RefmsgTime string `json:"refmsg_time"`
  4059. RespondTime string `json:"respond_time"`
  4060. Signtype interface{} `json:"signtype"`
  4061. WarnMsg interface{} `json:"warn_msg"`
  4062. }
  4063. type ResultNine struct {
  4064. Cainfo string `json:"cainfo"`
  4065. ErrMsg string `json:"err_msg"`
  4066. InfRefmsgid string `json:"inf_refmsgid"`
  4067. Infcode int64 `json:"infcode"`
  4068. Output struct {
  4069. FileQuryNo string `json:"file_qury_no"`
  4070. } `json:"output"`
  4071. RefmsgTime string `json:"refmsg_time"`
  4072. RespondTime string `json:"respond_time"`
  4073. Signtype interface{} `json:"signtype"`
  4074. WarnMsg interface{} `json:"warn_msg"`
  4075. }
  4076. type ResultTen struct {
  4077. Cainfo string `json:"cainfo"`
  4078. ErrMsg string `json:"err_msg"`
  4079. InfRefmsgid string `json:"inf_refmsgid"`
  4080. Infcode int64 `json:"infcode"`
  4081. Output struct {
  4082. DldEndtime string `json:"dld_endtime"`
  4083. FileQuryNo string `json:"file_qury_no"`
  4084. Filename string `json:"filename"`
  4085. } `json:"output"`
  4086. RefmsgTime string `json:"refmsg_time"`
  4087. RespondTime string `json:"respond_time"`
  4088. Signtype interface{} `json:"signtype"`
  4089. WarnMsg interface{} `json:"warn_msg"`
  4090. }
  4091. //type Autogenerated struct {
  4092. // Output struct {
  4093. // Setlinfo struct {
  4094. // SetlTime string `json:"setl_time"`
  4095. // CvlservPay float64 `json:"cvlserv_pay"`
  4096. // Year string `json:"year"`
  4097. // MedType string `json:"med_type"`
  4098. // PsnPay float64 `json:"psn_pay"`
  4099. // OpterID string `json:"opter_id"`
  4100. // Begndate string `json:"begndate"`
  4101. // FlxempeFlag string `json:"flxempe_flag"`
  4102. // HifmiPay float64 `json:"hifmi_pay"`
  4103. // PsnNo string `json:"psn_no"`
  4104. // ActPayDedc float64 `json:"act_pay_dedc"`
  4105. // MedinsSetlID interface{} `json:"medins_setl_id"`
  4106. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4107. // ClrWay string `json:"clr_way"`
  4108. // OthPay float64 `json:"oth_pay"`
  4109. // Gend string `json:"gend"`
  4110. // MdtrtID string `json:"mdtrt_id"`
  4111. // AcctPay float64 `json:"acct_pay"`
  4112. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  4113. // Insutype string `json:"insutype"`
  4114. // Invono interface{} `json:"invono"`
  4115. // Enddate string `json:"enddate"`
  4116. // CashPayamt float64 `json:"cash_payamt"`
  4117. // PsnType string `json:"psn_type"`
  4118. // FixmedinsName string `json:"fixmedins_name"`
  4119. // HifpPay float64 `json:"hifp_pay"`
  4120. // NewFlag interface{} `json:"new_flag"`
  4121. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4122. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  4123. // PayLoc string `json:"pay_loc"`
  4124. // ClrType string `json:"clr_type"`
  4125. // RefdSetlFlag string `json:"refd_setl_flag"`
  4126. // CvlservFlag string `json:"cvlserv_flag"`
  4127. // EmpName string `json:"emp_name"`
  4128. // Brdy string `json:"brdy"`
  4129. // Naty string `json:"naty"`
  4130. // Certno string `json:"certno"`
  4131. // DiseCode string `json:"dise_code"`
  4132. // FixmedinsCode string `json:"fixmedins_code"`
  4133. // DedcHospLv string `json:"dedc_hosp_lv"`
  4134. // OpterName string `json:"opter_name"`
  4135. // Balc float64 `json:"balc"`
  4136. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4137. // PsnCertType string `json:"psn_cert_type"`
  4138. // HifobPay float64 `json:"hifob_pay"`
  4139. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  4140. // HifesPay float64 `json:"hifes_pay"`
  4141. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4142. // OptTime string `json:"opt_time"`
  4143. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4144. // SetlID string `json:"setl_id"`
  4145. // MafPay float64 `json:"maf_pay"`
  4146. // PsnName string `json:"psn_name"`
  4147. // InsuOptins interface{} `json:"insu_optins"`
  4148. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4149. // ClrOptins string `json:"clr_optins"`
  4150. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4151. // DiseName string `json:"dise_name"`
  4152. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4153. // Age float64 `json:"age"`
  4154. // DtrtCertType string `json:"dtrt_cert_type"`
  4155. // HospLv string `json:"hosp_lv"`
  4156. // } `json:"setlinfo"`
  4157. // Setldetail []struct {
  4158. // FundPayType string `json:"fund_pay_type"`
  4159. // FundPayamt float64 `json:"fund_payamt"`
  4160. // SetlProcInfo interface{} `json:"setl_proc_info"`
  4161. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  4162. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  4163. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  4164. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4165. // } `json:"setldetail"`
  4166. // } `json:"output"`
  4167. // Infcode int `json:"infcode"`
  4168. // WarnMsg interface{} `json:"warn_msg"`
  4169. // Cainfo interface{} `json:"cainfo"`
  4170. // ErrMsg interface{} `json:"err_msg"`
  4171. // RefmsgTime string `json:"refmsg_time"`
  4172. // Signtype interface{} `json:"signtype"`
  4173. // RespondTime string `json:"respond_time"`
  4174. // InfRefmsgid string `json:"inf_refmsgid"`
  4175. //}
  4176. type ResultEleven struct {
  4177. Cainfo string `json:"cainfo"`
  4178. ErrMsg string `json:"err_msg"`
  4179. InfRefmsgid string `json:"inf_refmsgid"`
  4180. Infcode int64 `json:"infcode"`
  4181. Output struct {
  4182. Setlinfo struct {
  4183. SetlTime string `json:"setl_time"`
  4184. CvlservPay float64 `json:"cvlserv_pay"`
  4185. Year string `json:"year"`
  4186. MedType string `json:"med_type"`
  4187. PsnPay float64 `json:"psn_pay"`
  4188. OpterID string `json:"opter_id"`
  4189. Begndate string `json:"begndate"`
  4190. FlxempeFlag string `json:"flxempe_flag"`
  4191. HifmiPay float64 `json:"hifmi_pay"`
  4192. PsnNo string `json:"psn_no"`
  4193. ActPayDedc float64 `json:"act_pay_dedc"`
  4194. MedinsSetlID interface{} `json:"medins_setl_id"`
  4195. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4196. ClrWay string `json:"clr_way"`
  4197. OthPay float64 `json:"oth_pay"`
  4198. Gend string `json:"gend"`
  4199. MdtrtID string `json:"mdtrt_id"`
  4200. AcctPay float64 `json:"acct_pay"`
  4201. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4202. Insutype string `json:"insutype"`
  4203. Invono interface{} `json:"invono"`
  4204. Enddate string `json:"enddate"`
  4205. CashPayamt float64 `json:"cash_payamt"`
  4206. PsnType string `json:"psn_type"`
  4207. FixmedinsName string `json:"fixmedins_name"`
  4208. HifpPay float64 `json:"hifp_pay"`
  4209. NewFlag interface{} `json:"new_flag"`
  4210. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4211. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4212. PayLoc string `json:"pay_loc"`
  4213. ClrType string `json:"clr_type"`
  4214. RefdSetlFlag string `json:"refd_setl_flag"`
  4215. CvlservFlag string `json:"cvlserv_flag"`
  4216. EmpName string `json:"emp_name"`
  4217. Brdy string `json:"brdy"`
  4218. Naty string `json:"naty"`
  4219. Certno string `json:"certno"`
  4220. DiseCode string `json:"dise_code"`
  4221. FixmedinsCode string `json:"fixmedins_code"`
  4222. DedcHospLv string `json:"dedc_hosp_lv"`
  4223. OpterName string `json:"opter_name"`
  4224. Balc float64 `json:"balc"`
  4225. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4226. PsnCertType string `json:"psn_cert_type"`
  4227. HifobPay float64 `json:"hifob_pay"`
  4228. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4229. HifesPay float64 `json:"hifes_pay"`
  4230. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4231. OptTime string `json:"opt_time"`
  4232. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4233. SetlID string `json:"setl_id"`
  4234. MafPay float64 `json:"maf_pay"`
  4235. PsnName string `json:"psn_name"`
  4236. InsuOptins interface{} `json:"insu_optins"`
  4237. PrefFundPay interface{} `json:"pref_fund_pay"`
  4238. ClrOptins string `json:"clr_optins"`
  4239. DiseName string `json:"dise_name"`
  4240. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4241. Age float64 `json:"age"`
  4242. DtrtCertType string `json:"dtrt_cert_type"`
  4243. HospLv string `json:"hosp_lv"`
  4244. } `json:"setlinfo"`
  4245. } `json:"output"`
  4246. RefmsgTime string `json:"refmsg_time"`
  4247. RespondTime string `json:"respond_time"`
  4248. Signtype interface{} `json:"signtype"`
  4249. WarnMsg interface{} `json:"warn_msg"`
  4250. }
  4251. type ResultEleven10265 struct {
  4252. Cainfo string `json:"cainfo"`
  4253. ErrMsg string `json:"err_msg"`
  4254. InfRefmsgid string `json:"inf_refmsgid"`
  4255. Infcode string `json:"infcode"`
  4256. Output struct {
  4257. Setlinfo struct {
  4258. SetlTime string `json:"setl_time"`
  4259. CvlservPay float64 `json:"cvlserv_pay"`
  4260. Year string `json:"year"`
  4261. MedType string `json:"med_type"`
  4262. PsnPay float64 `json:"psn_pay"`
  4263. OpterID string `json:"opter_id"`
  4264. Begndate string `json:"begndate"`
  4265. FlxempeFlag string `json:"flxempe_flag"`
  4266. HifmiPay float64 `json:"hifmi_pay"`
  4267. PsnNo string `json:"psn_no"`
  4268. ActPayDedc float64 `json:"act_pay_dedc"`
  4269. MedinsSetlID interface{} `json:"medins_setl_id"`
  4270. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4271. ClrWay string `json:"clr_way"`
  4272. OthPay float64 `json:"oth_pay"`
  4273. Gend string `json:"gend"`
  4274. MdtrtID string `json:"mdtrt_id"`
  4275. AcctPay float64 `json:"acct_pay"`
  4276. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4277. Insutype string `json:"insutype"`
  4278. Invono interface{} `json:"invono"`
  4279. Enddate string `json:"enddate"`
  4280. CashPayamt float64 `json:"cash_payamt"`
  4281. PsnType string `json:"psn_type"`
  4282. FixmedinsName string `json:"fixmedins_name"`
  4283. HifpPay float64 `json:"hifp_pay"`
  4284. NewFlag interface{} `json:"new_flag"`
  4285. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4286. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4287. PayLoc string `json:"pay_loc"`
  4288. ClrType string `json:"clr_type"`
  4289. RefdSetlFlag string `json:"refd_setl_flag"`
  4290. CvlservFlag string `json:"cvlserv_flag"`
  4291. EmpName string `json:"emp_name"`
  4292. Brdy string `json:"brdy"`
  4293. Naty string `json:"naty"`
  4294. Certno string `json:"certno"`
  4295. DiseCode string `json:"dise_code"`
  4296. FixmedinsCode string `json:"fixmedins_code"`
  4297. DedcHospLv string `json:"dedc_hosp_lv"`
  4298. OpterName string `json:"opter_name"`
  4299. Balc float64 `json:"balc"`
  4300. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4301. PsnCertType string `json:"psn_cert_type"`
  4302. HifobPay float64 `json:"hifob_pay"`
  4303. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4304. HifesPay float64 `json:"hifes_pay"`
  4305. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4306. OptTime string `json:"opt_time"`
  4307. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4308. SetlID string `json:"setl_id"`
  4309. MafPay float64 `json:"maf_pay"`
  4310. PsnName string `json:"psn_name"`
  4311. InsuOptins interface{} `json:"insu_optins"`
  4312. PrefFundPay interface{} `json:"pref_fund_pay"`
  4313. ClrOptins string `json:"clr_optins"`
  4314. DiseName string `json:"dise_name"`
  4315. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4316. Age float64 `json:"age"`
  4317. DtrtCertType string `json:"dtrt_cert_type"`
  4318. HospLv string `json:"hosp_lv"`
  4319. } `json:"setlinfo"`
  4320. } `json:"output"`
  4321. RefmsgTime string `json:"refmsg_time"`
  4322. RespondTime string `json:"respond_time"`
  4323. Signtype interface{} `json:"signtype"`
  4324. WarnMsg interface{} `json:"warn_msg"`
  4325. }
  4326. type ResultTwelve struct {
  4327. Cainfo string `json:"cainfo"`
  4328. ErrMsg string `json:"err_msg"`
  4329. InfRefmsgid string `json:"inf_refmsgid"`
  4330. Infcode int64 `json:"infcode"`
  4331. Output struct {
  4332. MdtrtId string `json:"mdtrt_id"`
  4333. ChrgBchno string `json:"chrg_bchno"`
  4334. PsnNo string `json:"psn_no"`
  4335. } `json:"output"`
  4336. RefmsgTime string `json:"refmsg_time"`
  4337. RespondTime string `json:"respond_time"`
  4338. Signtype interface{} `json:"signtype"`
  4339. WarnMsg interface{} `json:"warn_msg"`
  4340. }
  4341. type ResultThirteen struct {
  4342. ErrMsg string `json:"err_msg"`
  4343. InfRefmsgid string `json:"inf_refmsgid"`
  4344. Infcode int64 `json:"infcode"`
  4345. Output struct {
  4346. Result struct {
  4347. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4348. } `json:"result"`
  4349. } `json:"output"`
  4350. RefmsgTime string `json:"refmsg_time"`
  4351. RespondTime string `json:"respond_time"`
  4352. Signtype interface{} `json:"signtype"`
  4353. WarnInfo interface{} `json:"warn_info"`
  4354. }
  4355. type ResultThirteen10265 struct {
  4356. ErrMsg string `json:"err_msg"`
  4357. InfRefmsgid string `json:"inf_refmsgid"`
  4358. Infcode string `json:"infcode"`
  4359. Output struct {
  4360. Result struct {
  4361. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4362. } `json:"result"`
  4363. } `json:"output"`
  4364. RefmsgTime string `json:"refmsg_time"`
  4365. RespondTime string `json:"respond_time"`
  4366. Signtype interface{} `json:"signtype"`
  4367. WarnInfo interface{} `json:"warn_info"`
  4368. }
  4369. type ResultFourteen struct {
  4370. ErrMsg string `json:"err_msg"`
  4371. InfRefmsgid string `json:"inf_refmsgid"`
  4372. Infcode int64 `json:"infcode"`
  4373. Output struct {
  4374. } `json:"output"`
  4375. RefmsgTime string `json:"refmsg_time"`
  4376. RespondTime string `json:"respond_time"`
  4377. Signtype interface{} `json:"signtype"`
  4378. WarnInfo interface{} `json:"warn_info"`
  4379. }
  4380. type ResultFourteen10265 struct {
  4381. ErrMsg string `json:"err_msg"`
  4382. InfRefmsgid string `json:"inf_refmsgid"`
  4383. Infcode string `json:"infcode"`
  4384. Output struct {
  4385. } `json:"output"`
  4386. RefmsgTime string `json:"refmsg_time"`
  4387. RespondTime string `json:"respond_time"`
  4388. Signtype interface{} `json:"signtype"`
  4389. WarnInfo interface{} `json:"warn_info"`
  4390. }
  4391. type ResultSixteen struct {
  4392. Cainfo string `json:"cainfo"`
  4393. ErrMsg string `json:"err_msg"`
  4394. InfRefmsgid string `json:"inf_refmsgid"`
  4395. Infcode int64 `json:"infcode"`
  4396. Output struct {
  4397. Setldetail []interface{} `json:"setldetail"`
  4398. Setlinfo struct {
  4399. MdtrtID string `json:"mdtrt_id"`
  4400. SetlID string `json:"setl_id"`
  4401. ClrOptins string `json:"clr_optins"`
  4402. SetlTime string `json:"setl_time"`
  4403. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4404. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4405. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4406. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4407. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4408. ActPayDedc float64 `json:"act_pay_dedc"`
  4409. HifpPay float64 `json:"hifp_pay"`
  4410. Lfpay float64 `json:"selfpay"`
  4411. CvlservPay float64 `json:"cvlserv_pay"`
  4412. HifesPay float64 `json:"hifes_pay"`
  4413. HifmiPay float64 `json:"hifmi_pay"`
  4414. HifobPay float64 `json:"hifob_pay"`
  4415. MafPay float64 `json:"maf_pay"`
  4416. OthPay float64 `json:"oth_pay"`
  4417. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4418. PsnPartAmt float64 `json:"psn_part_amt"`
  4419. AcctPay float64 `json:"acct_pay"`
  4420. Balc float64 `json:"balc"`
  4421. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4422. HospPartAmt float64 `json:"hosp_part_amt"`
  4423. MedinsSetlID string `json:"medins_setl_id"`
  4424. PdnCashPay string `json:"pdn_cash_pay"`
  4425. } `json:"setlinfo"`
  4426. } `json:"output"`
  4427. RefmsgTime string `json:"refmsg_time"`
  4428. RespondTime string `json:"respond_time"`
  4429. Signtype interface{} `json:"signtype"`
  4430. WarnMsg interface{} `json:"warn_msg"`
  4431. }
  4432. type ResultSixteen10265 struct {
  4433. Cainfo string `json:"cainfo"`
  4434. ErrMsg string `json:"err_msg"`
  4435. InfRefmsgid string `json:"inf_refmsgid"`
  4436. Infcode string `json:"infcode"`
  4437. Output struct {
  4438. Setldetail []interface{} `json:"setldetail"`
  4439. Setlinfo struct {
  4440. MdtrtID string `json:"mdtrt_id"`
  4441. SetlID string `json:"setl_id"`
  4442. ClrOptins string `json:"clr_optins"`
  4443. SetlTime string `json:"setl_time"`
  4444. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4445. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4446. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4447. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4448. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4449. ActPayDedc float64 `json:"act_pay_dedc"`
  4450. HifpPay float64 `json:"hifp_pay"`
  4451. Lfpay float64 `json:"selfpay"`
  4452. CvlservPay float64 `json:"cvlserv_pay"`
  4453. HifesPay float64 `json:"hifes_pay"`
  4454. HifmiPay float64 `json:"hifmi_pay"`
  4455. HifobPay float64 `json:"hifob_pay"`
  4456. MafPay float64 `json:"maf_pay"`
  4457. OthPay float64 `json:"oth_pay"`
  4458. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4459. PsnPartAmt float64 `json:"psn_part_amt"`
  4460. AcctPay float64 `json:"acct_pay"`
  4461. Balc float64 `json:"balc"`
  4462. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4463. HospPartAmt float64 `json:"hosp_part_amt"`
  4464. MedinsSetlID string `json:"medins_setl_id"`
  4465. PdnCashPay string `json:"pdn_cash_pay"`
  4466. } `json:"setlinfo"`
  4467. } `json:"output"`
  4468. RefmsgTime string `json:"refmsg_time"`
  4469. RespondTime string `json:"respond_time"`
  4470. Signtype interface{} `json:"signtype"`
  4471. WarnMsg interface{} `json:"warn_msg"`
  4472. }
  4473. type ResultSeventeen struct {
  4474. ErrMsg string `json:"err_msg"`
  4475. InfRefmsgid string `json:"inf_refmsgid"`
  4476. Infcode int64 `json:"infcode"`
  4477. Output struct {
  4478. SetlListId string `json:"setl_list_id"`
  4479. } `json:"output"`
  4480. RefmsgTime string `json:"refmsg_time"`
  4481. RespondTime string `json:"respond_time"`
  4482. Signtype string `json:"signtype"`
  4483. WarnInfo string `json:"warn_info"`
  4484. }
  4485. type ResultSeventeenOther struct {
  4486. ErrMsg string `json:"err_msg"`
  4487. InfRefmsgid string `json:"inf_refmsgid"`
  4488. Infcode string `json:"infcode"`
  4489. Output struct {
  4490. SetlListId string `json:"setl_list_id"`
  4491. } `json:"output"`
  4492. RefmsgTime string `json:"refmsg_time"`
  4493. RespondTime string `json:"respond_time"`
  4494. Signtype string `json:"signtype"`
  4495. WarnInfo string `json:"warn_info"`
  4496. }
  4497. type Result90991 struct {
  4498. ErrMsg string `json:"err_msg"`
  4499. InfRefmsgid string `json:"inf_refmsgid"`
  4500. Infcode int64 `json:"infcode"`
  4501. Output struct {
  4502. Result struct {
  4503. PsnNo string `json:"psn_no"`
  4504. CardStat string `json:"card_stat"`
  4505. Certno string `json:"certno"`
  4506. PsnName string `json:"psn_name"`
  4507. CheckStat string `json:"check_stat"`
  4508. SscnoCheckStat string `json:"sscno_check_stat"`
  4509. } `json:"result"`
  4510. } `json:"output"`
  4511. RefmsgTime string `json:"refmsg_time"`
  4512. RespondTime string `json:"respond_time"`
  4513. Signtype interface{} `json:"signtype"`
  4514. WarnInfo interface{} `json:"warn_info"`
  4515. }
  4516. type Result90100 struct {
  4517. ErrMsg string `json:"err_msg"`
  4518. InfRefmsgid string `json:"inf_refmsgid"`
  4519. Infcode int64 `json:"infcode"`
  4520. Output struct {
  4521. PoolareaNo string `json:"poolarea_no"`
  4522. PoolareaNoName string `json:"poolarea_no_name"`
  4523. Insutype string `json:"insutype"`
  4524. InsutypeName string `json:"insutype_name"`
  4525. ClctType string `json:"clct_type"`
  4526. ClctTypeName string `json:"clct_type_name"`
  4527. ClctFlag string `json:"clct_flag"`
  4528. ClctFlagName string `json:"clct_flag_name"`
  4529. AccrymBegn string `json:"accrym_begn"`
  4530. AccrymEnd string `json:"accrym_end"`
  4531. ClctTime string `json:"clct_time"`
  4532. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  4533. } `json:"output"`
  4534. RefmsgTime string `json:"refmsg_time"`
  4535. RespondTime string `json:"respond_time"`
  4536. Signtype interface{} `json:"signtype"`
  4537. WarnInfo interface{} `json:"warn_info"`
  4538. }
  4539. type Custom struct {
  4540. DetItemFeeSumamt string
  4541. Cut string
  4542. FeedetlSn string
  4543. Price string
  4544. MedListCodg string
  4545. Type int64
  4546. AdviceId int64
  4547. ProjectId int64
  4548. ItemId int64
  4549. }
  4550. type Result5301 struct {
  4551. ErrMsg string `json:"err_msg"`
  4552. InfRefmsgid string `json:"inf_refmsgid"`
  4553. Infcode int64 `json:"infcode"`
  4554. Output struct {
  4555. Result []struct {
  4556. OpspDiseCode string `json:"opsp_dise_code"`
  4557. OpspDiseName string `json:"opsp_dise_name"`
  4558. Begndate string `json:"begndate"`
  4559. Enddate string `json:"enddate"`
  4560. } `json:"feedetail"`
  4561. } `json:"output"`
  4562. RefmsgTime string `json:"refmsg_time"`
  4563. RespondTime string `json:"respond_time"`
  4564. Signtype interface{} `json:"signtype"`
  4565. WarnInfo interface{} `json:"warn_info"`
  4566. }
  4567. type Result5301For10265 struct {
  4568. ErrMsg string `json:"err_msg"`
  4569. InfRefmsgid string `json:"inf_refmsgid"`
  4570. Infcode string `json:"infcode"`
  4571. Output struct {
  4572. Result []struct {
  4573. OpspDiseCode string `json:"opsp_dise_code"`
  4574. OpspDiseName string `json:"opsp_dise_name"`
  4575. Begndate string `json:"begndate"`
  4576. Enddate string `json:"enddate"`
  4577. } `json:"feedetail"`
  4578. } `json:"output"`
  4579. RefmsgTime string `json:"refmsg_time"`
  4580. RespondTime string `json:"respond_time"`
  4581. Signtype interface{} `json:"signtype"`
  4582. WarnInfo interface{} `json:"warn_info"`
  4583. }
  4584. //获取个人信息----挂号-----上传就诊信息
  4585. func (c *HisApiController) GetRegisterInfo() {
  4586. id, _ := c.GetInt64("id")
  4587. record_time := c.GetString("record_time")
  4588. settlementValue, _ := c.GetInt64("settlement_value")
  4589. medical_insurance_card := c.GetString("medical_insurance_card")
  4590. name := c.GetString("name")
  4591. id_card_type, _ := c.GetInt64("id_card_type")
  4592. certificates, _ := c.GetInt64("certificates")
  4593. medical_care, _ := c.GetInt64("medical_care")
  4594. birthday := c.GetString("birthday")
  4595. id_card := c.GetString("id_card")
  4596. register_type, _ := c.GetInt64("register")
  4597. doctor, _ := c.GetInt64("doctor")
  4598. department, _ := c.GetInt64("department")
  4599. gender, _ := c.GetInt64("sex")
  4600. registration_fee, _ := c.GetFloat("registration_fee")
  4601. medical_expenses, _ := c.GetFloat("medical_expenses")
  4602. social_type, _ := c.GetInt64("social_type")
  4603. med_type := c.GetString("social_type")
  4604. admin_user_id, _ := c.GetInt64("admin_user_id")
  4605. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4606. timeLayout := "2006-01-02"
  4607. loc, _ := time.LoadLocation("Local")
  4608. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4609. birthUnix := birthdays.Unix()
  4610. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4611. if err != nil {
  4612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4613. return
  4614. }
  4615. recordDateTime := theTime.Unix()
  4616. adminInfo := c.GetAdminUserInfo()
  4617. var patient service.Patients
  4618. if id == 0 {
  4619. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4620. } else {
  4621. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4622. }
  4623. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4624. if patientPrescription.ID == 0 {
  4625. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4626. }
  4627. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4628. if patient.ID == 0 {
  4629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4630. return
  4631. }
  4632. if len(patient.IdCardNo) == 0 {
  4633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4634. return
  4635. }
  4636. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4637. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4638. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4639. //就诊结算未完成,不能进行二次挂号
  4640. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4641. if len(his) >= 1 {
  4642. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  4643. if len(his) >= 1 && order.ID == 0 {
  4644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  4645. return
  4646. }
  4647. }
  4648. //var register_log string
  4649. if config.IsOpen == 1 {
  4650. var res ResultTwo
  4651. var res10265 ResultTwo10265
  4652. var PsnNo string
  4653. var PsnCertType string
  4654. var Certno string
  4655. var PsnName string
  4656. var Gend string
  4657. var Naty string
  4658. var Brdy string
  4659. var Age float64
  4660. var infoStr string
  4661. var idetinfoStr string
  4662. var infocode int64
  4663. var verify_number string
  4664. fmt.Println(verify_number)
  4665. if miConfig.MdtrtareaAdmvs == "421300" {
  4666. psn_info, _ := service.GetPsnByPatientId(id)
  4667. PsnNo = psn_info.PsnNo
  4668. PsnCertType = psn_info.PsnCertType
  4669. Certno = psn_info.Certno
  4670. PsnName = psn_info.PsnName
  4671. Gend = psn_info.Gend
  4672. Naty = psn_info.Naty
  4673. Brdy = psn_info.Brdy
  4674. Age = psn_info.Age
  4675. infoStr = psn_info.Insuinfo
  4676. idetinfoStr = psn_info.Idetinfo
  4677. infocode = 0
  4678. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4679. psn_info, _ := service.GetPsnByPatientId(id)
  4680. PsnNo = psn_info.PsnNo
  4681. PsnCertType = psn_info.PsnCertType
  4682. Certno = psn_info.Certno
  4683. PsnName = psn_info.PsnName
  4684. Gend = psn_info.Gend
  4685. Naty = psn_info.Naty
  4686. Brdy = psn_info.Brdy
  4687. Age = psn_info.Age
  4688. infoStr = psn_info.Insuinfo
  4689. idetinfoStr = psn_info.Idetinfo
  4690. infocode = 0
  4691. verify_number = psn_info.VerifyNumber
  4692. } else {
  4693. var result string
  4694. var requestLog string
  4695. if miConfig.UserOrgId == 10138 {
  4696. 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)
  4697. } else {
  4698. 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)
  4699. }
  4700. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4701. if miConfig.Code == "H15049901371" {
  4702. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4703. utils.ErrorLog("解析失败:%v", err)
  4704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4705. return
  4706. }
  4707. res.ErrMsg = res10265.ErrMsg
  4708. //res.Output = res10265.Output
  4709. res.InfRefmsgid = res10265.InfRefmsgid
  4710. } else {
  4711. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4712. utils.ErrorLog("解析失败:%v", err)
  4713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4714. return
  4715. }
  4716. }
  4717. PsnNo = res.Output[0].Baseinfo.PsnNo
  4718. PsnCertType = res.Output[0].Baseinfo.PsnCertType
  4719. Certno = res.Output[0].Baseinfo.Certno
  4720. PsnName = res.Output[0].Baseinfo.PsnName
  4721. Gend = res.Output[0].Baseinfo.Gend
  4722. Naty = res.Output[0].Baseinfo.Naty
  4723. Brdy = res.Output[0].Baseinfo.Brdy
  4724. Age = res.Output[0].Baseinfo.Age
  4725. Iinfos, _ := json.Marshal(res.Output[0].Iinfo)
  4726. Idetinfos, _ := json.Marshal(res.Output[0].Idetinfo)
  4727. infoStr = string(Iinfos)
  4728. idetinfoStr = string(Idetinfos)
  4729. if miConfig.Code == "H15049901371" {
  4730. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  4731. } else {
  4732. infocode = res.Infcode
  4733. }
  4734. }
  4735. if infocode == 0 {
  4736. his := models.VMHisPatient{
  4737. Name: name,
  4738. Gender: gender,
  4739. Birthday: birthUnix,
  4740. MedicalTreatmentType: medical_care,
  4741. IdType: certificates,
  4742. IdCardNo: id_card,
  4743. BalanceAccountsType: settlementValue,
  4744. SocialType: social_type,
  4745. MedicalInsuranceNumber: medical_insurance_card,
  4746. RegisterType: register_type,
  4747. RegisterCost: registration_fee,
  4748. TreatmentCost: medical_expenses,
  4749. Status: 1,
  4750. Ctime: time.Now().Unix(),
  4751. Mtime: time.Now().Unix(),
  4752. PsnNo: PsnNo,
  4753. PsnCertType: PsnCertType,
  4754. Certno: Certno,
  4755. PsnName: PsnName,
  4756. Gend: Gend,
  4757. Naty: Naty,
  4758. Brdy: Brdy,
  4759. Age: Age,
  4760. Iinfo: infoStr,
  4761. Idetinfo: idetinfoStr,
  4762. PatientId: patient.ID,
  4763. RecordDate: theTime.Unix(),
  4764. UserOrgId: adminInfo.CurrentOrgId,
  4765. AdminUserId: admin_user_id,
  4766. IsReturn: 1,
  4767. IdCardType: id_card_type,
  4768. Doctor: doctor,
  4769. Departments: department,
  4770. }
  4771. timestamp := time.Now().Unix()
  4772. tempTime := time.Unix(timestamp, 0)
  4773. timeFormat := tempTime.Format("20060102150405")
  4774. chrgBchno := rand.Intn(100000) + 10000
  4775. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4776. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  4777. department, _ := service.GetDepartMentDetail(department)
  4778. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  4779. IdCardNo := ""
  4780. if id_card_type == 1 {
  4781. // IdCardNo = medical_insurance_card
  4782. IdCardNo = patient.IdCardNo
  4783. } else {
  4784. IdCardNo = patient.IdCardNo
  4785. }
  4786. var rf []*ResultFive
  4787. json.Unmarshal([]byte(his.Iinfo), &rf)
  4788. var insutypes []*ResultFive
  4789. var insutype string
  4790. var insuplc_admdvs_temp string
  4791. var is390 int = 0
  4792. var is310 int = 0
  4793. for _, item := range rf {
  4794. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4795. insutypes = append(insutypes, item)
  4796. }
  4797. }
  4798. if len(insutypes) == 1 {
  4799. insutype = insutypes[0].Insutype
  4800. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4801. } else {
  4802. for _, i := range insutypes {
  4803. if i.Insutype == "390" {
  4804. is390 = 1
  4805. }
  4806. if i.Insutype == "310" {
  4807. is310 = 1
  4808. }
  4809. }
  4810. }
  4811. if is390 == 1 {
  4812. insutype = "390"
  4813. }
  4814. if is310 == 1 {
  4815. insutype = "310"
  4816. }
  4817. if len(insutypes) == 0 {
  4818. insutype = "310"
  4819. }
  4820. if len(insutypes) == 2 {
  4821. insutype = med_type
  4822. }
  4823. if len(med_type) > 0 {
  4824. insutype = med_type
  4825. }
  4826. //for _, item := range rf {
  4827. // if item.Insutype == insutype {
  4828. // insuplc_admdvs = item.InsuplcAdmdvs
  4829. // }
  4830. //}
  4831. var infocode int64
  4832. var resThree ResultThree
  4833. var resThree10265 ResultThree10265
  4834. if len(insuplc_admdvs) == 0 {
  4835. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  4836. } else {
  4837. insuplc_admdvs_temp = insuplc_admdvs
  4838. }
  4839. if miConfig.MdtrtareaAdmvs == "421300" {
  4840. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  4841. "&org_name=" + miConfig.OrgName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4842. "&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
  4843. resp, requestErr := http.Get(api)
  4844. if requestErr != nil {
  4845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4846. return
  4847. }
  4848. body, ioErr := ioutil.ReadAll(resp.Body)
  4849. if ioErr != nil {
  4850. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4852. return
  4853. }
  4854. var respJSON map[string]interface{}
  4855. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4856. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4858. return
  4859. }
  4860. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4861. result, _ := json.Marshal(respJSON)
  4862. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4863. utils.ErrorLog("解析失败:%v", err)
  4864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4865. return
  4866. }
  4867. infocode = resThree.Infcode
  4868. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4869. psn_info, _ := service.GetPsnByPatientId(id)
  4870. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4871. var cert_no string
  4872. if id_card_type == 3 {
  4873. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  4874. cert_no = IdCardNo
  4875. } else if id_card_type == 4 {
  4876. cert_no = IdCardNo
  4877. psn_info.VerifyNumber = psn_info.VerifyNumber
  4878. } else {
  4879. bas := strings.Split(psn_info.CardInfo, "|")
  4880. cert_no = bas[2]
  4881. }
  4882. var api string
  4883. if miConfig.MdtrtareaAdmvs == "320921" {
  4884. api = "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4885. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4886. "&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
  4887. } else {
  4888. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4889. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4890. "&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
  4891. }
  4892. resp, requestErr := http.Get(api)
  4893. if requestErr != nil {
  4894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4895. return
  4896. }
  4897. body, ioErr := ioutil.ReadAll(resp.Body)
  4898. if ioErr != nil {
  4899. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4901. return
  4902. }
  4903. var respJSON map[string]interface{}
  4904. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4905. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4907. return
  4908. }
  4909. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4910. result, _ := json.Marshal(respJSON)
  4911. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4912. utils.ErrorLog("解析失败:%v", err)
  4913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4914. return
  4915. }
  4916. resThree.ErrMsg = resThree10265.ErrMsg
  4917. resThree.Output = resThree10265.Output
  4918. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4919. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4920. } else {
  4921. result, requestLog := service.Gdyb2201ForGz(res.Output[0].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)
  4922. saveLog(result, requestLog, "2201A", "挂号")
  4923. if miConfig.Code == "H15049901371" {
  4924. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4925. utils.ErrorLog("解析失败:%v", err)
  4926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4927. return
  4928. }
  4929. resThree.ErrMsg = resThree10265.ErrMsg
  4930. resThree.Output = resThree10265.Output
  4931. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4932. } else {
  4933. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4934. utils.ErrorLog("解析失败:%v", err)
  4935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4936. return
  4937. }
  4938. }
  4939. if miConfig.Code == "H15049901371" {
  4940. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4941. } else {
  4942. infocode = resThree.Infcode
  4943. }
  4944. }
  4945. if infocode != 0 {
  4946. adminUser := c.GetAdminUserInfo()
  4947. errlog := &models.HisOrderError{
  4948. UserOrgId: adminUser.CurrentOrgId,
  4949. Ctime: time.Now().Unix(),
  4950. Mtime: time.Now().Unix(),
  4951. ErrMsg: resThree.ErrMsg,
  4952. Status: 1,
  4953. PatientId: id,
  4954. RecordTime: recordDateTime,
  4955. Stage: 2,
  4956. }
  4957. service.CreateErrMsgLog(errlog)
  4958. c.ServeSuccessJSON(map[string]interface{}{
  4959. "failed_code": -10,
  4960. "msg": resThree.ErrMsg,
  4961. })
  4962. return
  4963. }
  4964. his.Number = resThree.Output.Data.MdtrtID
  4965. his.PsnNo = resThree.Output.Data.PsnNo
  4966. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  4967. his.IdCardNo = patient.IdCardNo
  4968. his.PhoneNumber = patient.Phone
  4969. his.UserOrgId = adminInfo.CurrentOrgId
  4970. his.Insutype = insutype
  4971. his.Ctime = time.Now().Unix()
  4972. his.Mtime = time.Now().Unix()
  4973. his.InsuplcAdmdvs = insuplc_admdvs_temp
  4974. his.Status = 1
  4975. service.UpdateHisPatientStatus(&his)
  4976. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  4977. c.ServeSuccessJSON(map[string]interface{}{
  4978. "his_info": his,
  4979. })
  4980. } else {
  4981. adminUser := c.GetAdminUserInfo()
  4982. errlog := &models.HisOrderError{
  4983. UserOrgId: adminUser.CurrentOrgId,
  4984. Ctime: time.Now().Unix(),
  4985. Mtime: time.Now().Unix(),
  4986. ErrMsg: res.ErrMsg,
  4987. Status: 1,
  4988. PatientId: id,
  4989. RecordTime: recordDateTime,
  4990. Stage: 1,
  4991. }
  4992. service.CreateErrMsgLog(errlog)
  4993. c.ServeSuccessJSON(map[string]interface{}{
  4994. "failed_code": -10,
  4995. "msg": res.ErrMsg,
  4996. })
  4997. return
  4998. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  4999. }
  5000. }
  5001. }
  5002. //上传明细----预结算----确认订单
  5003. func (c *HisApiController) GetUploadInfo() {
  5004. id, _ := c.GetInt64("id")
  5005. record_time := c.GetString("record_time")
  5006. his_patient_id, _ := c.GetInt64("his_patient_id")
  5007. order_id, _ := c.GetInt64("order_id")
  5008. pay_way, _ := c.GetInt64("pay_way")
  5009. pay_price, _ := c.GetFloat("pay_price")
  5010. pay_card_no := c.GetString("pay_card_no")
  5011. token := c.GetString("token")
  5012. discount_price, _ := c.GetFloat("discount_price")
  5013. preferential_price, _ := c.GetFloat("preferential_price")
  5014. reality_price, _ := c.GetFloat("reality_price")
  5015. found_price, _ := c.GetFloat("found_price")
  5016. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  5017. private_price, _ := c.GetFloat("private_price")
  5018. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5019. admin_user_id, _ := c.GetInt64("admin_user_id")
  5020. fapiao_code := c.GetString("fapiao_code")
  5021. fapiao_number := c.GetString("fapiao_number")
  5022. diagnosis_id := c.GetString("diagnosis")
  5023. sick_type, _ := c.GetInt64("sick_type")
  5024. reg_type, _ := c.GetInt64("p_type")
  5025. begin_time := c.GetString("begin_time")
  5026. id_str := c.GetString("ids")
  5027. ids_arr := strings.Split(id_str, ",")
  5028. timeLayout := "2006-01-02"
  5029. loc, _ := time.LoadLocation("Local")
  5030. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5031. if err != nil {
  5032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5033. return
  5034. }
  5035. recordDateTime := theTime.Unix()
  5036. adminUser := c.GetAdminUserInfo()
  5037. var tempOrder models.HisOrder
  5038. tempOrder, _ = service.GetHisOrderByID(order_id)
  5039. var prescriptions []*models.HisPrescription
  5040. var start_time int64
  5041. var end_time int64
  5042. //押金模块
  5043. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  5044. tmp_decimal := c.GetString("tmp_decimal")
  5045. var decimal float64 //本次使用的押金
  5046. var errmsg error
  5047. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  5048. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  5049. return
  5050. }
  5051. if len(tmp_decimal) > 0 {
  5052. if tmp_decimal[0] == 45 {
  5053. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  5054. return
  5055. }
  5056. }
  5057. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  5058. fmt.Println(errs)
  5059. decimal = tt
  5060. //if adminUser.CurrentOrgId == 10106{
  5061. // if len(fapiao_code) == 0{
  5062. // fapiao_code = "144072080589"
  5063. // }
  5064. // if len(fapiao_number) == 0{
  5065. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  5066. // if order.ID == 0{
  5067. // fapiao_number = "00001520"
  5068. // }else{
  5069. // //fapiao_code = "00001520"
  5070. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  5071. // var zero string
  5072. // if fpNumber >= 1000{
  5073. // zero = "0000" + strconv.Itoa(fpNumber)
  5074. // }else if fpNumber >= 10000{
  5075. // zero = "000" + strconv.Itoa(fpNumber)
  5076. // } else if fpNumber >= 100000{
  5077. // zero = "00" + strconv.Itoa(fpNumber)
  5078. // } else if fpNumber >= 1000000{
  5079. // zero = "0" + strconv.Itoa(fpNumber)
  5080. // }else {
  5081. // zero = strconv.Itoa(fpNumber)
  5082. // }
  5083. // fapiao_number = zero
  5084. // }
  5085. // }
  5086. //}
  5087. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5088. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5089. var patientPrescription models.HisPrescriptionInfo
  5090. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5091. if patientPrescription.ID == 0 {
  5092. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5093. }
  5094. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5095. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5096. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5097. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5098. var config []*models.HisXtDiagnoseConfig
  5099. for _, item := range diagnosis_ids {
  5100. id, _ := strconv.ParseInt(item, 10, 64)
  5101. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5102. config = append(config, &diagnosisConfig)
  5103. }
  5104. sickConfig, _ := service.FindSickById(sick_type)
  5105. //if tempOrder.ID == 0 {
  5106. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  5107. //}
  5108. if tempOrder.ID == 0 {
  5109. var result string
  5110. var requestLog string
  5111. var res2 ResultSix
  5112. var ressix10265 ResultSix10265
  5113. if miConfig.MdtrtareaAdmvs == "421300" {
  5114. data := make(map[string]interface{})
  5115. client := &http.Client{}
  5116. data["psn_no"] = his.PsnNo
  5117. data["mdtrt_id"] = his.Number
  5118. data["doctor"] = roles.UserName
  5119. data["department"] = department.Name
  5120. data["org_name"] = miConfig.OrgName
  5121. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5122. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5123. data["fixmedins_code"] = miConfig.Code
  5124. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5125. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5126. data["secret_key"] = miConfig.SecretKey
  5127. data["sick_code"] = sickConfig.CountryCode
  5128. data["sick_name"] = sickConfig.ClassName
  5129. data["dept"] = strconv.FormatInt(department.ID, 10)
  5130. data["config"] = config
  5131. data["begin_time"] = begin_time
  5132. bytesData, _ := json.Marshal(data)
  5133. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5134. resp, _ := client.Do(req)
  5135. defer resp.Body.Close()
  5136. body, ioErr := ioutil.ReadAll(resp.Body)
  5137. if ioErr != nil {
  5138. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5140. return
  5141. }
  5142. var respJSON map[string]interface{}
  5143. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5144. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5146. return
  5147. }
  5148. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5149. userJSONBytes, _ := json.Marshal(respJSON)
  5150. fmt.Println("log")
  5151. fmt.Println(string(userJSONBytes))
  5152. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5153. utils.ErrorLog("解析失败:%v", err)
  5154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5155. return
  5156. }
  5157. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5158. //江苏地区国家医保医疗类别
  5159. //职工透析:医疗类别选特殊情况门诊9933
  5160. //居民血透门慢: 医疗类别选门诊慢病1402
  5161. //var med_type string
  5162. //if his.Insutype == "310" {
  5163. // if reg_type == 14 {
  5164. // med_type = "9933"
  5165. // } else if reg_type == 11 {
  5166. // med_type = "11"
  5167. //
  5168. // }
  5169. //} else if his.Insutype == "390" {
  5170. // if reg_type == 14 {
  5171. // med_type = "1402"
  5172. // } else if reg_type == 11 {
  5173. // med_type = "11"
  5174. // }
  5175. //}
  5176. data := make(map[string]interface{})
  5177. client := &http.Client{}
  5178. data["psn_no"] = his.PsnNo
  5179. data["mdtrt_id"] = his.Number
  5180. data["doctor"] = roles.UserName
  5181. data["department"] = department.Name
  5182. data["org_name"] = miConfig.OrgName
  5183. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5184. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5185. data["fixmedins_code"] = miConfig.Code
  5186. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5187. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5188. data["secret_key"] = miConfig.SecretKey
  5189. data["sick_code"] = sickConfig.CountryCode
  5190. data["sick_name"] = sickConfig.ClassName
  5191. data["url"] = miConfig.Url
  5192. data["ak"] = miConfig.AccessKey
  5193. data["begin_time"] = begin_time
  5194. data["cainfo"] = miConfig.Cainfo
  5195. data["dept"] = strconv.FormatInt(department.ID, 10)
  5196. data["config"] = config
  5197. bytesData, _ := json.Marshal(data)
  5198. var req *http.Request
  5199. if miConfig.MdtrtareaAdmvs == "320921" {
  5200. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5201. //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 +
  5202. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  5203. } else {
  5204. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5205. }
  5206. resp, _ := client.Do(req)
  5207. defer resp.Body.Close()
  5208. body, ioErr := ioutil.ReadAll(resp.Body)
  5209. if ioErr != nil {
  5210. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5212. return
  5213. }
  5214. var respJSON map[string]interface{}
  5215. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5216. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5218. return
  5219. }
  5220. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5221. userJSONBytes, _ := json.Marshal(respJSON)
  5222. fmt.Println("log")
  5223. fmt.Println(string(userJSONBytes))
  5224. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5225. utils.ErrorLog("解析失败:%v", err)
  5226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5227. return
  5228. }
  5229. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5230. // res2.Output = ressix10265.Output
  5231. res2.ErrMsg = ressix10265.ErrMsg
  5232. res2.Cainfo = ressix10265.Cainfo
  5233. res2.WarnMsg = ressix10265.WarnMsg
  5234. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5235. res2.Infcode = infocode
  5236. } else {
  5237. if miConfig.MdtrtareaAdmvs == "440781" { //
  5238. result, requestLog = service.Gdyb2203ForGz(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)
  5239. } else {
  5240. if miConfig.Code == "H15049901371" {
  5241. //赤峰地区国家医保医疗类别
  5242. //职工透析:医疗类别选特殊情况门诊990502
  5243. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5244. var med_type string
  5245. if his.Insutype == "390" {
  5246. if reg_type == 14 {
  5247. med_type = "9933"
  5248. } else if reg_type == 11 {
  5249. med_type = "11"
  5250. }
  5251. } else if his.Insutype == "310" {
  5252. if reg_type == 14 {
  5253. med_type = "990502"
  5254. } else if reg_type == 11 {
  5255. med_type = "11"
  5256. }
  5257. }
  5258. result, requestLog = service.Gdyb2203ForGz(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)
  5259. } else {
  5260. var med_type string
  5261. if reg_type == 14 {
  5262. med_type = "141009"
  5263. result, requestLog = service.Gdyb2203ForGz(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)
  5264. } else if reg_type == 11 {
  5265. med_type = "11"
  5266. // sickConfig.ClassName = sic
  5267. // sickConfig.ContentCode = ""
  5268. result, requestLog = service.Gdyb2203ForGz(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, "", roles.UserName, config, begin_time)
  5269. }
  5270. }
  5271. }
  5272. saveLog(result, requestLog, "2203", "上传就诊信息")
  5273. var respJSON2 map[string]interface{}
  5274. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5275. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5277. return
  5278. }
  5279. userJSONBytes2, _ := json.Marshal(respJSON2)
  5280. if miConfig.Code == "H15049901371" {
  5281. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  5282. utils.ErrorLog("解析失败:%v", err)
  5283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5284. return
  5285. }
  5286. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5287. // res2.Output = ressix10265.Output
  5288. res2.ErrMsg = ressix10265.ErrMsg
  5289. res2.Cainfo = ressix10265.Cainfo
  5290. res2.WarnMsg = ressix10265.WarnMsg
  5291. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5292. res2.Infcode = infocode
  5293. } else {
  5294. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5295. utils.ErrorLog("解析失败:%v", err)
  5296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5297. return
  5298. }
  5299. }
  5300. }
  5301. if res2.Infcode != 0 {
  5302. adminUser := c.GetAdminUserInfo()
  5303. errlog := &models.HisOrderError{
  5304. UserOrgId: adminUser.CurrentOrgId,
  5305. Ctime: time.Now().Unix(),
  5306. Mtime: time.Now().Unix(),
  5307. ErrMsg: res2.ErrMsg,
  5308. Status: 1,
  5309. PatientId: id,
  5310. RecordTime: recordDateTime,
  5311. Stage: 3,
  5312. }
  5313. service.CreateErrMsgLog(errlog)
  5314. c.ServeSuccessJSON(map[string]interface{}{
  5315. "failed_code": -10,
  5316. "msg": res2.ErrMsg,
  5317. })
  5318. return
  5319. } else {
  5320. his.Diagnosis = diagnosis_id
  5321. his.SickType = sickConfig.ID
  5322. //var p_type int64
  5323. //if reg_type == 1111 || reg_type == 1112 {
  5324. // p_type = 11
  5325. //
  5326. //}
  5327. his.PType = fmt.Sprintf("%d", reg_type)
  5328. service.UpdateHisPatientThree(&his)
  5329. data := make(map[string]interface{})
  5330. if settle_accounts_type == 1 { //日结
  5331. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5332. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5333. } else {
  5334. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5335. }
  5336. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  5337. data["pre"] = prescriptions
  5338. } else { //月结
  5339. start_time_str := c.GetString("start_time")
  5340. end_time_str := c.GetString("end_time")
  5341. timeLayout := "2006-01-02"
  5342. loc, _ := time.LoadLocation("Local")
  5343. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5344. if err != nil {
  5345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5346. return
  5347. }
  5348. recordStartTime := theStartTime.Unix()
  5349. start_time = recordStartTime
  5350. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5351. if err != nil {
  5352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5353. return
  5354. }
  5355. recordEndTime := theEndTime.Unix()
  5356. end_time = recordEndTime
  5357. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5358. data["pre"] = prescriptions
  5359. }
  5360. timestamp := time.Now().Unix()
  5361. tempTime := time.Unix(timestamp, 0)
  5362. timeFormat := tempTime.Format("20060102150405")
  5363. chrgBchno := rand.Intn(100000) + 10000
  5364. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5365. strconv.FormatInt(his.PatientId, 10)
  5366. client := &http.Client{}
  5367. data["psn_no"] = his.PsnNo
  5368. data["mdtrt_id"] = his.Number
  5369. data["chrg_bchno"] = chrg_bchno
  5370. data["org_name"] = miConfig.OrgName
  5371. data["doctor"] = roles.UserName
  5372. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5373. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5374. data["fixmedins_code"] = miConfig.Code
  5375. //if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  5376. // data["dept_code"] = "15"
  5377. //} else {
  5378. data["dept_code"] = department.Number
  5379. //}
  5380. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5381. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5382. data["secret_key"] = miConfig.SecretKey
  5383. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5384. data["url"] = miConfig.Url
  5385. data["ak"] = miConfig.AccessKey
  5386. data["new_doctor_name"] = patientPrescription.Doctor
  5387. data["diag_code"] = sickConfig.CountryCode
  5388. data["cainfo"] = miConfig.Cainfo
  5389. var ids []int64
  5390. for _, item := range prescriptions {
  5391. ids = append(ids, item.ID)
  5392. }
  5393. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5394. if config.IsOpen == 1 { //对接了医保,走医保流程
  5395. var res ResultFour
  5396. var resFour10265 ResultFour10265
  5397. if miConfig.MdtrtareaAdmvs == "421300" {
  5398. bytesData, _ := json.Marshal(data)
  5399. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5400. resp, _ := client.Do(req)
  5401. defer resp.Body.Close()
  5402. body, ioErr := ioutil.ReadAll(resp.Body)
  5403. if ioErr != nil {
  5404. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5406. return
  5407. }
  5408. var respJSON map[string]interface{}
  5409. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5410. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5412. return
  5413. }
  5414. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5415. userJSONBytes, _ := json.Marshal(respJSON)
  5416. fmt.Println("log")
  5417. fmt.Println(string(userJSONBytes))
  5418. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5419. utils.ErrorLog("解析失败:%v", err)
  5420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5421. return
  5422. }
  5423. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5424. bytesData, _ := json.Marshal(data)
  5425. var req *http.Request
  5426. if miConfig.MdtrtareaAdmvs == "320921" {
  5427. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5428. } else {
  5429. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5430. }
  5431. resp, _ := client.Do(req)
  5432. defer resp.Body.Close()
  5433. body, ioErr := ioutil.ReadAll(resp.Body)
  5434. if ioErr != nil {
  5435. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5437. return
  5438. }
  5439. var respJSON map[string]interface{}
  5440. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5441. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5443. return
  5444. }
  5445. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5446. userJSONBytes, _ := json.Marshal(respJSON)
  5447. fmt.Println("log")
  5448. fmt.Println(string(userJSONBytes))
  5449. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5450. utils.ErrorLog("解析失败:%v", err)
  5451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5452. return
  5453. }
  5454. res.InfRefmsgid = resFour10265.InfRefmsgid
  5455. res.Output = resFour10265.Output
  5456. res.ErrMsg = resFour10265.ErrMsg
  5457. res.Cainfo = resFour10265.Cainfo
  5458. res.WarnMsg = resFour10265.WarnMsg
  5459. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5460. res.Infcode = infocode
  5461. } else {
  5462. if miConfig.Code == "H15049901371" {
  5463. 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)
  5464. var dat map[string]interface{}
  5465. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5466. fmt.Println(dat)
  5467. } else {
  5468. fmt.Println(err)
  5469. }
  5470. saveLog(result, request_log, "2204", "上传费用明细")
  5471. userJSONBytes, _ := json.Marshal(dat)
  5472. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5473. utils.ErrorLog("解析失败:%v", err)
  5474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5475. return
  5476. }
  5477. res.InfRefmsgid = resFour10265.InfRefmsgid
  5478. res.Output = resFour10265.Output
  5479. res.ErrMsg = resFour10265.ErrMsg
  5480. res.Cainfo = resFour10265.Cainfo
  5481. res.WarnMsg = resFour10265.WarnMsg
  5482. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5483. res.Infcode = infocode
  5484. } else {
  5485. 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)
  5486. var dat map[string]interface{}
  5487. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5488. fmt.Println(dat)
  5489. } else {
  5490. fmt.Println(err)
  5491. }
  5492. saveLog(result, request_log, "2204", "上传费用明细")
  5493. userJSONBytes, _ := json.Marshal(dat)
  5494. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5495. utils.ErrorLog("解析失败:%v", err)
  5496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5497. return
  5498. }
  5499. }
  5500. }
  5501. if res.Infcode == 0 {
  5502. order := &models.HisOrder{
  5503. UserOrgId: adminUser.CurrentOrgId,
  5504. HisPatientId: his.ID,
  5505. PatientId: his.PatientId,
  5506. SettleAccountsDate: recordDateTime,
  5507. MdtrtId: his.Number,
  5508. PsnNo: his.PsnNo,
  5509. MedType: strconv.FormatInt(reg_type, 10),
  5510. Ctime: time.Now().Unix(),
  5511. Mtime: time.Now().Unix(),
  5512. Status: 1,
  5513. Number: chrg_bchno,
  5514. Infcode: res.Infcode,
  5515. WarnMsg: res.WarnMsg,
  5516. Cainfo: res.Cainfo,
  5517. ErrMsg: res.ErrMsg,
  5518. RespondTime: res.RefmsgTime,
  5519. InfRefmsgid: res.InfRefmsgid,
  5520. OrderStatus: 1,
  5521. PayWay: pay_way,
  5522. PayPrice: pay_price,
  5523. PayCardNo: pay_card_no,
  5524. DiscountPrice: discount_price,
  5525. PreferentialPrice: preferential_price,
  5526. RealityPrice: reality_price,
  5527. FoundPrice: found_price,
  5528. MedicalInsurancePrice: medical_insurance_price,
  5529. PrivatePrice: private_price,
  5530. IsMedicineInsurance: 1,
  5531. SettleType: settle_accounts_type,
  5532. SettleStartTime: start_time,
  5533. SettleEndTime: end_time,
  5534. Creator: roles.AdminUserId,
  5535. Modify: roles.AdminUserId,
  5536. FaPiaoNumber: fapiao_number,
  5537. FaPiaoCode: fapiao_code,
  5538. PType: 2,
  5539. Diagnosis: diagnosis_id,
  5540. }
  5541. err = service.CreateOrder(order)
  5542. if err != nil {
  5543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5544. return
  5545. }
  5546. for _, item := range res.Output.Result {
  5547. temp := strings.Split(item.FeedetlSn, "-")
  5548. var advice_id int64 = 0
  5549. var project_id int64 = 0
  5550. var types int64 = 0
  5551. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5552. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5553. if temp[1] == "1" {
  5554. advice_id = id
  5555. project_id = 0
  5556. } else if temp[1] == "2" {
  5557. advice_id = 0
  5558. project_id = id
  5559. }
  5560. info := &models.HisOrderInfo{
  5561. OrderNumber: order.Number,
  5562. FeedetlSn: item.FeedetlSn,
  5563. UploadDate: time.Now().Unix(),
  5564. AdviceId: advice_id,
  5565. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5566. Cnt: item.Cnt,
  5567. Pric: float64(item.Pric),
  5568. PatientId: his.PatientId,
  5569. PricUplmtAmt: item.PricUplmtAmt,
  5570. SelfpayProp: item.SelfpayProp,
  5571. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5572. OverlmtAmt: item.OverlmtAmt,
  5573. PreselfpayAmt: item.PreselfpayAmt,
  5574. BasMednFlag: item.BasMednFlag,
  5575. MedChrgitmType: item.MedChrgitmType,
  5576. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5577. Status: 1,
  5578. Memo: item.Memo,
  5579. Mtime: time.Now().Unix(),
  5580. InscpScpAmt: item.InscpScpAmt,
  5581. DrtReimFlag: item.DrtReimFlag,
  5582. Ctime: time.Now().Unix(),
  5583. ListSpItemFlag: item.ListSpItemFlag,
  5584. ChldMedcFlag: item.ChldMedcFlag,
  5585. LmtUsedFlag: item.LmtUsedFlag,
  5586. ChrgitmLv: item.ChrgitmLv,
  5587. UserOrgId: adminUser.CurrentOrgId,
  5588. HisPatientId: his.ID,
  5589. OrderId: order.ID,
  5590. ProjectId: project_id,
  5591. Type: types,
  5592. }
  5593. service.CreateOrderInfo(info)
  5594. }
  5595. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5596. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5597. var total float64
  5598. for _, item := range prescriptions {
  5599. if item.Type == 1 { //药品
  5600. for _, subItem := range item.HisDoctorAdviceInfo {
  5601. total = total + (subItem.Price * subItem.PrescribingNumber)
  5602. }
  5603. }
  5604. if item.Type == 2 { //项目
  5605. for _, subItem := range item.HisPrescriptionProject {
  5606. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5607. total = total + (subItem.Price * cnt)
  5608. }
  5609. }
  5610. }
  5611. for _, item := range prescriptions {
  5612. for _, subItem := range item.HisAdditionalCharge {
  5613. total = total + (subItem.Price * float64(subItem.Count))
  5614. }
  5615. }
  5616. var allTotal string
  5617. if adminUser.CurrentOrgId == 9919 {
  5618. allTotal = fmt.Sprintf("%.4f", total)
  5619. } else {
  5620. allTotal = fmt.Sprintf("%.4f", total)
  5621. }
  5622. if res.Infcode == 0 {
  5623. var rf []*ResultFive
  5624. json.Unmarshal([]byte(his.Iinfo), &rf)
  5625. chrg_bchno := chrg_bchno
  5626. cert_no := his.Certno
  5627. var insutypes []string
  5628. var insutype string
  5629. var is390 int = 0
  5630. var is310 int = 0
  5631. for _, item := range rf {
  5632. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5633. insutypes = append(insutypes, item.Insutype)
  5634. }
  5635. }
  5636. if len(insutypes) == 1 {
  5637. insutype = insutypes[0]
  5638. } else {
  5639. for _, i := range insutypes {
  5640. if i == "390" {
  5641. is390 = 1
  5642. }
  5643. if i == "310" {
  5644. is310 = 1
  5645. }
  5646. }
  5647. }
  5648. if is390 == 1 {
  5649. insutype = "390"
  5650. }
  5651. if is310 == 1 {
  5652. insutype = "310"
  5653. }
  5654. if len(insutypes) == 0 {
  5655. insutype = "310"
  5656. }
  5657. if len(insutypes) == 2 {
  5658. insutype = strconv.FormatInt(his.SocialType, 10)
  5659. }
  5660. insutype = strconv.FormatInt(his.SocialType, 10)
  5661. //insutype = "390"
  5662. if his.IdCardType == 1 {
  5663. // cert_no = his.MedicalInsuranceNumber
  5664. cert_no = his.Certno
  5665. } else {
  5666. cert_no = his.Certno
  5667. }
  5668. var res models.GZResult2207
  5669. var resSeven10265 ResultSeven10265
  5670. var src_resquest string
  5671. var result2 string
  5672. var acct_used_flag string
  5673. fmt.Println("pay_way")
  5674. fmt.Println(pay_way)
  5675. fmt.Println("pay_way")
  5676. if pay_way == 5 {
  5677. acct_used_flag = "1"
  5678. } else {
  5679. acct_used_flag = "0"
  5680. }
  5681. if miConfig.MdtrtareaAdmvs == "421300" {
  5682. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5683. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5684. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5685. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5686. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5687. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5688. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5689. resp, requestErr := http.Get(api)
  5690. if requestErr != nil {
  5691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5692. return
  5693. }
  5694. body, ioErr := ioutil.ReadAll(resp.Body)
  5695. if ioErr != nil {
  5696. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5698. return
  5699. }
  5700. var respJSON map[string]interface{}
  5701. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5702. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5704. return
  5705. }
  5706. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5707. result, _ := json.Marshal(respJSON)
  5708. if miConfig.Code == "H15049901371" {
  5709. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5710. utils.ErrorLog("解析失败:%v", err)
  5711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5712. return
  5713. }
  5714. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5715. // res.Output = resSeven10265.Output
  5716. res.ErrMsg = resSeven10265.ErrMsg
  5717. res.Cainfo = resSeven10265.Cainfo
  5718. // res.WarnMsg = resSeven10265.WarnMsg
  5719. // infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5720. // res.Infcode = infocode
  5721. } else {
  5722. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5723. utils.ErrorLog("解析失败:%v", err)
  5724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5725. return
  5726. }
  5727. }
  5728. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5729. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5730. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5731. bas := strings.Split(psn_info.CardInfo, "|")
  5732. if his.IdCardType == 1 {
  5733. cert_no = bas[2]
  5734. } else if his.IdCardType == 3 {
  5735. cert_no = his.Certno
  5736. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  5737. } else if his.IdCardType == 4 {
  5738. cert_no = his.Certno
  5739. psn_info.VerifyNumber = token
  5740. }
  5741. var api string
  5742. if miConfig.MdtrtareaAdmvs == "320921" {
  5743. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5744. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5745. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5746. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5747. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5748. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5749. "&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
  5750. } else {
  5751. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5752. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5753. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5754. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5755. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5756. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5757. "&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
  5758. }
  5759. resp, requestErr := http.Get(api)
  5760. if requestErr != nil {
  5761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5762. return
  5763. }
  5764. body, ioErr := ioutil.ReadAll(resp.Body)
  5765. if ioErr != nil {
  5766. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5768. return
  5769. }
  5770. var respJSON map[string]interface{}
  5771. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5772. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5774. return
  5775. }
  5776. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5777. result, _ := json.Marshal(respJSON)
  5778. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5779. utils.ErrorLog("解析失败:%v", err)
  5780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5781. return
  5782. }
  5783. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5784. // res.Output = resSeven10265.Output
  5785. res.ErrMsg = resSeven10265.ErrMsg
  5786. res.Cainfo = resSeven10265.Cainfo
  5787. // res.WarnMsg = resSeven10265.WarnMsg
  5788. // infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5789. // res.Infcode = infocode
  5790. } else {
  5791. if miConfig.Code == "H15049901371" {
  5792. //赤峰地区国家医保医疗类别
  5793. //职工透析:医疗类别选特殊情况门诊990502
  5794. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5795. var med_type string
  5796. if his.Insutype == "390" {
  5797. if reg_type == 14 {
  5798. med_type = "9933"
  5799. } else if reg_type == 11 {
  5800. med_type = "11"
  5801. }
  5802. } else if his.Insutype == "310" {
  5803. if reg_type == 14 {
  5804. med_type = "990502"
  5805. } else if reg_type == 11 {
  5806. med_type = "11"
  5807. }
  5808. }
  5809. 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)
  5810. } else {
  5811. var med_type string
  5812. if reg_type == 14 {
  5813. med_type = "141009"
  5814. } else if reg_type == 11 {
  5815. med_type = "11"
  5816. }
  5817. 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)
  5818. }
  5819. //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)
  5820. var dat map[string]interface{}
  5821. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5822. fmt.Println(dat)
  5823. } else {
  5824. fmt.Println(err)
  5825. }
  5826. saveLog(result2, src_resquest, "2207", "结算")
  5827. userJSONBytes, _ := json.Marshal(dat)
  5828. if miConfig.Code == "H15049901371" {
  5829. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5830. utils.ErrorLog("解析失败:%v", err)
  5831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5832. return
  5833. }
  5834. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5835. // res.Output = resSeven10265.Output
  5836. res.ErrMsg = resSeven10265.ErrMsg
  5837. res.Cainfo = resSeven10265.Cainfo
  5838. // res.WarnMsg = resSeven10265.WarnMsg
  5839. // infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5840. // res.Infcode = infocode
  5841. } else {
  5842. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5843. utils.ErrorLog("解析失败:%v", err)
  5844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5845. return
  5846. }
  5847. }
  5848. }
  5849. if res.Infcode != 0 {
  5850. errlog := &models.HisOrderError{
  5851. UserOrgId: adminUser.CurrentOrgId,
  5852. Ctime: time.Now().Unix(),
  5853. Mtime: time.Now().Unix(),
  5854. Number: chrg_bchno,
  5855. ErrMsg: res.ErrMsg,
  5856. Status: 1,
  5857. PatientId: id,
  5858. RecordTime: recordDateTime,
  5859. Stage: 6,
  5860. }
  5861. service.CreateErrMsgLog(errlog)
  5862. c.ServeSuccessJSON(map[string]interface{}{
  5863. "failed_code": -10,
  5864. "msg": res.ErrMsg,
  5865. })
  5866. return
  5867. } else {
  5868. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5869. order.OrderStatus = 2
  5870. order.Status = 1
  5871. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5872. order.SetlId = res.Output.Setlinfo.SetlID
  5873. order.PsnNo = res.Output.Setlinfo.PsnNo
  5874. order.PsnName = res.Output.Setlinfo.PsnName
  5875. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5876. order.Certno = res.Output.Setlinfo.Certno
  5877. order.Gend = res.Output.Setlinfo.Gend
  5878. order.Naty = res.Output.Setlinfo.Naty
  5879. order.Age = res.Output.Setlinfo.Age
  5880. order.Insutype = res.Output.Setlinfo.Insutype
  5881. order.PsnType = res.Output.Setlinfo.PsnType
  5882. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5883. order.SetlTime = res.Output.Setlinfo.SetlTime
  5884. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5885. if res.Output.Setlinfo.MedType == "140101" {
  5886. order.MedType = "14"
  5887. } else {
  5888. order.MedType = res.Output.Setlinfo.MedType
  5889. }
  5890. if reg_type == 1112 {
  5891. order.MedType = "1112"
  5892. }
  5893. if reg_type == 1111 {
  5894. order.MedType = "1111"
  5895. }
  5896. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5897. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5898. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5899. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5900. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5901. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5902. order.HifpPay = res.Output.Setlinfo.HifpPay
  5903. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5904. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5905. order.HifesPay = res.Output.Setlinfo.HifesPay
  5906. order.HifobPay = res.Output.Setlinfo.HifobPay
  5907. order.MafPay = res.Output.Setlinfo.MafPay
  5908. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5909. order.OthPay = res.Output.Setlinfo.OthPay
  5910. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5911. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5912. order.AcctPay = res.Output.Setlinfo.AcctPay
  5913. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5914. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5915. order.Balc = res.Output.Setlinfo.Balc
  5916. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5917. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5918. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5919. order.ClrType = res.Output.Setlinfo.ClrType
  5920. order.ClrWay = res.Output.Setlinfo.ClrWay
  5921. order.Creator = order.Creator
  5922. order.Modify = roles.AdminUserId
  5923. order.RequestLog = src_resquest
  5924. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5925. detailStr := string(setlDetail)
  5926. order.SetlDetail = detailStr
  5927. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5928. err = service.UpDateOrder(order)
  5929. if err == nil {
  5930. //判断是否使用了押金
  5931. if dec_way == "true" {
  5932. tmpstring := strconv.FormatInt(order.ID, 10)
  5933. order.Decimal = decimal
  5934. service.UpDateOrder(order)
  5935. //扣押金
  5936. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  5937. if errmsg != nil {
  5938. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  5939. return
  5940. }
  5941. }
  5942. c.ServeSuccessJSON(map[string]interface{}{
  5943. "msg": "结算成功",
  5944. })
  5945. } else {
  5946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5947. return
  5948. }
  5949. }
  5950. } else {
  5951. adminUser := c.GetAdminUserInfo()
  5952. errlog := &models.HisOrderError{
  5953. UserOrgId: adminUser.CurrentOrgId,
  5954. Ctime: time.Now().Unix(),
  5955. Mtime: time.Now().Unix(),
  5956. ErrMsg: res.ErrMsg,
  5957. Status: 1,
  5958. PatientId: id,
  5959. RecordTime: recordDateTime,
  5960. Stage: 4,
  5961. }
  5962. service.CreateErrMsgLog(errlog)
  5963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5964. return
  5965. }
  5966. } else {
  5967. adminUser := c.GetAdminUserInfo()
  5968. errlog := &models.HisOrderError{
  5969. UserOrgId: adminUser.CurrentOrgId,
  5970. Ctime: time.Now().Unix(),
  5971. Mtime: time.Now().Unix(),
  5972. ErrMsg: res.ErrMsg,
  5973. Status: 1,
  5974. PatientId: id,
  5975. RecordTime: recordDateTime,
  5976. Stage: 4,
  5977. }
  5978. service.CreateErrMsgLog(errlog)
  5979. c.ServeSuccessJSON(map[string]interface{}{
  5980. "failed_code": -10,
  5981. "msg": res.ErrMsg,
  5982. })
  5983. return
  5984. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5985. //return
  5986. }
  5987. }
  5988. }
  5989. } else if tempOrder.ID > 0 {
  5990. if tempOrder.IsPre == 1 {
  5991. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  5992. var rf []*ResultFive
  5993. json.Unmarshal([]byte(his.Iinfo), &rf)
  5994. chrg_bchno := tempOrder.Number
  5995. cert_no := his.Certno
  5996. var insutypes []string
  5997. var insutype string
  5998. var is390 int = 0
  5999. var is310 int = 0
  6000. for _, item := range rf {
  6001. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6002. insutypes = append(insutypes, item.Insutype)
  6003. }
  6004. }
  6005. if len(insutypes) == 1 {
  6006. insutype = insutypes[0]
  6007. } else {
  6008. for _, i := range insutypes {
  6009. if i == "390" {
  6010. is390 = 1
  6011. }
  6012. if i == "310" {
  6013. is310 = 1
  6014. }
  6015. }
  6016. }
  6017. if is390 == 1 {
  6018. insutype = "390"
  6019. }
  6020. if is310 == 1 {
  6021. insutype = "310"
  6022. }
  6023. if len(insutypes) == 0 {
  6024. insutype = "310"
  6025. }
  6026. if len(insutypes) == 2 {
  6027. insutype = strconv.FormatInt(his.SocialType, 64)
  6028. }
  6029. //insutype = "390"
  6030. if his.IdCardType == 1 {
  6031. // cert_no = his.MedicalInsuranceNumber
  6032. cert_no = his.Certno
  6033. } else {
  6034. cert_no = his.Certno
  6035. }
  6036. var res ResultSeven
  6037. var resSeven10265 ResultSeven10265
  6038. var src_resquest string
  6039. var result2 string
  6040. var acct_used_flag string
  6041. fmt.Println("pay_way")
  6042. fmt.Println(pay_way)
  6043. fmt.Println("pay_way")
  6044. if pay_way == 5 {
  6045. acct_used_flag = "1"
  6046. } else {
  6047. acct_used_flag = "0"
  6048. }
  6049. if miConfig.MdtrtareaAdmvs == "421300" {
  6050. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6051. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6052. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6053. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6054. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6055. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6056. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  6057. resp, requestErr := http.Get(api)
  6058. if requestErr != nil {
  6059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6060. return
  6061. }
  6062. body, ioErr := ioutil.ReadAll(resp.Body)
  6063. if ioErr != nil {
  6064. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6066. return
  6067. }
  6068. var respJSON map[string]interface{}
  6069. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6070. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6072. return
  6073. }
  6074. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6075. result, _ := json.Marshal(respJSON)
  6076. fmt.Println("log")
  6077. fmt.Println(string(result))
  6078. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6079. utils.ErrorLog("解析失败:%v", err)
  6080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6081. return
  6082. }
  6083. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6084. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6085. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6086. //psn_info, _ := service.GetPsnByPatientId(id)
  6087. bas := strings.Split(psn_info.CardInfo, "|")
  6088. if his.IdCardType == 1 {
  6089. cert_no = bas[2]
  6090. } else {
  6091. cert_no = bas[1]
  6092. }
  6093. //江苏地区国家医保医疗类别
  6094. //职工透析:医疗类别选特殊情况门诊9933
  6095. //居民血透门慢: 医疗类别选门诊慢病1402
  6096. //var med_type string
  6097. //if his.Insutype == "310" {
  6098. // if reg_type == 14 {
  6099. // med_type = "9933"
  6100. // } else if reg_type == 11 {
  6101. // med_type = "11"
  6102. //
  6103. // }
  6104. //} else if his.Insutype == "390" {
  6105. // if reg_type == 14 {
  6106. // med_type = "1402"
  6107. // } else if reg_type == 11 {
  6108. // med_type = "11"
  6109. // }
  6110. //}
  6111. var api string
  6112. if miConfig.MdtrtareaAdmvs == "320921" {
  6113. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6114. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6115. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6116. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6117. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6118. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6119. "&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
  6120. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6121. } else {
  6122. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6123. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6124. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6125. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6126. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6127. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6128. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6129. "&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
  6130. }
  6131. resp, requestErr := http.Get(api)
  6132. if requestErr != nil {
  6133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6134. return
  6135. }
  6136. body, ioErr := ioutil.ReadAll(resp.Body)
  6137. if ioErr != nil {
  6138. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6140. return
  6141. }
  6142. var respJSON map[string]interface{}
  6143. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6144. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6146. return
  6147. }
  6148. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6149. result, _ := json.Marshal(respJSON)
  6150. fmt.Println("log")
  6151. fmt.Println(string(result))
  6152. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6153. utils.ErrorLog("解析失败:%v", err)
  6154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6155. return
  6156. }
  6157. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6158. res.Output = resSeven10265.Output
  6159. res.ErrMsg = resSeven10265.ErrMsg
  6160. res.Cainfo = resSeven10265.Cainfo
  6161. res.WarnMsg = resSeven10265.WarnMsg
  6162. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6163. res.Infcode = infocode
  6164. } else {
  6165. var src_resquest string
  6166. if miConfig.Code == "H15049901371" {
  6167. //赤峰地区国家医保医疗类别
  6168. //职工透析:医疗类别选特殊情况门诊990502
  6169. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6170. var med_type string
  6171. if his.Insutype == "390" {
  6172. if reg_type == 14 {
  6173. med_type = "9933"
  6174. } else if reg_type == 11 {
  6175. med_type = "11"
  6176. }
  6177. } else if his.Insutype == "310" {
  6178. if reg_type == 14 {
  6179. med_type = "990502"
  6180. } else if reg_type == 11 {
  6181. med_type = "11"
  6182. }
  6183. }
  6184. 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)
  6185. } else {
  6186. var med_type string
  6187. if reg_type == 14 {
  6188. med_type = "14"
  6189. } else if reg_type == 11 {
  6190. med_type = "11"
  6191. }
  6192. result2, src_resquest = service.Gdyb2207ForGz(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)
  6193. }
  6194. var dat map[string]interface{}
  6195. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6196. fmt.Println(dat)
  6197. } else {
  6198. fmt.Println(err)
  6199. }
  6200. saveLog(result2, src_resquest, "2207", "结算")
  6201. userJSONBytes, _ := json.Marshal(dat)
  6202. if miConfig.Code == "H15049901371" {
  6203. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6204. utils.ErrorLog("解析失败:%v", err)
  6205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6206. return
  6207. }
  6208. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6209. res.Output = resSeven10265.Output
  6210. res.ErrMsg = resSeven10265.ErrMsg
  6211. res.Cainfo = resSeven10265.Cainfo
  6212. res.WarnMsg = resSeven10265.WarnMsg
  6213. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6214. res.Infcode = infocode
  6215. } else {
  6216. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6217. utils.ErrorLog("解析失败:%v", err)
  6218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6219. return
  6220. }
  6221. }
  6222. }
  6223. if res.Infcode != 0 {
  6224. errlog := &models.HisOrderError{
  6225. UserOrgId: adminUser.CurrentOrgId,
  6226. Ctime: time.Now().Unix(),
  6227. Mtime: time.Now().Unix(),
  6228. Number: chrg_bchno,
  6229. ErrMsg: res.ErrMsg,
  6230. Status: 1,
  6231. PatientId: id,
  6232. RecordTime: recordDateTime,
  6233. Stage: 6,
  6234. }
  6235. service.CreateErrMsgLog(errlog)
  6236. c.ServeSuccessJSON(map[string]interface{}{
  6237. "failed_code": -10,
  6238. "msg": res.ErrMsg,
  6239. })
  6240. return
  6241. } else {
  6242. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6243. order.OrderStatus = 2
  6244. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6245. order.SetlId = res.Output.Setlinfo.SetlID
  6246. order.PsnNo = res.Output.Setlinfo.PsnNo
  6247. order.PsnName = res.Output.Setlinfo.PsnName
  6248. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6249. order.Certno = res.Output.Setlinfo.Certno
  6250. order.Gend = res.Output.Setlinfo.Gend
  6251. order.Naty = res.Output.Setlinfo.Naty
  6252. order.Age = res.Output.Setlinfo.Age
  6253. order.Insutype = res.Output.Setlinfo.Insutype
  6254. order.PsnType = res.Output.Setlinfo.PsnType
  6255. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6256. order.SetlTime = res.Output.Setlinfo.SetlTime
  6257. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6258. //order.MedType = res.Output.Setlinfo.MedType
  6259. if reg_type == 1112 {
  6260. order.MedType = "1112"
  6261. }
  6262. if reg_type == 1111 {
  6263. order.MedType = "1111"
  6264. }
  6265. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6266. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6267. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6268. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6269. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6270. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6271. order.HifpPay = res.Output.Setlinfo.HifpPay
  6272. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6273. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6274. order.HifesPay = res.Output.Setlinfo.HifesPay
  6275. order.HifobPay = res.Output.Setlinfo.HifobPay
  6276. order.MafPay = res.Output.Setlinfo.MafPay
  6277. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6278. order.OthPay = res.Output.Setlinfo.OthPay
  6279. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6280. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6281. order.AcctPay = res.Output.Setlinfo.AcctPay
  6282. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6283. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6284. order.Balc = res.Output.Setlinfo.Balc
  6285. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6286. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6287. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6288. order.ClrWay = res.Output.Setlinfo.ClrWay
  6289. order.Creator = order.Creator
  6290. order.Modify = roles.AdminUserId
  6291. order.RequestLog = src_resquest
  6292. order.Diagnosis = diagnosis_id
  6293. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6294. detailStr := string(setlDetail)
  6295. order.SetlDetail = detailStr
  6296. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6297. err = service.UpDateOrder(order)
  6298. if err == nil {
  6299. //判断是否使用了押金
  6300. if dec_way == "true" {
  6301. tmpstring := strconv.FormatInt(order.ID, 10)
  6302. //扣押金
  6303. order.Decimal = decimal
  6304. service.UpDateOrder(order)
  6305. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6306. if errmsg != nil {
  6307. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6308. return
  6309. }
  6310. }
  6311. c.ServeSuccessJSON(map[string]interface{}{
  6312. "msg": "结算成功",
  6313. })
  6314. } else {
  6315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6316. return
  6317. }
  6318. }
  6319. }
  6320. }
  6321. }
  6322. //func (c *HisApiController) GetPreUploadInfo() {
  6323. // id, _ := c.GetInt64("id")
  6324. // record_time := c.GetString("record_time")
  6325. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6326. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6327. //
  6328. // timeLayout := "2006-01-02"
  6329. // loc, _ := time.LoadLocation("Local")
  6330. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6331. // if err != nil {
  6332. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6333. // return
  6334. // }
  6335. // recordDateTime := theTime.Unix()
  6336. // adminUser := c.GetAdminUserInfo()
  6337. //
  6338. // var prescriptions []*models.HisPrescription
  6339. //
  6340. // var start_time int64
  6341. // var end_time int64
  6342. //
  6343. // data := make(map[string]interface{})
  6344. // if settle_accounts_type == 1 { //日结
  6345. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6346. // data["pre"] = prescriptions
  6347. //
  6348. // } else { //月结
  6349. // start_time_str := c.GetString("start_time")
  6350. // end_time_str := c.GetString("end_time")
  6351. // timeLayout := "2006-01-02"
  6352. // loc, _ := time.LoadLocation("Local")
  6353. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6354. // if err != nil {
  6355. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6356. // return
  6357. // }
  6358. // recordStartTime := theStartTime.Unix()
  6359. // start_time = recordStartTime
  6360. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6361. // if err != nil {
  6362. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6363. // return
  6364. // }
  6365. // recordEndTime := theEndTime.Unix()
  6366. // end_time = recordEndTime
  6367. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6368. // data["pre"] = prescriptions
  6369. //
  6370. // }
  6371. //
  6372. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6373. //
  6374. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6375. // timestamp := time.Now().Unix()
  6376. // tempTime := time.Unix(timestamp, 0)
  6377. // timeFormat := tempTime.Format("20060102150405")
  6378. // chrgBchno := rand.Intn(100000) + 10000
  6379. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6380. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6381. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6382. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6383. // strconv.FormatInt(his.PatientId, 10)
  6384. // client := &http.Client{}
  6385. // data["psn_no"] = his.PsnNo
  6386. // data["mdtrt_id"] = his.Number
  6387. // data["chrg_bchno"] = chrg_bchno
  6388. // data["org_name"] = miConfig.OrgName
  6389. // data["doctor"] = roles.UserName
  6390. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6391. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6392. // data["fixmedins_code"] = miConfig.Code
  6393. // data["dept_code"] = department.Number
  6394. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6395. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6396. // data["secret_key"] = miConfig.SecretKey
  6397. // var ids []int64
  6398. //
  6399. // for _, item := range prescriptions {
  6400. // ids = append(ids, item.ID)
  6401. // }
  6402. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6403. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6404. // bytesData, _ := json.Marshal(data)
  6405. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  6406. // resp, _ := client.Do(req)
  6407. // defer resp.Body.Close()
  6408. // body, ioErr := ioutil.ReadAll(resp.Body)
  6409. // if ioErr != nil {
  6410. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6411. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6412. // return
  6413. // }
  6414. // var respJSON map[string]interface{}
  6415. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6416. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6417. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6418. // return
  6419. // }
  6420. //
  6421. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6422. // userJSONBytes, _ := json.Marshal(respJSON)
  6423. // var res ResultFour
  6424. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6425. // utils.ErrorLog("解析失败:%v", err)
  6426. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6427. // return
  6428. // }
  6429. //
  6430. // if res.Infcode == 0 {
  6431. // order := &models.HisOrder{
  6432. // UserOrgId: adminUser.CurrentOrgId,
  6433. // HisPatientId: his.ID,
  6434. // PatientId: his.PatientId,
  6435. // SettleAccountsDate: recordDateTime,
  6436. // Ctime: time.Now().Unix(),
  6437. // Mtime: time.Now().Unix(),
  6438. // Status: 1,
  6439. // Number: chrg_bchno,
  6440. // Infcode: res.Infcode,
  6441. // WarnMsg: res.WarnMsg,
  6442. // Cainfo: res.Cainfo,
  6443. // ErrMsg: res.ErrMsg,
  6444. // RespondTime: res.RefmsgTime,
  6445. // InfRefmsgid: res.InfRefmsgid,
  6446. // OrderStatus: 1,
  6447. // IsMedicineInsurance: 1,
  6448. // SettleType: settle_accounts_type,
  6449. // SettleStartTime: start_time,
  6450. // SettleEndTime: end_time,
  6451. // Creator: roles.ID,
  6452. // Modify: roles.ID,
  6453. // PType: 2,
  6454. // }
  6455. // err = service.CreateOrder(order)
  6456. // if err != nil {
  6457. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6458. // return
  6459. // }
  6460. //
  6461. // for _, item := range res.Output.Result {
  6462. // temp := strings.Split(item.FeedetlSn, "-")
  6463. // var advice_id int64 = 0
  6464. // var project_id int64 = 0
  6465. // var types int64 = 0
  6466. //
  6467. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  6468. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  6469. //
  6470. // if temp[1] == "1" {
  6471. // advice_id = id
  6472. // project_id = 0
  6473. // } else if temp[1] == "2" {
  6474. // advice_id = 0
  6475. // project_id = id
  6476. // }
  6477. //
  6478. // info := &models.HisOrderInfo{
  6479. // OrderNumber: order.Number,
  6480. // FeedetlSn: item.FeedetlSn,
  6481. // UploadDate: time.Now().Unix(),
  6482. // AdviceId: advice_id,
  6483. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  6484. // Cnt: item.Cnt,
  6485. // Pric: float64(item.Pric),
  6486. // PatientId: his.PatientId,
  6487. // PricUplmtAmt: item.PricUplmtAmt,
  6488. // SelfpayProp: item.SelfpayProp,
  6489. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6490. // OverlmtAmt: item.OverlmtAmt,
  6491. // PreselfpayAmt: item.PreselfpayAmt,
  6492. // BasMednFlag: item.BasMednFlag,
  6493. // MedChrgitmType: item.MedChrgitmType,
  6494. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  6495. // Status: 1,
  6496. // Memo: item.Memo,
  6497. // Mtime: time.Now().Unix(),
  6498. // InscpScpAmt: item.InscpScpAmt,
  6499. // DrtReimFlag: item.DrtReimFlag,
  6500. // Ctime: time.Now().Unix(),
  6501. // ListSpItemFlag: item.ListSpItemFlag,
  6502. // ChldMedcFlag: item.ChldMedcFlag,
  6503. // LmtUsedFlag: item.LmtUsedFlag,
  6504. // ChrgitmLv: item.ChrgitmLv,
  6505. // UserOrgId: adminUser.CurrentOrgId,
  6506. // HisPatientId: his.ID,
  6507. // OrderId: order.ID,
  6508. // ProjectId: project_id,
  6509. // Type: types,
  6510. // }
  6511. // service.CreateOrderInfo(info)
  6512. //
  6513. // }
  6514. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6515. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  6516. //
  6517. // var total float64
  6518. // for _, item := range prescriptions {
  6519. // if item.Type == 1 { //药品
  6520. // for _, subItem := range item.HisDoctorAdviceInfo {
  6521. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6522. // }
  6523. // }
  6524. // if item.Type == 2 { //项目
  6525. // for _, subItem := range item.HisPrescriptionProject {
  6526. // total = total + (subItem.Price * float64(subItem.Count))
  6527. // }
  6528. // }
  6529. // }
  6530. //
  6531. // for _, item := range prescriptions {
  6532. // for _, subItem := range item.HisAdditionalCharge {
  6533. // total = total + (subItem.Price * float64(subItem.Count))
  6534. // }
  6535. // }
  6536. //
  6537. // allTotal := fmt.Sprintf("%.2f", total)
  6538. // if res.Infcode == 0 {
  6539. // var rf []*ResultFive
  6540. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6541. // psn_no := his.PsnNo
  6542. // mdtrt_id := his.Number
  6543. // chrg_bchno := chrg_bchno
  6544. // cert_no := his.Certno
  6545. // insutype := rf[0].Insutype
  6546. //
  6547. // if his.IdCardType == 1 {
  6548. // cert_no = his.MedicalInsuranceNumber
  6549. //
  6550. // } else {
  6551. //
  6552. // cert_no = his.Certno
  6553. //
  6554. // }
  6555. //
  6556. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  6557. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  6558. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  6559. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  6560. // resp, requestErr := http.Get(api)
  6561. // if requestErr != nil {
  6562. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6563. // return
  6564. // }
  6565. // defer resp.Body.Close()
  6566. // body, ioErr := ioutil.ReadAll(resp.Body)
  6567. // if ioErr != nil {
  6568. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6569. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6570. // return
  6571. // }
  6572. // var respJSON map[string]interface{}
  6573. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6574. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6575. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6576. // return
  6577. // }
  6578. // fmt.Println(respJSON)
  6579. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6580. // userJSONBytes, _ := json.Marshal(respJSON)
  6581. // var res ResultSeven
  6582. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6583. // utils.ErrorLog("解析失败:%v", err)
  6584. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6585. // return
  6586. // }
  6587. // if res.Infcode != 0 {
  6588. // errlog := &models.HisOrderError{
  6589. // UserOrgId: adminUser.CurrentOrgId,
  6590. // Ctime: time.Now().Unix(),
  6591. // Mtime: time.Now().Unix(),
  6592. // Number: chrg_bchno,
  6593. // ErrMsg: res.ErrMsg,
  6594. // Status: 1,
  6595. // PatientId: id,
  6596. // RecordTime: recordDateTime,
  6597. // Stage: 7,
  6598. // }
  6599. // service.CreateErrMsgLog(errlog)
  6600. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6601. // return
  6602. // } else {
  6603. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6604. // order.OrderStatus = 1
  6605. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6606. // order.SetlId = res.Output.Setlinfo.SetlID
  6607. // order.PsnNo = res.Output.Setlinfo.PsnNo
  6608. // order.PsnName = res.Output.Setlinfo.PsnName
  6609. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6610. // order.Certno = res.Output.Setlinfo.Certno
  6611. // order.Gend = res.Output.Setlinfo.Gend
  6612. // order.Naty = res.Output.Setlinfo.Naty
  6613. // order.Age = res.Output.Setlinfo.Age
  6614. // order.Insutype = res.Output.Setlinfo.Insutype
  6615. // order.PsnType = res.Output.Setlinfo.PsnType
  6616. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6617. // order.SetlTime = res.Output.Setlinfo.SetlTime
  6618. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6619. // order.MedType = res.Output.Setlinfo.MedType
  6620. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6621. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6622. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6623. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6624. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6625. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6626. // order.HifpPay = res.Output.Setlinfo.HifpPay
  6627. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6628. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6629. // order.HifesPay = res.Output.Setlinfo.HifesPay
  6630. // order.HifobPay = res.Output.Setlinfo.HifobPay
  6631. // order.MafPay = res.Output.Setlinfo.MafPay
  6632. // order.OthPay = res.Output.Setlinfo.OthPay
  6633. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6634. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6635. // order.AcctPay = res.Output.Setlinfo.AcctPay
  6636. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6637. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6638. // order.Balc = res.Output.Setlinfo.Balc
  6639. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6640. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6641. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6642. // order.ClrWay = res.Output.Setlinfo.ClrWay
  6643. // order.Creator = order.Creator
  6644. // order.Modify = roles.ID
  6645. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6646. // detailStr := string(setlDetail)
  6647. // order.SetlDetail = detailStr
  6648. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6649. // err = service.UpDateOrder(order)
  6650. // if err == nil {
  6651. // c.ServeSuccessJSON(map[string]interface{}{
  6652. // "msg": "预结算成功",
  6653. // })
  6654. // } else {
  6655. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6656. // return
  6657. // }
  6658. // }
  6659. // } else {
  6660. // adminUser := c.GetAdminUserInfo()
  6661. // errlog := &models.HisOrderError{
  6662. // UserOrgId: adminUser.CurrentOrgId,
  6663. // Ctime: time.Now().Unix(),
  6664. // Mtime: time.Now().Unix(),
  6665. // ErrMsg: res.ErrMsg,
  6666. // Status: 1,
  6667. // PatientId: id,
  6668. // RecordTime: recordDateTime,
  6669. // Stage: 4,
  6670. // }
  6671. // service.CreateErrMsgLog(errlog)
  6672. //
  6673. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6674. // return
  6675. // }
  6676. // } else {
  6677. // adminUser := c.GetAdminUserInfo()
  6678. // errlog := &models.HisOrderError{
  6679. // UserOrgId: adminUser.CurrentOrgId,
  6680. // Ctime: time.Now().Unix(),
  6681. // Mtime: time.Now().Unix(),
  6682. // ErrMsg: res.ErrMsg,
  6683. // Status: 1,
  6684. // PatientId: id,
  6685. // RecordTime: recordDateTime,
  6686. // Stage: 4,
  6687. // }
  6688. // service.CreateErrMsgLog(errlog)
  6689. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6690. // return
  6691. // }
  6692. //
  6693. // } else {
  6694. // var total float64
  6695. // for _, item := range prescriptions {
  6696. // if item.Type == 1 { //药品
  6697. // for _, subItem := range item.HisDoctorAdviceInfo {
  6698. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6699. // }
  6700. // }
  6701. // if item.Type == 2 { //项目
  6702. // for _, subItem := range item.HisPrescriptionProject {
  6703. // total = total + (subItem.Price * float64(subItem.Count))
  6704. // }
  6705. // }
  6706. //
  6707. // for _, subItem := range item.HisAdditionalCharge {
  6708. // total = total + (subItem.Price * float64(subItem.Count))
  6709. // }
  6710. // }
  6711. //
  6712. // allTotal := fmt.Sprintf("%.2f", total)
  6713. // totals, _ := strconv.ParseFloat(allTotal, 64)
  6714. // order := &models.HisOrder{
  6715. // UserOrgId: adminUser.CurrentOrgId,
  6716. // HisPatientId: his.ID,
  6717. // PatientId: id,
  6718. // SettleAccountsDate: recordDateTime,
  6719. // Ctime: time.Now().Unix(),
  6720. // Mtime: time.Now().Unix(),
  6721. // Status: 1,
  6722. // OrderStatus: 2,
  6723. // Number: chrg_bchno,
  6724. // MedfeeSumamt: totals,
  6725. // }
  6726. // err = service.CreateOrder(order)
  6727. // if err != nil {
  6728. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6729. // return
  6730. // }
  6731. //
  6732. // var customs []*Custom
  6733. // for _, item := range prescriptions {
  6734. //
  6735. // if item.Type == 1 { //药品
  6736. // for _, subItem := range item.HisDoctorAdviceInfo {
  6737. // cus := &Custom{
  6738. // AdviceId: subItem.ID,
  6739. // ProjectId: 0,
  6740. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  6741. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  6742. // FeedetlSn: subItem.FeedetlSn,
  6743. // Price: fmt.Sprintf("%.2f", subItem.Price),
  6744. // MedListCodg: subItem.MedListCodg,
  6745. // Type: 1,
  6746. // }
  6747. // customs = append(customs, cus)
  6748. // }
  6749. // }
  6750. //
  6751. // if item.Type == 2 { //项目
  6752. // for _, subItem := range item.HisPrescriptionProject {
  6753. //
  6754. // cus := &Custom{
  6755. // AdviceId: 0,
  6756. // ProjectId: subItem.ID,
  6757. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  6758. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  6759. // FeedetlSn: subItem.FeedetlSn,
  6760. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  6761. // MedListCodg: subItem.MedListCodg,
  6762. // Type: 2,
  6763. // }
  6764. //
  6765. // customs = append(customs, cus)
  6766. // }
  6767. // }
  6768. //
  6769. // for _, item := range item.HisAdditionalCharge {
  6770. // cus := &Custom{
  6771. // ItemId: item.ID,
  6772. // AdviceId: 0,
  6773. // ProjectId: 0,
  6774. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  6775. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  6776. // FeedetlSn: item.FeedetlSn,
  6777. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  6778. // MedListCodg: item.XtHisAddtionConfig.Code,
  6779. // Type: 3,
  6780. // }
  6781. //
  6782. // customs = append(customs, cus)
  6783. // }
  6784. //
  6785. // }
  6786. //
  6787. // for _, item := range customs {
  6788. // var advice_id int64 = 0
  6789. // var project_id int64 = 0
  6790. // var item_id int64 = 0
  6791. //
  6792. // var types int64 = 0
  6793. //
  6794. // if item.Type == 1 {
  6795. // advice_id = item.AdviceId
  6796. // project_id = 0
  6797. // item_id = 0
  6798. // } else if item.Type == 2 {
  6799. // advice_id = 0
  6800. // item_id = 0
  6801. //
  6802. // project_id = item.ProjectId
  6803. // } else if item.Type == 3 {
  6804. // advice_id = 0
  6805. // item_id = item.ItemId
  6806. // project_id = 0
  6807. // }
  6808. //
  6809. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  6810. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  6811. // pric, _ := strconv.ParseFloat(item.Price, 32)
  6812. //
  6813. // info := &models.HisOrderInfo{
  6814. // OrderNumber: order.Number,
  6815. // UploadDate: time.Now().Unix(),
  6816. // AdviceId: advice_id,
  6817. // DetItemFeeSumamt: detItemFeeSumamt,
  6818. // Cnt: cut,
  6819. // Pric: pric,
  6820. // PatientId: id,
  6821. // Status: 1,
  6822. // Mtime: time.Now().Unix(),
  6823. // Ctime: time.Now().Unix(),
  6824. // UserOrgId: adminUser.CurrentOrgId,
  6825. // HisPatientId: his.ID,
  6826. // OrderId: order.ID,
  6827. // ProjectId: project_id,
  6828. // Type: types,
  6829. // ItemId: item_id,
  6830. // }
  6831. // service.CreateOrderInfo(info)
  6832. // }
  6833. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6834. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6835. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  6836. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6837. // if err == nil {
  6838. // c.ServeSuccessJSON(map[string]interface{}{
  6839. // "msg": "结算成功",
  6840. // })
  6841. // } else {
  6842. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6843. // return
  6844. // }
  6845. // }
  6846. //}
  6847. //上传明细-预结算-
  6848. func (c *HisApiController) GetPreUploadInfo() {
  6849. id, _ := c.GetInt64("id")
  6850. record_time := c.GetString("record_time")
  6851. his_patient_id, _ := c.GetInt64("his_patient_id")
  6852. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6853. admin_user_id, _ := c.GetInt64("admin_user_id")
  6854. diagnosis_id := c.GetString("diagnosis")
  6855. sick_type, _ := c.GetInt64("sick_type")
  6856. reg_type, _ := c.GetInt64("p_type")
  6857. begin_time := c.GetString("begin_time")
  6858. id_str := c.GetString("ids")
  6859. ids_arr := strings.Split(id_str, ",")
  6860. timeLayout := "2006-01-02"
  6861. loc, _ := time.LoadLocation("Local")
  6862. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6863. if err != nil {
  6864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6865. return
  6866. }
  6867. recordDateTime := theTime.Unix()
  6868. adminUser := c.GetAdminUserInfo()
  6869. diagnosis_ids := strings.Split(diagnosis_id, ",")
  6870. var config []*models.HisXtDiagnoseConfig
  6871. for _, item := range diagnosis_ids {
  6872. id, _ := strconv.ParseInt(item, 10, 64)
  6873. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6874. config = append(config, &diagnosisConfig)
  6875. }
  6876. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  6877. sickConfig, _ := service.FindSickById(sick_type)
  6878. var prescriptions []*models.HisPrescription
  6879. var start_time int64
  6880. var end_time int64
  6881. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6882. fmt.Println(his_patient_id)
  6883. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6884. timestamp := time.Now().Unix()
  6885. tempTime := time.Unix(timestamp, 0)
  6886. timeFormat := tempTime.Format("20060102150405")
  6887. chrgBchno := rand.Intn(100000) + 10000
  6888. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6889. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6890. var patientPrescription models.HisPrescriptionInfo
  6891. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6892. if patientPrescription.ID == 0 {
  6893. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6894. }
  6895. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6896. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6897. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6898. strconv.FormatInt(his.PatientId, 10)
  6899. var res2 ResultSix
  6900. var resSix10265 ResultSix10265
  6901. var time_stamp string
  6902. if miConfig.MdtrtareaAdmvs == "421300" {
  6903. data := make(map[string]interface{})
  6904. client := &http.Client{}
  6905. data["psn_no"] = his.PsnNo
  6906. data["mdtrt_id"] = his.Number
  6907. data["doctor"] = roles.UserName
  6908. data["department"] = department.Name
  6909. data["org_name"] = miConfig.OrgName
  6910. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6911. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6912. data["fixmedins_code"] = miConfig.Code
  6913. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6914. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6915. data["secret_key"] = miConfig.SecretKey
  6916. data["sick_code"] = sickConfig.CountryCode
  6917. data["sick_name"] = sickConfig.ClassName
  6918. data["begin_time"] = begin_time
  6919. data["dept"] = strconv.FormatInt(department.ID, 10)
  6920. data["config"] = config
  6921. fmt.Println(data)
  6922. bytesData, _ := json.Marshal(data)
  6923. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  6924. resp, _ := client.Do(req)
  6925. defer resp.Body.Close()
  6926. body, ioErr := ioutil.ReadAll(resp.Body)
  6927. if ioErr != nil {
  6928. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6930. return
  6931. }
  6932. var respJSON map[string]interface{}
  6933. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6934. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6936. return
  6937. }
  6938. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6939. userJSONBytes, _ := json.Marshal(respJSON)
  6940. fmt.Println("log")
  6941. fmt.Println(string(userJSONBytes))
  6942. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6943. utils.ErrorLog("解析失败:%v", err)
  6944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6945. return
  6946. }
  6947. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6948. //江苏地区国家医保医疗类别
  6949. //职工透析:医疗类别选特殊情况门诊9933
  6950. //居民血透门慢: 医疗类别选门诊慢病1402
  6951. //var med_type string
  6952. //if his.Insutype == "310" {
  6953. // if reg_type == 14 {
  6954. // med_type = "9933"
  6955. // } else if reg_type == 11 {
  6956. // med_type = "11"
  6957. //
  6958. // }
  6959. //} else if his.Insutype == "390" {
  6960. // if reg_type == 14 {
  6961. // med_type = "1402"
  6962. // } else if reg_type == 11 {
  6963. // med_type = "11"
  6964. // }
  6965. //}
  6966. data := make(map[string]interface{})
  6967. client := &http.Client{}
  6968. data["psn_no"] = his.PsnNo
  6969. data["mdtrt_id"] = his.Number
  6970. data["doctor"] = roles.UserName
  6971. data["department"] = department.Name
  6972. data["org_name"] = miConfig.OrgName
  6973. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6974. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6975. data["fixmedins_code"] = miConfig.Code
  6976. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6977. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6978. data["secret_key"] = miConfig.SecretKey
  6979. data["sick_code"] = sickConfig.CountryCode
  6980. data["sick_name"] = sickConfig.ClassName
  6981. data["begin_time"] = begin_time
  6982. data["dept"] = strconv.FormatInt(department.ID, 10)
  6983. data["config"] = config
  6984. data["url"] = miConfig.Url
  6985. data["ak"] = miConfig.AccessKey
  6986. data["cainfo"] = miConfig.Cainfo
  6987. bytesData, _ := json.Marshal(data)
  6988. var req *http.Request
  6989. if miConfig.MdtrtareaAdmvs == "320921" {
  6990. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6991. //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 +
  6992. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  6993. } else {
  6994. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6995. }
  6996. resp, _ := client.Do(req)
  6997. defer resp.Body.Close()
  6998. body, ioErr := ioutil.ReadAll(resp.Body)
  6999. if ioErr != nil {
  7000. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7002. return
  7003. }
  7004. var respJSON map[string]interface{}
  7005. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7006. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7008. return
  7009. }
  7010. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  7011. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  7012. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  7013. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7014. userJSONBytes, _ := json.Marshal(respJSON)
  7015. fmt.Println("log")
  7016. fmt.Println(string(userJSONBytes))
  7017. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7018. utils.ErrorLog("解析失败:%v", err)
  7019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7020. return
  7021. }
  7022. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7023. // res2.Output = resSix10265.Output
  7024. res2.ErrMsg = resSix10265.ErrMsg
  7025. res2.Cainfo = resSix10265.Cainfo
  7026. res2.WarnMsg = resSix10265.WarnMsg
  7027. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7028. res2.Infcode = infocode
  7029. } else {
  7030. var result string
  7031. var requestLog string
  7032. if miConfig.MdtrtareaAdmvs == "440781" { //
  7033. 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)
  7034. } else {
  7035. if miConfig.Code == "H15049901371" {
  7036. //赤峰地区国家医保医疗类别
  7037. //职工透析:医疗类别选特殊情况门诊990502
  7038. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7039. var med_type string
  7040. if his.Insutype == "390" {
  7041. if reg_type == 14 {
  7042. med_type = "9933"
  7043. } else if reg_type == 11 {
  7044. med_type = "11"
  7045. }
  7046. } else if his.Insutype == "310" {
  7047. if reg_type == 14 {
  7048. med_type = "990502"
  7049. } else if reg_type == 11 {
  7050. med_type = "11"
  7051. }
  7052. }
  7053. result, requestLog = service.Gdyb2203ForGz(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)
  7054. } else {
  7055. var med_type string
  7056. if reg_type == 14 {
  7057. med_type = "14"
  7058. result, requestLog = service.Gdyb2203ForGz(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)
  7059. } else if reg_type == 11 {
  7060. med_type = "11"
  7061. // sickConfig.ClassName = "普通门诊"
  7062. // sickConfig.ContentCode = "11"
  7063. result, requestLog = service.Gdyb2203ForGz(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)
  7064. }
  7065. }
  7066. saveLog(result, requestLog, "2203", "上传就诊信息")
  7067. var respJSON2 map[string]interface{}
  7068. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7069. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7071. return
  7072. }
  7073. userJSONBytes2, _ := json.Marshal(respJSON2)
  7074. if miConfig.Code == "H15049901371" {
  7075. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  7076. utils.ErrorLog("解析失败:%v", err)
  7077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7078. return
  7079. }
  7080. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7081. // res2.Output = resSix10265.Output
  7082. res2.ErrMsg = resSix10265.ErrMsg
  7083. res2.Cainfo = resSix10265.Cainfo
  7084. res2.WarnMsg = resSix10265.WarnMsg
  7085. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7086. res2.Infcode = infocode
  7087. } else {
  7088. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7089. utils.ErrorLog("解析失败:%v", err)
  7090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7091. return
  7092. }
  7093. }
  7094. }
  7095. }
  7096. if res2.Infcode != 0 {
  7097. adminUser := c.GetAdminUserInfo()
  7098. errlog := &models.HisOrderError{
  7099. UserOrgId: adminUser.CurrentOrgId,
  7100. Ctime: time.Now().Unix(),
  7101. Mtime: time.Now().Unix(),
  7102. ErrMsg: res2.ErrMsg,
  7103. Status: 1,
  7104. PatientId: id,
  7105. RecordTime: recordDateTime,
  7106. Stage: 3,
  7107. }
  7108. service.CreateErrMsgLog(errlog)
  7109. c.ServeSuccessJSON(map[string]interface{}{
  7110. "failed_code": -10,
  7111. "msg": res2.ErrMsg,
  7112. })
  7113. return
  7114. } else {
  7115. his.Diagnosis = diagnosis_id
  7116. his.SickType = sickConfig.ID
  7117. his.PType = fmt.Sprintf("%d", reg_type)
  7118. service.UpdateHisPatientThree(&his)
  7119. data := make(map[string]interface{})
  7120. if settle_accounts_type == 1 { //日结
  7121. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  7122. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  7123. } else {
  7124. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  7125. }
  7126. data["pre"] = prescriptions
  7127. } else { //月结
  7128. start_time_str := c.GetString("start_time")
  7129. end_time_str := c.GetString("end_time")
  7130. timeLayout := "2006-01-02"
  7131. loc, _ := time.LoadLocation("Local")
  7132. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7133. if err != nil {
  7134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7135. return
  7136. }
  7137. recordStartTime := theStartTime.Unix()
  7138. start_time = recordStartTime
  7139. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7140. if err != nil {
  7141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7142. return
  7143. }
  7144. recordEndTime := theEndTime.Unix()
  7145. end_time = recordEndTime
  7146. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  7147. data["pre"] = prescriptions
  7148. }
  7149. client := &http.Client{}
  7150. data["psn_no"] = his.PsnNo
  7151. data["mdtrt_id"] = his.Number
  7152. data["chrg_bchno"] = chrg_bchno
  7153. data["org_name"] = miConfig.OrgName
  7154. data["doctor"] = roles.UserName
  7155. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  7156. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  7157. data["fixmedins_code"] = miConfig.Code
  7158. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  7159. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  7160. data["dept_code"] = "15"
  7161. } else {
  7162. data["dept_code"] = department.Number
  7163. }
  7164. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7165. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7166. data["secret_key"] = miConfig.SecretKey
  7167. data["url"] = miConfig.Url
  7168. data["ak"] = miConfig.AccessKey
  7169. data["new_doctor_name"] = patientPrescription.Doctor
  7170. data["diag_code"] = sickConfig.CountryCode
  7171. data["time_stamp"] = time_stamp
  7172. data["cainfo"] = miConfig.Cainfo
  7173. var ids []int64
  7174. for _, item := range prescriptions {
  7175. ids = append(ids, item.ID)
  7176. }
  7177. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7178. if config.IsOpen == 1 { //对接了医保,走医保流程
  7179. var res ResultFour
  7180. var resFour10265 ResultFour10265
  7181. if miConfig.MdtrtareaAdmvs == "421300" {
  7182. bytesData, _ := json.Marshal(data)
  7183. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  7184. resp, _ := client.Do(req)
  7185. defer resp.Body.Close()
  7186. body, ioErr := ioutil.ReadAll(resp.Body)
  7187. if ioErr != nil {
  7188. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7190. return
  7191. }
  7192. var respJSON map[string]interface{}
  7193. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7194. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7196. return
  7197. }
  7198. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7199. userJSONBytes, _ := json.Marshal(respJSON)
  7200. fmt.Println("log")
  7201. fmt.Println(string(userJSONBytes))
  7202. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7203. utils.ErrorLog("解析失败:%v", err)
  7204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7205. return
  7206. }
  7207. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7208. bytesData, _ := json.Marshal(data)
  7209. var req *http.Request
  7210. if miConfig.MdtrtareaAdmvs == "320921" {
  7211. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7212. } else {
  7213. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7214. }
  7215. resp, _ := client.Do(req)
  7216. defer resp.Body.Close()
  7217. body, ioErr := ioutil.ReadAll(resp.Body)
  7218. if ioErr != nil {
  7219. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7221. return
  7222. }
  7223. var respJSON map[string]interface{}
  7224. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7225. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7227. return
  7228. }
  7229. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7230. userJSONBytes, _ := json.Marshal(respJSON)
  7231. fmt.Println("log")
  7232. fmt.Println(string(userJSONBytes))
  7233. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7234. utils.ErrorLog("解析失败:%v", err)
  7235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7236. return
  7237. }
  7238. res.InfRefmsgid = resFour10265.InfRefmsgid
  7239. res.Output = resFour10265.Output
  7240. res.ErrMsg = resFour10265.ErrMsg
  7241. res.Cainfo = resFour10265.Cainfo
  7242. res.WarnMsg = resFour10265.WarnMsg
  7243. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7244. res.Infcode = infocode
  7245. } else {
  7246. if miConfig.Code == "H15049901371" {
  7247. 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)
  7248. var dat map[string]interface{}
  7249. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7250. fmt.Println(dat)
  7251. } else {
  7252. fmt.Println(err)
  7253. }
  7254. saveLog(result, request_log, "2204", "上传费用明细")
  7255. userJSONBytes, _ := json.Marshal(dat)
  7256. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7257. utils.ErrorLog("解析失败:%v", err)
  7258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7259. return
  7260. }
  7261. res.InfRefmsgid = resFour10265.InfRefmsgid
  7262. res.Output = resFour10265.Output
  7263. res.ErrMsg = resFour10265.ErrMsg
  7264. res.Cainfo = resFour10265.Cainfo
  7265. res.WarnMsg = resFour10265.WarnMsg
  7266. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7267. res.Infcode = infocode
  7268. } else {
  7269. 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)
  7270. var dat map[string]interface{}
  7271. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7272. fmt.Println(dat)
  7273. } else {
  7274. fmt.Println(err)
  7275. }
  7276. saveLog(result, request_log, "2204", "上传费用明细")
  7277. userJSONBytes, _ := json.Marshal(dat)
  7278. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7279. utils.ErrorLog("解析失败:%v", err)
  7280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7281. return
  7282. }
  7283. }
  7284. }
  7285. if res.Infcode == 0 {
  7286. order := &models.HisOrder{
  7287. UserOrgId: adminUser.CurrentOrgId,
  7288. HisPatientId: his.ID,
  7289. PatientId: his.PatientId,
  7290. SettleAccountsDate: recordDateTime,
  7291. Ctime: time.Now().Unix(),
  7292. Mtime: time.Now().Unix(),
  7293. MdtrtId: his.Number,
  7294. PsnNo: his.PsnNo,
  7295. MedType: strconv.FormatInt(reg_type, 10),
  7296. Status: 1,
  7297. Number: chrg_bchno,
  7298. Infcode: res.Infcode,
  7299. WarnMsg: res.WarnMsg,
  7300. Cainfo: res.Cainfo,
  7301. ErrMsg: res.ErrMsg,
  7302. RespondTime: res.RefmsgTime,
  7303. InfRefmsgid: res.InfRefmsgid,
  7304. OrderStatus: 1,
  7305. IsMedicineInsurance: 1,
  7306. SettleType: settle_accounts_type,
  7307. SettleStartTime: start_time,
  7308. SettleEndTime: end_time,
  7309. Creator: roles.AdminUserId,
  7310. Modify: roles.AdminUserId,
  7311. PType: 2,
  7312. Diagnosis: diagnosis_id,
  7313. }
  7314. err = service.CreateOrder(order)
  7315. if err != nil {
  7316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7317. return
  7318. }
  7319. for _, item := range res.Output.Result {
  7320. temp := strings.Split(item.FeedetlSn, "-")
  7321. var advice_id int64 = 0
  7322. var project_id int64 = 0
  7323. var types int64 = 0
  7324. id, _ := strconv.ParseInt(temp[2], 10, 64)
  7325. types, _ = strconv.ParseInt(temp[1], 10, 64)
  7326. if temp[1] == "1" {
  7327. advice_id = id
  7328. project_id = 0
  7329. } else if temp[1] == "2" {
  7330. advice_id = 0
  7331. project_id = id
  7332. }
  7333. info := &models.HisOrderInfo{
  7334. OrderNumber: order.Number,
  7335. FeedetlSn: item.FeedetlSn,
  7336. UploadDate: time.Now().Unix(),
  7337. AdviceId: advice_id,
  7338. DetItemFeeSumamt: item.DetItemFeeSumamt,
  7339. Cnt: item.Cnt,
  7340. Pric: float64(item.Pric),
  7341. PatientId: his.PatientId,
  7342. PricUplmtAmt: item.PricUplmtAmt,
  7343. SelfpayProp: item.SelfpayProp,
  7344. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7345. OverlmtAmt: item.OverlmtAmt,
  7346. PreselfpayAmt: item.PreselfpayAmt,
  7347. BasMednFlag: item.BasMednFlag,
  7348. MedChrgitmType: item.MedChrgitmType,
  7349. HiNegoDrugFlag: item.HiNegoDrugFlag,
  7350. Status: 1,
  7351. Memo: item.Memo,
  7352. Mtime: time.Now().Unix(),
  7353. InscpScpAmt: item.InscpScpAmt,
  7354. DrtReimFlag: item.DrtReimFlag,
  7355. Ctime: time.Now().Unix(),
  7356. ListSpItemFlag: item.ListSpItemFlag,
  7357. ChldMedcFlag: item.ChldMedcFlag,
  7358. LmtUsedFlag: item.LmtUsedFlag,
  7359. ChrgitmLv: item.ChrgitmLv,
  7360. UserOrgId: adminUser.CurrentOrgId,
  7361. HisPatientId: his.ID,
  7362. OrderId: order.ID,
  7363. ProjectId: project_id,
  7364. Type: types,
  7365. }
  7366. service.CreateOrderInfo(info)
  7367. }
  7368. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7369. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  7370. var total float64
  7371. for _, item := range prescriptions {
  7372. if item.Type == 1 { //药品
  7373. for _, subItem := range item.HisDoctorAdviceInfo {
  7374. total = total + (subItem.Price * subItem.PrescribingNumber)
  7375. }
  7376. }
  7377. if item.Type == 2 { //项目
  7378. for _, subItem := range item.HisPrescriptionProject {
  7379. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7380. total = total + (subItem.Price * cnt)
  7381. }
  7382. }
  7383. }
  7384. for _, item := range prescriptions {
  7385. for _, subItem := range item.HisAdditionalCharge {
  7386. total = total + (subItem.Price * float64(subItem.Count))
  7387. }
  7388. }
  7389. allTotal := fmt.Sprintf("%.4f", total)
  7390. if res.Infcode == 0 {
  7391. var rf []*ResultFive
  7392. json.Unmarshal([]byte(his.Iinfo), &rf)
  7393. chrg_bchno := chrg_bchno
  7394. cert_no := his.Certno
  7395. var insutypes []string
  7396. var insutype string
  7397. var is390 int = 0
  7398. var is310 int = 0
  7399. for _, item := range rf {
  7400. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7401. insutypes = append(insutypes, item.Insutype)
  7402. }
  7403. }
  7404. if len(insutypes) == 1 {
  7405. insutype = insutypes[0]
  7406. } else {
  7407. for _, i := range insutypes {
  7408. if i == "390" {
  7409. is390 = 1
  7410. }
  7411. if i == "310" {
  7412. is310 = 1
  7413. }
  7414. }
  7415. }
  7416. if is390 == 1 {
  7417. insutype = "390"
  7418. }
  7419. if is310 == 1 {
  7420. insutype = "310"
  7421. }
  7422. if len(insutypes) == 0 {
  7423. insutype = "310"
  7424. }
  7425. if len(insutypes) == 2 {
  7426. insutype = strconv.FormatInt(his.SocialType, 64)
  7427. }
  7428. //insutype = "390"
  7429. if his.IdCardType == 1 {
  7430. cert_no = his.MedicalInsuranceNumber
  7431. } else {
  7432. cert_no = his.Certno
  7433. }
  7434. var res models.GZResult2206
  7435. var resSeven10265 ResultSeven10265
  7436. if miConfig.MdtrtareaAdmvs == "421300" {
  7437. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7438. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7439. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7440. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7441. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7442. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7443. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  7444. resp, requestErr := http.Get(api)
  7445. if requestErr != nil {
  7446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7447. return
  7448. }
  7449. body, ioErr := ioutil.ReadAll(resp.Body)
  7450. if ioErr != nil {
  7451. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7453. return
  7454. }
  7455. var respJSON map[string]interface{}
  7456. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7457. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7459. return
  7460. }
  7461. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7462. result, _ := json.Marshal(respJSON)
  7463. fmt.Println("log")
  7464. fmt.Println(string(result))
  7465. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7466. utils.ErrorLog("解析失败:%v", err)
  7467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7468. return
  7469. }
  7470. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7471. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7472. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7473. bas := strings.Split(psn_info.CardInfo, "|")
  7474. if his.IdCardType == 1 {
  7475. cert_no = bas[2]
  7476. } else {
  7477. cert_no = bas[1]
  7478. }
  7479. //江苏地区国家医保医疗类别
  7480. //职工透析:医疗类别选特殊情况门诊9933
  7481. //居民血透门慢: 医疗类别选门诊慢病1402
  7482. //var med_type string
  7483. //if his.Insutype == "310" {
  7484. // if reg_type == 14 {
  7485. // med_type = "9933"
  7486. // } else if reg_type == 11 {
  7487. // med_type = "11"
  7488. //
  7489. // }
  7490. //} else if his.Insutype == "390" {
  7491. // if reg_type == 14 {
  7492. // med_type = "1402"
  7493. // } else if reg_type == 11 {
  7494. // med_type = "11"
  7495. // }
  7496. //}
  7497. var api string
  7498. if miConfig.MdtrtareaAdmvs == "320921" {
  7499. api = "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7500. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7501. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7502. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7503. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7504. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7505. "&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
  7506. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7507. } else {
  7508. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7509. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7510. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7511. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7512. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7513. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7514. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7515. "&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
  7516. }
  7517. resp, requestErr := http.Get(api)
  7518. if requestErr != nil {
  7519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7520. return
  7521. }
  7522. body, ioErr := ioutil.ReadAll(resp.Body)
  7523. if ioErr != nil {
  7524. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7526. return
  7527. }
  7528. var respJSON map[string]interface{}
  7529. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7530. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7532. return
  7533. }
  7534. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7535. result, _ := json.Marshal(respJSON)
  7536. fmt.Println("log")
  7537. fmt.Println(string(result))
  7538. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7539. utils.ErrorLog("解析失败:%v", err)
  7540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7541. return
  7542. }
  7543. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7544. // res.Output = resSeven10265.Output
  7545. res.ErrMsg = resSeven10265.ErrMsg
  7546. res.Cainfo = resSeven10265.Cainfo
  7547. // res.WarnMsg = resSeven10265.WarnMsg
  7548. // infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7549. // res.Infcode = infocode
  7550. } else {
  7551. var result string
  7552. var request_log string
  7553. if miConfig.Code == "H15049901371" {
  7554. //赤峰地区国家医保医疗类别
  7555. //职工透析:医疗类别选特殊情况门诊990502
  7556. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7557. var med_type string
  7558. if his.Insutype == "390" {
  7559. if reg_type == 14 {
  7560. med_type = "9933"
  7561. } else if reg_type == 11 {
  7562. med_type = "11"
  7563. }
  7564. } else if his.Insutype == "310" {
  7565. if reg_type == 14 {
  7566. med_type = "990502"
  7567. } else if reg_type == 11 {
  7568. med_type = "11"
  7569. }
  7570. }
  7571. 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)
  7572. } else {
  7573. var med_type string
  7574. if reg_type == 14 {
  7575. med_type = "141009"
  7576. } else if reg_type == 11 {
  7577. med_type = "11"
  7578. }
  7579. 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)
  7580. }
  7581. var dat map[string]interface{}
  7582. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7583. fmt.Println(dat)
  7584. } else {
  7585. fmt.Println(err)
  7586. }
  7587. saveLog(result, request_log, "2206", "预结算")
  7588. //userJSONBytes, _ := json.Marshal(dat)
  7589. //
  7590. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7591. // utils.ErrorLog("解析失败:%v", err)
  7592. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7593. // return
  7594. //}
  7595. userJSONBytes, _ := json.Marshal(dat)
  7596. if miConfig.Code == "H15049901371" {
  7597. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7598. utils.ErrorLog("解析失败:%v", err)
  7599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7600. return
  7601. }
  7602. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7603. // res.Output = resSeven10265.Output
  7604. res.ErrMsg = resSeven10265.ErrMsg
  7605. res.Cainfo = resSeven10265.Cainfo
  7606. // res.WarnMsg = resSeven10265.WarnMsg
  7607. // infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7608. // res.Infcode = infocode
  7609. } else {
  7610. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7611. utils.ErrorLog("解析失败:%v", err)
  7612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7613. return
  7614. }
  7615. }
  7616. }
  7617. if res.Infcode != 0 {
  7618. errlog := &models.HisOrderError{
  7619. UserOrgId: adminUser.CurrentOrgId,
  7620. Ctime: time.Now().Unix(),
  7621. Mtime: time.Now().Unix(),
  7622. Number: chrg_bchno,
  7623. ErrMsg: res.ErrMsg,
  7624. Status: 1,
  7625. PatientId: id,
  7626. RecordTime: recordDateTime,
  7627. Stage: 20,
  7628. }
  7629. service.CreateErrMsgLog(errlog)
  7630. c.ServeSuccessJSON(map[string]interface{}{
  7631. "failed_code": -10,
  7632. "msg": res.ErrMsg,
  7633. })
  7634. return
  7635. } else {
  7636. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7637. order.OrderStatus = 1
  7638. order.IsPre = 1
  7639. order.Status = 1
  7640. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7641. // order.SetlId = res.Output.Setlinfo.SetlID
  7642. order.PsnNo = res.Output.Setlinfo.PsnNo
  7643. order.PsnName = res.Output.Setlinfo.PsnName
  7644. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7645. order.Certno = res.Output.Setlinfo.Certno
  7646. order.Gend = res.Output.Setlinfo.Gend
  7647. order.Naty = res.Output.Setlinfo.Naty
  7648. order.Age = res.Output.Setlinfo.Age
  7649. order.Insutype = res.Output.Setlinfo.Insutype
  7650. order.PsnType = res.Output.Setlinfo.PsnType
  7651. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7652. order.SetlTime = res.Output.Setlinfo.SetlTime
  7653. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7654. if res.Output.Setlinfo.MedType == "140101" {
  7655. order.MedType = "14"
  7656. } else {
  7657. order.MedType = res.Output.Setlinfo.MedType
  7658. }
  7659. if reg_type == 1112 {
  7660. order.MedType = "1112"
  7661. }
  7662. if reg_type == 1111 {
  7663. order.MedType = "1111"
  7664. }
  7665. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7666. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7667. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7668. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7669. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7670. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7671. order.HifpPay = res.Output.Setlinfo.HifpPay
  7672. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7673. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7674. order.HifesPay = res.Output.Setlinfo.HifesPay
  7675. order.HifobPay = res.Output.Setlinfo.HifobPay
  7676. order.MafPay = res.Output.Setlinfo.MafPay
  7677. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  7678. order.OthPay = res.Output.Setlinfo.OthPay
  7679. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7680. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7681. order.AcctPay = res.Output.Setlinfo.AcctPay
  7682. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7683. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7684. order.Balc = res.Output.Setlinfo.Balc
  7685. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7686. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7687. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7688. order.ClrWay = res.Output.Setlinfo.ClrWay
  7689. order.Creator = order.Creator
  7690. order.Modify = roles.AdminUserId
  7691. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7692. detailStr := string(setlDetail)
  7693. order.SetlDetail = detailStr
  7694. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7695. err = service.UpDateOrder(order)
  7696. if err == nil {
  7697. c.ServeSuccessJSON(map[string]interface{}{
  7698. "msg": "预结算成功",
  7699. })
  7700. } else {
  7701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7702. return
  7703. }
  7704. }
  7705. } else {
  7706. adminUser := c.GetAdminUserInfo()
  7707. errlog := &models.HisOrderError{
  7708. UserOrgId: adminUser.CurrentOrgId,
  7709. Ctime: time.Now().Unix(),
  7710. Mtime: time.Now().Unix(),
  7711. ErrMsg: res.ErrMsg,
  7712. Status: 1,
  7713. PatientId: id,
  7714. RecordTime: recordDateTime,
  7715. Stage: 4,
  7716. }
  7717. service.CreateErrMsgLog(errlog)
  7718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7719. return
  7720. }
  7721. } else {
  7722. adminUser := c.GetAdminUserInfo()
  7723. errlog := &models.HisOrderError{
  7724. UserOrgId: adminUser.CurrentOrgId,
  7725. Ctime: time.Now().Unix(),
  7726. Mtime: time.Now().Unix(),
  7727. ErrMsg: res.ErrMsg,
  7728. Status: 1,
  7729. PatientId: id,
  7730. RecordTime: recordDateTime,
  7731. Stage: 4,
  7732. }
  7733. service.CreateErrMsgLog(errlog)
  7734. c.ServeSuccessJSON(map[string]interface{}{
  7735. "failed_code": -10,
  7736. "msg": res.ErrMsg,
  7737. })
  7738. return
  7739. }
  7740. }
  7741. }
  7742. }
  7743. //func (c *HisApiController) GetSettleInfo() {
  7744. // id, _ := c.GetInt64("id")
  7745. // order_id, _ := c.GetInt64("order_id")
  7746. //
  7747. // record_time := c.GetString("record_time")
  7748. // pay_way, _ := c.GetInt64("pay_way")
  7749. // pay_price, _ := c.GetFloat("pay_price")
  7750. // pay_card_no := c.GetString("pay_card_no")
  7751. // discount_price, _ := c.GetFloat("discount_price")
  7752. // preferential_price, _ := c.GetFloat("preferential_price")
  7753. // reality_price, _ := c.GetFloat("reality_price")
  7754. // found_price, _ := c.GetFloat("found_price")
  7755. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  7756. // private_price, _ := c.GetFloat("private_price")
  7757. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7758. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7759. //
  7760. // timeLayout := "2006-01-02"
  7761. // loc, _ := time.LoadLocation("Local")
  7762. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7763. // if err != nil {
  7764. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7765. // return
  7766. // }
  7767. // recordDateTime := theTime.Unix()
  7768. // adminUser := c.GetAdminUserInfo()
  7769. //
  7770. // var prescriptions []*models.HisPrescription
  7771. //
  7772. // data := make(map[string]interface{})
  7773. // if settle_accounts_type == 1 { //日结
  7774. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  7775. // data["pre"] = prescriptions
  7776. //
  7777. // } else { //月结
  7778. // start_time_str := c.GetString("start_time")
  7779. // end_time_str := c.GetString("end_time")
  7780. // timeLayout := "2006-01-02"
  7781. // loc, _ := time.LoadLocation("Local")
  7782. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7783. // if err != nil {
  7784. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7785. // return
  7786. // }
  7787. // recordStartTime := theStartTime.Unix()
  7788. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7789. // if err != nil {
  7790. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7791. // return
  7792. // }
  7793. // recordEndTime := theEndTime.Unix()
  7794. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  7795. // data["pre"] = prescriptions
  7796. //
  7797. // }
  7798. //
  7799. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7800. //
  7801. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7802. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7803. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7804. // strconv.FormatInt(his.PatientId, 10)
  7805. //
  7806. // order_src, _ := service.GetHisOrderByID(order_id)
  7807. //
  7808. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7809. // if config.IsOpen == 1 { //对接了医保,走医保流程
  7810. //
  7811. // var total float64
  7812. // for _, item := range prescriptions {
  7813. // if item.Type == 1 { //药品
  7814. // for _, subItem := range item.HisDoctorAdviceInfo {
  7815. // total = total + (subItem.Price * subItem.PrescribingNumber)
  7816. // }
  7817. // }
  7818. // if item.Type == 2 { //项目
  7819. // for _, subItem := range item.HisPrescriptionProject {
  7820. // total = total + (subItem.Price * float64(subItem.Count))
  7821. // }
  7822. // }
  7823. // }
  7824. //
  7825. // for _, item := range prescriptions {
  7826. // for _, subItem := range item.HisAdditionalCharge {
  7827. // total = total + (subItem.Price * float64(subItem.Count))
  7828. // }
  7829. // }
  7830. //
  7831. // allTotal := fmt.Sprintf("%.2f", total)
  7832. // var rf []*ResultFive
  7833. // json.Unmarshal([]byte(his.Iinfo), &rf)
  7834. // psn_no := order_src.PsnNo
  7835. // mdtrt_id := order_src.MdtrtId
  7836. // chrg_bchno := order_src.Number
  7837. // cert_no := order_src.Certno
  7838. // insutype := rf[0].Insutype
  7839. //
  7840. // if his.IdCardType == 1 {
  7841. // cert_no = his.MedicalInsuranceNumber
  7842. // } else {
  7843. // cert_no = his.Certno
  7844. // }
  7845. //
  7846. // 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)
  7847. // var dat map[string]interface{}
  7848. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7849. // fmt.Println(dat)
  7850. // } else {
  7851. // fmt.Println(err)
  7852. // }
  7853. //
  7854. // userJSONBytes, _ := json.Marshal(dat)
  7855. //
  7856. //
  7857. //
  7858. // var res ResultSeven
  7859. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7860. // utils.ErrorLog("解析失败:%v", err)
  7861. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7862. // return
  7863. // }
  7864. // if res.Infcode == -1 {
  7865. // errlog := &models.HisOrderError{
  7866. // UserOrgId: adminUser.CurrentOrgId,
  7867. // Ctime: time.Now().Unix(),
  7868. // Mtime: time.Now().Unix(),
  7869. // Number: chrg_bchno,
  7870. // ErrMsg: res.ErrMsg,
  7871. // Status: 1,
  7872. // PatientId: id,
  7873. // RecordTime: recordDateTime,
  7874. // Stage: 6,
  7875. // }
  7876. // service.CreateErrMsgLog(errlog)
  7877. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7878. // return
  7879. // } else {
  7880. // order_src.OrderStatus = 2
  7881. // order_src.PayWay = pay_way
  7882. // order_src.PayPrice = pay_price
  7883. // order_src.PayCardNo = pay_card_no
  7884. // order_src.DiscountPrice = discount_price
  7885. // order_src.PreferentialPrice = preferential_price
  7886. // order_src.RealityPrice = reality_price
  7887. // order_src.FoundPrice = found_price
  7888. // order_src.MedicalInsurancePrice = medical_insurance_price
  7889. // order_src.PrivatePrice = private_price
  7890. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  7891. // order_src.SetlId = res.Output.Setlinfo.SetlID
  7892. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  7893. // order_src.PsnName = res.Output.Setlinfo.PsnName
  7894. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  7895. // order_src.Certno = res.Output.Setlinfo.Certno
  7896. // order_src.Gend = res.Output.Setlinfo.Gend
  7897. // order_src.Naty = res.Output.Setlinfo.Naty
  7898. // order_src.Age = res.Output.Setlinfo.Age
  7899. // order_src.Insutype = res.Output.Setlinfo.Insutype
  7900. // order_src.PsnType = res.Output.Setlinfo.PsnType
  7901. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7902. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  7903. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7904. // order_src.MedType = res.Output.Setlinfo.MedType
  7905. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7906. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7907. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7908. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7909. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7910. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7911. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  7912. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  7913. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7914. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  7915. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  7916. // order_src.MafPay = res.Output.Setlinfo.MafPay
  7917. // order_src.OthPay = res.Output.Setlinfo.OthPay
  7918. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7919. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7920. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  7921. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7922. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7923. // order_src.Balc = res.Output.Setlinfo.Balc
  7924. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7925. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7926. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  7927. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  7928. // order_src.Creator = order_src.Creator
  7929. // order_src.Modify = roles.ID
  7930. // order_src.RequestLog = src_resquest
  7931. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7932. // detailStr := string(setlDetail)
  7933. // order_src.SetlDetail = detailStr
  7934. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7935. // err = service.UpDateOrder(order_src)
  7936. //
  7937. // if err == nil {
  7938. // c.ServeSuccessJSON(map[string]interface{}{
  7939. // "msg": "结算成功",
  7940. // })
  7941. // } else {
  7942. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7943. // return
  7944. // }
  7945. // }
  7946. // }
  7947. //}
  7948. //退款
  7949. func (c *HisApiController) Refund() {
  7950. order_id, _ := c.GetInt64("order_id")
  7951. admin_user_id, _ := c.GetInt64("admin_user_id")
  7952. adminUser := c.GetAdminUserInfo()
  7953. var order models.HisOrder
  7954. order, _ = service.GetHisOrderByID(order_id)
  7955. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7956. if order.ID == 0 {
  7957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7958. return
  7959. }
  7960. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7961. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7962. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7963. if config.IsOpen == 1 { //对接了医保,走医保流程
  7964. var res ResultFourteen
  7965. var resSixteen10265 ResultSixteen10265
  7966. var src_resquest string
  7967. var result string
  7968. if miConfig.MdtrtareaAdmvs == "421300" {
  7969. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  7970. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7971. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7972. resp3, requestErr3 := http.Get(api3)
  7973. if requestErr3 != nil {
  7974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7975. return
  7976. }
  7977. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7978. if ioErr3 != nil {
  7979. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7981. return
  7982. }
  7983. var respJSON3 map[string]interface{}
  7984. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7985. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7987. return
  7988. }
  7989. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7990. userJSONBytes3, _ := json.Marshal(respJSON3)
  7991. fmt.Println("log")
  7992. fmt.Println(string(userJSONBytes3))
  7993. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  7994. utils.ErrorLog("解析失败:%v", err)
  7995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7996. return
  7997. }
  7998. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7999. var api3 string
  8000. if miConfig.MdtrtareaAdmvs == "320921" {
  8001. api3 = "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  8002. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8003. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8004. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8005. } else {
  8006. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8007. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  8008. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8009. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8010. }
  8011. resp3, requestErr3 := http.Get(api3)
  8012. if requestErr3 != nil {
  8013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8014. return
  8015. }
  8016. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8017. if ioErr3 != nil {
  8018. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8020. return
  8021. }
  8022. var respJSON3 map[string]interface{}
  8023. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8024. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8026. return
  8027. }
  8028. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8029. userJSONBytes3, _ := json.Marshal(respJSON3)
  8030. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  8031. utils.ErrorLog("解析失败:%v", err)
  8032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8033. return
  8034. }
  8035. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  8036. // res.Output = resSixteen10265.Output
  8037. res.ErrMsg = resSixteen10265.ErrMsg
  8038. // res.Cainfo = resSixteen10265.Cainfo
  8039. // res.WarnMsg = resSixteen10265.WarnMsg
  8040. // infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  8041. // res.Infcode = infocode
  8042. } else {
  8043. if miConfig.Code == "H15049901371" {
  8044. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  8045. var dat map[string]interface{}
  8046. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8047. fmt.Println(dat)
  8048. } else {
  8049. fmt.Println(err)
  8050. }
  8051. saveLog(result, src_resquest, "2208", "退费")
  8052. userJSONBytes, _ := json.Marshal(dat)
  8053. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  8054. utils.ErrorLog("解析失败:%v", err)
  8055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8056. return
  8057. }
  8058. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  8059. // res.Output = resSixteen10265.Output
  8060. res.ErrMsg = resSixteen10265.ErrMsg
  8061. // res.Cainfo = resSixteen10265.Cainfo
  8062. // res.WarnMsg = resSixteen10265.WarnMsg
  8063. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  8064. res.Infcode = infocode
  8065. } else {
  8066. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  8067. var dat map[string]interface{}
  8068. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8069. fmt.Println(dat)
  8070. } else {
  8071. fmt.Println(err)
  8072. }
  8073. saveLog(result, src_resquest, "2208", "退费")
  8074. userJSONBytes, _ := json.Marshal(dat)
  8075. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8076. utils.ErrorLog("解析失败:%v", err)
  8077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8078. return
  8079. }
  8080. }
  8081. }
  8082. if res.Infcode == 0 {
  8083. var res2 ResultSix
  8084. var resSix10265 ResultSix10265
  8085. if miConfig.MdtrtareaAdmvs == "421300" {
  8086. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8087. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8088. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8089. resp3, requestErr3 := http.Get(api3)
  8090. if requestErr3 != nil {
  8091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8092. return
  8093. }
  8094. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8095. if ioErr3 != nil {
  8096. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8098. return
  8099. }
  8100. var respJSON3 map[string]interface{}
  8101. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8102. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8104. return
  8105. }
  8106. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8107. userJSONBytes3, _ := json.Marshal(respJSON3)
  8108. fmt.Println("log")
  8109. fmt.Println(string(userJSONBytes3))
  8110. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8111. utils.ErrorLog("解析失败:%v", err)
  8112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8113. return
  8114. }
  8115. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8116. var api3 string
  8117. if miConfig.MdtrtareaAdmvs == "320921" {
  8118. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8119. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8120. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8121. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8122. } else {
  8123. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8124. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8125. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8126. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8127. }
  8128. resp3, requestErr3 := http.Get(api3)
  8129. if requestErr3 != nil {
  8130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8131. return
  8132. }
  8133. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8134. if ioErr3 != nil {
  8135. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8137. return
  8138. }
  8139. var respJSON3 map[string]interface{}
  8140. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8141. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8143. return
  8144. }
  8145. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8146. userJSONBytes3, _ := json.Marshal(respJSON3)
  8147. fmt.Println("log")
  8148. fmt.Println(string(userJSONBytes3))
  8149. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8150. utils.ErrorLog("解析失败:%v", err)
  8151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8152. return
  8153. }
  8154. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8155. // res2.Output = resSix10265.Output
  8156. res2.ErrMsg = resSix10265.ErrMsg
  8157. res2.Cainfo = resSix10265.Cainfo
  8158. res2.WarnMsg = resSix10265.WarnMsg
  8159. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8160. res2.Infcode = infocode
  8161. } else {
  8162. if miConfig.Code == "H15049901371" {
  8163. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8164. var dat map[string]interface{}
  8165. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8166. fmt.Println(dat)
  8167. } else {
  8168. fmt.Println(err)
  8169. }
  8170. saveLog(result2, src_request, "2205", "撤销明细")
  8171. userJSONBytes, _ := json.Marshal(dat)
  8172. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  8173. utils.ErrorLog("解析失败:%v", err)
  8174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8175. return
  8176. }
  8177. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8178. // res2.Output = resSix10265.Output
  8179. res2.ErrMsg = resSix10265.ErrMsg
  8180. res2.Cainfo = resSix10265.Cainfo
  8181. res2.WarnMsg = resSix10265.WarnMsg
  8182. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8183. res2.Infcode = infocode
  8184. } else {
  8185. order_infos, _ := service.GetHisOrderInfoByNumberFour(order.Number)
  8186. for _, item := range order_infos {
  8187. result2, src_request := service.Gdyb2205ForGz(order.PsnNo, order.MdtrtId, item.FeedetlSn, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8188. var dat map[string]interface{}
  8189. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8190. fmt.Println(dat)
  8191. } else {
  8192. fmt.Println(err)
  8193. }
  8194. saveLog(result2, src_request, "2205", "撤销明细")
  8195. userJSONBytes, _ := json.Marshal(dat)
  8196. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8197. utils.ErrorLog("解析失败:%v", err)
  8198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8199. return
  8200. }
  8201. }
  8202. }
  8203. }
  8204. if res2.Infcode == 0 {
  8205. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  8206. if err == nil {
  8207. //当押金不为零时产生退费记录
  8208. if order.Decimal != 0 {
  8209. tmp := strconv.FormatInt(order.ID, 10)
  8210. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  8211. if err != nil {
  8212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8213. return
  8214. }
  8215. }
  8216. c.ServeSuccessJSON(map[string]interface{}{
  8217. "msg": "退费成功",
  8218. })
  8219. } else {
  8220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8221. return
  8222. }
  8223. } else {
  8224. c.ServeSuccessJSON(map[string]interface{}{
  8225. "code": -10,
  8226. "msg": res2.ErrMsg,
  8227. })
  8228. }
  8229. } else {
  8230. c.ServeSuccessJSON(map[string]interface{}{
  8231. "code": -10,
  8232. "msg": res.ErrMsg,
  8233. })
  8234. }
  8235. }
  8236. }
  8237. func (c *HisApiController) RefundNumber() {
  8238. record_time := c.GetString("record_time")
  8239. //patient_id, _ := c.GetInt64("patient_id")
  8240. admin_user_id, _ := c.GetInt64("admin_user_id")
  8241. his_patient_id, _ := c.GetInt64("id")
  8242. timeLayout := "2006-01-02"
  8243. loc, _ := time.LoadLocation("Local")
  8244. adminUser := c.GetAdminUserInfo()
  8245. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8246. fmt.Println(err)
  8247. if err != nil {
  8248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8249. return
  8250. }
  8251. recordDateTime := theTime.Unix()
  8252. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8253. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  8254. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8255. //order, _ := service.GetHisOrderByID(order_id)
  8256. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8257. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8258. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8259. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  8260. if count > 0 {
  8261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  8262. return
  8263. }
  8264. if config.IsOpen == 1 { //对接了医保,走医保流程
  8265. var res2 ResultSix
  8266. var resSix10265 ResultSix10265
  8267. if miConfig.MdtrtareaAdmvs == "421300" {
  8268. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  8269. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8270. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8271. resp3, requestErr3 := http.Get(api3)
  8272. if requestErr3 != nil {
  8273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8274. return
  8275. }
  8276. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8277. if ioErr3 != nil {
  8278. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8280. return
  8281. }
  8282. var respJSON3 map[string]interface{}
  8283. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8284. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8286. return
  8287. }
  8288. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8289. userJSONBytes3, _ := json.Marshal(respJSON3)
  8290. fmt.Println("log")
  8291. fmt.Println(string(userJSONBytes3))
  8292. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8293. utils.ErrorLog("解析失败:%v", err)
  8294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8295. return
  8296. }
  8297. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8298. var api3 string
  8299. if miConfig.MdtrtareaAdmvs == "320921" {
  8300. api3 = "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8301. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8302. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8303. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8304. } else {
  8305. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8306. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8307. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8308. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8309. }
  8310. resp3, requestErr3 := http.Get(api3)
  8311. if requestErr3 != nil {
  8312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8313. return
  8314. }
  8315. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8316. if ioErr3 != nil {
  8317. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8319. return
  8320. }
  8321. var respJSON3 map[string]interface{}
  8322. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8323. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8325. return
  8326. }
  8327. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8328. userJSONBytes3, _ := json.Marshal(respJSON3)
  8329. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8330. utils.ErrorLog("解析失败:%v", err)
  8331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8332. return
  8333. }
  8334. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8335. // res2.Output = resSix10265.Output
  8336. res2.ErrMsg = resSix10265.ErrMsg
  8337. res2.Cainfo = resSix10265.Cainfo
  8338. res2.WarnMsg = resSix10265.WarnMsg
  8339. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8340. res2.Infcode = infocode
  8341. } else {
  8342. var api3 string
  8343. if miConfig.Code == "H15049901371" {
  8344. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8345. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8346. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8347. } else {
  8348. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8349. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8350. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8351. }
  8352. resp3, requestErr3 := http.Get(api3)
  8353. if requestErr3 != nil {
  8354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8355. return
  8356. }
  8357. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8358. if ioErr3 != nil {
  8359. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8361. return
  8362. }
  8363. var respJSON3 map[string]interface{}
  8364. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8365. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8367. return
  8368. }
  8369. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8370. userJSONBytes3, _ := json.Marshal(respJSON3)
  8371. if miConfig.Code == "H15049901371" {
  8372. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8373. utils.ErrorLog("解析失败:%v", err)
  8374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8375. return
  8376. }
  8377. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8378. // res2.Output = resSix10265.Output
  8379. res2.ErrMsg = resSix10265.ErrMsg
  8380. res2.Cainfo = resSix10265.Cainfo
  8381. res2.WarnMsg = resSix10265.WarnMsg
  8382. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8383. res2.Infcode = infocode
  8384. } else {
  8385. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8386. utils.ErrorLog("解析失败:%v", err)
  8387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8388. return
  8389. }
  8390. }
  8391. }
  8392. if res2.Infcode == 0 {
  8393. if err == nil {
  8394. c.ServeSuccessJSON(map[string]interface{}{
  8395. "msg": "退号成功",
  8396. })
  8397. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  8398. } else {
  8399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8400. return
  8401. }
  8402. } else {
  8403. c.ServeSuccessJSON(map[string]interface{}{
  8404. "code": -10,
  8405. "msg": res2.ErrMsg,
  8406. })
  8407. }
  8408. } else {
  8409. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  8410. //if err == nil {
  8411. // c.ServeSuccessJSON(map[string]interface{}{
  8412. // "msg": "退费成功",
  8413. // })
  8414. //} else {
  8415. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8416. // return
  8417. //}
  8418. }
  8419. }
  8420. func (c *HisApiController) RefundDetail() {
  8421. order_id, _ := c.GetInt64("order_id")
  8422. admin_user_id, _ := c.GetInt64("admin_user_id")
  8423. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8424. number := c.GetString("number")
  8425. record_time := c.GetString("record_time")
  8426. patient_id, _ := c.GetInt64("patient_id")
  8427. //med_type, _ := c.GetInt64("med_type")
  8428. timeLayout := "2006-01-02"
  8429. loc, _ := time.LoadLocation("Local")
  8430. adminUser := c.GetAdminUserInfo()
  8431. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8432. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8433. fmt.Println(err)
  8434. if err != nil {
  8435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8436. return
  8437. }
  8438. recordDateTime := theTime.Unix()
  8439. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8440. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8441. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8442. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8443. var order models.HisOrder
  8444. order, _ = service.GetHisOrderByID(order_id)
  8445. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8446. if config.IsOpen == 1 { //对接了医保,走医保流程
  8447. var res2 ResultSix
  8448. if miConfig.MdtrtareaAdmvs == "421300" {
  8449. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8450. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8451. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8452. resp3, requestErr3 := http.Get(api3)
  8453. if requestErr3 != nil {
  8454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8455. return
  8456. }
  8457. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8458. if ioErr3 != nil {
  8459. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8461. return
  8462. }
  8463. var respJSON3 map[string]interface{}
  8464. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8465. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8467. return
  8468. }
  8469. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8470. userJSONBytes3, _ := json.Marshal(respJSON3)
  8471. fmt.Println("log")
  8472. fmt.Println(string(userJSONBytes3))
  8473. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8474. utils.ErrorLog("解析失败:%v", err)
  8475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8476. return
  8477. }
  8478. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8479. if err == nil {
  8480. c.ServeSuccessJSON(map[string]interface{}{
  8481. "msg": "撤销明细成功",
  8482. })
  8483. return
  8484. } else {
  8485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8486. return
  8487. }
  8488. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8489. var resSix10265 ResultSix10265
  8490. var api3 string
  8491. if miConfig.MdtrtareaAdmvs == "320921" {
  8492. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8493. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8494. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8495. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8496. } else {
  8497. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8498. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8499. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8500. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8501. }
  8502. resp3, requestErr3 := http.Get(api3)
  8503. if requestErr3 != nil {
  8504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8505. return
  8506. }
  8507. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8508. if ioErr3 != nil {
  8509. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8511. return
  8512. }
  8513. var respJSON3 map[string]interface{}
  8514. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8515. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8517. return
  8518. }
  8519. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8520. userJSONBytes3, _ := json.Marshal(respJSON3)
  8521. fmt.Println("log")
  8522. fmt.Println(string(userJSONBytes3))
  8523. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8524. utils.ErrorLog("解析失败:%v", err)
  8525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8526. return
  8527. }
  8528. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8529. // res2.Output = resSix10265.Output
  8530. res2.ErrMsg = resSix10265.ErrMsg
  8531. res2.Cainfo = resSix10265.Cainfo
  8532. res2.WarnMsg = resSix10265.WarnMsg
  8533. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8534. res2.Infcode = infocode
  8535. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8536. if err == nil {
  8537. c.ServeSuccessJSON(map[string]interface{}{
  8538. "msg": "撤销明细成功",
  8539. })
  8540. return
  8541. } else {
  8542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8543. return
  8544. }
  8545. } else {
  8546. order_infos, _ := service.GetHisOrderInfoByNumberFour(order.Number)
  8547. for _, item := range order_infos {
  8548. result2, src_request := service.Gdyb2205ForGz(order.PsnNo, order.MdtrtId, item.FeedetlSn, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8549. var dat map[string]interface{}
  8550. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8551. fmt.Println(dat)
  8552. } else {
  8553. fmt.Println(err)
  8554. }
  8555. saveLog(result2, src_request, "2205", "撤销明细")
  8556. userJSONBytes, _ := json.Marshal(dat)
  8557. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8558. utils.ErrorLog("解析失败:%v", err)
  8559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8560. return
  8561. }
  8562. }
  8563. }
  8564. }
  8565. }
  8566. //对账
  8567. func (c *HisApiController) GetCheckAccount() {
  8568. start_time := c.GetString("start_time")
  8569. end_time := c.GetString("end_time")
  8570. insutype := c.GetString("insutype")
  8571. clr_type := c.GetString("clr_type")
  8572. clr_org := c.GetString("clr_optins")
  8573. admin_user_id, _ := c.GetInt64("admin_user_id")
  8574. adminUser := c.GetAdminUserInfo()
  8575. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8576. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8577. if len(clr_org) == 0 {
  8578. clr_org = miConfig.MdtrtareaAdmvs
  8579. }
  8580. timeLayout := "2006-01-02"
  8581. loc, _ := time.LoadLocation("Local")
  8582. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8583. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8584. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  8585. fixmedins_setl_cnt := int64(len(orders))
  8586. var medfee_sumamt float64
  8587. var acct_pay float64
  8588. var fund_pay_sumamt float64
  8589. for _, item := range orders {
  8590. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8591. acct_pay = acct_pay + item.AcctPay
  8592. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8593. }
  8594. var user_name string
  8595. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8596. if role.ID == 0 {
  8597. user_name = "xxx"
  8598. } else {
  8599. user_name = role.UserName
  8600. }
  8601. var res ResultEight
  8602. var res10188 ResultEightFor10188
  8603. if config.IsOpen == 1 {
  8604. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8605. api := "http://192.168.3.111:9532/" + "jsyb/3201?" +
  8606. "insutype=" + insutype +
  8607. "&clr_type=" + "11" +
  8608. "&setl_optins=" + clr_org +
  8609. "&stmt_begndate=" + start_time +
  8610. "&stm_enddate=" + end_time +
  8611. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8612. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8613. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8614. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8615. "&fixmedins_code=" + miConfig.Code +
  8616. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8617. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8618. "&secret_key=" + miConfig.SecretKey +
  8619. "&org_name=" + miConfig.OrgName +
  8620. "&doctor=" + user_name +
  8621. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8622. fmt.Println(api)
  8623. resp, requestErr := http.Get(api)
  8624. if requestErr != nil {
  8625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8626. return
  8627. }
  8628. body, ioErr := ioutil.ReadAll(resp.Body)
  8629. fmt.Println(body)
  8630. if ioErr != nil {
  8631. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8633. return
  8634. }
  8635. var respJSON map[string]interface{}
  8636. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8637. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8639. return
  8640. }
  8641. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8642. userJSONBytes, _ := json.Marshal(respJSON)
  8643. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8644. utils.ErrorLog("解析失败:%v", err)
  8645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8646. return
  8647. }
  8648. res.InfRefmsgid = res10188.InfRefmsgid
  8649. res.Output = res10188.Output
  8650. res.ErrMsg = res10188.ErrMsg
  8651. res.Cainfo = res10188.Cainfo
  8652. res.WarnMsg = res10188.WarnMsg
  8653. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8654. res.Infcode = infocode
  8655. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8656. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  8657. "insutype=" + insutype +
  8658. "&clr_type=" + "21" +
  8659. "&setl_optins=" + clr_org +
  8660. "&stmt_begndate=" + start_time +
  8661. "&stm_enddate=" + end_time +
  8662. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8663. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8664. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8665. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8666. "&fixmedins_code=" + miConfig.Code +
  8667. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8668. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8669. "&secret_key=" + miConfig.SecretKey +
  8670. "&org_name=" + miConfig.OrgName +
  8671. "&doctor=" + user_name
  8672. resp, requestErr := http.Get(api)
  8673. if requestErr != nil {
  8674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8675. return
  8676. }
  8677. body, ioErr := ioutil.ReadAll(resp.Body)
  8678. if ioErr != nil {
  8679. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8681. return
  8682. }
  8683. var respJSON map[string]interface{}
  8684. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8685. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8687. return
  8688. }
  8689. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8690. result, _ := json.Marshal(respJSON)
  8691. fmt.Println("log")
  8692. fmt.Println(string(result))
  8693. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  8694. utils.ErrorLog("解析失败:%v", err)
  8695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8696. return
  8697. }
  8698. res.InfRefmsgid = res10188.InfRefmsgid
  8699. res.Output = res10188.Output
  8700. res.ErrMsg = res10188.ErrMsg
  8701. res.Cainfo = res10188.Cainfo
  8702. res.WarnMsg = res10188.WarnMsg
  8703. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8704. res.Infcode = infocode
  8705. } else {
  8706. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8707. "insutype=" + insutype +
  8708. "&clr_type=" + clr_type +
  8709. "&setl_optins=" + "440104" +
  8710. "&stmt_begndate=" + start_time +
  8711. "&stm_enddate=" + end_time +
  8712. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8713. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8714. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8715. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8716. "&fixmedins_code=" + miConfig.Code +
  8717. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8718. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8719. "&secret_key=" + miConfig.SecretKey +
  8720. "&org_name=" + miConfig.OrgName +
  8721. "&doctor=" + user_name
  8722. fmt.Println(api)
  8723. resp, requestErr := http.Get(api)
  8724. if requestErr != nil {
  8725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8726. return
  8727. }
  8728. body, ioErr := ioutil.ReadAll(resp.Body)
  8729. fmt.Println(body)
  8730. if ioErr != nil {
  8731. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8733. return
  8734. }
  8735. var respJSON map[string]interface{}
  8736. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8737. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8739. return
  8740. }
  8741. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8742. userJSONBytes, _ := json.Marshal(respJSON)
  8743. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8744. utils.ErrorLog("解析失败:%v", err)
  8745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8746. return
  8747. }
  8748. }
  8749. if res.Infcode == 0 {
  8750. if res.Output.Stmtinfo.StmtRslt == "0" {
  8751. micc := &models.MedicalInsuranceCostCompare{
  8752. StartTime: startime.Unix(),
  8753. EndTime: endtime.Unix(),
  8754. Insutype: insutype,
  8755. CheckType: 1,
  8756. Num: fixmedins_setl_cnt,
  8757. Mtime: time.Now().Unix(),
  8758. Status: 1,
  8759. UserOrgId: adminUser.CurrentOrgId,
  8760. CostTotal: medfee_sumamt,
  8761. FuncTotal: fund_pay_sumamt,
  8762. PsnPay: acct_pay,
  8763. Creator: admin_user_id,
  8764. Ctime: time.Now().Unix(),
  8765. ClrType: clr_type,
  8766. }
  8767. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  8768. if err == nil {
  8769. c.ServeSuccessJSON(map[string]interface{}{
  8770. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8771. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8772. })
  8773. } else {
  8774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8775. }
  8776. } else {
  8777. c.ServeSuccessJSON(map[string]interface{}{
  8778. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8779. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8780. })
  8781. }
  8782. } else {
  8783. c.ServeSuccessJSON(map[string]interface{}{
  8784. "code": -10,
  8785. "msg": res.ErrMsg,
  8786. })
  8787. }
  8788. }
  8789. }
  8790. func (c *HisApiController) Check310() {
  8791. adminUser := c.GetAdminUserInfo()
  8792. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8793. var user_name string
  8794. user_name = "高慧裕"
  8795. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8796. "insutype=" + "310" +
  8797. "&clr_type=" + "" +
  8798. "&setl_optins=" + "441202" +
  8799. "&stmt_begndate=" + "2022-03-01" +
  8800. "&stm_enddate=" + "2022-03-31" +
  8801. "&medfee_sumamt=" + "194930.12" +
  8802. "&fund_pay_sumamt=" + "188741.46" +
  8803. "&acct_pay=" + "0" +
  8804. "&fixmedins_setl_cnt=" + "452" +
  8805. "&fixmedins_code=" + miConfig.Code +
  8806. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8807. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8808. "&secret_key=" + miConfig.SecretKey +
  8809. "&org_name=" + miConfig.OrgName +
  8810. "&doctor=" + user_name
  8811. fmt.Println(api)
  8812. resp, requestErr := http.Get(api)
  8813. if requestErr != nil {
  8814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8815. return
  8816. }
  8817. body, ioErr := ioutil.ReadAll(resp.Body)
  8818. fmt.Println(body)
  8819. if ioErr != nil {
  8820. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8822. return
  8823. }
  8824. var respJSON map[string]interface{}
  8825. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8826. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8828. return
  8829. }
  8830. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8831. userJSONBytes, _ := json.Marshal(respJSON)
  8832. var res ResultEight
  8833. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8834. utils.ErrorLog("解析失败:%v", err)
  8835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8836. return
  8837. }
  8838. }
  8839. func (c *HisApiController) Check390() {
  8840. adminUser := c.GetAdminUserInfo()
  8841. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8842. var user_name string
  8843. user_name = "高慧裕"
  8844. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8845. "insutype=" + "390" +
  8846. "&clr_type=" + "" +
  8847. "&setl_optins=" + "441202" +
  8848. "&stmt_begndate=" + "2022-03-01" +
  8849. "&stm_enddate=" + "2022-03-31" +
  8850. "&medfee_sumamt=" + "1068448.89" +
  8851. "&fund_pay_sumamt=" + "1014677.62" +
  8852. "&acct_pay=" + "0" +
  8853. "&fixmedins_setl_cnt=" + "1950" +
  8854. "&fixmedins_code=" + miConfig.Code +
  8855. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8856. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8857. "&secret_key=" + miConfig.SecretKey +
  8858. "&org_name=" + miConfig.OrgName +
  8859. "&doctor=" + user_name
  8860. fmt.Println(api)
  8861. resp, requestErr := http.Get(api)
  8862. if requestErr != nil {
  8863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8864. return
  8865. }
  8866. body, ioErr := ioutil.ReadAll(resp.Body)
  8867. fmt.Println(body)
  8868. if ioErr != nil {
  8869. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8871. return
  8872. }
  8873. var respJSON map[string]interface{}
  8874. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8875. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8877. return
  8878. }
  8879. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8880. userJSONBytes, _ := json.Marshal(respJSON)
  8881. var res ResultEight
  8882. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8883. utils.ErrorLog("解析失败:%v", err)
  8884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8885. return
  8886. }
  8887. }
  8888. //对账明细
  8889. func (c *HisApiController) GetCheckDetailAccount() {
  8890. start_time := c.GetString("start_time")
  8891. end_time := c.GetString("end_time")
  8892. admin_user_id, _ := c.GetInt64("admin_user_id")
  8893. adminUser := c.GetAdminUserInfo()
  8894. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8895. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8896. timeLayout := "2006-01-02"
  8897. loc, _ := time.LoadLocation("Local")
  8898. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8899. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8900. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  8901. rand.Seed(time.Now().UnixNano())
  8902. num := rand.Intn(30000)
  8903. Mkdir(miConfig.OrgName)
  8904. file := strconv.FormatInt(int64(num), 10)
  8905. file_name := file + ".txt"
  8906. zip_name := file + ".zip"
  8907. zip_path := miConfig.OrgName + "/" + zip_name
  8908. file_path := miConfig.OrgName + "/" + file_name
  8909. decimal.DivisionPrecision = 2
  8910. var medfee_sumamt float64
  8911. var psn_cash_pay float64
  8912. var fund_pay_sumamt float64
  8913. fixmedins_setl_cnt := int64(len(orders))
  8914. for _, item := range orders {
  8915. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8916. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  8917. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8918. }
  8919. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  8920. defer f.Close()
  8921. if err != nil {
  8922. fmt.Println(err.Error())
  8923. } else {
  8924. for _, item := range orders {
  8925. var refd_setl_flag string
  8926. if item.OrderStatus == 2 {
  8927. refd_setl_flag = "0"
  8928. var str string
  8929. str = item.SetlId + " " +
  8930. item.MdtrtId + " " +
  8931. item.PsnNo + " " +
  8932. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8933. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8934. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  8935. _, err = f.Write([]byte(str))
  8936. }
  8937. if item.OrderStatus == 3 {
  8938. var str string
  8939. str = item.SetlId + " " +
  8940. item.MdtrtId + " " +
  8941. item.PsnNo + " " +
  8942. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8943. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8944. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  8945. _, err = f.Write([]byte(str))
  8946. var str2 string
  8947. str2 = item.SetlId + " " +
  8948. item.MdtrtId + " " +
  8949. item.PsnNo + " " +
  8950. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  8951. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  8952. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  8953. _, err = f.Write([]byte(str2))
  8954. }
  8955. }
  8956. }
  8957. Zip(file_path, zip_path)
  8958. fmt.Println(ReadFile(zip_path))
  8959. fmt.Println(string(ReadFile(zip_path)))
  8960. if config.IsOpen == 1 {
  8961. var user_name string
  8962. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8963. if role.ID == 0 {
  8964. user_name = "管理员"
  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. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  8977. var dat map[string]interface{}
  8978. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8979. fmt.Println(dat)
  8980. } else {
  8981. fmt.Println(err)
  8982. }
  8983. userJSONBytes, _ := json.Marshal(dat)
  8984. var res ResultNine
  8985. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8986. utils.ErrorLog("解析失败:%v", err)
  8987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8988. return
  8989. }
  8990. if res.Infcode == 0 {
  8991. fileNo := res.Output.FileQuryNo
  8992. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  8993. "file_qury_no=" + fileNo +
  8994. "&setl_optins=" + "定点医保中心" +
  8995. "&stmt_begndate=" + start_time +
  8996. "&stm_enddate=" + end_time +
  8997. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8998. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8999. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  9000. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  9001. "&fixmedins_code=" + miConfig.Code +
  9002. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9003. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9004. "&secret_key=" + miConfig.SecretKey +
  9005. "&org_name=" + miConfig.OrgName +
  9006. "&doctor=" + user_name
  9007. resp, requestErr := http.Get(api)
  9008. if requestErr != nil {
  9009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9010. return
  9011. }
  9012. body, ioErr := ioutil.ReadAll(resp.Body)
  9013. if ioErr != nil {
  9014. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9016. return
  9017. }
  9018. var respJSON map[string]interface{}
  9019. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9020. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9022. return
  9023. }
  9024. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9025. userJSONBytes, _ := json.Marshal(respJSON)
  9026. var res ResultTen
  9027. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9028. utils.ErrorLog("解析失败:%v", err)
  9029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9030. return
  9031. }
  9032. if res.Infcode == 0 {
  9033. service.Gdyb9102(baseParams, zip_name, fileNo)
  9034. micc := &models.MedicalInsuranceCostCompare{
  9035. StartTime: startime.Unix(),
  9036. EndTime: endtime.Unix(),
  9037. Insutype: "0",
  9038. CheckType: 2,
  9039. Num: fixmedins_setl_cnt,
  9040. Mtime: time.Now().Unix(),
  9041. Status: 1,
  9042. UserOrgId: adminUser.CurrentOrgId,
  9043. CostTotal: medfee_sumamt,
  9044. FuncTotal: fund_pay_sumamt,
  9045. PsnPay: psn_cash_pay,
  9046. Creator: admin_user_id,
  9047. Ctime: time.Now().Unix(),
  9048. }
  9049. service.CreateMedicalInsuranceCostCompareRecord(micc)
  9050. c.ServeSuccessJSON(map[string]interface{}{
  9051. "msg": "明细对账成功",
  9052. })
  9053. }
  9054. } else {
  9055. }
  9056. }
  9057. }
  9058. type CustomOrderInfo struct {
  9059. Name string
  9060. Spec string
  9061. Unit string
  9062. Count float64
  9063. Price float64
  9064. Total float64
  9065. }
  9066. func (c *HisApiController) GetSettleAccounts() {
  9067. //id, _ := c.GetInt64("id")
  9068. //record_time := c.GetString("record_time")
  9069. order_id, _ := c.GetInt64("order_id")
  9070. admin_user_id, _ := c.GetInt64("admin_user_id")
  9071. //timeLayout := "2006-01-02"
  9072. //loc, _ := time.LoadLocation("Local")
  9073. //
  9074. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9075. //if err != nil {
  9076. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9077. // return
  9078. //}
  9079. //recordDateTime := theTime.Unix()
  9080. adminUser := c.GetAdminUserInfo()
  9081. order, _ := service.GetHisOrderByID(order_id)
  9082. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9083. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  9084. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  9085. orderInfos = append(orderInfos, orderInfos_two...)
  9086. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9087. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  9088. var diagnosis_ids []string
  9089. if his.ID > 0 {
  9090. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  9091. } else {
  9092. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  9093. }
  9094. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  9095. var dia_config []*models.HisXtDiagnoseConfig
  9096. var name string
  9097. for _, item := range diagnosis_ids {
  9098. id, _ := strconv.ParseInt(item, 10, 64)
  9099. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9100. dia_config = append(dia_config, &diagnosisConfig)
  9101. if len(name) == 0 {
  9102. name = diagnosisConfig.ClassName
  9103. } else {
  9104. name = name + "," + diagnosisConfig.ClassName
  9105. }
  9106. }
  9107. var bedCostTotal float64 = 0 //床位总费
  9108. var bedCostSelfTotal float64 = 0 //床位自费
  9109. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  9110. var operationCostTotal float64 = 0 //手术费
  9111. var operationCostSelfTotal float64 = 0 //手术费
  9112. var operationCostPartSelfTotal float64 = 0 //手术费
  9113. var otherCostTotal float64 = 0 //其他费用
  9114. var otherCostSelfTotal float64 = 0 //其他费用
  9115. var otherCostPartSelfTotal float64 = 0 //其他费用
  9116. var materialCostTotal float64 = 0 //材料费
  9117. var materialCostSelfTotal float64 = 0 //材料费
  9118. var materialCostPartSelfTotal float64 = 0 //材料费
  9119. var westernMedicineCostTotal float64 = 0 //西药费
  9120. var westernMedicineCostSelfTotal float64 = 0 //西药费
  9121. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  9122. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  9123. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  9124. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  9125. var checkCostTotal float64 = 0 //检查费
  9126. var checkCostSelfTotal float64 = 0 //检查费
  9127. var checkCostPartSelfTotal float64 = 0 //检查费
  9128. var laboratoryCostTotal float64 = 0 //化验费
  9129. var laboratoryCostSelfTotal float64 = 0 //化验费
  9130. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  9131. var treatCostTotal float64 = 0 //治疗费用
  9132. var treatCostSelfTotal float64 = 0 //治疗费用
  9133. var treatCostPartSelfTotal float64 = 0 //治疗费用
  9134. decimal.DivisionPrecision = 2
  9135. for _, item := range orderInfos {
  9136. if item.MedChrgitmType == "01" { //床位费
  9137. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9138. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9139. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9140. }
  9141. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  9142. if item.MedChrgitmType == "03" { //检查费
  9143. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9144. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9145. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9146. }
  9147. } else {
  9148. if item.MedChrgitmType == "03" { //检查费
  9149. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9150. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9151. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9152. }
  9153. }
  9154. if item.MedChrgitmType == "04" { //化验费
  9155. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9156. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9157. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9158. }
  9159. if item.MedChrgitmType == "05" { //治疗费
  9160. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9161. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9162. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9163. }
  9164. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  9165. fmt.Println("------------")
  9166. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9167. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9168. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9169. }
  9170. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  9171. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9172. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9173. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9174. }
  9175. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403"{ //材料费
  9176. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9177. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9178. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9179. }
  9180. if item.MedChrgitmType == "09" { //西药费
  9181. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9182. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9183. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9184. }
  9185. if item.MedChrgitmType == "11" { //中成费
  9186. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9187. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9188. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9189. }
  9190. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  9191. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9192. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9193. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9194. }
  9195. }
  9196. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9197. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9198. var user_name string
  9199. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9200. if role.ID == 0 {
  9201. user_name = "管理员"
  9202. } else {
  9203. user_name = role.UserName
  9204. }
  9205. baseParams := models.BaseParams{
  9206. SecretKey: miConfig.SecretKey,
  9207. FixmedinsCode: miConfig.Code,
  9208. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9209. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9210. OrgName: miConfig.OrgName,
  9211. Doctor: user_name,
  9212. }
  9213. businessParams := models.BusinessParams{
  9214. PsnNo: order.PsnNo,
  9215. MdtrtId: order.MdtrtId,
  9216. SetlId: order.SetlId,
  9217. }
  9218. var res ResultEleven
  9219. var resEleven10265 ResultEleven10265
  9220. if config.IsOpen == 1 {
  9221. if miConfig.MdtrtareaAdmvs == "421300" {
  9222. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9223. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9224. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9225. resp, requestErr := http.Get(api)
  9226. if requestErr != nil {
  9227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9228. return
  9229. }
  9230. body, ioErr := ioutil.ReadAll(resp.Body)
  9231. if ioErr != nil {
  9232. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9234. return
  9235. }
  9236. var respJSON map[string]interface{}
  9237. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9238. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9240. return
  9241. }
  9242. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9243. result, _ := json.Marshal(respJSON)
  9244. fmt.Println("log")
  9245. fmt.Println(string(result))
  9246. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9247. utils.ErrorLog("解析失败:%v", err)
  9248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9249. return
  9250. }
  9251. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9252. var api string
  9253. if miConfig.MdtrtareaAdmvs == "320921" {
  9254. api = "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9255. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9256. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9257. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9258. } else {
  9259. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9260. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9261. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9262. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9263. }
  9264. resp, requestErr := http.Get(api)
  9265. if requestErr != nil {
  9266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9267. return
  9268. }
  9269. body, ioErr := ioutil.ReadAll(resp.Body)
  9270. if ioErr != nil {
  9271. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9273. return
  9274. }
  9275. var respJSON map[string]interface{}
  9276. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9277. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9279. return
  9280. }
  9281. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9282. result, _ := json.Marshal(respJSON)
  9283. fmt.Println("log")
  9284. fmt.Println(string(result))
  9285. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9286. utils.ErrorLog("解析失败:%v", err)
  9287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9288. return
  9289. }
  9290. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9291. res.Output = resEleven10265.Output
  9292. res.ErrMsg = resEleven10265.ErrMsg
  9293. res.Cainfo = resEleven10265.Cainfo
  9294. res.WarnMsg = resEleven10265.WarnMsg
  9295. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9296. res.Infcode = infocode
  9297. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9298. fmt.Println("~~~~~~~")
  9299. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9300. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9301. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9302. resp, requestErr := http.Get(api)
  9303. if requestErr != nil {
  9304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9305. return
  9306. }
  9307. body, ioErr := ioutil.ReadAll(resp.Body)
  9308. if ioErr != nil {
  9309. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9311. return
  9312. }
  9313. var respJSON map[string]interface{}
  9314. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9315. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9317. return
  9318. }
  9319. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9320. result, _ := json.Marshal(respJSON)
  9321. fmt.Println("log")
  9322. fmt.Println(string(result))
  9323. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9324. utils.ErrorLog("解析失败:%v", err)
  9325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9326. return
  9327. }
  9328. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9329. res.Output = resEleven10265.Output
  9330. res.ErrMsg = resEleven10265.ErrMsg
  9331. res.Cainfo = resEleven10265.Cainfo
  9332. res.WarnMsg = resEleven10265.WarnMsg
  9333. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9334. res.Infcode = infocode
  9335. } else {
  9336. result := service.Gdyb5203(baseParams, businessParams)
  9337. //service.Gdyb5204(baseParams, businessParams)
  9338. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  9339. var dat map[string]interface{}
  9340. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9341. fmt.Println(dat)
  9342. } else {
  9343. fmt.Println(err)
  9344. }
  9345. userJSONBytes, _ := json.Marshal(dat)
  9346. if miConfig.Code == "H15049901371" {
  9347. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  9348. utils.ErrorLog("解析失败:%v", err)
  9349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9350. return
  9351. }
  9352. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9353. res.Output = resEleven10265.Output
  9354. res.ErrMsg = resEleven10265.ErrMsg
  9355. res.Cainfo = resEleven10265.Cainfo
  9356. res.WarnMsg = resEleven10265.WarnMsg
  9357. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9358. res.Infcode = infocode
  9359. } else {
  9360. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9361. utils.ErrorLog("解析失败:%v", err)
  9362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9363. return
  9364. }
  9365. }
  9366. }
  9367. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9368. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  9369. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  9370. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9371. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  9372. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9373. var doctor_name string
  9374. if roles.ID == 0 {
  9375. doctor_name = "管理员"
  9376. } else {
  9377. doctor_name = roles.UserName
  9378. }
  9379. yiliao_leibie := ""
  9380. switch order.MedType {
  9381. case "11":
  9382. yiliao_leibie = "普通门诊"
  9383. break
  9384. case "12":
  9385. yiliao_leibie = "门诊挂号"
  9386. break
  9387. case "13":
  9388. yiliao_leibie = "急诊"
  9389. break
  9390. case "14":
  9391. yiliao_leibie = "门诊特殊病"
  9392. break
  9393. case "15":
  9394. yiliao_leibie = "门诊统筹"
  9395. break
  9396. case "16":
  9397. yiliao_leibie = "门诊慢性病"
  9398. break
  9399. case "21":
  9400. yiliao_leibie = "普通住院"
  9401. break
  9402. }
  9403. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9404. if res.Infcode == 0 {
  9405. c.ServeSuccessJSON(map[string]interface{}{
  9406. "diagnosis": name,
  9407. "order_infos": orderInfos,
  9408. "number": order.MdtrtId,
  9409. "date": order.SettleAccountsDate,
  9410. "charge_admin": charge_admin,
  9411. "printor_admin": printor_admin,
  9412. "info": res.Output.Setlinfo,
  9413. "order": order,
  9414. "bedCostTotal": bedCostTotal,
  9415. "bedCostSelfTotal": bedCostSelfTotal,
  9416. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  9417. "operationCostTotal": operationCostTotal,
  9418. "operationCostSelfTotal": operationCostSelfTotal,
  9419. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  9420. "otherCostTotal": otherCostTotal,
  9421. "otherCostSelfTotal": otherCostSelfTotal,
  9422. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  9423. "materialCostTotal": materialCostTotal,
  9424. "materialCostSelfTotal": materialCostSelfTotal,
  9425. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  9426. "westernMedicineCostTotal": westernMedicineCostTotal,
  9427. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  9428. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  9429. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  9430. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  9431. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  9432. "checkCostTotal": checkCostTotal,
  9433. "checkCostSelfTotal": checkCostSelfTotal,
  9434. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  9435. "laboratoryCostTotal": laboratoryCostTotal,
  9436. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  9437. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  9438. "treatCostTotal": treatCostTotal,
  9439. "treatCostSelfTotal": treatCostSelfTotal,
  9440. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  9441. "doctor_info": doctor_info,
  9442. "doctor_code": adminRole_two.DoctorCode,
  9443. "doctor_name": doctor_name,
  9444. "health_card_no": order.PsnNo,
  9445. "department": departments.Name,
  9446. "yiliao_leibie": yiliao_leibie,
  9447. "after_money": order.AccountPrice,
  9448. "patient": patient,
  9449. "org_name": miConfig.OrgName,
  9450. "org_code": miConfig.Code,
  9451. "order_number": order.Number,
  9452. "his_hospital": his_hospital,
  9453. "his": his,
  9454. "dia_config": dia_config,
  9455. //"check_order_info": cus_slice,
  9456. })
  9457. }
  9458. }
  9459. }
  9460. func (c *HisApiController) CheckTreatment() {
  9461. patient_id, _ := c.GetInt64("patient_id")
  9462. id_card_no := c.GetString("id_card_no")
  9463. insutype := c.GetString("insutype")
  9464. med_type := c.GetString("med_type")
  9465. admin_user_id, _ := c.GetInt64("admin_user_id")
  9466. adminUser := c.GetAdminUserInfo()
  9467. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9468. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9469. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9470. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9471. if miConfig.MdtrtareaAdmvs == "421300" {
  9472. var res ResultTwo
  9473. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  9474. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9475. "&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)
  9476. resp, requestErr := http.Get(api)
  9477. if requestErr != nil {
  9478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9479. return
  9480. }
  9481. body, ioErr := ioutil.ReadAll(resp.Body)
  9482. if ioErr != nil {
  9483. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9485. return
  9486. }
  9487. var respJSON map[string]interface{}
  9488. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9489. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9491. return
  9492. }
  9493. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9494. result, _ := json.Marshal(respJSON)
  9495. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9496. utils.ErrorLog("解析失败:%v", err)
  9497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9498. return
  9499. }
  9500. if res.Infcode == 0 {
  9501. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  9502. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9503. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output[0].Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  9504. resp, requestErr := http.Get(api)
  9505. if requestErr != nil {
  9506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9507. return
  9508. }
  9509. body, ioErr := ioutil.ReadAll(resp.Body)
  9510. if ioErr != nil {
  9511. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9513. return
  9514. }
  9515. var respJSON map[string]interface{}
  9516. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9517. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9519. return
  9520. }
  9521. var res Result2001
  9522. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9523. result2, _ := json.Marshal(respJSON)
  9524. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9525. utils.ErrorLog("解析失败:%v", err)
  9526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9527. return
  9528. }
  9529. if res.Infcode == 0 {
  9530. c.ServeSuccessJSON(map[string]interface{}{
  9531. "msg": res.Output.Trtinfo,
  9532. })
  9533. }
  9534. } else {
  9535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9536. return
  9537. }
  9538. } else {
  9539. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9540. var dat map[string]interface{}
  9541. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9542. fmt.Println(dat)
  9543. } else {
  9544. fmt.Println(err)
  9545. }
  9546. userJSONBytes, _ := json.Marshal(dat)
  9547. var res ResultTwo
  9548. var res10265 ResultTwo10265
  9549. if miConfig.Code == "H15049901371" {
  9550. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9551. utils.ErrorLog("解析失败:%v", err)
  9552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9553. return
  9554. }
  9555. res.ErrMsg = res10265.ErrMsg
  9556. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9557. res.Infcode = infocode
  9558. //res.Output = res10265.Output
  9559. res.InfRefmsgid = res10265.InfRefmsgid
  9560. } else {
  9561. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9562. utils.ErrorLog("解析失败:%v", err)
  9563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9564. return
  9565. }
  9566. }
  9567. var user_name string
  9568. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  9569. if role.ID == 0 {
  9570. user_name = "xxx"
  9571. } else {
  9572. user_name = role.UserName
  9573. }
  9574. baseParams := models.BaseParams{
  9575. SecretKey: miConfig.SecretKey,
  9576. FixmedinsCode: miConfig.Code,
  9577. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9578. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9579. OrgName: miConfig.OrgName,
  9580. Doctor: user_name,
  9581. }
  9582. if config.IsOpen == 1 {
  9583. if miConfig.Code == "H15049901371" {
  9584. if med_type == "14" {
  9585. if insutype == "390" {
  9586. med_type = "9933"
  9587. } else if insutype == "310" {
  9588. med_type = "990502"
  9589. }
  9590. } else if med_type == "11" {
  9591. med_type = "11"
  9592. }
  9593. }
  9594. result := service.Gdyb2001(baseParams, res.Output[0].Baseinfo.PsnNo, insutype, med_type)
  9595. var dat map[string]interface{}
  9596. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9597. fmt.Println(dat)
  9598. } else {
  9599. fmt.Println(err)
  9600. }
  9601. var res Result2001
  9602. var res10265 Result2001Org10265
  9603. if miConfig.Code == "H15049901371" {
  9604. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9605. utils.ErrorLog("解析失败:%v", err)
  9606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9607. return
  9608. }
  9609. res.ErrMsg = res10265.ErrMsg
  9610. res.Output = res10265.Output
  9611. res.InfRefmsgid = res10265.InfRefmsgid
  9612. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9613. res.Infcode = infocode
  9614. } else {
  9615. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9616. utils.ErrorLog("解析失败:%v", err)
  9617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9618. return
  9619. }
  9620. }
  9621. if res.Infcode == 0 {
  9622. c.ServeSuccessJSON(map[string]interface{}{
  9623. "msg": res.Output.Trtinfo,
  9624. })
  9625. }
  9626. }
  9627. }
  9628. }
  9629. //func (c *HisApiController) PutRecord() {
  9630. // id, _ := c.GetInt64("id")
  9631. // record_time := c.GetString("record_time")
  9632. // timeLayout := "2006-01-02"
  9633. // loc, _ := time.LoadLocation("Local")
  9634. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9635. // if err != nil {
  9636. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9637. // return
  9638. // }
  9639. // recordDateTime := theTime.Unix()
  9640. //
  9641. // adminInfo := c.GetAdminUserInfo()
  9642. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  9643. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9644. //
  9645. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9646. //
  9647. // fmt.Println(miConfig.SecretKey)
  9648. //
  9649. // if patient == nil {
  9650. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9651. // return
  9652. // }
  9653. // if len(patient.IdCardNo) == 0 {
  9654. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  9655. // return
  9656. // }
  9657. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  9658. // if config.IsOpen == 1 {
  9659. // 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
  9660. // resp, requestErr := http.Get(api)
  9661. // if requestErr != nil {
  9662. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9663. // return
  9664. // }
  9665. // defer resp.Body.Close()
  9666. // body, ioErr := ioutil.ReadAll(resp.Body)
  9667. // if ioErr != nil {
  9668. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9669. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9670. // return
  9671. // }
  9672. // var respJSON map[string]interface{}
  9673. //
  9674. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9675. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9676. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9677. // return
  9678. // }
  9679. //
  9680. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9681. // userJSONBytes, _ := json.Marshal(userJSON)
  9682. // var res ResultTwo
  9683. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9684. // utils.ErrorLog("解析失败:%v", err)
  9685. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9686. // return
  9687. // }
  9688. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9689. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9690. // infoStr := string(Iinfos)
  9691. // idetinfoStr := string(Idetinfos)
  9692. //
  9693. // if res.Infcode == 0 {
  9694. // his := models.VMHisPatient{
  9695. // Status: 1,
  9696. // Ctime: time.Now().Unix(),
  9697. // Mtime: time.Now().Unix(),
  9698. // PsnNo: res.Output.Baseinfo.PsnNo,
  9699. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  9700. // Certno: res.Output.Baseinfo.Certno,
  9701. // PsnName: res.Output.Baseinfo.PsnName,
  9702. // Gend: res.Output.Baseinfo.Gend,
  9703. // Naty: res.Output.Baseinfo.Naty,
  9704. // Brdy: res.Output.Baseinfo.Brdy,
  9705. // Age: res.Output.Baseinfo.Age,
  9706. // Iinfo: infoStr,
  9707. // Idetinfo: idetinfoStr,
  9708. // PatientId: patient.ID,
  9709. // RecordDate: theTime.Unix(),
  9710. // UserOrgId: adminInfo.CurrentOrgId,
  9711. // AdminUserId: adminInfo.AdminUser.Id,
  9712. // IsReturn: 1,
  9713. // }
  9714. //
  9715. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  9716. // //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")
  9717. // //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")
  9718. //
  9719. // //var dat map[string]interface{}
  9720. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9721. // // fmt.Println(dat)
  9722. // //} else {
  9723. // // fmt.Println(err)
  9724. // //}
  9725. //
  9726. // var dat2 map[string]interface{}
  9727. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9728. // fmt.Println(dat2)
  9729. // } else {
  9730. // fmt.Println(err)
  9731. // }
  9732. //
  9733. // } else {
  9734. // adminUser := c.GetAdminUserInfo()
  9735. // errlog := &models.HisOrderError{
  9736. // UserOrgId: adminUser.CurrentOrgId,
  9737. // Ctime: time.Now().Unix(),
  9738. // Mtime: time.Now().Unix(),
  9739. // ErrMsg: res.ErrMsg,
  9740. // Status: 1,
  9741. // PatientId: id,
  9742. // RecordTime: recordDateTime,
  9743. // Stage: 1,
  9744. // }
  9745. // service.CreateErrMsgLog(errlog)
  9746. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  9747. // return
  9748. // }
  9749. // }
  9750. //
  9751. //}
  9752. //func (c *HisApiController) GetUploadDiag() {
  9753. // id, _ := c.GetInt64("id")
  9754. // record_time := c.GetString("record_time")
  9755. //
  9756. // diagnosis_id, _ := c.GetInt64("diagnosis")
  9757. // sick_type, _ := c.GetInt64("sick_type")
  9758. // reg_type, _ := c.GetInt64("reg_type")
  9759. //
  9760. // timeLayout := "2006-01-02"
  9761. // loc, _ := time.LoadLocation("Local")
  9762. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9763. // if err != nil {
  9764. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9765. // return
  9766. // }
  9767. //
  9768. // var patientPrescription models.HisPrescriptionInfo
  9769. // recordDateTime := theTime.Unix()
  9770. // adminInfo := c.GetAdminUserInfo()
  9771. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9772. //
  9773. // if patientPrescription.ID == 0 {
  9774. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9775. // }
  9776. //
  9777. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9778. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9779. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9780. // sickConfig, _ := service.FindSickById(sick_type)
  9781. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9782. //
  9783. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  9784. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  9785. // "&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 +
  9786. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  9787. // resp2, requestErr2 := http.Get(api2)
  9788. // if requestErr2 != nil {
  9789. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9790. // return
  9791. // }
  9792. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  9793. // if ioErr2 != nil {
  9794. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  9795. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9796. // return
  9797. // }
  9798. // var respJSON2 map[string]interface{}
  9799. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  9800. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9801. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9802. // return
  9803. // }
  9804. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9805. // userJSONBytes2, _ := json.Marshal(respJSON2)
  9806. //
  9807. // var res2 ResultSix
  9808. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9809. // utils.ErrorLog("解析失败:%v", err)
  9810. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9811. // return
  9812. // }
  9813. // if res2.Infcode != 0 {
  9814. // adminUser := c.GetAdminUserInfo()
  9815. // errlog := &models.HisOrderError{
  9816. // UserOrgId: adminUser.CurrentOrgId,
  9817. // Ctime: time.Now().Unix(),
  9818. // Mtime: time.Now().Unix(),
  9819. // ErrMsg: res2.ErrMsg,
  9820. // Status: 1,
  9821. // PatientId: id,
  9822. // RecordTime: recordDateTime,
  9823. // Stage: 3,
  9824. // }
  9825. // service.CreateErrMsgLog(errlog)
  9826. //
  9827. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  9828. // return
  9829. // }
  9830. //
  9831. // c.ServeSuccessJSON(map[string]interface{}{
  9832. // "msg": "上传成功",
  9833. // })
  9834. //
  9835. //}
  9836. type QueryResult struct {
  9837. ID int64
  9838. Name string
  9839. Code string
  9840. List_type_code string
  9841. }
  9842. func (c *HisApiController) GetCheckCode() {
  9843. ids_str := c.GetString("ids")
  9844. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9845. ids_arr := strings.Split(ids_str, ",")
  9846. var queryResult []QueryResult
  9847. ids := make([]int64, 0)
  9848. for _, item := range ids_arr {
  9849. id, _ := strconv.ParseInt(item, 10, 64)
  9850. ids = append(ids, id)
  9851. }
  9852. if record_type == 1 {
  9853. drugs, _ := service.GetBatchDrugList(ids)
  9854. for _, item := range drugs {
  9855. result := QueryResult{
  9856. ID: item.ID,
  9857. Name: item.DrugName,
  9858. Code: item.MedicalInsuranceNumber,
  9859. List_type_code: "101",
  9860. }
  9861. queryResult = append(queryResult, result)
  9862. }
  9863. } else if record_type == 2 {
  9864. goods, _ := service.GetBatchGoodInformationList(ids)
  9865. for _, item := range goods {
  9866. result := QueryResult{
  9867. ID: item.ID,
  9868. Name: item.GoodName,
  9869. Code: item.MedicalInsuranceNumber,
  9870. List_type_code: "301",
  9871. }
  9872. queryResult = append(queryResult, result)
  9873. }
  9874. } else if record_type == 3 {
  9875. projects, _ := service.GetBathchMyPorjecgList(ids)
  9876. for _, item := range projects {
  9877. result := QueryResult{
  9878. ID: item.ID,
  9879. Name: item.ProjectName,
  9880. Code: item.MedicalCode,
  9881. List_type_code: "201",
  9882. }
  9883. queryResult = append(queryResult, result)
  9884. }
  9885. }
  9886. admin_user_id, _ := c.GetInt64("admin_user_id")
  9887. adminUser := c.GetAdminUserInfo()
  9888. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9889. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9890. var user_name string
  9891. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9892. if role.ID == 0 {
  9893. user_name = "xxx"
  9894. } else {
  9895. user_name = role.UserName
  9896. }
  9897. baseParams := &models.BaseParams{
  9898. SecretKey: miConfig.SecretKey,
  9899. FixmedinsCode: miConfig.Code,
  9900. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9901. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9902. OrgName: miConfig.OrgName,
  9903. Doctor: user_name,
  9904. }
  9905. if config.IsOpen == 1 {
  9906. for _, item := range queryResult {
  9907. var result string
  9908. if record_type == 1 {
  9909. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9910. } else if record_type == 2 {
  9911. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9912. } else if record_type == 3 {
  9913. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9914. }
  9915. var dat map[string]interface{}
  9916. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9917. fmt.Println(dat)
  9918. } else {
  9919. fmt.Println(err)
  9920. }
  9921. userJSONBytes, _ := json.Marshal(dat)
  9922. var res ResultSix
  9923. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9924. utils.ErrorLog("解析失败:%v", err)
  9925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9926. return
  9927. }
  9928. if res.Infcode == 0 {
  9929. if record_type == 1 {
  9930. service.UpdateBaseDrugById(item.ID)
  9931. } else if record_type == 2 {
  9932. service.UpdateGoodInformaitonByDetail(item.ID)
  9933. } else if record_type == 3 {
  9934. service.UpdateProjectById(item.ID)
  9935. }
  9936. c.ServeSuccessJSON(map[string]interface{}{
  9937. "failed_code": 0,
  9938. "msg": "目录对照成功",
  9939. })
  9940. } else {
  9941. c.ServeSuccessJSON(map[string]interface{}{
  9942. "failed_code": -10,
  9943. "msg": res.ErrMsg,
  9944. })
  9945. }
  9946. }
  9947. }
  9948. }
  9949. func (c *HisApiController) UnCheckCode() {
  9950. ids_str := c.GetString("ids")
  9951. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9952. admin_user_id, _ := c.GetInt64("admin_user_id")
  9953. ids_arr := strings.Split(ids_str, ",")
  9954. var queryResult []QueryResult
  9955. ids := make([]int64, 0)
  9956. for _, item := range ids_arr {
  9957. id, _ := strconv.ParseInt(item, 10, 64)
  9958. ids = append(ids, id)
  9959. }
  9960. if record_type == 1 {
  9961. drugs, _ := service.GetBatchDrugList(ids)
  9962. for _, item := range drugs {
  9963. result := QueryResult{
  9964. ID: item.ID,
  9965. Name: item.DrugName,
  9966. Code: item.MedicalInsuranceNumber,
  9967. List_type_code: "101",
  9968. }
  9969. queryResult = append(queryResult, result)
  9970. }
  9971. } else if record_type == 2 {
  9972. goods, _ := service.GetBatchGoodInformationList(ids)
  9973. for _, item := range goods {
  9974. result := QueryResult{
  9975. ID: item.ID,
  9976. Name: item.GoodName,
  9977. Code: item.MedicalInsuranceNumber,
  9978. List_type_code: "301",
  9979. }
  9980. queryResult = append(queryResult, result)
  9981. }
  9982. } else if record_type == 3 {
  9983. projects, _ := service.GetBathchMyPorjecgList(ids)
  9984. for _, item := range projects {
  9985. result := QueryResult{
  9986. ID: item.ID,
  9987. Name: item.ProjectName,
  9988. Code: item.MedicalCode,
  9989. List_type_code: "201",
  9990. }
  9991. queryResult = append(queryResult, result)
  9992. }
  9993. }
  9994. adminUser := c.GetAdminUserInfo()
  9995. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9996. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9997. var user_name string
  9998. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9999. if role.ID == 0 {
  10000. user_name = "xxx"
  10001. } else {
  10002. user_name = role.UserName
  10003. }
  10004. baseParams := &models.BaseParams{
  10005. SecretKey: miConfig.SecretKey,
  10006. FixmedinsCode: miConfig.Code,
  10007. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  10008. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  10009. OrgName: miConfig.OrgName,
  10010. Doctor: user_name,
  10011. }
  10012. if config.IsOpen == 1 {
  10013. for _, item := range queryResult {
  10014. var result string
  10015. if record_type == 1 {
  10016. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10017. } else if record_type == 2 {
  10018. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10019. } else if record_type == 3 {
  10020. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10021. }
  10022. var dat2 map[string]interface{}
  10023. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  10024. fmt.Println(dat2)
  10025. } else {
  10026. fmt.Println(err)
  10027. }
  10028. userJSONBytes, _ := json.Marshal(dat2)
  10029. var res ResultSix
  10030. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10031. utils.ErrorLog("解析失败:%v", err)
  10032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10033. return
  10034. }
  10035. if res.Infcode == 0 {
  10036. if record_type == 1 {
  10037. service.UpdateDrugByIdDetail(item.ID)
  10038. } else if record_type == 2 {
  10039. service.UpdateGoodInfoById(item.ID)
  10040. } else if record_type == 3 {
  10041. service.UpdateMyProjectById(item.ID)
  10042. }
  10043. c.ServeSuccessJSON(map[string]interface{}{
  10044. "failed_code": 0,
  10045. "msg": "撤销目录对照成功",
  10046. })
  10047. } else {
  10048. c.ServeSuccessJSON(map[string]interface{}{
  10049. "failed_code": -10,
  10050. "msg": res.ErrMsg,
  10051. })
  10052. }
  10053. }
  10054. }
  10055. }
  10056. func (c *HisApiController) GetPatientInfo() {
  10057. id_card_no := c.GetString("id_card_no")
  10058. admin_user_id, _ := c.GetInt64("admin_user_id")
  10059. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  10060. if patient.ID == 0 {
  10061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  10062. return
  10063. }
  10064. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10065. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10066. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  10067. if config.IsOpen == 1 {
  10068. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  10069. var dat map[string]interface{}
  10070. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10071. fmt.Println(dat)
  10072. } else {
  10073. fmt.Println(err)
  10074. }
  10075. userJSONBytes, _ := json.Marshal(dat)
  10076. var res ResultTwo
  10077. var res10265 ResultTwo10265
  10078. if miConfig.Code == "H15049901371" {
  10079. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10080. utils.ErrorLog("解析失败:%v", err)
  10081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10082. return
  10083. }
  10084. res.ErrMsg = res10265.ErrMsg
  10085. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10086. res.Infcode = infocode
  10087. //res.Output = res10265.Output
  10088. res.InfRefmsgid = res10265.InfRefmsgid
  10089. } else {
  10090. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10091. utils.ErrorLog("解析失败:%v", err)
  10092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10093. return
  10094. }
  10095. }
  10096. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10097. // utils.ErrorLog("解析失败:%v", err)
  10098. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10099. // return
  10100. //}
  10101. if res.Infcode != 0 {
  10102. c.ServeSuccessJSON(map[string]interface{}{
  10103. "failed_code": -10,
  10104. "msg": res.ErrMsg,
  10105. })
  10106. } else {
  10107. c.ServeSuccessJSON(map[string]interface{}{
  10108. "failed_code": 0,
  10109. "info": res,
  10110. })
  10111. }
  10112. }
  10113. }
  10114. func (c *HisApiController) PsnPutOnRecord() {
  10115. record_type, _ := c.GetInt64("type")
  10116. patient_id, _ := c.GetInt64("patient_id")
  10117. admin_user_id, _ := c.GetInt64("admin_user_id")
  10118. start_time := c.GetString("start_time")
  10119. end_time := c.GetString("end_time")
  10120. adminUser := c.GetAdminUserInfo()
  10121. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10122. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10123. var patients []*models.Patients
  10124. if record_type == 1 { //全部备案
  10125. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  10126. patients = append(patients, patient...)
  10127. } else { //单个备案
  10128. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10129. patients = append(patients, patient)
  10130. }
  10131. var user_name string
  10132. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10133. if role.ID == 0 {
  10134. user_name = "xxx"
  10135. } else {
  10136. user_name = role.UserName
  10137. }
  10138. if config.IsOpen == 1 {
  10139. for _, item := range patients {
  10140. 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
  10141. resp, requestErr := http.Get(api)
  10142. if requestErr != nil {
  10143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10144. return
  10145. }
  10146. defer resp.Body.Close()
  10147. body, ioErr := ioutil.ReadAll(resp.Body)
  10148. if ioErr != nil {
  10149. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10151. return
  10152. }
  10153. var respJSON map[string]interface{}
  10154. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10155. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10157. return
  10158. }
  10159. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10160. userJSONBytes, _ := json.Marshal(userJSON)
  10161. var res ResultTwo
  10162. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10163. utils.ErrorLog("解析失败:%v", err)
  10164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10165. return
  10166. }
  10167. if res.Infcode == 0 {
  10168. result := service.Gdyb2505(res.Output[0].Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  10169. var dat map[string]interface{}
  10170. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10171. fmt.Println(dat)
  10172. } else {
  10173. fmt.Println(err)
  10174. }
  10175. userJSONBytes, _ := json.Marshal(dat)
  10176. var res2 ResultThirteen
  10177. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10178. utils.ErrorLog("解析失败:%v", err)
  10179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10180. return
  10181. }
  10182. if res2.Infcode == 0 {
  10183. psnResult := &models.GdybPsnRecord{
  10184. UserOrgId: adminUser.CurrentOrgId,
  10185. PatientId: item.ID,
  10186. PsnNo: res.Output[0].Baseinfo.PsnNo,
  10187. Ctime: time.Now().Unix(),
  10188. Mtime: time.Now().Unix(),
  10189. Status: 1,
  10190. IsCancel: 1,
  10191. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10192. }
  10193. service.CreatePsnRecord(psnResult)
  10194. } else {
  10195. c.ServeSuccessJSON(map[string]interface{}{
  10196. "failed_code": -10,
  10197. "msg": res2.ErrMsg,
  10198. })
  10199. return
  10200. }
  10201. }
  10202. }
  10203. }
  10204. }
  10205. func (c *HisApiController) PsnUnPutOnRecord() {
  10206. id, _ := c.GetInt64("id")
  10207. //record_type, _ := c.GetInt64("type")
  10208. admin_user_id, _ := c.GetInt64("admin_user_id")
  10209. adminUser := c.GetAdminUserInfo()
  10210. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10211. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10212. var user_name string
  10213. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10214. if role.ID == 0 {
  10215. user_name = "xxx"
  10216. } else {
  10217. user_name = role.UserName
  10218. }
  10219. psn_record, _ := service.GetPsnRecordById(id)
  10220. if psn_record.ID == 0 {
  10221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10222. return
  10223. }
  10224. if config.IsOpen == 1 {
  10225. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10226. var dat map[string]interface{}
  10227. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10228. fmt.Println(dat)
  10229. } else {
  10230. fmt.Println(err)
  10231. }
  10232. userJSONBytes, _ := json.Marshal(dat)
  10233. var res ResultFourteen
  10234. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10235. utils.ErrorLog("解析失败:%v", err)
  10236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10237. return
  10238. }
  10239. if res.Infcode == 0 {
  10240. psn_record.IsCancel = 2
  10241. service.CreatePsnRecord(&psn_record)
  10242. } else {
  10243. c.ServeSuccessJSON(map[string]interface{}{
  10244. "failed_code": -10,
  10245. "msg": res.ErrMsg,
  10246. })
  10247. return
  10248. }
  10249. }
  10250. }
  10251. func (c *HisApiController) PsnPutNCDSOnRecord() {
  10252. patient_id, _ := c.GetInt64("patient_id")
  10253. insutype_two := c.GetString("insutype")
  10254. psn_no := c.GetString("psn_no")
  10255. doctor_id, _ := c.GetInt64("doctor_id")
  10256. sick_id, _ := c.GetInt64("sick_id")
  10257. department_id, _ := c.GetInt64("department_id")
  10258. start_time := c.GetString("start_time")
  10259. end_time := c.GetString("end_time")
  10260. check_time := c.GetString("check_time")
  10261. adminUser := c.GetAdminUserInfo()
  10262. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10263. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10264. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10265. sick, _ := service.FindSickById(sick_id)
  10266. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10267. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10268. var res ResultTwo
  10269. var res10265 ResultTwo10265
  10270. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10271. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  10272. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  10273. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  10274. "&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
  10275. resp, requestErr := http.Get(api)
  10276. if requestErr != nil {
  10277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10278. return
  10279. }
  10280. body, ioErr := ioutil.ReadAll(resp.Body)
  10281. if ioErr != nil {
  10282. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10284. return
  10285. }
  10286. var respJSON map[string]interface{}
  10287. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10288. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10290. return
  10291. }
  10292. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10293. result, _ := json.Marshal(respJSON)
  10294. fmt.Println("log")
  10295. fmt.Println(string(result))
  10296. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10297. utils.ErrorLog("解析失败:%v", err)
  10298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10299. return
  10300. }
  10301. res.ErrMsg = res10265.ErrMsg
  10302. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10303. res.Infcode = infocode
  10304. //res.Output = res10265.Output
  10305. res.InfRefmsgid = res10265.InfRefmsgid
  10306. } else {
  10307. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10308. if miConfig.Code == "H15049901371" {
  10309. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10310. utils.ErrorLog("解析失败:%v", err)
  10311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10312. return
  10313. }
  10314. res.ErrMsg = res10265.ErrMsg
  10315. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10316. res.Infcode = infocode
  10317. //res.Output = res10265.Output
  10318. res.InfRefmsgid = res10265.InfRefmsgid
  10319. } else {
  10320. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10321. utils.ErrorLog("解析失败:%v", err)
  10322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10323. return
  10324. }
  10325. }
  10326. }
  10327. Iinfos, _ := json.Marshal(res.Output[0].Iinfo)
  10328. infoStr := string(Iinfos)
  10329. var rf []*ResultFive
  10330. json.Unmarshal([]byte(infoStr), &rf)
  10331. var insuplc_admdvs string
  10332. var insutype string
  10333. var is390 int = 0
  10334. var is310 int = 0
  10335. var insutypes []*ResultFive
  10336. for _, item := range rf {
  10337. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10338. insutypes = append(insutypes, item)
  10339. }
  10340. }
  10341. if len(insutypes) == 1 {
  10342. insutype = insutypes[0].Insutype
  10343. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10344. } else {
  10345. for _, i := range insutypes {
  10346. if i.Insutype == "390" {
  10347. is390 = 1
  10348. }
  10349. if i.Insutype == "310" {
  10350. is310 = 1
  10351. }
  10352. }
  10353. }
  10354. if is390 == 1 {
  10355. insutype = "390"
  10356. }
  10357. if is310 == 1 {
  10358. insutype = "310"
  10359. }
  10360. if len(insutypes) == 2 {
  10361. insutype = insutype_two
  10362. }
  10363. if len(insutypes) == 0 {
  10364. insutype = "310"
  10365. }
  10366. insutype = insutype_two
  10367. fmt.Println(insutype)
  10368. for _, item := range rf {
  10369. fmt.Println(item.Insutype)
  10370. fmt.Println(insutype)
  10371. if item.Insutype == insutype {
  10372. fmt.Println(item.Insutype)
  10373. fmt.Println(insutype)
  10374. insuplc_admdvs = item.InsuplcAdmdvs
  10375. }
  10376. }
  10377. fmt.Println(insuplc_admdvs)
  10378. var res2 ResultThirteen
  10379. var res10265_2 ResultThirteen10265
  10380. if config.IsOpen == 1 {
  10381. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10382. } else {
  10383. 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)
  10384. var dat map[string]interface{}
  10385. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10386. fmt.Println(dat)
  10387. } else {
  10388. fmt.Println(err)
  10389. }
  10390. userJSONBytes, _ := json.Marshal(dat)
  10391. if miConfig.Code == "H15049901371" {
  10392. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  10393. utils.ErrorLog("解析失败:%v", err)
  10394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10395. return
  10396. }
  10397. res2.ErrMsg = res10265_2.ErrMsg
  10398. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  10399. res2.Infcode = infocode
  10400. res2.Output = res10265_2.Output
  10401. res2.InfRefmsgid = res10265_2.InfRefmsgid
  10402. } else {
  10403. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10404. utils.ErrorLog("解析失败:%v", err)
  10405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10406. return
  10407. }
  10408. }
  10409. }
  10410. if res2.Infcode == 0 {
  10411. psnResult := &models.GdybPsnNcdsRecord{
  10412. UserOrgId: adminUser.CurrentOrgId,
  10413. PatientId: patient.ID,
  10414. PsnNo: psn_no,
  10415. DoctorId: doctor.AdminUserId,
  10416. DepartmentId: department_id,
  10417. SickType: sick_id,
  10418. Insutype: insutype,
  10419. Ctime: time.Now().Unix(),
  10420. Mtime: time.Now().Unix(),
  10421. Status: 1,
  10422. IsCancel: 1,
  10423. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10424. }
  10425. service.CreatePsnNCDSRecord(psnResult)
  10426. c.ServeSuccessJSON(map[string]interface{}{
  10427. "failed_code": 0,
  10428. "msg": "备案成功",
  10429. "result": psnResult,
  10430. })
  10431. } else {
  10432. c.ServeSuccessJSON(map[string]interface{}{
  10433. "failed_code": -10,
  10434. "msg": res2.ErrMsg,
  10435. })
  10436. return
  10437. }
  10438. }
  10439. }
  10440. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  10441. id, _ := c.GetInt64("id")
  10442. admin_user_id, _ := c.GetInt64("admin_user_id")
  10443. adminUser := c.GetAdminUserInfo()
  10444. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10445. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10446. //config, _ := service.Ge(adminUser.CurrentOrgId)
  10447. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  10448. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10449. //var user_name string
  10450. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10451. //if role.ID == 0 {
  10452. // user_name = "xxx"
  10453. //} else {
  10454. // user_name = role.UserName
  10455. //}
  10456. psn_record, _ := service.GetPsnNCDSRecordById(id)
  10457. if psn_record.ID == 0 {
  10458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10459. return
  10460. }
  10461. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10462. var res ResultTwo
  10463. var res10265 ResultTwo10265
  10464. if miConfig.Code == "H15049901371" {
  10465. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10466. utils.ErrorLog("解析失败:%v", err)
  10467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10468. return
  10469. }
  10470. res.ErrMsg = res10265.ErrMsg
  10471. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10472. res.Infcode = infocode
  10473. //res.Output = res10265.Output
  10474. res.InfRefmsgid = res10265.InfRefmsgid
  10475. } else {
  10476. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10477. utils.ErrorLog("解析失败:%v", err)
  10478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10479. return
  10480. }
  10481. }
  10482. Iinfos, _ := json.Marshal(res.Output[0].Iinfo)
  10483. infoStr := string(Iinfos)
  10484. var rf []*ResultFive
  10485. json.Unmarshal([]byte(infoStr), &rf)
  10486. var insuplc_admdvs string
  10487. var insutype string
  10488. var is390 int = 0
  10489. var is310 int = 0
  10490. var insutypes []*ResultFive
  10491. for _, item := range rf {
  10492. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10493. insutypes = append(insutypes, item)
  10494. }
  10495. }
  10496. if len(insutypes) == 1 {
  10497. insutype = insutypes[0].Insutype
  10498. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10499. } else {
  10500. for _, i := range insutypes {
  10501. if i.Insutype == "390" {
  10502. is390 = 1
  10503. }
  10504. if i.Insutype == "310" {
  10505. is310 = 1
  10506. }
  10507. }
  10508. }
  10509. if is390 == 1 {
  10510. insutype = "390"
  10511. }
  10512. if is310 == 1 {
  10513. insutype = "310"
  10514. }
  10515. if len(insutypes) == 0 {
  10516. insutype = "310"
  10517. }
  10518. insutype = psn_record.Insutype
  10519. for _, item := range rf {
  10520. if item.Insutype == insutype {
  10521. insuplc_admdvs = item.InsuplcAdmdvs
  10522. }
  10523. }
  10524. if config.IsOpen == 1 {
  10525. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10526. var dat map[string]interface{}
  10527. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10528. fmt.Println(dat)
  10529. } else {
  10530. fmt.Println(err)
  10531. }
  10532. userJSONBytes, _ := json.Marshal(dat)
  10533. var res ResultFourteen
  10534. var res10265 ResultFourteen10265
  10535. if miConfig.Code == "H15049901371" {
  10536. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10537. utils.ErrorLog("解析失败:%v", err)
  10538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10539. return
  10540. }
  10541. res.ErrMsg = res10265.ErrMsg
  10542. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10543. res.Infcode = infocode
  10544. res.Output = res10265.Output
  10545. res.InfRefmsgid = res10265.InfRefmsgid
  10546. } else {
  10547. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10548. utils.ErrorLog("解析失败:%v", err)
  10549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10550. return
  10551. }
  10552. }
  10553. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10554. // utils.ErrorLog("解析失败:%v", err)
  10555. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10556. // return
  10557. //}
  10558. if res.Infcode == 0 {
  10559. psn_record.IsCancel = 2
  10560. service.CreatePsnNCDSRecord(&psn_record)
  10561. c.ServeSuccessJSON(map[string]interface{}{
  10562. "failed_code": 0,
  10563. "msg": "撤销备案成功",
  10564. })
  10565. } else {
  10566. c.ServeSuccessJSON(map[string]interface{}{
  10567. "failed_code": -10,
  10568. "msg": res.ErrMsg,
  10569. })
  10570. return
  10571. }
  10572. }
  10573. }
  10574. func (c *HisApiController) TestTest() {
  10575. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  10576. fmt.Println(patient.Iinfo)
  10577. }
  10578. type CustomData struct {
  10579. MsgId string
  10580. PsnNo string
  10581. Info string
  10582. }
  10583. func (c *HisApiController) ReversalData() {
  10584. var customData []*CustomData
  10585. custom := &CustomData{
  10586. MsgId: "H44022900158202103301714472004",
  10587. PsnNo: "44020000001101329945",
  10588. Info: "2207",
  10589. }
  10590. customData = append(customData, custom)
  10591. custom1 := &CustomData{
  10592. MsgId: "H4402290015820210330172057803",
  10593. PsnNo: "44020000001101161813",
  10594. Info: "2207",
  10595. }
  10596. customData = append(customData, custom1)
  10597. custom2 := &CustomData{
  10598. MsgId: "H44022900158202103301705198813",
  10599. PsnNo: "44190000133097375417",
  10600. Info: "2207",
  10601. }
  10602. customData = append(customData, custom2)
  10603. custom3 := &CustomData{
  10604. MsgId: "H44022900158202103301715524756",
  10605. PsnNo: "44020000001100187221",
  10606. Info: "2207",
  10607. }
  10608. customData = append(customData, custom3)
  10609. custom4 := &CustomData{
  10610. MsgId: "H44022900158202103301730376224",
  10611. PsnNo: "44020000001101959155",
  10612. Info: "2207",
  10613. }
  10614. customData = append(customData, custom4)
  10615. custom5 := &CustomData{
  10616. MsgId: "H44022900158202103301748008725",
  10617. PsnNo: "44020000001104246641",
  10618. Info: "2207",
  10619. }
  10620. customData = append(customData, custom5)
  10621. custom6 := &CustomData{
  10622. MsgId: "H44022900158202103301718096755",
  10623. PsnNo: "44020000001102211860",
  10624. Info: "2207",
  10625. }
  10626. customData = append(customData, custom6)
  10627. custom7 := &CustomData{
  10628. MsgId: "H44022900158202103301736551640",
  10629. PsnNo: "44020000001102687718",
  10630. Info: "2207",
  10631. }
  10632. customData = append(customData, custom7)
  10633. custom8 := &CustomData{
  10634. MsgId: "H44022900158202103301743097676",
  10635. PsnNo: "44020000001102127785",
  10636. Info: "2207",
  10637. }
  10638. customData = append(customData, custom8)
  10639. custom9 := &CustomData{
  10640. MsgId: "H44022900158202103301712304203",
  10641. PsnNo: "44020000001101518097",
  10642. Info: "2207",
  10643. }
  10644. customData = append(customData, custom9)
  10645. custom10 := &CustomData{
  10646. MsgId: "H44022900158202103301738448785",
  10647. PsnNo: "44020000001100500813",
  10648. Info: "2207",
  10649. }
  10650. customData = append(customData, custom10)
  10651. custom11 := &CustomData{
  10652. MsgId: "H44022900158202103301732455843",
  10653. PsnNo: "44020000001102690557",
  10654. Info: "2207",
  10655. }
  10656. customData = append(customData, custom11)
  10657. custom12 := &CustomData{
  10658. MsgId: "H44022900158202103301745421708",
  10659. PsnNo: "44020000001102211928",
  10660. Info: "2207",
  10661. }
  10662. customData = append(customData, custom12)
  10663. custom1212 := &CustomData{
  10664. MsgId: "H440229001582021033017351627",
  10665. PsnNo: "44020000001102481733",
  10666. Info: "2207",
  10667. }
  10668. customData = append(customData, custom1212)
  10669. custom13 := &CustomData{
  10670. MsgId: "H44022900158202103301740327951",
  10671. PsnNo: "44020000001103174866",
  10672. Info: "2207",
  10673. }
  10674. customData = append(customData, custom13)
  10675. custom14 := &CustomData{
  10676. MsgId: "H4402290015820210330174922668",
  10677. PsnNo: "44020000001102927272",
  10678. Info: "2207",
  10679. }
  10680. customData = append(customData, custom14)
  10681. custom15 := &CustomData{
  10682. MsgId: "H44022900158202103301752362273",
  10683. PsnNo: "44020000001102942890",
  10684. Info: "2207",
  10685. }
  10686. customData = append(customData, custom15)
  10687. custom16 := &CustomData{
  10688. MsgId: "H44022900158202103301751082917",
  10689. PsnNo: "44020000001101662162",
  10690. Info: "2207",
  10691. }
  10692. customData = append(customData, custom16)
  10693. custom17 := &CustomData{
  10694. MsgId: "H44022900158202103301754147728",
  10695. PsnNo: "44020000000229014511",
  10696. Info: "2207",
  10697. }
  10698. customData = append(customData, custom17)
  10699. adminUser := c.GetAdminUserInfo()
  10700. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10701. for _, item := range customData {
  10702. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10703. fmt.Println(result)
  10704. }
  10705. }
  10706. //func (c *HisApiController) GetAllopatry() {
  10707. // year := c.GetString("year")
  10708. // month := c.GetString("month")
  10709. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10710. // adminUser := c.GetAdminUserInfo()
  10711. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10712. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10713. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10714. //
  10715. // var dat map[string]interface{}
  10716. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10717. // fmt.Println(dat)
  10718. // } else {
  10719. // fmt.Println(err)
  10720. // }
  10721. // userJSONBytes, _ := json.Marshal(dat)
  10722. // var res models.Result9001
  10723. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10724. // utils.ErrorLog("解析失败:%v", err)
  10725. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10726. // return
  10727. // }
  10728. //
  10729. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "")
  10730. // var dat2 map[string]interface{}
  10731. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10732. // fmt.Println(dat)
  10733. // } else {
  10734. // fmt.Println(err)
  10735. // }
  10736. // userJSONBytes2, _ := json.Marshal(dat2)
  10737. // var res2 models.Result3260
  10738. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10739. // utils.ErrorLog("解析失败:%v", err)
  10740. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10741. // return
  10742. // }
  10743. // if res2.Infcode == 0 {
  10744. // c.ServeSuccessJSON(map[string]interface{}{
  10745. // "list": res2.Output.Data,
  10746. // })
  10747. // return
  10748. // } else {
  10749. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10750. // return
  10751. // }
  10752. //
  10753. //}
  10754. //func (c *HisApiController) ComfirmAllopatry() {
  10755. // year := c.GetString("year")
  10756. // month := c.GetString("month")
  10757. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10758. // adminUser := c.GetAdminUserInfo()
  10759. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10760. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10761. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10762. // var dat map[string]interface{}
  10763. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10764. // fmt.Println(dat)
  10765. // } else {
  10766. // fmt.Println(err)
  10767. // }
  10768. // userJSONBytes, _ := json.Marshal(dat)
  10769. // var res models.Result9001
  10770. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10771. // utils.ErrorLog("解析失败:%v", err)
  10772. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10773. // return
  10774. // }
  10775. //
  10776. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "")
  10777. // var dat2 map[string]interface{}
  10778. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10779. // fmt.Println(dat)
  10780. // } else {
  10781. // fmt.Println(err)
  10782. // }
  10783. // userJSONBytes2, _ := json.Marshal(dat2)
  10784. // var res2 models.Result3260
  10785. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10786. // utils.ErrorLog("解析失败:%v", err)
  10787. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10788. // return
  10789. // }
  10790. //
  10791. // if res2.Infcode == 0 {
  10792. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  10793. // var dat map[string]interface{}
  10794. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10795. // fmt.Println(dat)
  10796. // } else {
  10797. // fmt.Println(err)
  10798. // }
  10799. // userJSONBytes, _ := json.Marshal(dat)
  10800. // var res3 models.Result3261
  10801. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  10802. // utils.ErrorLog("解析失败:%v", err)
  10803. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10804. // return
  10805. // }
  10806. //
  10807. // if res3.Infcode == 0 {
  10808. // record := &models.HisYidiClearRecord{
  10809. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10810. // Ctime: time.Now().Unix(),
  10811. // Mtime: time.Now().Unix(),
  10812. // Status: 1,
  10813. // MsgId: msgId,
  10814. // }
  10815. // service.SaveClearRecord(record)
  10816. // c.ServeSuccessJSON(map[string]interface{}{
  10817. // "msg": "提取成功",
  10818. // })
  10819. // }
  10820. // }
  10821. //}
  10822. //
  10823. //func (c *HisApiController) RefundAllopatry() {
  10824. // year := c.GetString("year")
  10825. // month := c.GetString("month")
  10826. // id, _ := c.GetInt64("id")
  10827. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10828. // adminUser := c.GetAdminUserInfo()
  10829. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10830. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10831. // record, _ := service.GetClearRecordById(id)
  10832. // result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  10833. //
  10834. // var dat map[string]interface{}
  10835. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10836. // fmt.Println(dat)
  10837. // } else {
  10838. // fmt.Println(err)
  10839. // }
  10840. // userJSONBytes, _ := json.Marshal(dat)
  10841. // var empty ResultFourteen
  10842. // if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  10843. // utils.ErrorLog("解析失败:%v", err)
  10844. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10845. // return
  10846. // }
  10847. // if empty.Infcode == 0 {
  10848. // c.ServeSuccessJSON(map[string]interface{}{
  10849. // "msg": "撤销成功",
  10850. // })
  10851. // return
  10852. // }
  10853. //}
  10854. func (c *HisApiController) ReversalOtherData() {
  10855. var customData []*CustomData
  10856. custom := &CustomData{
  10857. MsgId: "H44022900158202103301714472004",
  10858. PsnNo: "44020000001101329945",
  10859. Info: "2208",
  10860. }
  10861. customData = append(customData, custom)
  10862. custom1 := &CustomData{
  10863. MsgId: "H4402290015820210330172057803",
  10864. PsnNo: "44020000001101161813",
  10865. Info: "2208",
  10866. }
  10867. customData = append(customData, custom1)
  10868. custom2 := &CustomData{
  10869. MsgId: "H44022900158202103301705198813",
  10870. PsnNo: "44190000133097375417",
  10871. Info: "2208",
  10872. }
  10873. customData = append(customData, custom2)
  10874. custom3 := &CustomData{
  10875. MsgId: "H44022900158202103301715524756",
  10876. PsnNo: "44020000001100187221",
  10877. Info: "2208",
  10878. }
  10879. customData = append(customData, custom3)
  10880. custom4 := &CustomData{
  10881. MsgId: "H44022900158202103301730376224",
  10882. PsnNo: "44020000001101959155",
  10883. Info: "2208",
  10884. }
  10885. customData = append(customData, custom4)
  10886. custom5 := &CustomData{
  10887. MsgId: "H44022900158202103301748008725",
  10888. PsnNo: "44020000001104246641",
  10889. Info: "2208",
  10890. }
  10891. customData = append(customData, custom5)
  10892. custom6 := &CustomData{
  10893. MsgId: "H44022900158202103301718096755",
  10894. PsnNo: "44020000001102211860",
  10895. Info: "2208",
  10896. }
  10897. customData = append(customData, custom6)
  10898. custom7 := &CustomData{
  10899. MsgId: "H44022900158202103301736551640",
  10900. PsnNo: "44020000001102687718",
  10901. Info: "2208",
  10902. }
  10903. customData = append(customData, custom7)
  10904. custom8 := &CustomData{
  10905. MsgId: "H44022900158202103301743097676",
  10906. PsnNo: "44020000001102127785",
  10907. Info: "2208",
  10908. }
  10909. customData = append(customData, custom8)
  10910. custom9 := &CustomData{
  10911. MsgId: "H44022900158202103301712304203",
  10912. PsnNo: "44020000001101518097",
  10913. Info: "2208",
  10914. }
  10915. customData = append(customData, custom9)
  10916. custom10 := &CustomData{
  10917. MsgId: "H44022900158202103301738448785",
  10918. PsnNo: "44020000001100500813",
  10919. Info: "2208",
  10920. }
  10921. customData = append(customData, custom10)
  10922. custom11 := &CustomData{
  10923. MsgId: "H44022900158202103301732455843",
  10924. PsnNo: "44020000001102690557",
  10925. Info: "2208",
  10926. }
  10927. customData = append(customData, custom11)
  10928. custom12 := &CustomData{
  10929. MsgId: "H44022900158202103301745421708",
  10930. PsnNo: "44020000001102211928",
  10931. Info: "2208",
  10932. }
  10933. customData = append(customData, custom12)
  10934. custom1212 := &CustomData{
  10935. MsgId: "H440229001582021033017351627",
  10936. PsnNo: "44020000001102481733",
  10937. Info: "2208",
  10938. }
  10939. customData = append(customData, custom1212)
  10940. custom13 := &CustomData{
  10941. MsgId: "H44022900158202103301740327951",
  10942. PsnNo: "44020000001103174866",
  10943. Info: "2208",
  10944. }
  10945. customData = append(customData, custom13)
  10946. custom14 := &CustomData{
  10947. MsgId: "H4402290015820210330174922668",
  10948. PsnNo: "44020000001102927272",
  10949. Info: "2208",
  10950. }
  10951. customData = append(customData, custom14)
  10952. custom15 := &CustomData{
  10953. MsgId: "H44022900158202103301752362273",
  10954. PsnNo: "44020000001102942890",
  10955. Info: "2208",
  10956. }
  10957. customData = append(customData, custom15)
  10958. custom16 := &CustomData{
  10959. MsgId: "H44022900158202103301751082917",
  10960. PsnNo: "44020000001101662162",
  10961. Info: "2208",
  10962. }
  10963. customData = append(customData, custom16)
  10964. custom17 := &CustomData{
  10965. MsgId: "H44022900158202103301754147728",
  10966. PsnNo: "44020000000229014511",
  10967. Info: "2208",
  10968. }
  10969. customData = append(customData, custom17)
  10970. adminUser := c.GetAdminUserInfo()
  10971. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10972. for _, item := range customData {
  10973. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10974. fmt.Println(result)
  10975. }
  10976. }
  10977. func PathExists(path string) (bool, error) {
  10978. _, err := os.Stat(path)
  10979. if err == nil {
  10980. return true, nil
  10981. }
  10982. if os.IsNotExist(err) {
  10983. return false, nil
  10984. }
  10985. return false, err
  10986. }
  10987. //创建文件夹
  10988. func Mkdir(dir string) {
  10989. // 创建文件夹
  10990. exist, err := PathExists(dir)
  10991. if err != nil {
  10992. fmt.Println(err.Error())
  10993. } else {
  10994. if exist {
  10995. fmt.Println(dir + "文件夹已存在!")
  10996. } else {
  10997. // 文件夹名称,权限
  10998. err := os.Mkdir(dir, os.ModePerm)
  10999. if err != nil {
  11000. fmt.Println(dir+"文件夹创建失败:", err.Error())
  11001. } else {
  11002. fmt.Println(dir + "文件夹创建成功!")
  11003. }
  11004. }
  11005. }
  11006. }
  11007. //压缩文件
  11008. func Zip(srcFile string, destZip string) error {
  11009. zipfile, err := os.Create(destZip)
  11010. if err != nil {
  11011. return err
  11012. }
  11013. defer zipfile.Close()
  11014. archive := zip.NewWriter(zipfile)
  11015. defer archive.Close()
  11016. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  11017. if err != nil {
  11018. return err
  11019. }
  11020. header, err := zip.FileInfoHeader(info)
  11021. if err != nil {
  11022. return err
  11023. }
  11024. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  11025. // header.Name = path
  11026. if info.IsDir() {
  11027. header.Name += "/"
  11028. } else {
  11029. header.Method = zip.Deflate
  11030. }
  11031. writer, err := archive.CreateHeader(header)
  11032. if err != nil {
  11033. return err
  11034. }
  11035. if !info.IsDir() {
  11036. file, err := os.Open(path)
  11037. if err != nil {
  11038. return err
  11039. }
  11040. defer file.Close()
  11041. _, err = io.Copy(writer, file)
  11042. }
  11043. return err
  11044. })
  11045. return err
  11046. }
  11047. func ReadFile(filePath string) []byte {
  11048. f, err := os.Open(filePath)
  11049. if err != nil {
  11050. fmt.Println("read file fail", err)
  11051. return nil
  11052. }
  11053. defer f.Close()
  11054. fd, err := ioutil.ReadAll(f)
  11055. if err != nil {
  11056. fmt.Println("read to fd fail", err)
  11057. return nil
  11058. }
  11059. return fd
  11060. }
  11061. func saveLog(result string, request string, infno string, desc string) {
  11062. org_id, _ := beego.AppConfig.Int64("org_id")
  11063. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  11064. dir := miConfig.OrgName + "日志"
  11065. utils.Mkdir(dir)
  11066. month := time.Unix(1557042972, 0).Format("1")
  11067. year := time.Now().Format("2006")
  11068. month = time.Now().Format("01")
  11069. day := time.Now().Format("02")
  11070. hour := time.Now().Format("15")
  11071. min := time.Now().Format("04")
  11072. sec := time.Now().Format("05")
  11073. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  11074. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  11075. file_name := file + ".txt"
  11076. file_path := miConfig.OrgName + "日志" + "/" + file_name
  11077. exist, _ := utils.PathExists(file_path)
  11078. if exist { //存在
  11079. fmt.Println("存在")
  11080. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  11081. if err != nil {
  11082. fmt.Println("read fail")
  11083. }
  11084. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  11085. n, _ := f.Seek(0, 2)
  11086. _, err = f.WriteAt([]byte(content), n)
  11087. } else { //不存在
  11088. fmt.Println("文件不存在,创建文件")
  11089. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  11090. defer f.Close()
  11091. if err != nil {
  11092. } else {
  11093. _, err = f.Write([]byte("记录日志"))
  11094. }
  11095. }
  11096. }
  11097. type Charset string
  11098. const (
  11099. UTF8 = Charset("UTF-8")
  11100. GB18030 = Charset("GB18030")
  11101. )
  11102. func ConvertToString(src string, srcCode string, tagCode string) string {
  11103. srcCoder := mahonia.NewDecoder(srcCode)
  11104. srcResult := srcCoder.ConvertString(src)
  11105. tagCoder := mahonia.NewDecoder(tagCode)
  11106. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  11107. result := string(cdata)
  11108. return result
  11109. }
  11110. func (c *HisApiController) ReadEleCard() {
  11111. id_card_type, _ := c.GetInt64("id_card_type")
  11112. admin_user_id, _ := c.GetInt64("admin_user_id")
  11113. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  11114. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11115. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11116. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11117. var api string
  11118. if miConfig.MdtrtareaAdmvs == "320921" {
  11119. 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 +
  11120. "&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
  11121. fmt.Println(api)
  11122. } else {
  11123. 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 +
  11124. "&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)
  11125. }
  11126. resp, requestErr := http.Get(api)
  11127. if requestErr != nil {
  11128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11129. return
  11130. }
  11131. body, ioErr := ioutil.ReadAll(resp.Body)
  11132. if ioErr != nil {
  11133. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11135. return
  11136. }
  11137. var respJSON map[string]interface{}
  11138. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11139. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11141. return
  11142. }
  11143. var status string
  11144. status = respJSON["data"].(map[string]interface{})["status"].(string)
  11145. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  11146. var token string
  11147. var res ResultTwo //1101结果
  11148. var res10265 ResultTwo10265 //1101结果
  11149. if status == "0" { //读卡成功
  11150. var card_info string //卡信息
  11151. var busi_card_info string
  11152. token = respJSON["data"].(map[string]interface{})["token"].(string)
  11153. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  11154. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  11155. fmt.Println(card_info)
  11156. fmt.Println(busi_card_info)
  11157. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  11158. result, _ := json.Marshal(respJSON)
  11159. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11160. utils.ErrorLog("解析失败:%v", err)
  11161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11162. return
  11163. }
  11164. res.ErrMsg = res10265.ErrMsg
  11165. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11166. res.Infcode = infocode
  11167. //res.Output = res10265.Output
  11168. res.InfRefmsgid = res10265.InfRefmsgid
  11169. if res.Infcode == 0 {
  11170. c.ServeSuccessJSON(map[string]interface{}{
  11171. "number": token,
  11172. })
  11173. }
  11174. } else {
  11175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11176. return
  11177. }
  11178. } else { //读卡失败
  11179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11180. return
  11181. }
  11182. }