new_his_api_controller.go 451KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353
  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/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  69. beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  70. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  71. beego.Router("/api/check", &HisApiController{}, "get:Check")
  72. beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  73. beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  74. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  75. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  76. beego.Router("/9002", &HisApiController{}, "get:Get9002")
  77. beego.Router("/2505", &HisApiController{}, "get:Get2505")
  78. beego.Router("/2503", &HisApiController{}, "get:Get2503")
  79. beego.Router("/5301", &HisApiController{}, "get:Get5301")
  80. beego.Router("/2504", &HisApiController{}, "get:Get2504")
  81. beego.Router("/1160", &HisApiController{}, "get:Get1160")
  82. beego.Router("/2001", &HisApiController{}, "get:Get2001")
  83. // beego.Router("/api/gzpatient/get", &HisApiController{}, "get:GetGZPatientInfo")
  84. beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  85. }
  86. // func (c *HisApiController) GetGZPatientInfo() {
  87. // id_card_no := c.GetString("id_card_no")
  88. // admin_user_id, _ := c.GetInt64("admin_user_id")
  89. // patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  90. // if patient.ID == 0 {
  91. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  92. // return
  93. // }
  94. // role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  95. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  96. // config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  97. // var result string
  98. // var request_log string
  99. // var result_log string
  100. // 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)
  101. // var dat map[string]interface{}
  102. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  103. // fmt.Println(dat)
  104. // } else {
  105. // fmt.Println(err)
  106. // }
  107. // userJSONBytes, _ := json.Marshal(dat)
  108. // var res ResultTwo
  109. // var resTwo10265 ResultTwo10265
  110. // if miConfig.Code == "H15049901371" {
  111. // if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  112. // utils.ErrorLog("解析失败:%v", err)
  113. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  114. // return
  115. // }
  116. // Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  117. // res.Infcode = Infcode
  118. // res.ErrMsg = resTwo10265.ErrMsg
  119. // res.Output = resTwo10265.Output
  120. // res.InfRefmsgid = resTwo10265.InfRefmsgid
  121. // res.RespondTime = resTwo10265.RespondTime
  122. // res.WarnInfo = resTwo10265.WarnInfo
  123. // } else {
  124. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  125. // utils.ErrorLog("解析失败:%v", err)
  126. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  127. // return
  128. // }
  129. // }
  130. // var insutypes []string
  131. // var insutype string
  132. // var is390 int = 0
  133. // var is310 int = 0
  134. // for _, item := range res.Output.Iinfo {
  135. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  136. // insutypes = append(insutypes, item.Insutype)
  137. // }
  138. // }
  139. // if len(insutypes) == 1 {
  140. // insutype = insutypes[0]
  141. // } else {
  142. // for _, i := range insutypes {
  143. // if i == "390" {
  144. // is390 = 1
  145. // }
  146. // if i == "310" {
  147. // is310 = 1
  148. // }
  149. // }
  150. // }
  151. // if is390 == 1 {
  152. // insutype = "390"
  153. // }
  154. // if is310 == 1 {
  155. // insutype = "310"
  156. // }
  157. // if len(insutypes) == 0 {
  158. // insutype = "310"
  159. // }
  160. // if res.Infcode != 0 {
  161. // c.ServeSuccessJSON(map[string]interface{}{
  162. // "failed_code": -10,
  163. // "msg": res.ErrMsg,
  164. // })
  165. // } else {
  166. // c.ServeSuccessJSON(map[string]interface{}{
  167. // "failed_code": 0,
  168. // "info": res,
  169. // "insutype": insutype,
  170. // })
  171. // }
  172. // }
  173. func (c *HisApiController) Get9002() {
  174. adminUser := c.GetAdminUserInfo()
  175. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  176. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  177. service.Gdyb9002(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  178. }
  179. func (c *HisApiController) Get2001() {
  180. adminUser := c.GetAdminUserInfo()
  181. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  182. baseParams := models.BaseParams{
  183. SecretKey: "h1hEqxQm12ryULCgPKolkid8S9hZFu6M",
  184. FixmedinsCode: miConfig.Code,
  185. InsuplcAdmdvs: "441599",
  186. MdtrtareaAdmvs: "440100",
  187. OrgName: miConfig.OrgName,
  188. Doctor: "1111",
  189. }
  190. service.Gdyb2001(baseParams, "441500CS000000301426", "310", "11")
  191. }
  192. func (c *HisApiController) Get1160() {
  193. adminUser := c.GetAdminUserInfo()
  194. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  195. baseParams := models.BaseParams{
  196. SecretKey: "h1hEqxQm12ryULCgPKolkid8S9hZFu6M",
  197. FixmedinsCode: miConfig.Code,
  198. InsuplcAdmdvs: "440100",
  199. MdtrtareaAdmvs: "440100",
  200. OrgName: miConfig.OrgName,
  201. Doctor: "1111",
  202. }
  203. service.Gdyb1160(baseParams, "441500CS000000301426", "310", "14")
  204. }
  205. func (c *HisApiController) Get2504() {
  206. adminUser := c.GetAdminUserInfo()
  207. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  208. result := service.Gdyb2504("441500CS000000301426", miConfig.OrgName, "admin", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "20220629626617")
  209. fmt.Println(result)
  210. }
  211. func (c *HisApiController) Get5301() {
  212. adminUser := c.GetAdminUserInfo()
  213. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  214. result := service.Gdyb5301("44010000003501822495", miConfig.OrgName, "admin", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  215. fmt.Println(result)
  216. }
  217. func (c *HisApiController) Get2505() {
  218. adminUser := c.GetAdminUserInfo()
  219. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  220. 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")
  221. fmt.Println(result)
  222. }
  223. func (c *HisApiController) Get2503() {
  224. adminUser := c.GetAdminUserInfo()
  225. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  226. 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")
  227. fmt.Println(result)
  228. }
  229. func (c *HisApiController) Get9001() {
  230. adminUser := c.GetAdminUserInfo()
  231. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  232. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  233. result, inputLog := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  234. var dat map[string]interface{}
  235. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  236. fmt.Println(dat)
  237. } else {
  238. fmt.Println(err)
  239. }
  240. userJSONBytes, _ := json.Marshal(dat)
  241. var res models.Result9001
  242. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  243. utils.ErrorLog("解析失败:%v", err)
  244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  245. return
  246. }
  247. if res.Infcode == 0 {
  248. sign := models.HisSignIn{
  249. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  250. SignNo: res.Output.Result.SignNo,
  251. SignTime: res.Output.Result.SignTime,
  252. Ctime: time.Now().Unix(),
  253. Mtime: time.Now().Unix(),
  254. Status: 1,
  255. InputLog: inputLog,
  256. OutputLog: result,
  257. FixmedinsCode: miConfig.Code,
  258. }
  259. err := service.CreateSignIn(&sign)
  260. if err == nil {
  261. c.ServeSuccessJSON(map[string]interface{}{
  262. "msg": "签到成功",
  263. })
  264. }
  265. }
  266. }
  267. func (c *HisApiController) Check3101() {
  268. patient_id, _ := c.GetInt64("patient_id")
  269. his_patient_id, _ := c.GetInt64("his_patient_id")
  270. admin_user_id, _ := c.GetInt64("admin_user_id")
  271. adminUser := c.GetAdminUserInfo()
  272. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  273. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  274. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  275. record_time := c.GetString("record_time")
  276. trig_scen := c.GetString("trig_scen")
  277. timeLayout := "2006-01-02"
  278. loc, _ := time.LoadLocation("Local")
  279. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  280. if err != nil {
  281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  282. return
  283. }
  284. recordDateTime := theTime.Unix()
  285. var patientPrescription models.HisPrescriptionInfo
  286. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  287. if patientPrescription.ID == 0 {
  288. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  289. }
  290. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  291. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  292. //
  293. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  294. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  295. var pp models.PublicParams
  296. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  297. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  298. pp.FixmedinsName = miConfig.OrgName
  299. pp.FixmedinsCode = miConfig.Code
  300. pp.RequestUrl = miConfig.Url
  301. pp.Cainfo = miConfig.Cainfo
  302. pp.SecretKey = miConfig.SecretKey
  303. pp.AccessKey = miConfig.AccessKey
  304. pp.OpterName = roles.UserName
  305. var config []*models.HisXtDiagnoseConfig
  306. for _, item := range diagnosis_ids {
  307. id, _ := strconv.ParseInt(item, 10, 64)
  308. diagnosisConfig, _ := service.FindDiagnoseById(id)
  309. config = append(config, &diagnosisConfig)
  310. }
  311. var pd models.PatientDtos
  312. pd.PatnID = his.PsnNo
  313. pd.PatnName = his.Name
  314. pd.Gend = his.Gend
  315. pd.Brdy = his.Brdy
  316. pd.Poolarea = his.InsuplcAdmdvs
  317. pd.CurrMdtrtID = his.Number
  318. var fed models.FsiEncounterDtos
  319. fed.MdtrtID = his.Number
  320. fed.MedinsID = miConfig.Code
  321. fed.MedinsName = miConfig.OrgName
  322. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  323. fed.MedMdtrtType = "1"
  324. fed.MedinsType = "1"
  325. fed.MedinsLv = "11"
  326. tm := time.Unix(his.RecordDate, 0)
  327. s_tm := tm.Format("2006-01-02 15:04:05")
  328. fed.AdmDate = s_tm
  329. fed.DscgDate = s_tm
  330. fed.DscgMainDiseCodg = config[0].CountryCode
  331. fed.DscgMainDiseName = config[0].CountryContentName
  332. //诊断信息
  333. var fdds []*models.FsiDiagnoseDtos
  334. for index, item := range config {
  335. if index == 0 {
  336. var fdd models.FsiDiagnoseDtos
  337. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  338. fdd.InoutDiseType = "1"
  339. fdd.MaindiseFlag = "1"
  340. fdd.DiseDate = s_tm
  341. fdd.DiasSrtNo = "1"
  342. fdd.DiseName = item.CountryContentName
  343. fdd.DiseCodg = item.CountryCode
  344. fdds = append(fdds, &fdd)
  345. } else {
  346. var fdd models.FsiDiagnoseDtos
  347. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  348. fdd.InoutDiseType = "1"
  349. fdd.MaindiseFlag = "1"
  350. fdd.DiseDate = s_tm
  351. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  352. fdd.DiseName = item.CountryContentName
  353. fdd.DiseCodg = item.CountryCode
  354. fdds = append(fdds, &fdd)
  355. }
  356. }
  357. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  358. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  359. fed.AdmDeptName = department.Name
  360. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  361. fed.DscgDeptName = department.Name
  362. fed.MedMdtrtType = "1"
  363. fed.MedType = "11"
  364. //if his.Insutype == "390" {
  365. // fed.MedType = "1402"
  366. //} else {
  367. // fed.MedType = "9933"
  368. //}
  369. var orders []*models.FsiOrderDtos
  370. if trig_scen == "2" {
  371. //处方医嘱信息
  372. for _, item := range prescriptions {
  373. for _, subItem := range item.HisDoctorAdviceInfo {
  374. var order models.FsiOrderDtos
  375. order.RxID = strconv.FormatInt(item.ID, 10)
  376. order.Rxno = strconv.FormatInt(item.ID, 10)
  377. order.LongDrordFlag = "0"
  378. order.HilistType = "1"
  379. order.ChrgType = "1"
  380. order.DrordBhvr = "-"
  381. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  382. order.HosplistName = subItem.BaseDrugLib.DrugName
  383. order.HilistLv = "1"
  384. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  385. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  386. order.HosplistName = subItem.BaseDrugLib.DrugName
  387. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  388. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  389. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  390. order.OwnpayAmt = ""
  391. order.SelfpayAmt = ""
  392. order.Spec = ""
  393. order.SpecUnt = ""
  394. order.DrordBegnDate = s_tm
  395. order.DrordStopDate = ""
  396. order.DrordDrCodg = "1"
  397. order.DrordDeptName = department.Name
  398. order.DrordDrCodg = "1"
  399. order.DrordDrName = doctor_info.UserName
  400. order.DrordDrProfttl = ""
  401. order.CurrDrordFlag = "1"
  402. orders = append(orders, &order)
  403. }
  404. for _, subItem := range item.HisPrescriptionProject {
  405. if subItem.Type == 2 {
  406. var order models.FsiOrderDtos
  407. order.RxID = strconv.FormatInt(item.ID, 10)
  408. order.Rxno = strconv.FormatInt(item.ID, 10)
  409. order.LongDrordFlag = "0"
  410. order.HilistType = "1"
  411. order.ChrgType = "1"
  412. order.DrordBhvr = "-"
  413. order.HilistCode = subItem.HisProject.MedicalCode
  414. order.HosplistName = subItem.HisProject.ProjectName
  415. order.HilistLv = "1"
  416. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  417. order.HosplistCode = subItem.HisProject.MedicalCode
  418. order.HosplistName = subItem.HisProject.ProjectName
  419. order.Cnt = subItem.Count
  420. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  421. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  422. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  423. order.OwnpayAmt = ""
  424. order.SelfpayAmt = ""
  425. order.Spec = ""
  426. order.SpecUnt = ""
  427. order.DrordBegnDate = s_tm
  428. order.DrordStopDate = ""
  429. order.DrordDrCodg = "1"
  430. order.DrordDeptName = department.Name
  431. order.DrordDrCodg = "1"
  432. order.DrordDrName = doctor_info.UserName
  433. order.DrordDrProfttl = ""
  434. order.CurrDrordFlag = "1"
  435. orders = append(orders, &order)
  436. }
  437. if subItem.Type == 3 {
  438. var order models.FsiOrderDtos
  439. order.RxID = strconv.FormatInt(item.ID, 10)
  440. order.Rxno = strconv.FormatInt(item.ID, 10)
  441. order.LongDrordFlag = "0"
  442. order.HilistType = "1"
  443. order.ChrgType = "1"
  444. order.DrordBhvr = "-"
  445. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  446. order.HosplistName = subItem.GoodInfo.GoodName
  447. order.HilistLv = "1"
  448. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  449. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  450. order.HosplistName = subItem.GoodInfo.GoodName
  451. order.Cnt = subItem.Count
  452. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  453. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  454. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  455. order.OwnpayAmt = ""
  456. order.SelfpayAmt = ""
  457. order.Spec = ""
  458. order.SpecUnt = ""
  459. order.DrordBegnDate = s_tm
  460. order.DrordStopDate = ""
  461. order.DrordDrCodg = "1"
  462. order.DrordDeptName = department.Name
  463. order.DrordDrCodg = "1"
  464. order.DrordDrName = doctor_info.UserName
  465. order.DrordDrProfttl = ""
  466. order.CurrDrordFlag = "1"
  467. orders = append(orders, &order)
  468. }
  469. }
  470. }
  471. //处方医嘱信息
  472. }
  473. fed.MatnStas = "0"
  474. fed.MedfeeSumamt = "0"
  475. fed.OwnpayAmt = "0"
  476. fed.SelfpayAmt = "0"
  477. fed.AcctPayamt = "0"
  478. fed.MaAmt = "0"
  479. fed.HifpPayamt = "0"
  480. fed.SetlTotlnum = "1"
  481. fed.Insutype = his.Insutype
  482. fed.ReimFlag = "0"
  483. fed.OutSetlFlag = "0"
  484. var fopd []*models.FsiOperationDtosData
  485. data := make(map[string]interface{})
  486. data["fed"] = fed
  487. data["fdd"] = fdds
  488. data["fod"] = orders
  489. data["pd"] = pd
  490. data["pp"] = pp
  491. data["fopd"] = fopd
  492. data["trig_scen"] = trig_scen
  493. fmt.Println(data)
  494. fmt.Println(fed)
  495. fmt.Println(fdds)
  496. fmt.Println(orders)
  497. fmt.Println(pd)
  498. fmt.Println(pp)
  499. fmt.Println(fopd)
  500. client := &http.Client{}
  501. bytesData, _ := json.Marshal(data)
  502. var req *http.Request
  503. if miConfig.MdtrtareaAdmvs == "320921" {
  504. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  505. } else {
  506. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  507. }
  508. resp, _ := client.Do(req)
  509. defer resp.Body.Close()
  510. body, ioErr := ioutil.ReadAll(resp.Body)
  511. if ioErr != nil {
  512. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  514. return
  515. }
  516. var respJSON map[string]interface{}
  517. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  518. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  520. return
  521. }
  522. //手术操作集合
  523. //手术操作集合
  524. }
  525. func (c *HisApiController) Check3102() {
  526. patient_id, _ := c.GetInt64("patient_id")
  527. order_id, _ := c.GetInt64("order_id")
  528. his_patient_id, _ := c.GetInt64("his_patient_id")
  529. admin_user_id, _ := c.GetInt64("admin_user_id")
  530. trig_scen := c.GetString("trig_scen")
  531. adminUser := c.GetAdminUserInfo()
  532. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  533. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  534. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  535. record_time := c.GetString("record_time")
  536. order, _ := service.GetHisOrderByID(order_id)
  537. timeLayout := "2006-01-02"
  538. loc, _ := time.LoadLocation("Local")
  539. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  540. if err != nil {
  541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  542. return
  543. }
  544. recordDateTime := theTime.Unix()
  545. var patientPrescription models.HisPrescriptionInfo
  546. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  547. if patientPrescription.ID == 0 {
  548. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  549. }
  550. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  551. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  552. //
  553. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  554. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  555. var pp models.PublicParams
  556. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  557. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  558. pp.FixmedinsName = miConfig.OrgName
  559. pp.FixmedinsCode = miConfig.Code
  560. pp.RequestUrl = miConfig.Url
  561. pp.Cainfo = miConfig.Cainfo
  562. pp.SecretKey = miConfig.SecretKey
  563. pp.AccessKey = miConfig.AccessKey
  564. pp.OpterName = roles.UserName
  565. var config []*models.HisXtDiagnoseConfig
  566. for _, item := range diagnosis_ids {
  567. id, _ := strconv.ParseInt(item, 10, 64)
  568. diagnosisConfig, _ := service.FindDiagnoseById(id)
  569. config = append(config, &diagnosisConfig)
  570. }
  571. var pd models.PatientDtos
  572. pd.PatnID = his.PsnNo
  573. pd.PatnName = his.Name
  574. pd.Gend = his.Gend
  575. pd.Brdy = his.Brdy
  576. pd.Poolarea = his.InsuplcAdmdvs
  577. pd.CurrMdtrtID = his.Number
  578. var fed models.FsiEncounterDtos
  579. fed.MdtrtID = his.Number
  580. fed.MedinsID = miConfig.Code
  581. fed.MedinsName = miConfig.OrgName
  582. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  583. fed.MedMdtrtType = "1"
  584. fed.MedinsType = "1"
  585. fed.MedinsLv = "11"
  586. tm := time.Unix(his.RecordDate, 0)
  587. s_tm := tm.Format("2006-01-02 15:04:05")
  588. fed.AdmDate = s_tm
  589. fed.DscgDate = s_tm
  590. fed.DscgMainDiseCodg = config[0].CountryCode
  591. fed.DscgMainDiseName = config[0].CountryContentName
  592. //诊断信息
  593. var fdds []*models.FsiDiagnoseDtos
  594. for index, item := range config {
  595. if index == 0 {
  596. var fdd models.FsiDiagnoseDtos
  597. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  598. fdd.InoutDiseType = "1"
  599. fdd.MaindiseFlag = "1"
  600. fdd.DiseDate = s_tm
  601. fdd.DiasSrtNo = "1"
  602. fdd.DiseName = item.CountryContentName
  603. fdd.DiseCodg = item.CountryCode
  604. fdds = append(fdds, &fdd)
  605. } else {
  606. var fdd models.FsiDiagnoseDtos
  607. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  608. fdd.InoutDiseType = "1"
  609. fdd.MaindiseFlag = "1"
  610. fdd.DiseDate = s_tm
  611. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  612. fdd.DiseName = item.CountryContentName
  613. fdd.DiseCodg = item.CountryCode
  614. fdds = append(fdds, &fdd)
  615. }
  616. }
  617. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  618. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  619. fed.AdmDeptName = department.Name
  620. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  621. fed.DscgDeptName = department.Name
  622. fed.MedType = order.MedType
  623. //处方医嘱信息
  624. var orders []*models.FsiOrderDtos
  625. //for _, item := range prescriptions {
  626. // for _, subItem := range item.HisDoctorAdviceInfo {
  627. // var order models.FsiOrderDtos
  628. // order.RxID = strconv.FormatInt(item.ID, 10)
  629. // order.Rxno = strconv.FormatInt(item.ID, 10)
  630. // order.LongDrordFlag = "0"
  631. // order.HilistType = "1"
  632. // order.ChrgType = "1"
  633. // order.DrordBhvr = "-"
  634. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  635. // order.HosplistName = subItem.BaseDrugLib.DrugName
  636. // order.HilistLv = "1"
  637. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  638. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  639. // order.HosplistName = subItem.BaseDrugLib.DrugName
  640. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  641. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  642. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  643. // order.OwnpayAmt = ""
  644. // order.SelfpayAmt = ""
  645. // order.Spec = ""
  646. // order.SpecUnt = ""
  647. // order.DrordBegnDate = s_tm
  648. // order.DrordStopDate = ""
  649. // order.DrordDrCodg = "1"
  650. // order.DrordDeptName = department.Name
  651. // order.DrordDrCodg = "1"
  652. // order.DrordDrName = doctor_info.UserName
  653. // order.DrordDrProfttl = ""
  654. // order.CurrDrordFlag = "1"
  655. // orders = append(orders, &order)
  656. // }
  657. // for _, subItem := range item.HisPrescriptionProject {
  658. // if subItem.Type == 2 {
  659. // var order models.FsiOrderDtos
  660. // order.RxID = strconv.FormatInt(item.ID, 10)
  661. // order.Rxno = strconv.FormatInt(item.ID, 10)
  662. // order.LongDrordFlag = "0"
  663. // order.HilistType = "1"
  664. // order.ChrgType = "1"
  665. // order.DrordBhvr = "-"
  666. // order.HilistCode = subItem.HisProject.MedicalCode
  667. // order.HosplistName = subItem.HisProject.ProjectName
  668. // order.HilistLv = "1"
  669. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  670. // order.HosplistCode = subItem.HisProject.MedicalCode
  671. // order.HosplistName = subItem.HisProject.ProjectName
  672. // order.Cnt = subItem.Count
  673. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  674. //
  675. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  676. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  677. // order.OwnpayAmt = ""
  678. // order.SelfpayAmt = ""
  679. // order.Spec = ""
  680. // order.SpecUnt = ""
  681. // order.DrordBegnDate = s_tm
  682. // order.DrordStopDate = ""
  683. // order.DrordDrCodg = "1"
  684. // order.DrordDeptName = department.Name
  685. // order.DrordDrCodg = "1"
  686. // order.DrordDrName = doctor_info.UserName
  687. // order.DrordDrProfttl = ""
  688. // order.CurrDrordFlag = "1"
  689. // orders = append(orders, &order)
  690. //
  691. // }
  692. // if subItem.Type == 3 {
  693. //
  694. // var order models.FsiOrderDtos
  695. // order.RxID = strconv.FormatInt(item.ID, 10)
  696. // order.Rxno = strconv.FormatInt(item.ID, 10)
  697. // order.LongDrordFlag = "0"
  698. // order.HilistType = "1"
  699. // order.ChrgType = "1"
  700. // order.DrordBhvr = "-"
  701. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  702. // order.HosplistName = subItem.GoodInfo.GoodName
  703. // order.HilistLv = "1"
  704. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  705. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  706. // order.HosplistName = subItem.GoodInfo.GoodName
  707. // order.Cnt = subItem.Count
  708. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  709. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  710. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  711. // order.OwnpayAmt = ""
  712. // order.SelfpayAmt = ""
  713. // order.Spec = ""
  714. // order.SpecUnt = ""
  715. // order.DrordBegnDate = s_tm
  716. // order.DrordStopDate = ""
  717. // order.DrordDrCodg = "1"
  718. // order.DrordDeptName = department.Name
  719. // order.DrordDrCodg = "1"
  720. // order.DrordDrName = doctor_info.UserName
  721. // order.DrordDrProfttl = ""
  722. // order.CurrDrordFlag = "1"
  723. // orders = append(orders, &order)
  724. //
  725. // }
  726. // }
  727. //}
  728. for _, item := range prescriptions {
  729. for _, subItem := range item.HisDoctorAdviceInfo {
  730. var order models.FsiOrderDtos
  731. order.RxID = strconv.FormatInt(item.ID, 10)
  732. order.Rxno = strconv.FormatInt(item.ID, 10)
  733. order.LongDrordFlag = "0"
  734. order.HilistType = "1"
  735. order.ChrgType = "1"
  736. order.DrordBhvr = "-"
  737. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  738. order.HosplistName = subItem.BaseDrugLib.DrugName
  739. order.HilistLv = "1"
  740. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  741. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  742. order.HosplistName = subItem.BaseDrugLib.DrugName
  743. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  744. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  745. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  746. order.OwnpayAmt = ""
  747. order.SelfpayAmt = ""
  748. order.Spec = ""
  749. order.SpecUnt = ""
  750. order.DrordBegnDate = s_tm
  751. order.DrordStopDate = ""
  752. order.DrordDrCodg = "1"
  753. order.DrordDeptName = department.Name
  754. order.DrordDrCodg = "1"
  755. order.DrordDrName = doctor_info.UserName
  756. order.DrordDrProfttl = ""
  757. order.CurrDrordFlag = "1"
  758. orders = append(orders, &order)
  759. }
  760. for _, subItem := range item.HisPrescriptionProject {
  761. if subItem.Type == 2 {
  762. var order models.FsiOrderDtos
  763. order.RxID = strconv.FormatInt(item.ID, 10)
  764. order.Rxno = strconv.FormatInt(item.ID, 10)
  765. order.LongDrordFlag = "0"
  766. order.HilistType = "1"
  767. order.ChrgType = "1"
  768. order.DrordBhvr = "-"
  769. order.HilistCode = subItem.HisProject.MedicalCode
  770. order.HosplistName = subItem.HisProject.ProjectName
  771. order.HilistLv = "1"
  772. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  773. order.HosplistCode = subItem.HisProject.MedicalCode
  774. order.HosplistName = subItem.HisProject.ProjectName
  775. order.Cnt = subItem.Count
  776. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  777. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  778. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  779. order.OwnpayAmt = ""
  780. order.SelfpayAmt = ""
  781. order.Spec = ""
  782. order.SpecUnt = ""
  783. order.DrordBegnDate = s_tm
  784. order.DrordStopDate = ""
  785. order.DrordDrCodg = "1"
  786. order.DrordDeptName = department.Name
  787. order.DrordDrCodg = "1"
  788. order.DrordDrName = doctor_info.UserName
  789. order.DrordDrProfttl = ""
  790. order.CurrDrordFlag = "1"
  791. orders = append(orders, &order)
  792. }
  793. if subItem.Type == 3 {
  794. var order models.FsiOrderDtos
  795. order.RxID = strconv.FormatInt(item.ID, 10)
  796. order.Rxno = strconv.FormatInt(item.ID, 10)
  797. order.LongDrordFlag = "0"
  798. order.HilistType = "1"
  799. order.ChrgType = "1"
  800. order.DrordBhvr = "-"
  801. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  802. order.HosplistName = subItem.GoodInfo.GoodName
  803. order.HilistLv = "1"
  804. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  805. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  806. order.HosplistName = subItem.GoodInfo.GoodName
  807. order.Cnt = subItem.Count
  808. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  809. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  810. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  811. order.OwnpayAmt = ""
  812. order.SelfpayAmt = ""
  813. order.Spec = ""
  814. order.SpecUnt = ""
  815. order.DrordBegnDate = s_tm
  816. order.DrordStopDate = ""
  817. order.DrordDrCodg = "1"
  818. order.DrordDeptName = department.Name
  819. order.DrordDrCodg = "1"
  820. order.DrordDrName = doctor_info.UserName
  821. order.DrordDrProfttl = ""
  822. order.CurrDrordFlag = "1"
  823. orders = append(orders, &order)
  824. }
  825. }
  826. }
  827. //处方医嘱信息
  828. fed.MatnStas = "0"
  829. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  830. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  831. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  832. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  833. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  834. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  835. fed.SetlTotlnum = "1"
  836. fed.Insutype = his.Insutype
  837. fed.ReimFlag = "0"
  838. fed.OutSetlFlag = "0"
  839. var fopd []*models.FsiOperationDtosData
  840. data := make(map[string]interface{})
  841. data["fed"] = fed
  842. data["fdd"] = fdds
  843. data["fod"] = orders
  844. data["pd"] = pd
  845. data["pp"] = pp
  846. data["fopd"] = fopd
  847. data["trig_scen"] = trig_scen
  848. client := &http.Client{}
  849. bytesData, _ := json.Marshal(data)
  850. var req *http.Request
  851. if miConfig.MdtrtareaAdmvs == "320921" {
  852. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  853. } else {
  854. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  855. }
  856. resp, _ := client.Do(req)
  857. defer resp.Body.Close()
  858. body, ioErr := ioutil.ReadAll(resp.Body)
  859. if ioErr != nil {
  860. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  862. return
  863. }
  864. var respJSON map[string]interface{}
  865. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  866. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  868. return
  869. }
  870. //手术操作集合
  871. //手术操作集合
  872. }
  873. func (c *HisApiController) Check() {
  874. psn_no := c.GetString("psn_no")
  875. in := c.GetString("in")
  876. mt := c.GetString("mt")
  877. baseParams := models.BaseParams{
  878. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  879. FixmedinsCode: "H15049901371",
  880. InsuplcAdmdvs: "150499",
  881. MdtrtareaAdmvs: "150499",
  882. OrgName: "赤峰费森血液透析中心",
  883. Doctor: "1111",
  884. }
  885. service.Gdyb2001(baseParams, psn_no, in, mt)
  886. }
  887. func (c *HisApiController) GetPsnNcdsInfo() {
  888. admin_user_id, _ := c.GetInt64("admin_user_id")
  889. patient_id, _ := c.GetInt64("patient_id")
  890. id, _ := c.GetInt64("id")
  891. adminUser := c.GetAdminUserInfo()
  892. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  893. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  894. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  895. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  896. psn_record, _ := service.GetPsnNCDSRecordById(id)
  897. //
  898. //if psn_record.ID == 0 {
  899. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  900. // return
  901. //}
  902. var res Result5301
  903. var res10265 Result5301For10265
  904. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  905. psn_info, _ := service.GetPsnByPatientId(patient_id)
  906. var api string
  907. if miConfig.MdtrtareaAdmvs == "320921" {
  908. 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 +
  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. } else {
  911. 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 +
  912. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  913. }
  914. resp, requestErr := http.Get(api)
  915. if requestErr != nil {
  916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  917. return
  918. }
  919. body, ioErr := ioutil.ReadAll(resp.Body)
  920. if ioErr != nil {
  921. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  923. return
  924. }
  925. var respJSON map[string]interface{}
  926. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  927. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  929. return
  930. }
  931. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  932. result, _ := json.Marshal(respJSON)
  933. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  934. utils.ErrorLog("解析失败:%v", err)
  935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  936. return
  937. }
  938. res.ErrMsg = res10265.ErrMsg
  939. res.Output = res10265.Output
  940. res.InfRefmsgid = res10265.InfRefmsgid
  941. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  942. res.Infcode = infocode
  943. } else {
  944. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  945. var dat map[string]interface{}
  946. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  947. fmt.Println(dat)
  948. } else {
  949. fmt.Println(err)
  950. }
  951. userJSONBytes, _ := json.Marshal(dat)
  952. if miConfig.Code == "H15049901371" {
  953. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  954. utils.ErrorLog("解析失败:%v", err)
  955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  956. return
  957. }
  958. res.InfRefmsgid = res10265.InfRefmsgid
  959. res.Output = res10265.Output
  960. res.ErrMsg = res10265.ErrMsg
  961. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  962. res.Infcode = infocode
  963. } else {
  964. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  965. utils.ErrorLog("解析失败:%v", err)
  966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  967. return
  968. }
  969. }
  970. }
  971. if res.Infcode == 0 {
  972. c.ServeSuccessJSON(map[string]interface{}{
  973. "result": res.Output.Result,
  974. })
  975. }
  976. }
  977. func (c *HisApiController) CheckInsutype() {
  978. his_patient_id, _ := c.GetInt64("his_patient_id")
  979. admin_user_id, _ := c.GetInt64("admin_user_id")
  980. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  981. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  982. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  983. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  984. var dat map[string]interface{}
  985. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  986. fmt.Println(dat)
  987. } else {
  988. fmt.Println(err)
  989. }
  990. userJSONBytes, _ := json.Marshal(dat)
  991. var res Result90100
  992. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  993. utils.ErrorLog("解析失败:%v", err)
  994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  995. return
  996. }
  997. if res.Infcode != 0 {
  998. c.ServeSuccessJSON(map[string]interface{}{
  999. "failed_code": -10,
  1000. "msg": res.ErrMsg,
  1001. })
  1002. return
  1003. } else {
  1004. fmt.Println(res)
  1005. }
  1006. }
  1007. func (c *HisApiController) CheckCardPWD() {
  1008. card_pwd := c.GetString("card_pwd")
  1009. his_patient_id, _ := c.GetInt64("his_patient_id")
  1010. admin_user_id, _ := c.GetInt64("admin_user_id")
  1011. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1012. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1013. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1014. psn, _ := service.GetPsnByPatientId(his.PatientId)
  1015. bas := strings.Split(psn.CardInfo, "|")
  1016. basNumber := bas[2]
  1017. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  1018. var dat map[string]interface{}
  1019. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1020. fmt.Println(dat)
  1021. } else {
  1022. fmt.Println(err)
  1023. }
  1024. userJSONBytes, _ := json.Marshal(dat)
  1025. var res Result90991
  1026. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1027. utils.ErrorLog("解析失败:%v", err)
  1028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1029. return
  1030. }
  1031. if res.Infcode != 0 {
  1032. c.ServeSuccessJSON(map[string]interface{}{
  1033. "failed_code": -10,
  1034. "msg": res.ErrMsg,
  1035. })
  1036. return
  1037. } else {
  1038. if res.Output.Result.SscnoCheckStat == "0" {
  1039. var msg string
  1040. switch res.Output.Result.CardStat {
  1041. case "00":
  1042. msg = "未激活"
  1043. break
  1044. case "10":
  1045. msg = "激活"
  1046. break
  1047. case "20":
  1048. msg = "窗口挂失"
  1049. break
  1050. case "21":
  1051. msg = "电话挂失"
  1052. break
  1053. case "22":
  1054. msg = "单位网上申报挂失"
  1055. break
  1056. case "23":
  1057. msg = "保健办挂失"
  1058. break
  1059. case "24":
  1060. msg = "个人网上挂失"
  1061. break
  1062. case "25":
  1063. msg = "网上服务大厅挂失"
  1064. break
  1065. case "30":
  1066. msg = "注销"
  1067. break
  1068. case "40":
  1069. msg = "回收"
  1070. break
  1071. case "99":
  1072. msg = "制卡中(无效卡)"
  1073. break
  1074. }
  1075. c.ServeSuccessJSON(map[string]interface{}{
  1076. "failed_code": -10,
  1077. "msg": msg,
  1078. })
  1079. return
  1080. } else {
  1081. c.ServeSuccessJSON(map[string]interface{}{
  1082. "msg": "校验成功",
  1083. })
  1084. return
  1085. }
  1086. }
  1087. }
  1088. func (c *HisApiController) CheckCardPWDTwo() {
  1089. //card_pwd := c.GetString("card_pwd")
  1090. //his_patient_id, _ := c.GetInt64("his_patient_id")
  1091. admin_user_id, _ := c.GetInt64("admin_user_id")
  1092. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1093. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1094. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  1095. var dat map[string]interface{}
  1096. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1097. fmt.Println(dat)
  1098. } else {
  1099. fmt.Println(err)
  1100. }
  1101. userJSONBytes, _ := json.Marshal(dat)
  1102. var res Result90991
  1103. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1104. utils.ErrorLog("解析失败:%v", err)
  1105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1106. return
  1107. }
  1108. if res.Infcode != 0 {
  1109. c.ServeSuccessJSON(map[string]interface{}{
  1110. "failed_code": -10,
  1111. "msg": res.ErrMsg,
  1112. })
  1113. return
  1114. } else {
  1115. if res.Output.Result.SscnoCheckStat == "0" {
  1116. var msg string
  1117. switch res.Output.Result.CardStat {
  1118. case "00":
  1119. msg = "未激活"
  1120. break
  1121. case "10":
  1122. msg = "激活"
  1123. break
  1124. case "20":
  1125. msg = "窗口挂失"
  1126. break
  1127. case "21":
  1128. msg = "电话挂失"
  1129. break
  1130. case "22":
  1131. msg = "单位网上申报挂失"
  1132. break
  1133. case "23":
  1134. msg = "保健办挂失"
  1135. break
  1136. case "24":
  1137. msg = "个人网上挂失"
  1138. break
  1139. case "25":
  1140. msg = "网上服务大厅挂失"
  1141. break
  1142. case "30":
  1143. msg = "注销"
  1144. break
  1145. case "40":
  1146. msg = "回收"
  1147. break
  1148. case "99":
  1149. msg = "制卡中(无效卡)"
  1150. break
  1151. }
  1152. c.ServeSuccessJSON(map[string]interface{}{
  1153. "failed_code": -10,
  1154. "msg": msg,
  1155. })
  1156. return
  1157. } else {
  1158. c.ServeSuccessJSON(map[string]interface{}{
  1159. "msg": "校验成功",
  1160. })
  1161. return
  1162. }
  1163. }
  1164. }
  1165. //func (c *HisApiController) ReadCard() {
  1166. // id_card_type, _ := c.GetInt64("id_card_type")
  1167. // admin_user_id, _ := c.GetInt64("admin_user_id")
  1168. // certificates, _ := c.GetInt64("certificates")
  1169. // fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  1170. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1171. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1172. //
  1173. // switch id_card_type {
  1174. // case 1:
  1175. // if miConfig.MdtrtareaAdmvs == "421300" {
  1176. // var res ResultTwo
  1177. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  1178. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  1179. // "&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)
  1180. //
  1181. // resp, requestErr := http.Get(api)
  1182. // if requestErr != nil {
  1183. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1184. // return
  1185. // }
  1186. //
  1187. // body, ioErr := ioutil.ReadAll(resp.Body)
  1188. // if ioErr != nil {
  1189. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1190. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1191. // return
  1192. // }
  1193. // var respJSON map[string]interface{}
  1194. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1195. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1196. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1197. // return
  1198. // }
  1199. //
  1200. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1201. // result, _ := json.Marshal(respJSON)
  1202. // fmt.Println("log")
  1203. // fmt.Println(string(result))
  1204. //
  1205. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  1206. // utils.ErrorLog("解析失败:%v", err)
  1207. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1208. // return
  1209. // }
  1210. //
  1211. // if res.Infcode == 0 {
  1212. // patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1213. // if err == gorm.ErrRecordNotFound {
  1214. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1215. // return
  1216. // } else if err != nil {
  1217. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1218. // return
  1219. //
  1220. // } else {
  1221. //
  1222. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1223. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1224. // infoStr := string(Iinfos)
  1225. // idetinfoStr := string(Idetinfos)
  1226. // psn := &models.HisPsn{
  1227. // PsnNo: res.Output.Baseinfo.PsnNo,
  1228. // Age: res.Output.Baseinfo.Age,
  1229. // PatientId: patient.ID,
  1230. // Certno: res.Output.Baseinfo.Certno,
  1231. // Brdy: res.Output.Baseinfo.Brdy,
  1232. // Gend: res.Output.Baseinfo.Gend,
  1233. // Naty: res.Output.Baseinfo.Naty,
  1234. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  1235. // PsnName: res.Output.Baseinfo.PsnName,
  1236. // Idetinfo: idetinfoStr,
  1237. // Insuinfo: infoStr,
  1238. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1239. // }
  1240. // service.CreateHisPsn(psn)
  1241. //
  1242. // c.ServeSuccessJSON(map[string]interface{}{
  1243. // "patient": patient,
  1244. // "number": res.Output.Baseinfo.Certno,
  1245. // })
  1246. // }
  1247. // } else {
  1248. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1249. // return
  1250. // }
  1251. //
  1252. // } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1253. // var api string
  1254. // if miConfig.MdtrtareaAdmvs == "320921" {
  1255. // 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 +
  1256. // "&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
  1257. // fmt.Println(api)
  1258. // } else {
  1259. // 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 +
  1260. // "&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)
  1261. // }
  1262. //
  1263. // resp, requestErr := http.Get(api)
  1264. // if requestErr != nil {
  1265. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1266. // return
  1267. // }
  1268. //
  1269. // body, ioErr := ioutil.ReadAll(resp.Body)
  1270. // if ioErr != nil {
  1271. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1272. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1273. // return
  1274. // }
  1275. // var respJSON map[string]interface{}
  1276. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1277. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1278. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1279. // return
  1280. // }
  1281. // var status string
  1282. // status = respJSON["data"].(map[string]interface{})["status"].(string)
  1283. // card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1284. // //console.log()
  1285. // fmt.Println("type===")
  1286. //
  1287. // fmt.Println(card_type)
  1288. //
  1289. // var token string
  1290. // var res ResultTwo //1101结果
  1291. // var res10265 ResultTwo10265 //1101结果
  1292. // var card_info string //卡信息
  1293. // var busi_card_info string
  1294. //
  1295. // card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1296. // busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1297. //
  1298. // if status == "0" { //读卡成功
  1299. // if card_type == "1" {
  1300. //
  1301. // respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1302. // result, _ := json.Marshal(respJSON)
  1303. //
  1304. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1305. // utils.ErrorLog("解析失败:%v", err)
  1306. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1307. // return
  1308. // }
  1309. // res.ErrMsg = res10265.ErrMsg
  1310. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1311. // res.Infcode = infocode
  1312. // res.Output = res10265.Output
  1313. // res.InfRefmsgid = res10265.InfRefmsgid
  1314. //
  1315. // } else {
  1316. // //var card_info string //卡信息
  1317. // //var busi_card_info string
  1318. //
  1319. // token = respJSON["data"].(map[string]interface{})["token"].(string)
  1320. // //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1321. //
  1322. // //fmt.Println(card_info)
  1323. // //fmt.Println(busi_card_info)
  1324. //
  1325. // respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1326. // result, _ := json.Marshal(respJSON)
  1327. //
  1328. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1329. // utils.ErrorLog("解析失败:%v", err)
  1330. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1331. // return
  1332. // }
  1333. // res.ErrMsg = res10265.ErrMsg
  1334. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1335. // res.Infcode = infocode
  1336. // res.Output = res10265.Output
  1337. // res.InfRefmsgid = res10265.InfRefmsgid
  1338. //
  1339. // }
  1340. //
  1341. // if res.Infcode == 0 {
  1342. // patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1343. // if err == gorm.ErrRecordNotFound {
  1344. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1345. // return
  1346. // } else if err != nil {
  1347. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1348. // return
  1349. //
  1350. // } else {
  1351. //
  1352. // if card_type == "1" {
  1353. // bas := strings.Split(card_info, "|")
  1354. // basNumber := bas[2]
  1355. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1356. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1357. // infoStr := string(Iinfos)
  1358. // idetinfoStr := string(Idetinfos)
  1359. // psn := &models.HisPsn{
  1360. // PsnNo: res.Output.Baseinfo.PsnNo,
  1361. // Age: res.Output.Baseinfo.Age,
  1362. // PatientId: patient.ID,
  1363. // Certno: res.Output.Baseinfo.Certno,
  1364. // Brdy: res.Output.Baseinfo.Brdy,
  1365. // Gend: res.Output.Baseinfo.Gend,
  1366. // Naty: res.Output.Baseinfo.Naty,
  1367. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  1368. // PsnName: res.Output.Baseinfo.PsnName,
  1369. // Idetinfo: idetinfoStr,
  1370. // Insuinfo: infoStr,
  1371. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1372. // CardInfo: card_info,
  1373. // VerifyNumber: busi_card_info,
  1374. // }
  1375. // service.CreateHisPsn(psn)
  1376. //
  1377. // var rf []*ResultFive
  1378. // json.Unmarshal([]byte(infoStr), &rf)
  1379. //
  1380. // var insutypes []*ResultFive
  1381. // var insutype string
  1382. // var is390 int = 0
  1383. // var is310 int = 0
  1384. //
  1385. // for _, item := range rf {
  1386. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1387. // insutypes = append(insutypes, item)
  1388. // }
  1389. // }
  1390. //
  1391. // if len(insutypes) == 1 {
  1392. // insutype = insutypes[0].Insutype
  1393. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1394. // } else {
  1395. // for _, i := range insutypes {
  1396. // if i.Insutype == "390" {
  1397. // is390 = 1
  1398. // }
  1399. //
  1400. // if i.Insutype == "310" {
  1401. // is310 = 1
  1402. // }
  1403. // }
  1404. // }
  1405. // if is390 == 1 {
  1406. // insutype = "390"
  1407. // }
  1408. //
  1409. // if is310 == 1 {
  1410. // insutype = "310"
  1411. // }
  1412. //
  1413. // if len(insutypes) == 0 {
  1414. // insutype = "310"
  1415. // }
  1416. //
  1417. // c.ServeSuccessJSON(map[string]interface{}{
  1418. // "patient": patient,
  1419. // "number": basNumber,
  1420. // "insutype": insutype,
  1421. // })
  1422. // } else {
  1423. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1424. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1425. // infoStr := string(Iinfos)
  1426. // idetinfoStr := string(Idetinfos)
  1427. // psn := &models.HisPsn{
  1428. // PsnNo: res.Output.Baseinfo.PsnNo,
  1429. // Age: res.Output.Baseinfo.Age,
  1430. // PatientId: patient.ID,
  1431. // Certno: res.Output.Baseinfo.Certno,
  1432. // Brdy: res.Output.Baseinfo.Brdy,
  1433. // Gend: res.Output.Baseinfo.Gend,
  1434. // Naty: res.Output.Baseinfo.Naty,
  1435. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  1436. // PsnName: res.Output.Baseinfo.PsnName,
  1437. // Idetinfo: idetinfoStr,
  1438. // Insuinfo: infoStr,
  1439. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1440. // CardInfo: card_info,
  1441. // VerifyNumber: token,
  1442. // }
  1443. // service.CreateHisPsn(psn)
  1444. // c.ServeSuccessJSON(map[string]interface{}{
  1445. // "patient": patient,
  1446. // "number": token,
  1447. // })
  1448. // }
  1449. // }
  1450. // } else {
  1451. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1452. // return
  1453. // }
  1454. // } else { //读卡失败
  1455. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1456. // return
  1457. //
  1458. // }
  1459. //
  1460. // } else {
  1461. // if initFlag == 0 {
  1462. // c.TestGetBasBaseInit()
  1463. // }
  1464. // basStr := c.GetBasBaseInfo()
  1465. // if len(basStr) == 0 {
  1466. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1467. // return
  1468. // }
  1469. // fmt.Println(basStr)
  1470. // bas := strings.Split(basStr, "|")
  1471. // basNumber := bas[1]
  1472. // fmt.Println(basNumber)
  1473. // card_sn := bas[3]
  1474. // fmt.Println(card_sn)
  1475. // result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1476. // var dat map[string]interface{}
  1477. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1478. // fmt.Println(dat)
  1479. // } else {
  1480. // fmt.Println(err)
  1481. // }
  1482. //
  1483. // userJSONBytes, _ := json.Marshal(dat)
  1484. // var res ResultTwo
  1485. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1486. // utils.ErrorLog("解析失败:%v", err)
  1487. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1488. // return
  1489. // }
  1490. //
  1491. // if res.Infcode == 0 {
  1492. // patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1493. // if err == gorm.ErrRecordNotFound {
  1494. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1495. // return
  1496. // } else if err != nil {
  1497. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1498. // return
  1499. //
  1500. // } else {
  1501. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1502. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1503. // infoStr := string(Iinfos)
  1504. // idetinfoStr := string(Idetinfos)
  1505. // psn := &models.HisPsn{
  1506. // PsnNo: res.Output.Baseinfo.PsnNo,
  1507. // Age: res.Output.Baseinfo.Age,
  1508. // PatientId: patient.ID,
  1509. // Certno: res.Output.Baseinfo.Certno,
  1510. // Brdy: res.Output.Baseinfo.Brdy,
  1511. // Gend: res.Output.Baseinfo.Gend,
  1512. // Naty: res.Output.Baseinfo.Naty,
  1513. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  1514. // PsnName: res.Output.Baseinfo.PsnName,
  1515. // Idetinfo: idetinfoStr,
  1516. // Insuinfo: infoStr,
  1517. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1518. // CardInfo: basStr,
  1519. // VerifyNumber: "",
  1520. // }
  1521. // service.CreateHisPsn(psn)
  1522. //
  1523. // c.ServeSuccessJSON(map[string]interface{}{
  1524. // "patient": patient,
  1525. // "number": basNumber,
  1526. // })
  1527. // }
  1528. // } else {
  1529. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1530. // return
  1531. // }
  1532. // break
  1533. // }
  1534. // case 2:
  1535. // SFZStr := c.GetSFZBaseInfo()
  1536. // id_card_str := strings.Split(SFZStr, "^")
  1537. // id_card_number := id_card_str[0]
  1538. // card_sn := ""
  1539. // result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1540. // var dat map[string]interface{}
  1541. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1542. // fmt.Println(dat)
  1543. // } else {
  1544. // fmt.Println(err)
  1545. // }
  1546. //
  1547. // userJSONBytes, _ := json.Marshal(dat)
  1548. // var res ResultTwo
  1549. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1550. // utils.ErrorLog("解析失败:%v", err)
  1551. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1552. // return
  1553. // }
  1554. //
  1555. // if res.Infcode == 0 {
  1556. // patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1557. // if err == gorm.ErrRecordNotFound {
  1558. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1559. // return
  1560. // } else if err != nil {
  1561. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1562. // return
  1563. //
  1564. // } else {
  1565. // c.ServeSuccessJSON(map[string]interface{}{
  1566. // "patient": patient,
  1567. // "number": id_card_number,
  1568. // })
  1569. // }
  1570. // } else {
  1571. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1572. // return
  1573. // }
  1574. //
  1575. // break
  1576. // case 3:
  1577. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1578. // var api string
  1579. // if miConfig.MdtrtareaAdmvs == "320921" {
  1580. // 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 +
  1581. // "&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
  1582. // fmt.Println(api)
  1583. //
  1584. // } else {
  1585. // 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 +
  1586. // "&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)
  1587. // }
  1588. //
  1589. // resp, requestErr := http.Get(api)
  1590. // if requestErr != nil {
  1591. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1592. // return
  1593. // }
  1594. //
  1595. // body, ioErr := ioutil.ReadAll(resp.Body)
  1596. // if ioErr != nil {
  1597. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1598. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1599. // return
  1600. // }
  1601. // var respJSON map[string]interface{}
  1602. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1603. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1604. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1605. // return
  1606. // }
  1607. // var status string
  1608. // status = respJSON["data"].(map[string]interface{})["status"].(string)
  1609. // card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1610. //
  1611. // var token string
  1612. // var res ResultTwo //1101结果
  1613. // var res10265 ResultTwo10265 //1101结果
  1614. // var card_info string //卡信息
  1615. // var busi_card_info string
  1616. //
  1617. // //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1618. // busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1619. //
  1620. // if status == "0" { //读卡成功
  1621. // if card_type == "1" {
  1622. //
  1623. // respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1624. // result, _ := json.Marshal(respJSON)
  1625. //
  1626. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1627. // utils.ErrorLog("解析失败:%v", err)
  1628. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1629. // return
  1630. // }
  1631. // res.ErrMsg = res10265.ErrMsg
  1632. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1633. // res.Infcode = infocode
  1634. // res.Output = res10265.Output
  1635. // res.InfRefmsgid = res10265.InfRefmsgid
  1636. //
  1637. // } else {
  1638. // //var card_info string //卡信息
  1639. // //var busi_card_info string
  1640. //
  1641. // token = respJSON["data"].(map[string]interface{})["token"].(string)
  1642. // //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1643. //
  1644. // //fmt.Println(card_info)
  1645. // //fmt.Println(busi_card_info)
  1646. //
  1647. // respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1648. // result, _ := json.Marshal(respJSON)
  1649. //
  1650. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1651. // utils.ErrorLog("解析失败:%v", err)
  1652. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1653. // return
  1654. // }
  1655. // res.ErrMsg = res10265.ErrMsg
  1656. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1657. // res.Infcode = infocode
  1658. // res.Output = res10265.Output
  1659. // res.InfRefmsgid = res10265.InfRefmsgid
  1660. //
  1661. // }
  1662. //
  1663. // if res.Infcode == 0 {
  1664. // patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1665. // if err == gorm.ErrRecordNotFound {
  1666. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1667. // return
  1668. // } else if err != nil {
  1669. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1670. // return
  1671. //
  1672. // } else {
  1673. //
  1674. // if card_type == "1" {
  1675. // bas := strings.Split(card_info, "|")
  1676. // basNumber := bas[2]
  1677. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1678. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1679. // infoStr := string(Iinfos)
  1680. // idetinfoStr := string(Idetinfos)
  1681. // psn := &models.HisPsn{
  1682. // PsnNo: res.Output.Baseinfo.PsnNo,
  1683. // Age: res.Output.Baseinfo.Age,
  1684. // PatientId: patient.ID,
  1685. // Certno: res.Output.Baseinfo.Certno,
  1686. // Brdy: res.Output.Baseinfo.Brdy,
  1687. // Gend: res.Output.Baseinfo.Gend,
  1688. // Naty: res.Output.Baseinfo.Naty,
  1689. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  1690. // PsnName: res.Output.Baseinfo.PsnName,
  1691. // Idetinfo: idetinfoStr,
  1692. // Insuinfo: infoStr,
  1693. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1694. // CardInfo: card_info,
  1695. // VerifyNumber: busi_card_info,
  1696. // }
  1697. //
  1698. // service.CreateHisPsn(psn)
  1699. // c.ServeSuccessJSON(map[string]interface{}{
  1700. // "patient": patient,
  1701. // "number": basNumber,
  1702. // })
  1703. // } else {
  1704. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1705. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1706. // infoStr := string(Iinfos)
  1707. // idetinfoStr := string(Idetinfos)
  1708. // psn := &models.HisPsn{
  1709. // PsnNo: res.Output.Baseinfo.PsnNo,
  1710. // Age: res.Output.Baseinfo.Age,
  1711. // PatientId: patient.ID,
  1712. // Certno: res.Output.Baseinfo.Certno,
  1713. // Brdy: res.Output.Baseinfo.Brdy,
  1714. // Gend: res.Output.Baseinfo.Gend,
  1715. // Naty: res.Output.Baseinfo.Naty,
  1716. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  1717. // PsnName: res.Output.Baseinfo.PsnName,
  1718. // Idetinfo: idetinfoStr,
  1719. // Insuinfo: infoStr,
  1720. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1721. // CardInfo: card_info,
  1722. // VerifyNumber: token,
  1723. // }
  1724. // service.CreateHisPsn(psn)
  1725. // var rf []*ResultFive
  1726. // json.Unmarshal([]byte(infoStr), &rf)
  1727. // var insutypes []*ResultFive
  1728. // var insutype string
  1729. // var is390 int = 0
  1730. // var is310 int = 0
  1731. //
  1732. // for _, item := range rf {
  1733. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1734. // insutypes = append(insutypes, item)
  1735. // }
  1736. // }
  1737. //
  1738. // if len(insutypes) == 1 {
  1739. // insutype = insutypes[0].Insutype
  1740. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1741. // } else {
  1742. // for _, i := range insutypes {
  1743. // if i.Insutype == "390" {
  1744. // is390 = 1
  1745. // }
  1746. //
  1747. // if i.Insutype == "310" {
  1748. // is310 = 1
  1749. // }
  1750. // }
  1751. // }
  1752. //
  1753. // if is390 == 1 {
  1754. // insutype = "390"
  1755. // }
  1756. //
  1757. // if is310 == 1 {
  1758. // insutype = "310"
  1759. // }
  1760. //
  1761. // if len(insutypes) == 0 {
  1762. // insutype = "310"
  1763. // }
  1764. // c.ServeSuccessJSON(map[string]interface{}{
  1765. // "patient": patient,
  1766. // "number": token,
  1767. // "insutype": insutype,
  1768. // })
  1769. // }
  1770. // }
  1771. // } else {
  1772. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1773. // return
  1774. // }
  1775. // } else { //读卡失败
  1776. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1777. // return
  1778. //
  1779. // }
  1780. //
  1781. // }
  1782. //
  1783. // break
  1784. // case 4:
  1785. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1786. // var api string
  1787. // if miConfig.MdtrtareaAdmvs == "320921" {
  1788. // 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 +
  1789. // "&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
  1790. // fmt.Println(api)
  1791. //
  1792. // } else {
  1793. // 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 +
  1794. // "&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)
  1795. // }
  1796. //
  1797. // resp, requestErr := http.Get(api)
  1798. // if requestErr != nil {
  1799. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1800. // return
  1801. // }
  1802. //
  1803. // body, ioErr := ioutil.ReadAll(resp.Body)
  1804. // if ioErr != nil {
  1805. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1806. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1807. // return
  1808. // }
  1809. // var respJSON map[string]interface{}
  1810. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1811. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1812. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1813. // return
  1814. // }
  1815. // var status string
  1816. // status = respJSON["data"].(map[string]interface{})["status"].(string)
  1817. // //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1818. //
  1819. // var token string
  1820. // var res ResultTwo //1101结果
  1821. // var res10265 ResultTwo10265 //1101结果
  1822. //
  1823. // if status == "0" { //读卡成功
  1824. // var card_info string //卡信息
  1825. // var busi_card_info string
  1826. //
  1827. // token = respJSON["data"].(map[string]interface{})["token"].(string)
  1828. // busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1829. // card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1830. //
  1831. // fmt.Println(card_info)
  1832. // fmt.Println(busi_card_info)
  1833. //
  1834. // respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1835. // result, _ := json.Marshal(respJSON)
  1836. //
  1837. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1838. // utils.ErrorLog("解析失败:%v", err)
  1839. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1840. // return
  1841. // }
  1842. // res.ErrMsg = res10265.ErrMsg
  1843. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1844. // res.Infcode = infocode
  1845. // res.Output = res10265.Output
  1846. // res.InfRefmsgid = res10265.InfRefmsgid
  1847. //
  1848. // if res.Infcode == 0 {
  1849. // patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1850. // if err == gorm.ErrRecordNotFound {
  1851. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1852. // return
  1853. // } else if err != nil {
  1854. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1855. // return
  1856. //
  1857. // } else {
  1858. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1859. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1860. // infoStr := string(Iinfos)
  1861. // idetinfoStr := string(Idetinfos)
  1862. // psn := &models.HisPsn{
  1863. // PsnNo: res.Output.Baseinfo.PsnNo,
  1864. // Age: res.Output.Baseinfo.Age,
  1865. // PatientId: patient.ID,
  1866. // Certno: res.Output.Baseinfo.Certno,
  1867. // Brdy: res.Output.Baseinfo.Brdy,
  1868. // Gend: res.Output.Baseinfo.Gend,
  1869. // Naty: res.Output.Baseinfo.Naty,
  1870. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  1871. // PsnName: res.Output.Baseinfo.PsnName,
  1872. // Idetinfo: idetinfoStr,
  1873. // Insuinfo: infoStr,
  1874. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1875. // CardInfo: card_info,
  1876. // VerifyNumber: token,
  1877. // }
  1878. // service.CreateHisPsn(psn)
  1879. // c.ServeSuccessJSON(map[string]interface{}{
  1880. // "patient": patient,
  1881. // "number": token,
  1882. // })
  1883. // }
  1884. // } else {
  1885. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1886. // return
  1887. // }
  1888. // } else { //读卡失败
  1889. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1890. // return
  1891. // }
  1892. // }
  1893. // break
  1894. // }
  1895. //}
  1896. var initFlag int64 = 0
  1897. //func (c *HisApiController) TestGetBasBaseInit() {
  1898. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  1899. // Iinit := DllDef.MustFindProc("Init")
  1900. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1901. //
  1902. // ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  1903. // if ret != 0 {
  1904. // fmt.Println("SSCard的报错原因:", err)
  1905. // fmt.Println("SSCard的运算结果为:", ret)
  1906. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1907. // return
  1908. // }
  1909. //
  1910. // result := int(ret)
  1911. // fmt.Println("SSCard的运算结果为1:", result)
  1912. // initFlag = 1
  1913. // return
  1914. //}
  1915. //func (c *HisApiController) GetSFZBaseInfo() string {
  1916. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  1917. // readCard := DllDef.MustFindProc("ReadSFZ")
  1918. // if readCard == nil {
  1919. // fmt.Println("readcard is nil")
  1920. // readCard = DllDef.MustFindProc("ReadSFZ")
  1921. // }
  1922. //
  1923. // str := make([]byte, 256)
  1924. // str1 := make([]byte, 256)
  1925. // r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1926. //
  1927. // fmt.Println(r)
  1928. // return string(str)
  1929. //}
  1930. //func (c *HisApiController) GetBasBaseInfo() string {
  1931. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  1932. // readCard := DllDef.MustFindProc("ReadCardBas")
  1933. // if readCard == nil {
  1934. // fmt.Println("readcard is nil")
  1935. // readCard = DllDef.MustFindProc("ReadCardBas")
  1936. // }
  1937. // str := make([]byte, 1024)
  1938. // str1 := make([]byte, 1024)
  1939. // ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  1940. // fmt.Println(string(str1))
  1941. // fmt.Println(string(str))
  1942. // fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1943. // fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1944. // if ret2 != 0 {
  1945. // return ""
  1946. // }
  1947. // return string(str)
  1948. //}
  1949. type CustomFundPay struct {
  1950. FundPayType string `json:"fund_pay_type"`
  1951. FundPayamt float64 `json:"fund_payamt"`
  1952. }
  1953. func (c *HisApiController) GetSettleList() {
  1954. order_id, _ := c.GetInt64("order_id")
  1955. admin_user_id, _ := c.GetInt64("admin_user_id")
  1956. order, _ := service.GetHisOrderByIDTwo(order_id)
  1957. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1958. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1959. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1960. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1961. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1962. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1963. if order.ID == 0 {
  1964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1965. return
  1966. }
  1967. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1968. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1969. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1970. fmt.Println(count)
  1971. var zero string
  1972. number := count + 1
  1973. if number >= 1000 {
  1974. zero = "0000" + strconv.FormatInt(number, 10)
  1975. } else if number >= 10000 {
  1976. zero = "000" + strconv.FormatInt(number, 10)
  1977. } else if number >= 100000 {
  1978. zero = "00" + strconv.FormatInt(number, 10)
  1979. } else if number >= 1000000 {
  1980. zero = "0" + strconv.FormatInt(number, 10)
  1981. } else {
  1982. zero = strconv.FormatInt(number, 10)
  1983. }
  1984. fmt.Println(zero)
  1985. struct4101 := service.Struct4101{
  1986. PsnNo: order.PsnNo,
  1987. MdtrtId: order.MdtrtId,
  1988. SetlId: order.SetlId,
  1989. PsnName: order.PsnName,
  1990. Gend: order.Gend,
  1991. Brdy: his.Brdy,
  1992. Age: his.Age,
  1993. Naty: order.Naty,
  1994. PatnCertType: "01",
  1995. Certno: order.Certno,
  1996. Prfs: "90",
  1997. ConerName: roles[0].UserName,
  1998. PatnRlts: "99",
  1999. ConerAddr: miConfig.OrgName,
  2000. ConerTel: admin.Mobile,
  2001. HiType: order.Insutype,
  2002. Insuplc: miConfig.InsuplcAdmdvs,
  2003. MaindiagFlag: "1",
  2004. BillCode: last_order.FaPiaoCode,
  2005. BillNo: zero,
  2006. BizSn: order.Number,
  2007. PsnSelfPay: order.PsnPartAmt,
  2008. PsnOwnPay: order.PsnPartAmt,
  2009. AcctPay: order.AcctPay,
  2010. PsnCashpay: order.PsnCashPay,
  2011. HiPaymtd: "1",
  2012. Hsorg: miConfig.InsuplcAdmdvs,
  2013. HsorgOpter: miConfig.InsuplcAdmdvs,
  2014. MedinsFillPsn: curRoles.UserName,
  2015. MedinsFillDept: depart.Name,
  2016. IptMedType: "2",
  2017. }
  2018. struct4101.SetlBegnDate = order.SetlTime
  2019. struct4101.SetlEndDate = order.SetlTime
  2020. time_arr := strings.Split(order.SetlTime, " ")
  2021. struct4101.AdmTime = time_arr[0]
  2022. struct4101.AdmEndTime = time_arr[0]
  2023. var rf []CustomFundPay
  2024. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2025. var tempFunPays []service.CustomStruct
  2026. for _, item := range rf {
  2027. var tempFunPay service.CustomStruct
  2028. // v1, _ := strconv.ParseFloat(item.FundPayamt, 64)
  2029. tempFunPay.FundPayamt = item.FundPayamt
  2030. tempFunPay.FundPayType = item.FundPayType
  2031. tempFunPays = append(tempFunPays, tempFunPay)
  2032. }
  2033. struct4101.CustomStruct = tempFunPays
  2034. fmt.Println("111111111")
  2035. fmt.Println(tempFunPays)
  2036. fmt.Println(struct4101.CustomStruct)
  2037. var tempDiaginfos []service.DiaginfoStructTwo
  2038. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2039. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2040. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  2041. var config []*models.HisXtDiagnoseConfig
  2042. for _, item := range diagnosis_ids {
  2043. id, _ := strconv.ParseInt(item, 10, 64)
  2044. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2045. config = append(config, &diagnosisConfig)
  2046. }
  2047. for index, item := range config {
  2048. if index == 0 {
  2049. var tempDiaginfo service.DiaginfoStructTwo
  2050. tempDiaginfo.DiagCode = item.CountryCode
  2051. tempDiaginfo.DiagName = item.CountryContentName
  2052. tempDiaginfo.DiagType = "1"
  2053. tempDiaginfo.MaindiagFlag = "1"
  2054. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2055. } else {
  2056. var tempDiaginfo service.DiaginfoStructTwo
  2057. tempDiaginfo.DiagCode = item.CountryCode
  2058. tempDiaginfo.DiagName = item.CountryContentName
  2059. tempDiaginfo.DiagType = "2"
  2060. tempDiaginfo.MaindiagFlag = "0"
  2061. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2062. }
  2063. }
  2064. struct4101.Diseinfo = tempDiaginfos
  2065. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2066. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2067. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2068. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  2069. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  2070. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2071. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2072. var iteminfo service.IteminfoStruct
  2073. var bedCostTotal float64 = 0 //床位总费
  2074. var bedCostSelfTotal float64 = 0 //床位自费
  2075. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2076. var operationCostTotal float64 = 0 //手术费
  2077. var operationCostSelfTotal float64 = 0 //手术费
  2078. var operationCostPartSelfTotal float64 = 0 //手术费
  2079. var otherCostTotal float64 = 0 //其他费用
  2080. var otherCostSelfTotal float64 = 0 //其他费用
  2081. var otherCostPartSelfTotal float64 = 0 //其他费用
  2082. var materialCostTotal float64 = 0 //材料费
  2083. var materialCostSelfTotal float64 = 0 //材料费
  2084. var materialCostPartSelfTotal float64 = 0 //材料费
  2085. var westernMedicineCostTotal float64 = 0 //西药费
  2086. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2087. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2088. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2089. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2090. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2091. var checkCostTotal float64 = 0 //检查费
  2092. var checkCostSelfTotal float64 = 0 //检查费
  2093. var checkCostPartSelfTotal float64 = 0 //检查费
  2094. var laboratoryCostTotal float64 = 0 //化验费
  2095. var laboratoryCostSelfTotal float64 = 0 //化验费
  2096. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2097. var treatCostTotal float64 = 0 //治疗费用
  2098. var treatCostSelfTotal float64 = 0 //治疗费用
  2099. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2100. decimal.DivisionPrecision = 2
  2101. var bed_fulamt_ownpay_amt float64 = 0
  2102. var operation_fulamt_ownpay_amt float64 = 0
  2103. var other_fulamt_ownpay_amt float64 = 0
  2104. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2105. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2106. var check_fulamt_ownpay_amt float64 = 0
  2107. var material_fulamt_ownpay_amt float64 = 0
  2108. var laboratory_fulamt_ownpay_amt float64 = 0
  2109. var treat_fulamt_ownpay_amt float64 = 0
  2110. var bed_claa_sunmfee float64 = 0
  2111. var bed_clab_amt float64 = 0
  2112. var bed_other_amt float64 = 0
  2113. var operation_claa_sunmfee float64 = 0
  2114. var operation_clab_amt float64 = 0
  2115. var operation_other_amt float64 = 0
  2116. var other_claa_sunmfee float64 = 0
  2117. var other_clab_amt float64 = 0
  2118. var other_other_amt float64 = 0
  2119. var westernMedicine_claa_sunmfee float64 = 0
  2120. var westernMedicine_clab_amt float64 = 0
  2121. var westernMedicine_other_amt float64 = 0
  2122. var chineseTraditional_claa_sunmfee float64 = 0
  2123. var chineseTraditional_clab_amt float64 = 0
  2124. var chineseTraditional_other_amt float64 = 0
  2125. var check_claa_sunmfee float64 = 0
  2126. var check_clab_amt float64 = 0
  2127. var check_other_amt float64 = 0
  2128. var material_claa_sunmfee float64 = 0
  2129. var material_clab_amt float64 = 0
  2130. var material_other_amt float64 = 0
  2131. var laboratory_claa_sunmfee float64 = 0
  2132. var laboratory_clab_amt float64 = 0
  2133. var laboratory_other_amt float64 = 0
  2134. var treat_claa_sunmfee float64 = 0
  2135. var treat_clab_amt float64 = 0
  2136. var treat_other_amt float64 = 0
  2137. for _, item := range order.HisOrderInfo {
  2138. if item.MedChrgitmType == "01" { //床位费
  2139. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2140. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2141. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2142. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2143. if item.ChrgitmLv == "1" {
  2144. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2145. }
  2146. if item.ChrgitmLv == "2" {
  2147. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2148. }
  2149. if item.ChrgitmLv == "3" {
  2150. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2151. }
  2152. }
  2153. if item.MedChrgitmType == "03" { //检查费
  2154. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2155. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2156. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2157. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2158. if item.ChrgitmLv == "1" {
  2159. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2160. }
  2161. if item.ChrgitmLv == "2" {
  2162. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2163. }
  2164. if item.ChrgitmLv == "3" {
  2165. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2166. }
  2167. }
  2168. if item.MedChrgitmType == "04" { //化验费
  2169. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2170. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2171. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2172. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2173. if item.ChrgitmLv == "1" {
  2174. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2175. }
  2176. if item.ChrgitmLv == "2" {
  2177. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2178. }
  2179. if item.ChrgitmLv == "3" {
  2180. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2181. }
  2182. }
  2183. if item.MedChrgitmType == "05" { //治疗费
  2184. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2185. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2186. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2187. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2188. if item.ChrgitmLv == "1" {
  2189. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2190. }
  2191. if item.ChrgitmLv == "2" {
  2192. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2193. }
  2194. if item.ChrgitmLv == "3" {
  2195. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2196. }
  2197. }
  2198. if item.MedChrgitmType == "06" { //手术费
  2199. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2200. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2201. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2202. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2203. if item.ChrgitmLv == "1" {
  2204. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2205. }
  2206. if item.ChrgitmLv == "2" {
  2207. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2208. }
  2209. if item.ChrgitmLv == "3" {
  2210. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2211. }
  2212. }
  2213. if item.MedChrgitmType == "08" { //材料费
  2214. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2215. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2216. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2217. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2218. if item.ChrgitmLv == "1" {
  2219. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2220. }
  2221. if item.ChrgitmLv == "2" {
  2222. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2223. }
  2224. if item.ChrgitmLv == "3" {
  2225. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2226. }
  2227. }
  2228. if item.MedChrgitmType == "09" { //西药费
  2229. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2230. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2231. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2232. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2233. if item.ChrgitmLv == "1" {
  2234. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2235. }
  2236. if item.ChrgitmLv == "2" {
  2237. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2238. }
  2239. if item.ChrgitmLv == "3" {
  2240. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2241. }
  2242. }
  2243. if item.MedChrgitmType == "11" { //中成费
  2244. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2245. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2246. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2247. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2248. if item.ChrgitmLv == "1" {
  2249. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2250. }
  2251. if item.ChrgitmLv == "2" {
  2252. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2253. }
  2254. if item.ChrgitmLv == "3" {
  2255. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2256. }
  2257. }
  2258. if item.MedChrgitmType == "14" { //其他费
  2259. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2260. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2261. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2262. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2263. if item.ChrgitmLv == "1" {
  2264. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2265. }
  2266. if item.ChrgitmLv == "2" {
  2267. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2268. }
  2269. if item.ChrgitmLv == "3" {
  2270. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2271. }
  2272. }
  2273. }
  2274. var iteminfoStructs []service.IteminfoStruct
  2275. if bedCostTotal != 0 {
  2276. iteminfo.MedChrgitm = "01"
  2277. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2278. iteminfo.Amt = bedCostTotal
  2279. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2280. iteminfo.ClabAmt = bed_clab_amt
  2281. iteminfo.OthAmt = bed_other_amt
  2282. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2283. }
  2284. if checkCostTotal != 0 {
  2285. iteminfo.MedChrgitm = "03"
  2286. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2287. iteminfo.Amt = checkCostTotal
  2288. iteminfo.ClaaSumfee = check_claa_sunmfee
  2289. iteminfo.ClabAmt = check_clab_amt
  2290. iteminfo.OthAmt = check_other_amt
  2291. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2292. }
  2293. if laboratoryCostTotal != 0 {
  2294. iteminfo.MedChrgitm = "04"
  2295. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2296. iteminfo.Amt = laboratoryCostTotal
  2297. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2298. iteminfo.ClabAmt = laboratory_clab_amt
  2299. iteminfo.OthAmt = laboratory_other_amt
  2300. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2301. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2302. }
  2303. if treatCostTotal != 0 {
  2304. iteminfo.MedChrgitm = "05"
  2305. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2306. iteminfo.Amt = treatCostTotal
  2307. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2308. iteminfo.ClabAmt = treat_clab_amt
  2309. iteminfo.OthAmt = treat_other_amt
  2310. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2311. //(struct4101.IteminfoStruct, iteminfo)
  2312. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2313. }
  2314. if operationCostTotal != 0 {
  2315. iteminfo.MedChrgitm = "06"
  2316. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2317. iteminfo.Amt = operationCostTotal
  2318. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2319. iteminfo.ClabAmt = operation_clab_amt
  2320. iteminfo.OthAmt = operation_other_amt
  2321. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2322. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2323. }
  2324. if materialCostTotal != 0 {
  2325. iteminfo.MedChrgitm = "08"
  2326. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2327. iteminfo.Amt = materialCostTotal
  2328. iteminfo.ClaaSumfee = material_claa_sunmfee
  2329. iteminfo.ClabAmt = material_clab_amt
  2330. iteminfo.OthAmt = material_other_amt
  2331. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2332. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2333. }
  2334. if westernMedicineCostTotal != 0 {
  2335. iteminfo.MedChrgitm = "09"
  2336. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2337. iteminfo.Amt = westernMedicineCostTotal
  2338. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2339. iteminfo.ClabAmt = westernMedicine_clab_amt
  2340. iteminfo.OthAmt = westernMedicine_other_amt
  2341. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2342. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2343. }
  2344. if chineseTraditionalMedicineCostTotal != 0 {
  2345. iteminfo.MedChrgitm = "11"
  2346. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2347. iteminfo.Amt = westernMedicineCostTotal
  2348. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2349. iteminfo.ClabAmt = westernMedicine_clab_amt
  2350. iteminfo.OthAmt = westernMedicine_other_amt
  2351. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2352. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2353. }
  2354. if otherCostTotal != 0 {
  2355. iteminfo.MedChrgitm = "14"
  2356. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2357. iteminfo.Amt = otherCostTotal
  2358. iteminfo.ClaaSumfee = other_claa_sunmfee
  2359. iteminfo.ClabAmt = other_clab_amt
  2360. iteminfo.OthAmt = other_other_amt
  2361. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2362. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2363. }
  2364. struct4101.IteminfoStruct = iteminfoStructs
  2365. struct4101.Ntly = "中国"
  2366. struct4101.AdmCaty = "A03.06"
  2367. var res ResultSeventeen
  2368. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2369. var resOther ResultSeventeenOther
  2370. var pp models.PublicParams
  2371. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2372. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2373. pp.FixmedinsName = miConfig.OrgName
  2374. pp.FixmedinsCode = miConfig.Code
  2375. pp.RequestUrl = miConfig.Url
  2376. pp.Cainfo = miConfig.Cainfo
  2377. pp.SecretKey = miConfig.SecretKey
  2378. pp.AccessKey = miConfig.AccessKey
  2379. pp.OpterName = curRoles.UserName
  2380. client := &http.Client{}
  2381. var req *http.Request
  2382. data := make(map[string]interface{})
  2383. data["struct4101"] = struct4101
  2384. data["pp"] = pp
  2385. bytesData, _ := json.Marshal(data)
  2386. if miConfig.MdtrtareaAdmvs == "320921" {
  2387. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2388. } else {
  2389. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2390. }
  2391. resp, _ := client.Do(req)
  2392. defer resp.Body.Close()
  2393. body, ioErr := ioutil.ReadAll(resp.Body)
  2394. if ioErr != nil {
  2395. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2397. return
  2398. }
  2399. var respJSON map[string]interface{}
  2400. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2401. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2403. return
  2404. }
  2405. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2406. userJSONBytes, _ := json.Marshal(respJSON)
  2407. fmt.Println("log")
  2408. fmt.Println(string(userJSONBytes))
  2409. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  2410. utils.ErrorLog("解析失败:%v", err)
  2411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2412. return
  2413. }
  2414. res.InfRefmsgid = resOther.InfRefmsgid
  2415. res.Output = resOther.Output
  2416. res.ErrMsg = resOther.ErrMsg
  2417. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  2418. res.Infcode = infocode
  2419. } else {
  2420. result := service.Gdyb4101ForGZ(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2421. var dat map[string]interface{}
  2422. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2423. fmt.Println(dat)
  2424. } else {
  2425. fmt.Println(err)
  2426. }
  2427. userJSONBytes, _ := json.Marshal(dat)
  2428. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2429. utils.ErrorLog("解析失败:%v", err)
  2430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2431. return
  2432. }
  2433. }
  2434. if res.Infcode != 0 {
  2435. c.ServeSuccessJSON(map[string]interface{}{
  2436. "failed_code": -10,
  2437. "msg": res.ErrMsg,
  2438. })
  2439. return
  2440. } else {
  2441. order.FaPiaoNumber = zero
  2442. order.FaPiaoCode = last_order.FaPiaoCode
  2443. service.UpdateOrder(order)
  2444. hisFundSettleListResult := &models.HisFundSettleListResult{
  2445. Number: res.Output.SetlListId,
  2446. Status: 1,
  2447. Ctime: time.Now().Unix(),
  2448. Mtime: time.Now().Unix(),
  2449. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2450. IsUpload: 1,
  2451. OrderId: order_id,
  2452. }
  2453. service.CreateUploadRecord(hisFundSettleListResult)
  2454. c.ServeSuccessJSON(map[string]interface{}{
  2455. "msg": "上传成功",
  2456. "result": hisFundSettleListResult,
  2457. })
  2458. return
  2459. }
  2460. }
  2461. func (c *HisApiController) GetSettleListHospital() {
  2462. order_id, _ := c.GetInt64("order_id")
  2463. admin_user_id, _ := c.GetInt64("admin_user_id")
  2464. order, _ := service.GetHisOrderByIDTwo(order_id)
  2465. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2466. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2467. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2468. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2469. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2470. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2471. if order.ID == 0 {
  2472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2473. return
  2474. }
  2475. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  2476. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  2477. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  2478. fmt.Println(count)
  2479. var zero string
  2480. number := count + 1
  2481. if number >= 1000 {
  2482. zero = "0000" + strconv.FormatInt(number, 10)
  2483. } else if number >= 10000 {
  2484. zero = "000" + strconv.FormatInt(number, 10)
  2485. } else if number >= 100000 {
  2486. zero = "00" + strconv.FormatInt(number, 10)
  2487. } else if number >= 1000000 {
  2488. zero = "0" + strconv.FormatInt(number, 10)
  2489. } else {
  2490. zero = strconv.FormatInt(number, 10)
  2491. }
  2492. fmt.Println(zero)
  2493. struct4101 := service.Struct4101{
  2494. PsnNo: order.PsnNo,
  2495. MdtrtId: order.MdtrtId,
  2496. SetlId: order.SetlId,
  2497. PsnName: order.PsnName,
  2498. Gend: order.Gend,
  2499. Brdy: his.Brdy,
  2500. Age: int64(order.Age),
  2501. Naty: order.Naty,
  2502. PatnCertType: "01",
  2503. Certno: order.Certno,
  2504. Prfs: "90",
  2505. ConerName: roles[0].UserName,
  2506. PatnRlts: "99",
  2507. ConerAddr: miConfig.OrgName,
  2508. ConerTel: admin.Mobile,
  2509. HiType: order.Insutype,
  2510. Insuplc: miConfig.InsuplcAdmdvs,
  2511. MaindiagFlag: "1",
  2512. BillCode: last_order.FaPiaoCode,
  2513. BillNo: zero,
  2514. BizSn: order.Number,
  2515. PsnSelfPay: order.PsnPartAmt,
  2516. PsnOwnPay: order.PsnPartAmt,
  2517. AcctPay: order.AcctPay,
  2518. PsnCashpay: order.PsnCashPay,
  2519. HiPaymtd: "1",
  2520. Hsorg: miConfig.InsuplcAdmdvs,
  2521. HsorgOpter: miConfig.InsuplcAdmdvs,
  2522. MedinsFillPsn: curRoles.UserName,
  2523. MedinsFillDept: depart.Name,
  2524. IptMedType: "2",
  2525. AdmTime: his.InHosptialTime,
  2526. AdmEndTime: his.OutHosptialTime,
  2527. }
  2528. struct4101.SetlBegnDate = order.SetlTime
  2529. struct4101.SetlEndDate = order.SetlTime
  2530. var rf []CustomFundPay
  2531. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2532. var tempFunPays []service.CustomStruct
  2533. for _, item := range rf {
  2534. var tempFunPay service.CustomStruct
  2535. tempFunPay.FundPayamt = item.FundPayamt
  2536. tempFunPay.FundPayType = item.FundPayType
  2537. tempFunPays = append(tempFunPays, tempFunPay)
  2538. }
  2539. fmt.Println("111111111")
  2540. fmt.Println(tempFunPays)
  2541. struct4101.CustomStruct = tempFunPays
  2542. fmt.Println(struct4101.CustomStruct)
  2543. var tempDiaginfos []service.DiaginfoStructTwo
  2544. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2545. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2546. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2547. var config []*models.HisXtDiagnoseConfig
  2548. for _, item := range diagnosis_ids {
  2549. id, _ := strconv.ParseInt(item, 10, 64)
  2550. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2551. config = append(config, &diagnosisConfig)
  2552. }
  2553. for index, item := range config {
  2554. if index == 0 {
  2555. var tempDiaginfo service.DiaginfoStructTwo
  2556. tempDiaginfo.DiagCode = item.CountryCode
  2557. tempDiaginfo.DiagName = item.CountryContentName
  2558. tempDiaginfo.DiagType = "1"
  2559. tempDiaginfo.MaindiagFlag = "1"
  2560. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2561. } else {
  2562. var tempDiaginfo service.DiaginfoStructTwo
  2563. tempDiaginfo.DiagCode = item.CountryCode
  2564. tempDiaginfo.DiagName = item.CountryContentName
  2565. tempDiaginfo.DiagType = "2"
  2566. tempDiaginfo.MaindiagFlag = "0"
  2567. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2568. }
  2569. }
  2570. struct4101.Diseinfo = tempDiaginfos
  2571. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2572. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2573. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2574. tempOpspdiseinfo2.OprnOprtCode = ""
  2575. tempOpspdiseinfo2.OprnOprtName = ""
  2576. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2577. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2578. var iteminfo service.IteminfoStruct
  2579. var bedCostTotal float64 = 0 //床位总费
  2580. var bedCostSelfTotal float64 = 0 //床位自费
  2581. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2582. var operationCostTotal float64 = 0 //手术费
  2583. var operationCostSelfTotal float64 = 0 //手术费
  2584. var operationCostPartSelfTotal float64 = 0 //手术费
  2585. var otherCostTotal float64 = 0 //其他费用
  2586. var otherCostSelfTotal float64 = 0 //其他费用
  2587. var otherCostPartSelfTotal float64 = 0 //其他费用
  2588. var materialCostTotal float64 = 0 //材料费
  2589. var materialCostSelfTotal float64 = 0 //材料费
  2590. var materialCostPartSelfTotal float64 = 0 //材料费
  2591. var westernMedicineCostTotal float64 = 0 //西药费
  2592. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2593. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2594. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2595. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2596. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2597. var checkCostTotal float64 = 0 //检查费
  2598. var checkCostSelfTotal float64 = 0 //检查费
  2599. var checkCostPartSelfTotal float64 = 0 //检查费
  2600. var laboratoryCostTotal float64 = 0 //化验费
  2601. var laboratoryCostSelfTotal float64 = 0 //化验费
  2602. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2603. var treatCostTotal float64 = 0 //治疗费用
  2604. var treatCostSelfTotal float64 = 0 //治疗费用
  2605. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2606. decimal.DivisionPrecision = 2
  2607. var bed_fulamt_ownpay_amt float64 = 0
  2608. var operation_fulamt_ownpay_amt float64 = 0
  2609. var other_fulamt_ownpay_amt float64 = 0
  2610. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2611. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2612. var check_fulamt_ownpay_amt float64 = 0
  2613. var material_fulamt_ownpay_amt float64 = 0
  2614. var laboratory_fulamt_ownpay_amt float64 = 0
  2615. var treat_fulamt_ownpay_amt float64 = 0
  2616. var bed_claa_sunmfee float64 = 0
  2617. var bed_clab_amt float64 = 0
  2618. var bed_other_amt float64 = 0
  2619. var operation_claa_sunmfee float64 = 0
  2620. var operation_clab_amt float64 = 0
  2621. var operation_other_amt float64 = 0
  2622. var other_claa_sunmfee float64 = 0
  2623. var other_clab_amt float64 = 0
  2624. var other_other_amt float64 = 0
  2625. var westernMedicine_claa_sunmfee float64 = 0
  2626. var westernMedicine_clab_amt float64 = 0
  2627. var westernMedicine_other_amt float64 = 0
  2628. var chineseTraditional_claa_sunmfee float64 = 0
  2629. var chineseTraditional_clab_amt float64 = 0
  2630. var chineseTraditional_other_amt float64 = 0
  2631. var check_claa_sunmfee float64 = 0
  2632. var check_clab_amt float64 = 0
  2633. var check_other_amt float64 = 0
  2634. var material_claa_sunmfee float64 = 0
  2635. var material_clab_amt float64 = 0
  2636. var material_other_amt float64 = 0
  2637. var laboratory_claa_sunmfee float64 = 0
  2638. var laboratory_clab_amt float64 = 0
  2639. var laboratory_other_amt float64 = 0
  2640. var treat_claa_sunmfee float64 = 0
  2641. var treat_clab_amt float64 = 0
  2642. var treat_other_amt float64 = 0
  2643. for _, item := range order.HisOrderInfo {
  2644. if item.MedChrgitmType == "01" { //床位费
  2645. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2646. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2647. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2648. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2649. if item.ChrgitmLv == "1" {
  2650. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2651. }
  2652. if item.ChrgitmLv == "2" {
  2653. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2654. }
  2655. if item.ChrgitmLv == "3" {
  2656. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2657. }
  2658. }
  2659. if item.MedChrgitmType == "03" { //检查费
  2660. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2661. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2662. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2663. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2664. if item.ChrgitmLv == "1" {
  2665. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2666. }
  2667. if item.ChrgitmLv == "2" {
  2668. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2669. }
  2670. if item.ChrgitmLv == "3" {
  2671. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2672. }
  2673. }
  2674. if item.MedChrgitmType == "04" { //化验费
  2675. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2676. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2677. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2678. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2679. if item.ChrgitmLv == "1" {
  2680. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2681. }
  2682. if item.ChrgitmLv == "2" {
  2683. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2684. }
  2685. if item.ChrgitmLv == "3" {
  2686. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2687. }
  2688. }
  2689. if item.MedChrgitmType == "05" { //治疗费
  2690. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2691. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2692. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2693. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2694. if item.ChrgitmLv == "1" {
  2695. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2696. }
  2697. if item.ChrgitmLv == "2" {
  2698. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2699. }
  2700. if item.ChrgitmLv == "3" {
  2701. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2702. }
  2703. }
  2704. if item.MedChrgitmType == "06" { //手术费
  2705. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2706. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2707. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2708. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2709. if item.ChrgitmLv == "1" {
  2710. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2711. }
  2712. if item.ChrgitmLv == "2" {
  2713. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2714. }
  2715. if item.ChrgitmLv == "3" {
  2716. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2717. }
  2718. }
  2719. if item.MedChrgitmType == "08" { //材料费
  2720. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2721. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2722. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2723. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2724. if item.ChrgitmLv == "1" {
  2725. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2726. }
  2727. if item.ChrgitmLv == "2" {
  2728. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2729. }
  2730. if item.ChrgitmLv == "3" {
  2731. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2732. }
  2733. }
  2734. if item.MedChrgitmType == "09" { //西药费
  2735. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2736. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2737. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2738. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2739. if item.ChrgitmLv == "1" {
  2740. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2741. }
  2742. if item.ChrgitmLv == "2" {
  2743. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2744. }
  2745. if item.ChrgitmLv == "3" {
  2746. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2747. }
  2748. }
  2749. if item.MedChrgitmType == "11" { //中成费
  2750. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2751. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2752. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2753. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2754. if item.ChrgitmLv == "1" {
  2755. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2756. }
  2757. if item.ChrgitmLv == "2" {
  2758. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2759. }
  2760. if item.ChrgitmLv == "3" {
  2761. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2762. }
  2763. }
  2764. if item.MedChrgitmType == "14" { //其他费
  2765. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2766. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2767. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2768. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2769. if item.ChrgitmLv == "1" {
  2770. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2771. }
  2772. if item.ChrgitmLv == "2" {
  2773. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2774. }
  2775. if item.ChrgitmLv == "3" {
  2776. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2777. }
  2778. }
  2779. }
  2780. var iteminfoStructs []service.IteminfoStruct
  2781. if bedCostTotal != 0 {
  2782. iteminfo.MedChrgitm = "01"
  2783. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2784. iteminfo.Amt = bedCostTotal
  2785. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2786. iteminfo.ClabAmt = bed_clab_amt
  2787. iteminfo.OthAmt = bed_other_amt
  2788. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2789. }
  2790. if checkCostTotal != 0 {
  2791. iteminfo.MedChrgitm = "03"
  2792. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2793. iteminfo.Amt = checkCostTotal
  2794. iteminfo.ClaaSumfee = check_claa_sunmfee
  2795. iteminfo.ClabAmt = check_clab_amt
  2796. iteminfo.OthAmt = check_other_amt
  2797. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2798. }
  2799. if laboratoryCostTotal != 0 {
  2800. iteminfo.MedChrgitm = "04"
  2801. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2802. iteminfo.Amt = laboratoryCostTotal
  2803. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2804. iteminfo.ClabAmt = laboratory_clab_amt
  2805. iteminfo.OthAmt = laboratory_other_amt
  2806. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2807. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2808. }
  2809. if treatCostTotal != 0 {
  2810. iteminfo.MedChrgitm = "05"
  2811. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2812. iteminfo.Amt = treatCostTotal
  2813. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2814. iteminfo.ClabAmt = treat_clab_amt
  2815. iteminfo.OthAmt = treat_other_amt
  2816. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2817. //(struct4101.IteminfoStruct, iteminfo)
  2818. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2819. }
  2820. if operationCostTotal != 0 {
  2821. iteminfo.MedChrgitm = "06"
  2822. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2823. iteminfo.Amt = operationCostTotal
  2824. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2825. iteminfo.ClabAmt = operation_clab_amt
  2826. iteminfo.OthAmt = operation_other_amt
  2827. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2828. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2829. }
  2830. if materialCostTotal != 0 {
  2831. iteminfo.MedChrgitm = "08"
  2832. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2833. iteminfo.Amt = materialCostTotal
  2834. iteminfo.ClaaSumfee = material_claa_sunmfee
  2835. iteminfo.ClabAmt = material_clab_amt
  2836. iteminfo.OthAmt = material_other_amt
  2837. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2838. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2839. }
  2840. if westernMedicineCostTotal != 0 {
  2841. iteminfo.MedChrgitm = "09"
  2842. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2843. iteminfo.Amt = westernMedicineCostTotal
  2844. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2845. iteminfo.ClabAmt = westernMedicine_clab_amt
  2846. iteminfo.OthAmt = westernMedicine_other_amt
  2847. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2848. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2849. }
  2850. if chineseTraditionalMedicineCostTotal != 0 {
  2851. iteminfo.MedChrgitm = "11"
  2852. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2853. iteminfo.Amt = westernMedicineCostTotal
  2854. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2855. iteminfo.ClabAmt = westernMedicine_clab_amt
  2856. iteminfo.OthAmt = westernMedicine_other_amt
  2857. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2858. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2859. }
  2860. if otherCostTotal != 0 {
  2861. iteminfo.MedChrgitm = "14"
  2862. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2863. iteminfo.Amt = otherCostTotal
  2864. iteminfo.ClaaSumfee = other_claa_sunmfee
  2865. iteminfo.ClabAmt = other_clab_amt
  2866. iteminfo.OthAmt = other_other_amt
  2867. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2868. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2869. }
  2870. struct4101.IteminfoStruct = iteminfoStructs
  2871. struct4101.Ntly = "中国"
  2872. struct4101.AdmCaty = "A03.06"
  2873. fmt.Println("111111111")
  2874. fmt.Println(tempFunPays)
  2875. struct4101.CustomStruct = tempFunPays
  2876. fmt.Println(struct4101.CustomStruct)
  2877. result := service.Gdyb4101ForGZ(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2878. fmt.Println(result)
  2879. var dat map[string]interface{}
  2880. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2881. fmt.Println(dat)
  2882. } else {
  2883. fmt.Println(err)
  2884. }
  2885. userJSONBytes, _ := json.Marshal(dat)
  2886. var res ResultSeventeen
  2887. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2888. utils.ErrorLog("解析失败:%v", err)
  2889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2890. return
  2891. }
  2892. if res.Infcode != 0 {
  2893. c.ServeSuccessJSON(map[string]interface{}{
  2894. "failed_code": -10,
  2895. "msg": res.ErrMsg,
  2896. })
  2897. return
  2898. } else {
  2899. order.FaPiaoNumber = zero
  2900. order.FaPiaoCode = last_order.FaPiaoCode
  2901. service.UpdateOrder(order)
  2902. hisFundSettleListResult := &models.HisFundSettleListResult{
  2903. Number: res.Output.SetlListId,
  2904. Status: 1,
  2905. Ctime: time.Now().Unix(),
  2906. Mtime: time.Now().Unix(),
  2907. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2908. IsUpload: 1,
  2909. OrderId: order_id,
  2910. }
  2911. service.CreateUploadRecord(hisFundSettleListResult)
  2912. c.ServeSuccessJSON(map[string]interface{}{
  2913. "msg": "上传成功",
  2914. "result": hisFundSettleListResult,
  2915. })
  2916. return
  2917. }
  2918. }
  2919. func (c *HisApiController) GetBatchSettleList() {
  2920. orders, _ := service.GetAllHisOrder(10106)
  2921. for _, item := range orders {
  2922. order_id := item.ID
  2923. order, _ := service.GetHisOrderByIDTwo(order_id)
  2924. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2925. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2926. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2927. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  2928. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2929. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2930. if order.ID == 0 {
  2931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2932. return
  2933. }
  2934. if his.BalanceAccountsType == 2 {
  2935. continue
  2936. }
  2937. struct4101 := service.Struct4101{
  2938. PsnNo: order.PsnNo,
  2939. MdtrtId: order.MdtrtId,
  2940. SetlId: order.SetlId,
  2941. PsnName: order.PsnName,
  2942. Gend: order.Gend,
  2943. Brdy: his.Brdy,
  2944. Age: his.Age,
  2945. Naty: order.Naty,
  2946. PatnCertType: "01",
  2947. Certno: order.Certno,
  2948. Prfs: "90",
  2949. ConerName: roles[0].UserName,
  2950. PatnRlts: "99",
  2951. ConerAddr: miConfig.OrgName,
  2952. ConerTel: admin.Mobile,
  2953. HiType: order.Insutype,
  2954. Insuplc: his.InsuplcAdmdvs,
  2955. MaindiagFlag: "1",
  2956. BillCode: order.FaPiaoCode,
  2957. BillNo: order.FaPiaoNumber,
  2958. BizSn: order.Number,
  2959. PsnSelfPay: order.PsnPartAmt,
  2960. PsnOwnPay: order.PsnPartAmt,
  2961. AcctPay: order.AcctPay,
  2962. PsnCashpay: order.PsnCashPay,
  2963. HiPaymtd: "1",
  2964. Hsorg: his.InsuplcAdmdvs,
  2965. HsorgOpter: his.InsuplcAdmdvs,
  2966. MedinsFillPsn: curRoles.UserName,
  2967. MedinsFillDept: depart.Name,
  2968. IptMedType: "2",
  2969. }
  2970. struct4101.SetlBegnDate = order.SetlTime
  2971. struct4101.SetlEndDate = order.SetlTime
  2972. //if order.SettleType == 1 {
  2973. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  2974. // dateStr := t.Format("2006-01-02")
  2975. // struct4101.SetlBegnDate = dateStr
  2976. // struct4101.SetlEndDate = dateStr
  2977. //} else {
  2978. // t := time.Unix(int64(order.SettleStartTime), 0)
  2979. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  2980. // dateStartStr := t.Format("2006-01-02")
  2981. // dateEndStr := t2.Format("2006-01-02")
  2982. // struct4101.SetlBegnDate = dateStartStr
  2983. // struct4101.SetlEndDate = dateEndStr
  2984. //}
  2985. var rf []CustomFundPay
  2986. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2987. var tempFunPays []service.CustomStruct
  2988. var tempFunPay610100 service.CustomStruct
  2989. for _, item := range rf {
  2990. if item.FundPayType == "610100" {
  2991. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  2992. tempFunPay610100.FundPayType = item.FundPayType
  2993. } else {
  2994. var tempFunPay service.CustomStruct
  2995. tempFunPay.FundPayamt = item.FundPayamt
  2996. tempFunPay.FundPayType = item.FundPayType
  2997. tempFunPays = append(tempFunPays, tempFunPay)
  2998. }
  2999. }
  3000. tempFunPays = append(tempFunPays, tempFunPay610100)
  3001. struct4101.CustomStruct = tempFunPays
  3002. var tempDiaginfos []service.DiaginfoStructTwo
  3003. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  3004. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  3005. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3006. var config []*models.HisXtDiagnoseConfig
  3007. for _, item := range diagnosis_ids {
  3008. id, _ := strconv.ParseInt(item, 10, 64)
  3009. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3010. config = append(config, &diagnosisConfig)
  3011. }
  3012. for index, item := range config {
  3013. if index == 0 {
  3014. var tempDiaginfo service.DiaginfoStructTwo
  3015. tempDiaginfo.DiagCode = item.CountryCode
  3016. tempDiaginfo.DiagName = item.CountryContentName
  3017. tempDiaginfo.DiagType = "1"
  3018. tempDiaginfo.MaindiagFlag = "1"
  3019. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3020. } else {
  3021. var tempDiaginfo service.DiaginfoStructTwo
  3022. tempDiaginfo.DiagCode = item.CountryCode
  3023. tempDiaginfo.DiagName = item.CountryContentName
  3024. tempDiaginfo.DiagType = "2"
  3025. tempDiaginfo.MaindiagFlag = "0"
  3026. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3027. }
  3028. }
  3029. struct4101.Diseinfo = tempDiaginfos
  3030. sickConfigTwo, _ := service.FindSickById(his.SickType)
  3031. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  3032. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  3033. tempOpspdiseinfo2.OprnOprtCode = ""
  3034. tempOpspdiseinfo2.OprnOprtName = ""
  3035. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  3036. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  3037. var iteminfo service.IteminfoStruct
  3038. var bedCostTotal float64 = 0 //床位总费
  3039. var bedCostSelfTotal float64 = 0 //床位自费
  3040. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  3041. var examineCostTotal float64 = 0 //诊查总费
  3042. var examineCostSelfTotal float64 = 0 //诊查自费
  3043. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  3044. var nursingCostTotal float64 = 0 //护理总费
  3045. var nursingCostSelfTotal float64 = 0 //护理自费
  3046. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  3047. var chineseMedicineCostTotal float64 = 0 //中成药
  3048. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  3049. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  3050. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  3051. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  3052. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  3053. var registerCostTotal float64 = 0 //一般诊疗费
  3054. var registerCostSelfTotal float64 = 0 //一般诊疗费
  3055. var registerPartSelfTotal float64 = 0 //一般诊疗费
  3056. var operationCostTotal float64 = 0 //手术费
  3057. var operationCostSelfTotal float64 = 0 //手术费
  3058. var operationCostPartSelfTotal float64 = 0 //手术费
  3059. var otherCostTotal float64 = 0 //其他费用
  3060. var otherCostSelfTotal float64 = 0 //其他费用
  3061. var otherCostPartSelfTotal float64 = 0 //其他费用
  3062. var materialCostTotal float64 = 0 //材料费
  3063. var materialCostSelfTotal float64 = 0 //材料费
  3064. var materialCostPartSelfTotal float64 = 0 //材料费
  3065. var westernMedicineCostTotal float64 = 0 //西药费
  3066. var westernMedicineCostSelfTotal float64 = 0 //西药费
  3067. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  3068. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  3069. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  3070. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  3071. var checkCostTotal float64 = 0 //检查费
  3072. var checkCostSelfTotal float64 = 0 //检查费
  3073. var checkCostPartSelfTotal float64 = 0 //检查费
  3074. var laboratoryCostTotal float64 = 0 //化验费
  3075. var laboratoryCostSelfTotal float64 = 0 //化验费
  3076. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  3077. var treatCostTotal float64 = 0 //治疗费用
  3078. var treatCostSelfTotal float64 = 0 //治疗费用
  3079. var treatCostPartSelfTotal float64 = 0 //治疗费用
  3080. decimal.DivisionPrecision = 2
  3081. var bed_fulamt_ownpay_amt float64 = 0
  3082. var examine_fulamt_ownpay_amt float64 = 0
  3083. var nursing_fulamt_ownpay_amt float64 = 0
  3084. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  3085. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  3086. var register_fulamt_ownpay_amt float64 = 0
  3087. var operation_fulamt_ownpay_amt float64 = 0
  3088. var other_fulamt_ownpay_amt float64 = 0
  3089. var westernMedicine_fulamt_ownpay_amt float64 = 0
  3090. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  3091. var check_fulamt_ownpay_amt float64 = 0
  3092. var material_fulamt_ownpay_amt float64 = 0
  3093. var laboratory_fulamt_ownpay_amt float64 = 0
  3094. var treat_fulamt_ownpay_amt float64 = 0
  3095. var bed_claa_sunmfee float64 = 0
  3096. var bed_clab_amt float64 = 0
  3097. var bed_other_amt float64 = 0
  3098. var examine_claa_sunmfee float64 = 0
  3099. var examine_clab_amt float64 = 0
  3100. var examine_other_amt float64 = 0
  3101. var nursing_claa_sunmfee float64 = 0
  3102. var nursing_clab_amt float64 = 0
  3103. var nursing_other_amt float64 = 0
  3104. var chinese_medicine_claa_sunmfee float64 = 0
  3105. var chinese_medicine_clab_amt float64 = 0
  3106. var chinese_medicine_other_amt float64 = 0
  3107. var commonly_treatment_claa_sunmfee float64 = 0
  3108. var commonly_treatment_clab_amt float64 = 0
  3109. var commonly_treatment_other_amt float64 = 0
  3110. var operation_claa_sunmfee float64 = 0
  3111. var operation_clab_amt float64 = 0
  3112. var operation_other_amt float64 = 0
  3113. var other_claa_sunmfee float64 = 0
  3114. var other_clab_amt float64 = 0
  3115. var other_other_amt float64 = 0
  3116. var westernMedicine_claa_sunmfee float64 = 0
  3117. var westernMedicine_clab_amt float64 = 0
  3118. var westernMedicine_other_amt float64 = 0
  3119. var chineseTraditional_claa_sunmfee float64 = 0
  3120. var chineseTraditional_clab_amt float64 = 0
  3121. var chineseTraditional_other_amt float64 = 0
  3122. var check_claa_sunmfee float64 = 0
  3123. var check_clab_amt float64 = 0
  3124. var check_other_amt float64 = 0
  3125. var material_claa_sunmfee float64 = 0
  3126. var material_clab_amt float64 = 0
  3127. var material_other_amt float64 = 0
  3128. var laboratory_claa_sunmfee float64 = 0
  3129. var laboratory_clab_amt float64 = 0
  3130. var laboratory_other_amt float64 = 0
  3131. var treat_claa_sunmfee float64 = 0
  3132. var treat_clab_amt float64 = 0
  3133. var treat_other_amt float64 = 0
  3134. var register_claa_sunmfee float64 = 0
  3135. var register_clab_amt float64 = 0
  3136. var register_other_amt float64 = 0
  3137. for _, item := range order.HisOrderInfo {
  3138. if item.MedChrgitmType == "01" { //床位费
  3139. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3140. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3141. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3142. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3143. if item.ChrgitmLv == "1" {
  3144. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3145. }
  3146. if item.ChrgitmLv == "2" {
  3147. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3148. }
  3149. if item.ChrgitmLv == "3" {
  3150. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3151. }
  3152. }
  3153. if item.MedChrgitmType == "02" { //诊查
  3154. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3155. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3156. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3157. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3158. if item.ChrgitmLv == "1" {
  3159. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3160. }
  3161. if item.ChrgitmLv == "2" {
  3162. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3163. }
  3164. if item.ChrgitmLv == "3" {
  3165. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3166. }
  3167. }
  3168. if item.MedChrgitmType == "03" { //检查费
  3169. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3170. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3171. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3172. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3173. if item.ChrgitmLv == "1" {
  3174. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3175. }
  3176. if item.ChrgitmLv == "2" {
  3177. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3178. }
  3179. if item.ChrgitmLv == "3" {
  3180. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3181. }
  3182. }
  3183. if item.MedChrgitmType == "04" { //化验费
  3184. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3185. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3186. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3187. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3188. if item.ChrgitmLv == "1" {
  3189. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3190. }
  3191. if item.ChrgitmLv == "2" {
  3192. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3193. }
  3194. if item.ChrgitmLv == "3" {
  3195. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3196. }
  3197. }
  3198. if item.MedChrgitmType == "05" { //治疗费
  3199. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3200. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3201. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3202. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3203. if item.ChrgitmLv == "1" {
  3204. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3205. }
  3206. if item.ChrgitmLv == "2" {
  3207. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3208. }
  3209. if item.ChrgitmLv == "3" {
  3210. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3211. }
  3212. }
  3213. if item.MedChrgitmType == "06" { //手术费
  3214. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3215. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3216. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3217. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3218. if item.ChrgitmLv == "1" {
  3219. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3220. }
  3221. if item.ChrgitmLv == "2" {
  3222. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3223. }
  3224. if item.ChrgitmLv == "3" {
  3225. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3226. }
  3227. }
  3228. if item.MedChrgitmType == "07" { //手术费
  3229. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3230. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3231. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3232. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3233. if item.ChrgitmLv == "1" {
  3234. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3235. }
  3236. if item.ChrgitmLv == "2" {
  3237. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3238. }
  3239. if item.ChrgitmLv == "3" {
  3240. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3241. }
  3242. }
  3243. if item.MedChrgitmType == "08" { //材料费
  3244. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3245. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3246. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3247. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3248. if item.ChrgitmLv == "1" {
  3249. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3250. }
  3251. if item.ChrgitmLv == "2" {
  3252. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3253. }
  3254. if item.ChrgitmLv == "3" {
  3255. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3256. }
  3257. }
  3258. if item.MedChrgitmType == "09" { //西药费
  3259. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3260. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3261. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3262. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3263. if item.ChrgitmLv == "1" {
  3264. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3265. }
  3266. if item.ChrgitmLv == "2" {
  3267. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3268. }
  3269. if item.ChrgitmLv == "3" {
  3270. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3271. }
  3272. }
  3273. if item.MedChrgitmType == "10" { //中药饮片
  3274. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3275. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3276. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3277. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3278. if item.ChrgitmLv == "1" {
  3279. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3280. }
  3281. if item.ChrgitmLv == "2" {
  3282. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3283. }
  3284. if item.ChrgitmLv == "3" {
  3285. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3286. }
  3287. }
  3288. if item.MedChrgitmType == "11" { //中成费
  3289. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3290. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3291. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3292. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3293. if item.ChrgitmLv == "1" {
  3294. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3295. }
  3296. if item.ChrgitmLv == "2" {
  3297. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3298. }
  3299. if item.ChrgitmLv == "3" {
  3300. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3301. }
  3302. }
  3303. if item.MedChrgitmType == "12" { //中成费
  3304. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3305. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3306. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3307. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3308. if item.ChrgitmLv == "1" {
  3309. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3310. }
  3311. if item.ChrgitmLv == "2" {
  3312. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3313. }
  3314. if item.ChrgitmLv == "3" {
  3315. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3316. }
  3317. }
  3318. if item.MedChrgitmType == "13" { //中成费
  3319. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3320. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3321. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3322. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3323. if item.ChrgitmLv == "1" {
  3324. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3325. }
  3326. if item.ChrgitmLv == "2" {
  3327. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3328. }
  3329. if item.ChrgitmLv == "3" {
  3330. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3331. }
  3332. }
  3333. if item.MedChrgitmType == "14" { //其他费
  3334. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3335. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3336. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3337. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3338. if item.ChrgitmLv == "1" {
  3339. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3340. }
  3341. if item.ChrgitmLv == "2" {
  3342. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3343. }
  3344. if item.ChrgitmLv == "3" {
  3345. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3346. }
  3347. }
  3348. }
  3349. var iteminfoStructs []service.IteminfoStruct
  3350. if bedCostTotal != 0 {
  3351. iteminfo.MedChrgitm = "01"
  3352. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3353. iteminfo.Amt = bedCostTotal
  3354. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3355. iteminfo.ClabAmt = bed_clab_amt
  3356. iteminfo.OthAmt = bed_other_amt
  3357. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3358. }
  3359. if examineCostTotal != 0 {
  3360. iteminfo.MedChrgitm = "02"
  3361. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  3362. iteminfo.Amt = examineCostTotal
  3363. iteminfo.ClaaSumfee = examine_claa_sunmfee
  3364. iteminfo.ClabAmt = examine_clab_amt
  3365. iteminfo.OthAmt = examine_other_amt
  3366. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3367. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3368. }
  3369. if checkCostTotal != 0 {
  3370. iteminfo.MedChrgitm = "03"
  3371. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3372. iteminfo.Amt = checkCostTotal
  3373. iteminfo.ClaaSumfee = check_claa_sunmfee
  3374. iteminfo.ClabAmt = check_clab_amt
  3375. iteminfo.OthAmt = check_other_amt
  3376. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3377. }
  3378. if laboratoryCostTotal != 0 {
  3379. iteminfo.MedChrgitm = "04"
  3380. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3381. iteminfo.Amt = laboratoryCostTotal
  3382. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3383. iteminfo.ClabAmt = laboratory_clab_amt
  3384. iteminfo.OthAmt = laboratory_other_amt
  3385. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3386. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3387. }
  3388. if treatCostTotal != 0 {
  3389. iteminfo.MedChrgitm = "05"
  3390. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3391. iteminfo.Amt = treatCostTotal
  3392. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3393. iteminfo.ClabAmt = treat_clab_amt
  3394. iteminfo.OthAmt = treat_other_amt
  3395. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3396. //(struct4101.IteminfoStruct, iteminfo)
  3397. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3398. }
  3399. if operationCostTotal != 0 {
  3400. iteminfo.MedChrgitm = "06"
  3401. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3402. iteminfo.Amt = operationCostTotal
  3403. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3404. iteminfo.ClabAmt = operation_clab_amt
  3405. iteminfo.OthAmt = operation_other_amt
  3406. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3407. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3408. }
  3409. if nursingCostTotal != 0 {
  3410. iteminfo.MedChrgitm = "07"
  3411. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  3412. iteminfo.Amt = nursingCostTotal
  3413. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  3414. iteminfo.ClabAmt = nursing_clab_amt
  3415. iteminfo.OthAmt = nursing_other_amt
  3416. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3417. }
  3418. if materialCostTotal != 0 {
  3419. iteminfo.MedChrgitm = "08"
  3420. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3421. iteminfo.Amt = materialCostTotal
  3422. iteminfo.ClaaSumfee = material_claa_sunmfee
  3423. iteminfo.ClabAmt = material_clab_amt
  3424. iteminfo.OthAmt = material_other_amt
  3425. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3426. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3427. }
  3428. if westernMedicineCostTotal != 0 {
  3429. iteminfo.MedChrgitm = "09"
  3430. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3431. iteminfo.Amt = westernMedicineCostTotal
  3432. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3433. iteminfo.ClabAmt = westernMedicine_clab_amt
  3434. iteminfo.OthAmt = westernMedicine_other_amt
  3435. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3436. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3437. }
  3438. if chineseMedicineCostTotal != 0 {
  3439. iteminfo.MedChrgitm = "10"
  3440. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  3441. iteminfo.Amt = chineseMedicineCostTotal
  3442. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  3443. iteminfo.ClabAmt = chinese_medicine_clab_amt
  3444. iteminfo.OthAmt = chinese_medicine_other_amt
  3445. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3446. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3447. }
  3448. if chineseTraditionalMedicineCostTotal != 0 {
  3449. iteminfo.MedChrgitm = "11"
  3450. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3451. iteminfo.Amt = westernMedicineCostTotal
  3452. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3453. iteminfo.ClabAmt = westernMedicine_clab_amt
  3454. iteminfo.OthAmt = westernMedicine_other_amt
  3455. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3456. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3457. }
  3458. if commonlyTreatmentCostTotal != 0 {
  3459. iteminfo.MedChrgitm = "12"
  3460. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  3461. iteminfo.Amt = commonlyTreatmentCostTotal
  3462. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  3463. iteminfo.ClabAmt = commonly_treatment_clab_amt
  3464. iteminfo.OthAmt = commonly_treatment_other_amt
  3465. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3466. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3467. }
  3468. if registerCostTotal != 0 {
  3469. iteminfo.MedChrgitm = "13"
  3470. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  3471. iteminfo.Amt = registerCostTotal
  3472. iteminfo.ClaaSumfee = register_claa_sunmfee
  3473. iteminfo.ClabAmt = register_clab_amt
  3474. iteminfo.OthAmt = register_other_amt
  3475. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3476. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3477. }
  3478. if otherCostTotal != 0 {
  3479. iteminfo.MedChrgitm = "14"
  3480. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3481. iteminfo.Amt = otherCostTotal
  3482. iteminfo.ClaaSumfee = other_claa_sunmfee
  3483. iteminfo.ClabAmt = other_clab_amt
  3484. iteminfo.OthAmt = other_other_amt
  3485. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3486. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3487. }
  3488. struct4101.IteminfoStruct = iteminfoStructs
  3489. struct4101.Ntly = "中国"
  3490. struct4101.AdmCaty = "A03.06"
  3491. result := service.Gdyb4101ForGZ(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  3492. fmt.Println(result)
  3493. var dat map[string]interface{}
  3494. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3495. fmt.Println(dat)
  3496. } else {
  3497. fmt.Println(err)
  3498. }
  3499. userJSONBytes, _ := json.Marshal(dat)
  3500. var res ResultSeventeen
  3501. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3502. utils.ErrorLog("解析失败:%v", err)
  3503. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3504. adminUser := c.GetAdminUserInfo()
  3505. errlog := &models.HisOrderError{
  3506. UserOrgId: adminUser.CurrentOrgId,
  3507. Ctime: time.Now().Unix(),
  3508. Mtime: time.Now().Unix(),
  3509. ErrMsg: res.ErrMsg + "解析失败",
  3510. Status: 1,
  3511. PatientId: order_id,
  3512. Stage: 10106,
  3513. }
  3514. service.CreateErrMsgLog(errlog)
  3515. continue
  3516. }
  3517. if res.Infcode != 0 {
  3518. adminUser := c.GetAdminUserInfo()
  3519. errlog := &models.HisOrderError{
  3520. UserOrgId: adminUser.CurrentOrgId,
  3521. Ctime: time.Now().Unix(),
  3522. Mtime: time.Now().Unix(),
  3523. ErrMsg: res.ErrMsg,
  3524. Status: 1,
  3525. PatientId: order_id,
  3526. Stage: 10106,
  3527. }
  3528. service.CreateErrMsgLog(errlog)
  3529. continue
  3530. } else {
  3531. hisFundSettleListResult := &models.HisFundSettleListResult{
  3532. Number: res.Output.SetlListId,
  3533. Status: 1,
  3534. Ctime: time.Now().Unix(),
  3535. Mtime: time.Now().Unix(),
  3536. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3537. IsUpload: 1,
  3538. OrderId: order_id,
  3539. }
  3540. service.CreateUploadRecord(hisFundSettleListResult)
  3541. continue
  3542. }
  3543. }
  3544. }
  3545. func (c *HisApiController) GetOrgInfo() {
  3546. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  3547. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  3548. }
  3549. func (c *HisApiController) GetHisPatientInfo() {
  3550. medical_insurance_card := c.GetString("medical_insurance_card")
  3551. id_card_type, _ := c.GetInt64("id_card_type")
  3552. id_card := c.GetString("id_card")
  3553. adminInfo := c.GetAdminUserInfo()
  3554. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3555. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3556. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  3557. IdCardNo := ""
  3558. if id_card_type == 1 {
  3559. IdCardNo = medical_insurance_card
  3560. } else if id_card_type == 2 {
  3561. IdCardNo = id_card
  3562. }
  3563. if config.IsOpen == 1 {
  3564. 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
  3565. resp, requestErr := http.Get(api)
  3566. if requestErr != nil {
  3567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3568. return
  3569. }
  3570. defer resp.Body.Close()
  3571. body, ioErr := ioutil.ReadAll(resp.Body)
  3572. if ioErr != nil {
  3573. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3575. return
  3576. }
  3577. var respJSON map[string]interface{}
  3578. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3579. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3581. return
  3582. }
  3583. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3584. userJSONBytes, _ := json.Marshal(userJSON)
  3585. var res ResultTwo
  3586. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3587. utils.ErrorLog("解析失败:%v", err)
  3588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3589. return
  3590. }
  3591. Iinfos, _ := json.Marshal(res.Output[0].Iinfo)
  3592. Idetinfos, _ := json.Marshal(res.Output[0].Idetinfo)
  3593. infoStr := string(Iinfos)
  3594. idetinfoStr := string(Idetinfos)
  3595. if res.Infcode == 0 {
  3596. his := models.VMHisPatient{
  3597. Status: 1,
  3598. Ctime: time.Now().Unix(),
  3599. Mtime: time.Now().Unix(),
  3600. PsnNo: res.Output[0].Baseinfo.PsnNo,
  3601. PsnCertType: res.Output[0].Baseinfo.PsnCertType,
  3602. Certno: res.Output[0].Baseinfo.Certno,
  3603. PsnName: res.Output[0].Baseinfo.PsnName,
  3604. Gend: res.Output[0].Baseinfo.Gend,
  3605. Naty: res.Output[0].Baseinfo.Naty,
  3606. Brdy: res.Output[0].Baseinfo.Brdy,
  3607. Age: res.Output[0].Baseinfo.Age,
  3608. Iinfo: infoStr,
  3609. Idetinfo: idetinfoStr,
  3610. UserOrgId: adminInfo.CurrentOrgId,
  3611. IsReturn: 1,
  3612. IdCardType: id_card_type,
  3613. }
  3614. c.ServeSuccessJSON(map[string]interface{}{
  3615. "info": his,
  3616. })
  3617. } else {
  3618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3619. return
  3620. }
  3621. }
  3622. }
  3623. //func GetBasBaseInfo() (jsonStr string, err error) {
  3624. //
  3625. // handle := syscall.NewLazyDLL("SSCard.dll")
  3626. // add := handle.NewProc("ReadCardBas")
  3627. // str := make([]byte, 1024)
  3628. // str1 := make([]byte, 1024)
  3629. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3630. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3631. //
  3632. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3633. //
  3634. // fmt.Println("> Add(4,5)的结果为:", ret)
  3635. // handle.Release()
  3636. //
  3637. // return "", nil
  3638. //
  3639. //}
  3640. //func GetQRBaseInfo() (jsonStr string, err error) {
  3641. // handle := syscall.LoadDLL("SSCard.dll")
  3642. // ReadCardBas := handle.FindProc("GetQRBase")
  3643. //
  3644. // str := make([]byte, 256)
  3645. // str1 := make([]byte, 256)
  3646. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3647. //
  3648. // fmt.Println(string(str))
  3649. // fmt.Println(r)
  3650. // return string(str), nil
  3651. //}
  3652. //func CardInit() int {
  3653. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  3654. // add := DllTestDef.MustFindProc("Init")
  3655. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3656. // if err != nil {
  3657. // fmt.Println("SSCard的运算结果为:", ret)
  3658. // }
  3659. // result := int(ret)
  3660. // return result
  3661. //}
  3662. //func CardInit() int {
  3663. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3664. // if err != nil {
  3665. // fmt.Println("SSCard的运算结果为:", ret)
  3666. // }
  3667. // fmt.Println(err)
  3668. // result := int(ret)
  3669. // return result
  3670. //}
  3671. func IntPtr(n int) uintptr {
  3672. return uintptr(n)
  3673. }
  3674. func StrPtr(s string) uintptr {
  3675. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3676. }
  3677. type Result2001 struct {
  3678. Cainfo interface{} `json:"cainfo"`
  3679. ErrMsg string `json:"err_msg"`
  3680. InfRefmsgid string `json:"inf_refmsgid"`
  3681. Infcode int64 `json:"infcode"`
  3682. Output struct {
  3683. Trtinfo struct {
  3684. PsnNo string `json:"psn_no"`
  3685. TrtChkType string `json:"trt_chk_type"`
  3686. FundPayType string `json:"fund_pay_type"`
  3687. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3688. Begndate string `json:"begndate"`
  3689. Enddate string `json:"enddate"`
  3690. TrtChkRslt string `json:"trt_chk_rslt"`
  3691. } `json:"trtinfo"`
  3692. } `json:"output"`
  3693. RefmsgTime string `json:"refmsg_time"`
  3694. RespondTime string `json:"respond_time"`
  3695. Signtype interface{} `json:"signtype"`
  3696. WarnMsg interface{} `json:"warn_msg"`
  3697. }
  3698. type Result2001Org10265 struct {
  3699. Cainfo interface{} `json:"cainfo"`
  3700. ErrMsg string `json:"err_msg"`
  3701. InfRefmsgid string `json:"inf_refmsgid"`
  3702. Infcode string `json:"infcode"`
  3703. Output struct {
  3704. Trtinfo struct {
  3705. PsnNo string `json:"psn_no"`
  3706. TrtChkType string `json:"trt_chk_type"`
  3707. FundPayType string `json:"fund_pay_type"`
  3708. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3709. Begndate string `json:"begndate"`
  3710. Enddate string `json:"enddate"`
  3711. TrtChkRslt string `json:"trt_chk_rslt"`
  3712. } `json:"trtinfo"`
  3713. } `json:"output"`
  3714. RefmsgTime string `json:"refmsg_time"`
  3715. RespondTime string `json:"respond_time"`
  3716. Signtype interface{} `json:"signtype"`
  3717. WarnMsg interface{} `json:"warn_msg"`
  3718. }
  3719. type ResultTwo struct {
  3720. ErrMsg string `json:"err_msg"`
  3721. InfRefmsgid string `json:"inf_refmsgid"`
  3722. Infcode int64 `json:"infcode"`
  3723. Output []struct {
  3724. Baseinfo struct {
  3725. Age float64 `json:"age"`
  3726. Brdy string `json:"brdy"`
  3727. Certno string `json:"certno"`
  3728. Gend string `json:"gend"`
  3729. Naty string `json:"naty"`
  3730. PsnCertType string `json:"psn_cert_type"`
  3731. PsnName string `json:"psn_name"`
  3732. PsnNo string `json:"psn_no"`
  3733. } `json:"baseinfo"`
  3734. Idetinfo []interface{} `json:"idetinfo"`
  3735. Iinfo []struct {
  3736. Balc float64 `json:"balc"`
  3737. CvlservFlag string `json:"cvlserv_flag"`
  3738. EmpName string `json:"emp_name"`
  3739. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3740. Insutype string `json:"insutype"`
  3741. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3742. PausInsuDate string `json:"paus_insu_date"`
  3743. PsnInsuDate string `json:"psn_insu_date"`
  3744. PsnInsuStas string `json:"psn_insu_stas"`
  3745. PsnType string `json:"psn_type"`
  3746. } `json:"insuinfo"`
  3747. } `json:"output"`
  3748. RefmsgTime string `json:"refmsg_time"`
  3749. RespondTime string `json:"respond_time"`
  3750. Signtype interface{} `json:"signtype"`
  3751. WarnInfo interface{} `json:"warn_info"`
  3752. }
  3753. type ResultTwo10265 struct {
  3754. ErrMsg string `json:"err_msg"`
  3755. InfRefmsgid string `json:"inf_refmsgid"`
  3756. Infcode string `json:"infcode"`
  3757. Output struct {
  3758. Baseinfo struct {
  3759. Age float64 `json:"age"`
  3760. Brdy string `json:"brdy"`
  3761. Certno string `json:"certno"`
  3762. Gend string `json:"gend"`
  3763. Naty string `json:"naty"`
  3764. PsnCertType string `json:"psn_cert_type"`
  3765. PsnName string `json:"psn_name"`
  3766. PsnNo string `json:"psn_no"`
  3767. } `json:"baseinfo"`
  3768. Idetinfo []interface{} `json:"idetinfo"`
  3769. Iinfo []struct {
  3770. Balc float64 `json:"balc"`
  3771. CvlservFlag string `json:"cvlserv_flag"`
  3772. EmpName string `json:"emp_name"`
  3773. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3774. Insutype string `json:"insutype"`
  3775. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3776. PausInsuDate string `json:"paus_insu_date"`
  3777. PsnInsuDate string `json:"psn_insu_date"`
  3778. PsnInsuStas string `json:"psn_insu_stas"`
  3779. PsnType string `json:"psn_type"`
  3780. } `json:"insuinfo"`
  3781. } `json:"output"`
  3782. RefmsgTime string `json:"refmsg_time"`
  3783. RespondTime string `json:"respond_time"`
  3784. Signtype interface{} `json:"signtype"`
  3785. WarnInfo interface{} `json:"warn_info"`
  3786. }
  3787. type ResultThree struct {
  3788. Cainfo interface{} `json:"cainfo"`
  3789. ErrMsg string `json:"err_msg"`
  3790. InfRefmsgid string `json:"inf_refmsgid"`
  3791. Infcode int64 `json:"infcode"`
  3792. Output struct {
  3793. Data struct {
  3794. IptOtpNo string `json:"ipt_otp_no"`
  3795. MdtrtID string `json:"mdtrt_id"`
  3796. PsnNo string `json:"psn_no"`
  3797. } `json:"data"`
  3798. } `json:"output"`
  3799. RefmsgTime string `json:"refmsg_time"`
  3800. RespondTime string `json:"respond_time"`
  3801. Signtype interface{} `json:"signtype"`
  3802. WarnMsg interface{} `json:"warn_msg"`
  3803. }
  3804. type ResultThree10265 struct {
  3805. Cainfo interface{} `json:"cainfo"`
  3806. ErrMsg string `json:"err_msg"`
  3807. InfRefmsgid string `json:"inf_refmsgid"`
  3808. Infcode string `json:"infcode"`
  3809. Output struct {
  3810. Data struct {
  3811. IptOtpNo string `json:"ipt_otp_no"`
  3812. MdtrtID string `json:"mdtrt_id"`
  3813. PsnNo string `json:"psn_no"`
  3814. } `json:"data"`
  3815. } `json:"output"`
  3816. RefmsgTime string `json:"refmsg_time"`
  3817. RespondTime string `json:"respond_time"`
  3818. Signtype interface{} `json:"signtype"`
  3819. WarnMsg interface{} `json:"warn_msg"`
  3820. }
  3821. type ResultFour struct {
  3822. Cainfo string `json:"cainfo"`
  3823. ErrMsg string `json:"err_msg"`
  3824. InfRefmsgid string `json:"inf_refmsgid"`
  3825. Infcode int64 `json:"infcode"`
  3826. Output struct {
  3827. Result []struct {
  3828. BasMednFlag string `json:"bas_medn_flag"`
  3829. ChldMedcFlag string `json:"chld_medc_flag"`
  3830. ChrgitmLv string `json:"chrgitm_lv"`
  3831. Cnt float64 `json:"cnt"`
  3832. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3833. DrtReimFlag string `json:"drt_reim_flag"`
  3834. FeedetlSn string `json:"feedetl_sn"`
  3835. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3836. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3837. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3838. ListSpItemFlag string `json:"list_sp_item_flag"`
  3839. LmtUsedFlag string `json:"lmt_used_flag"`
  3840. MedChrgitmType string `json:"med_chrgitm_type"`
  3841. Memo string `json:"memo"`
  3842. OverlmtAmt float64 `json:"overlmt_amt"`
  3843. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3844. Pric float64 `json:"pric"`
  3845. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3846. SelfpayProp float64 `json:"selfpay_prop"`
  3847. } `json:"result"`
  3848. } `json:"output"`
  3849. RefmsgTime string `json:"refmsg_time"`
  3850. RespondTime string `json:"respond_time"`
  3851. Signtype string `json:"signtype"`
  3852. WarnMsg string `json:"warn_msg"`
  3853. }
  3854. type ResultFour10265 struct {
  3855. Cainfo string `json:"cainfo"`
  3856. ErrMsg string `json:"err_msg"`
  3857. InfRefmsgid string `json:"inf_refmsgid"`
  3858. Infcode string `json:"infcode"`
  3859. Output struct {
  3860. Result []struct {
  3861. BasMednFlag string `json:"bas_medn_flag"`
  3862. ChldMedcFlag string `json:"chld_medc_flag"`
  3863. ChrgitmLv string `json:"chrgitm_lv"`
  3864. Cnt float64 `json:"cnt"`
  3865. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3866. DrtReimFlag string `json:"drt_reim_flag"`
  3867. FeedetlSn string `json:"feedetl_sn"`
  3868. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3869. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3870. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3871. ListSpItemFlag string `json:"list_sp_item_flag"`
  3872. LmtUsedFlag string `json:"lmt_used_flag"`
  3873. MedChrgitmType string `json:"med_chrgitm_type"`
  3874. Memo string `json:"memo"`
  3875. OverlmtAmt float64 `json:"overlmt_amt"`
  3876. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3877. Pric float64 `json:"pric"`
  3878. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3879. SelfpayProp float64 `json:"selfpay_prop"`
  3880. } `json:"result"`
  3881. } `json:"output"`
  3882. RefmsgTime string `json:"refmsg_time"`
  3883. RespondTime string `json:"respond_time"`
  3884. Signtype string `json:"signtype"`
  3885. WarnMsg string `json:"warn_msg"`
  3886. }
  3887. type ResultFive struct {
  3888. Balc float64 `json:"balc"`
  3889. CvlservFlag string `json:"cvlserv_flag"`
  3890. EmpName string `json:"emp_name"`
  3891. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3892. Insutype string `json:"insutype"`
  3893. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3894. PausInsuDate string `json:"paus_insu_date"`
  3895. PsnInsuDate string `json:"psn_insu_date"`
  3896. PsnInsuStas string `json:"psn_insu_stas"`
  3897. PsnType string `json:"psn_type"`
  3898. }
  3899. type ResultSix struct {
  3900. Cainfo interface{} `json:"cainfo"`
  3901. ErrMsg string `json:"err_msg"`
  3902. InfRefmsgid string `json:"inf_refmsgid"`
  3903. Infcode int64 `json:"infcode"`
  3904. RefmsgTime string `json:"refmsg_time"`
  3905. RespondTime string `json:"respond_time"`
  3906. Signtype interface{} `json:"signtype"`
  3907. WarnMsg interface{} `json:"warn_msg"`
  3908. }
  3909. type ResultSix10265 struct {
  3910. Cainfo interface{} `json:"cainfo"`
  3911. ErrMsg string `json:"err_msg"`
  3912. InfRefmsgid string `json:"inf_refmsgid"`
  3913. Infcode string `json:"infcode"`
  3914. Output struct {
  3915. } `json:"output"`
  3916. RefmsgTime string `json:"refmsg_time"`
  3917. RespondTime string `json:"respond_time"`
  3918. Signtype interface{} `json:"signtype"`
  3919. WarnMsg interface{} `json:"warn_msg"`
  3920. }
  3921. type ResultSeven struct {
  3922. Cainfo string `json:"cainfo"`
  3923. ErrMsg string `json:"err_msg"`
  3924. InfRefmsgid string `json:"inf_refmsgid"`
  3925. Infcode int64 `json:"infcode"`
  3926. Output struct {
  3927. Setldetail []interface{} `json:"setldetail"`
  3928. Setlinfo struct {
  3929. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3930. AcctPay float64 `json:"acct_pay"`
  3931. ActPayDedc float64 `json:"act_pay_dedc"`
  3932. Age float64 `json:"age"`
  3933. Balc float64 `json:"balc"`
  3934. Brdy string `json:"brdy"`
  3935. Certno string `json:"certno"`
  3936. ClrOptins string `json:"clr_optins"`
  3937. ClrType string `json:"clr_type"`
  3938. ClrWay string `json:"clr_way"`
  3939. CvlservFlag string `json:"cvlserv_flag"`
  3940. CvlservPay float64 `json:"cvlserv_pay"`
  3941. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3942. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3943. Gend string `json:"gend"`
  3944. HifesPay float64 `json:"hifes_pay"`
  3945. HifmiPay float64 `json:"hifmi_pay"`
  3946. HifpPay float64 `json:"hifp_pay"`
  3947. HospPartAmt float64 `json:"hosp_part_amt"`
  3948. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3949. Insutype string `json:"insutype"`
  3950. MafPay float64 `json:"maf_pay"`
  3951. MdtrtCertType string `json:"mdtrt_cert_type"`
  3952. HifobPay float64 `json:"hifob_pay"`
  3953. MdtrtID string `json:"mdtrt_id"`
  3954. MedType string `json:"med_type"`
  3955. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3956. MedinsSetlID string `json:"medins_setl_id"`
  3957. Naty string `json:"naty"`
  3958. OthPay float64 `json:"oth_pay"`
  3959. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3960. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3961. PsnCashPay float64 `json:"psn_cash_pay"`
  3962. PsnCertType string `json:"psn_cert_type"`
  3963. PsnName string `json:"psn_name"`
  3964. PsnNo string `json:"psn_no"`
  3965. PsnPartAmt float64 `json:"psn_part_amt"`
  3966. PsnType string `json:"psn_type"`
  3967. SetlID string `json:"setl_id"`
  3968. SetlTime string `json:"setl_time"`
  3969. } `json:"setlinfo"`
  3970. } `json:"output"`
  3971. RefmsgTime string `json:"refmsg_time"`
  3972. RespondTime string `json:"respond_time"`
  3973. Signtype interface{} `json:"signtype"`
  3974. WarnMsg interface{} `json:"warn_msg"`
  3975. }
  3976. type ResultSeven10265 struct {
  3977. Cainfo string `json:"cainfo"`
  3978. ErrMsg string `json:"err_msg"`
  3979. InfRefmsgid string `json:"inf_refmsgid"`
  3980. Infcode string `json:"infcode"`
  3981. Output struct {
  3982. Setldetail []interface{} `json:"setldetail"`
  3983. Setlinfo struct {
  3984. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3985. AcctPay float64 `json:"acct_pay"`
  3986. ActPayDedc float64 `json:"act_pay_dedc"`
  3987. Age float64 `json:"age"`
  3988. Balc float64 `json:"balc"`
  3989. Brdy string `json:"brdy"`
  3990. Certno string `json:"certno"`
  3991. ClrOptins string `json:"clr_optins"`
  3992. ClrType string `json:"clr_type"`
  3993. ClrWay string `json:"clr_way"`
  3994. CvlservFlag string `json:"cvlserv_flag"`
  3995. CvlservPay float64 `json:"cvlserv_pay"`
  3996. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3997. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3998. Gend string `json:"gend"`
  3999. HifesPay float64 `json:"hifes_pay"`
  4000. HifmiPay float64 `json:"hifmi_pay"`
  4001. HifpPay float64 `json:"hifp_pay"`
  4002. HospPartAmt float64 `json:"hosp_part_amt"`
  4003. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4004. Insutype string `json:"insutype"`
  4005. MafPay float64 `json:"maf_pay"`
  4006. MdtrtCertType string `json:"mdtrt_cert_type"`
  4007. HifobPay float64 `json:"hifob_pay"`
  4008. MdtrtID string `json:"mdtrt_id"`
  4009. MedType string `json:"med_type"`
  4010. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4011. MedinsSetlID string `json:"medins_setl_id"`
  4012. Naty string `json:"naty"`
  4013. OthPay float64 `json:"oth_pay"`
  4014. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4015. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4016. PsnCashPay float64 `json:"psn_cash_pay"`
  4017. PsnCertType string `json:"psn_cert_type"`
  4018. PsnName string `json:"psn_name"`
  4019. PsnNo string `json:"psn_no"`
  4020. PsnPartAmt float64 `json:"psn_part_amt"`
  4021. PsnType string `json:"psn_type"`
  4022. SetlID string `json:"setl_id"`
  4023. SetlTime string `json:"setl_time"`
  4024. } `json:"setlinfo"`
  4025. } `json:"output"`
  4026. RefmsgTime string `json:"refmsg_time"`
  4027. RespondTime string `json:"respond_time"`
  4028. Signtype interface{} `json:"signtype"`
  4029. WarnMsg interface{} `json:"warn_msg"`
  4030. }
  4031. type ResultEight struct {
  4032. Cainfo string `json:"cainfo"`
  4033. ErrMsg string `json:"err_msg"`
  4034. InfRefmsgid string `json:"inf_refmsgid"`
  4035. Infcode int64 `json:"infcode"`
  4036. Output struct {
  4037. Stmtinfo struct {
  4038. SetlOptins string `json:"setl_optins"`
  4039. StmtRslt string `json:"stmt_rslt"`
  4040. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  4041. } `json:"stmtinfo"`
  4042. } `json:"output"`
  4043. RefmsgTime string `json:"refmsg_time"`
  4044. RespondTime string `json:"respond_time"`
  4045. Signtype interface{} `json:"signtype"`
  4046. WarnMsg interface{} `json:"warn_msg"`
  4047. }
  4048. type ResultEightFor10188 struct {
  4049. Cainfo string `json:"cainfo"`
  4050. ErrMsg string `json:"err_msg"`
  4051. InfRefmsgid string `json:"inf_refmsgid"`
  4052. Infcode string `json:"infcode"`
  4053. Output struct {
  4054. Stmtinfo struct {
  4055. SetlOptins string `json:"setl_optins"`
  4056. StmtRslt string `json:"stmt_rslt"`
  4057. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  4058. } `json:"stmtinfo"`
  4059. } `json:"output"`
  4060. RefmsgTime string `json:"refmsg_time"`
  4061. RespondTime string `json:"respond_time"`
  4062. Signtype interface{} `json:"signtype"`
  4063. WarnMsg interface{} `json:"warn_msg"`
  4064. }
  4065. type ResultNine struct {
  4066. Cainfo string `json:"cainfo"`
  4067. ErrMsg string `json:"err_msg"`
  4068. InfRefmsgid string `json:"inf_refmsgid"`
  4069. Infcode int64 `json:"infcode"`
  4070. Output struct {
  4071. FileQuryNo string `json:"file_qury_no"`
  4072. } `json:"output"`
  4073. RefmsgTime string `json:"refmsg_time"`
  4074. RespondTime string `json:"respond_time"`
  4075. Signtype interface{} `json:"signtype"`
  4076. WarnMsg interface{} `json:"warn_msg"`
  4077. }
  4078. type ResultTen struct {
  4079. Cainfo string `json:"cainfo"`
  4080. ErrMsg string `json:"err_msg"`
  4081. InfRefmsgid string `json:"inf_refmsgid"`
  4082. Infcode int64 `json:"infcode"`
  4083. Output struct {
  4084. DldEndtime string `json:"dld_endtime"`
  4085. FileQuryNo string `json:"file_qury_no"`
  4086. Filename string `json:"filename"`
  4087. } `json:"output"`
  4088. RefmsgTime string `json:"refmsg_time"`
  4089. RespondTime string `json:"respond_time"`
  4090. Signtype interface{} `json:"signtype"`
  4091. WarnMsg interface{} `json:"warn_msg"`
  4092. }
  4093. //type Autogenerated struct {
  4094. // Output struct {
  4095. // Setlinfo struct {
  4096. // SetlTime string `json:"setl_time"`
  4097. // CvlservPay float64 `json:"cvlserv_pay"`
  4098. // Year string `json:"year"`
  4099. // MedType string `json:"med_type"`
  4100. // PsnPay float64 `json:"psn_pay"`
  4101. // OpterID string `json:"opter_id"`
  4102. // Begndate string `json:"begndate"`
  4103. // FlxempeFlag string `json:"flxempe_flag"`
  4104. // HifmiPay float64 `json:"hifmi_pay"`
  4105. // PsnNo string `json:"psn_no"`
  4106. // ActPayDedc float64 `json:"act_pay_dedc"`
  4107. // MedinsSetlID interface{} `json:"medins_setl_id"`
  4108. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4109. // ClrWay string `json:"clr_way"`
  4110. // OthPay float64 `json:"oth_pay"`
  4111. // Gend string `json:"gend"`
  4112. // MdtrtID string `json:"mdtrt_id"`
  4113. // AcctPay float64 `json:"acct_pay"`
  4114. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  4115. // Insutype string `json:"insutype"`
  4116. // Invono interface{} `json:"invono"`
  4117. // Enddate string `json:"enddate"`
  4118. // CashPayamt float64 `json:"cash_payamt"`
  4119. // PsnType string `json:"psn_type"`
  4120. // FixmedinsName string `json:"fixmedins_name"`
  4121. // HifpPay float64 `json:"hifp_pay"`
  4122. // NewFlag interface{} `json:"new_flag"`
  4123. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4124. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  4125. // PayLoc string `json:"pay_loc"`
  4126. // ClrType string `json:"clr_type"`
  4127. // RefdSetlFlag string `json:"refd_setl_flag"`
  4128. // CvlservFlag string `json:"cvlserv_flag"`
  4129. // EmpName string `json:"emp_name"`
  4130. // Brdy string `json:"brdy"`
  4131. // Naty string `json:"naty"`
  4132. // Certno string `json:"certno"`
  4133. // DiseCode string `json:"dise_code"`
  4134. // FixmedinsCode string `json:"fixmedins_code"`
  4135. // DedcHospLv string `json:"dedc_hosp_lv"`
  4136. // OpterName string `json:"opter_name"`
  4137. // Balc float64 `json:"balc"`
  4138. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4139. // PsnCertType string `json:"psn_cert_type"`
  4140. // HifobPay float64 `json:"hifob_pay"`
  4141. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  4142. // HifesPay float64 `json:"hifes_pay"`
  4143. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4144. // OptTime string `json:"opt_time"`
  4145. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4146. // SetlID string `json:"setl_id"`
  4147. // MafPay float64 `json:"maf_pay"`
  4148. // PsnName string `json:"psn_name"`
  4149. // InsuOptins interface{} `json:"insu_optins"`
  4150. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4151. // ClrOptins string `json:"clr_optins"`
  4152. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4153. // DiseName string `json:"dise_name"`
  4154. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4155. // Age float64 `json:"age"`
  4156. // DtrtCertType string `json:"dtrt_cert_type"`
  4157. // HospLv string `json:"hosp_lv"`
  4158. // } `json:"setlinfo"`
  4159. // Setldetail []struct {
  4160. // FundPayType string `json:"fund_pay_type"`
  4161. // FundPayamt float64 `json:"fund_payamt"`
  4162. // SetlProcInfo interface{} `json:"setl_proc_info"`
  4163. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  4164. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  4165. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  4166. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4167. // } `json:"setldetail"`
  4168. // } `json:"output"`
  4169. // Infcode int `json:"infcode"`
  4170. // WarnMsg interface{} `json:"warn_msg"`
  4171. // Cainfo interface{} `json:"cainfo"`
  4172. // ErrMsg interface{} `json:"err_msg"`
  4173. // RefmsgTime string `json:"refmsg_time"`
  4174. // Signtype interface{} `json:"signtype"`
  4175. // RespondTime string `json:"respond_time"`
  4176. // InfRefmsgid string `json:"inf_refmsgid"`
  4177. //}
  4178. type ResultEleven struct {
  4179. Cainfo string `json:"cainfo"`
  4180. ErrMsg string `json:"err_msg"`
  4181. InfRefmsgid string `json:"inf_refmsgid"`
  4182. Infcode int64 `json:"infcode"`
  4183. Output struct {
  4184. Setlinfo struct {
  4185. SetlTime string `json:"setl_time"`
  4186. CvlservPay float64 `json:"cvlserv_pay"`
  4187. Year string `json:"year"`
  4188. MedType string `json:"med_type"`
  4189. PsnPay float64 `json:"psn_pay"`
  4190. OpterID string `json:"opter_id"`
  4191. Begndate string `json:"begndate"`
  4192. FlxempeFlag string `json:"flxempe_flag"`
  4193. HifmiPay float64 `json:"hifmi_pay"`
  4194. PsnNo string `json:"psn_no"`
  4195. ActPayDedc float64 `json:"act_pay_dedc"`
  4196. MedinsSetlID interface{} `json:"medins_setl_id"`
  4197. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4198. ClrWay string `json:"clr_way"`
  4199. OthPay float64 `json:"oth_pay"`
  4200. Gend string `json:"gend"`
  4201. MdtrtID string `json:"mdtrt_id"`
  4202. AcctPay float64 `json:"acct_pay"`
  4203. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4204. Insutype string `json:"insutype"`
  4205. Invono interface{} `json:"invono"`
  4206. Enddate string `json:"enddate"`
  4207. CashPayamt float64 `json:"cash_payamt"`
  4208. PsnType string `json:"psn_type"`
  4209. FixmedinsName string `json:"fixmedins_name"`
  4210. HifpPay float64 `json:"hifp_pay"`
  4211. NewFlag interface{} `json:"new_flag"`
  4212. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4213. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4214. PayLoc string `json:"pay_loc"`
  4215. ClrType string `json:"clr_type"`
  4216. RefdSetlFlag string `json:"refd_setl_flag"`
  4217. CvlservFlag string `json:"cvlserv_flag"`
  4218. EmpName string `json:"emp_name"`
  4219. Brdy string `json:"brdy"`
  4220. Naty string `json:"naty"`
  4221. Certno string `json:"certno"`
  4222. DiseCode string `json:"dise_code"`
  4223. FixmedinsCode string `json:"fixmedins_code"`
  4224. DedcHospLv string `json:"dedc_hosp_lv"`
  4225. OpterName string `json:"opter_name"`
  4226. Balc float64 `json:"balc"`
  4227. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4228. PsnCertType string `json:"psn_cert_type"`
  4229. HifobPay float64 `json:"hifob_pay"`
  4230. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4231. HifesPay float64 `json:"hifes_pay"`
  4232. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4233. OptTime string `json:"opt_time"`
  4234. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4235. SetlID string `json:"setl_id"`
  4236. MafPay float64 `json:"maf_pay"`
  4237. PsnName string `json:"psn_name"`
  4238. InsuOptins interface{} `json:"insu_optins"`
  4239. PrefFundPay interface{} `json:"pref_fund_pay"`
  4240. ClrOptins string `json:"clr_optins"`
  4241. DiseName string `json:"dise_name"`
  4242. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4243. Age float64 `json:"age"`
  4244. DtrtCertType string `json:"dtrt_cert_type"`
  4245. HospLv string `json:"hosp_lv"`
  4246. } `json:"setlinfo"`
  4247. } `json:"output"`
  4248. RefmsgTime string `json:"refmsg_time"`
  4249. RespondTime string `json:"respond_time"`
  4250. Signtype interface{} `json:"signtype"`
  4251. WarnMsg interface{} `json:"warn_msg"`
  4252. }
  4253. type ResultEleven10265 struct {
  4254. Cainfo string `json:"cainfo"`
  4255. ErrMsg string `json:"err_msg"`
  4256. InfRefmsgid string `json:"inf_refmsgid"`
  4257. Infcode string `json:"infcode"`
  4258. Output struct {
  4259. Setlinfo struct {
  4260. SetlTime string `json:"setl_time"`
  4261. CvlservPay float64 `json:"cvlserv_pay"`
  4262. Year string `json:"year"`
  4263. MedType string `json:"med_type"`
  4264. PsnPay float64 `json:"psn_pay"`
  4265. OpterID string `json:"opter_id"`
  4266. Begndate string `json:"begndate"`
  4267. FlxempeFlag string `json:"flxempe_flag"`
  4268. HifmiPay float64 `json:"hifmi_pay"`
  4269. PsnNo string `json:"psn_no"`
  4270. ActPayDedc float64 `json:"act_pay_dedc"`
  4271. MedinsSetlID interface{} `json:"medins_setl_id"`
  4272. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4273. ClrWay string `json:"clr_way"`
  4274. OthPay float64 `json:"oth_pay"`
  4275. Gend string `json:"gend"`
  4276. MdtrtID string `json:"mdtrt_id"`
  4277. AcctPay float64 `json:"acct_pay"`
  4278. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4279. Insutype string `json:"insutype"`
  4280. Invono interface{} `json:"invono"`
  4281. Enddate string `json:"enddate"`
  4282. CashPayamt float64 `json:"cash_payamt"`
  4283. PsnType string `json:"psn_type"`
  4284. FixmedinsName string `json:"fixmedins_name"`
  4285. HifpPay float64 `json:"hifp_pay"`
  4286. NewFlag interface{} `json:"new_flag"`
  4287. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4288. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4289. PayLoc string `json:"pay_loc"`
  4290. ClrType string `json:"clr_type"`
  4291. RefdSetlFlag string `json:"refd_setl_flag"`
  4292. CvlservFlag string `json:"cvlserv_flag"`
  4293. EmpName string `json:"emp_name"`
  4294. Brdy string `json:"brdy"`
  4295. Naty string `json:"naty"`
  4296. Certno string `json:"certno"`
  4297. DiseCode string `json:"dise_code"`
  4298. FixmedinsCode string `json:"fixmedins_code"`
  4299. DedcHospLv string `json:"dedc_hosp_lv"`
  4300. OpterName string `json:"opter_name"`
  4301. Balc float64 `json:"balc"`
  4302. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4303. PsnCertType string `json:"psn_cert_type"`
  4304. HifobPay float64 `json:"hifob_pay"`
  4305. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4306. HifesPay float64 `json:"hifes_pay"`
  4307. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4308. OptTime string `json:"opt_time"`
  4309. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4310. SetlID string `json:"setl_id"`
  4311. MafPay float64 `json:"maf_pay"`
  4312. PsnName string `json:"psn_name"`
  4313. InsuOptins interface{} `json:"insu_optins"`
  4314. PrefFundPay interface{} `json:"pref_fund_pay"`
  4315. ClrOptins string `json:"clr_optins"`
  4316. DiseName string `json:"dise_name"`
  4317. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4318. Age float64 `json:"age"`
  4319. DtrtCertType string `json:"dtrt_cert_type"`
  4320. HospLv string `json:"hosp_lv"`
  4321. } `json:"setlinfo"`
  4322. } `json:"output"`
  4323. RefmsgTime string `json:"refmsg_time"`
  4324. RespondTime string `json:"respond_time"`
  4325. Signtype interface{} `json:"signtype"`
  4326. WarnMsg interface{} `json:"warn_msg"`
  4327. }
  4328. type ResultTwelve struct {
  4329. Cainfo string `json:"cainfo"`
  4330. ErrMsg string `json:"err_msg"`
  4331. InfRefmsgid string `json:"inf_refmsgid"`
  4332. Infcode int64 `json:"infcode"`
  4333. Output struct {
  4334. MdtrtId string `json:"mdtrt_id"`
  4335. ChrgBchno string `json:"chrg_bchno"`
  4336. PsnNo string `json:"psn_no"`
  4337. } `json:"output"`
  4338. RefmsgTime string `json:"refmsg_time"`
  4339. RespondTime string `json:"respond_time"`
  4340. Signtype interface{} `json:"signtype"`
  4341. WarnMsg interface{} `json:"warn_msg"`
  4342. }
  4343. type ResultThirteen struct {
  4344. ErrMsg string `json:"err_msg"`
  4345. InfRefmsgid string `json:"inf_refmsgid"`
  4346. Infcode int64 `json:"infcode"`
  4347. Output struct {
  4348. Result struct {
  4349. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4350. } `json:"result"`
  4351. } `json:"output"`
  4352. RefmsgTime string `json:"refmsg_time"`
  4353. RespondTime string `json:"respond_time"`
  4354. Signtype interface{} `json:"signtype"`
  4355. WarnInfo interface{} `json:"warn_info"`
  4356. }
  4357. type ResultThirteen10265 struct {
  4358. ErrMsg string `json:"err_msg"`
  4359. InfRefmsgid string `json:"inf_refmsgid"`
  4360. Infcode string `json:"infcode"`
  4361. Output struct {
  4362. Result struct {
  4363. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4364. } `json:"result"`
  4365. } `json:"output"`
  4366. RefmsgTime string `json:"refmsg_time"`
  4367. RespondTime string `json:"respond_time"`
  4368. Signtype interface{} `json:"signtype"`
  4369. WarnInfo interface{} `json:"warn_info"`
  4370. }
  4371. type ResultFourteen struct {
  4372. ErrMsg string `json:"err_msg"`
  4373. InfRefmsgid string `json:"inf_refmsgid"`
  4374. Infcode int64 `json:"infcode"`
  4375. Output struct {
  4376. } `json:"output"`
  4377. RefmsgTime string `json:"refmsg_time"`
  4378. RespondTime string `json:"respond_time"`
  4379. Signtype interface{} `json:"signtype"`
  4380. WarnInfo interface{} `json:"warn_info"`
  4381. }
  4382. type ResultFourteen10265 struct {
  4383. ErrMsg string `json:"err_msg"`
  4384. InfRefmsgid string `json:"inf_refmsgid"`
  4385. Infcode string `json:"infcode"`
  4386. Output struct {
  4387. } `json:"output"`
  4388. RefmsgTime string `json:"refmsg_time"`
  4389. RespondTime string `json:"respond_time"`
  4390. Signtype interface{} `json:"signtype"`
  4391. WarnInfo interface{} `json:"warn_info"`
  4392. }
  4393. type ResultSixteen struct {
  4394. Cainfo string `json:"cainfo"`
  4395. ErrMsg string `json:"err_msg"`
  4396. InfRefmsgid string `json:"inf_refmsgid"`
  4397. Infcode int64 `json:"infcode"`
  4398. Output struct {
  4399. Setldetail []interface{} `json:"setldetail"`
  4400. Setlinfo struct {
  4401. MdtrtID string `json:"mdtrt_id"`
  4402. SetlID string `json:"setl_id"`
  4403. ClrOptins string `json:"clr_optins"`
  4404. SetlTime string `json:"setl_time"`
  4405. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4406. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4407. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4408. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4409. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4410. ActPayDedc float64 `json:"act_pay_dedc"`
  4411. HifpPay float64 `json:"hifp_pay"`
  4412. Lfpay float64 `json:"selfpay"`
  4413. CvlservPay float64 `json:"cvlserv_pay"`
  4414. HifesPay float64 `json:"hifes_pay"`
  4415. HifmiPay float64 `json:"hifmi_pay"`
  4416. HifobPay float64 `json:"hifob_pay"`
  4417. MafPay float64 `json:"maf_pay"`
  4418. OthPay float64 `json:"oth_pay"`
  4419. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4420. PsnPartAmt float64 `json:"psn_part_amt"`
  4421. AcctPay float64 `json:"acct_pay"`
  4422. Balc float64 `json:"balc"`
  4423. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4424. HospPartAmt float64 `json:"hosp_part_amt"`
  4425. MedinsSetlID string `json:"medins_setl_id"`
  4426. PdnCashPay string `json:"pdn_cash_pay"`
  4427. } `json:"setlinfo"`
  4428. } `json:"output"`
  4429. RefmsgTime string `json:"refmsg_time"`
  4430. RespondTime string `json:"respond_time"`
  4431. Signtype interface{} `json:"signtype"`
  4432. WarnMsg interface{} `json:"warn_msg"`
  4433. }
  4434. type ResultSixteen10265 struct {
  4435. Cainfo string `json:"cainfo"`
  4436. ErrMsg string `json:"err_msg"`
  4437. InfRefmsgid string `json:"inf_refmsgid"`
  4438. Infcode string `json:"infcode"`
  4439. Output struct {
  4440. Setldetail []interface{} `json:"setldetail"`
  4441. Setlinfo struct {
  4442. MdtrtID string `json:"mdtrt_id"`
  4443. SetlID string `json:"setl_id"`
  4444. ClrOptins string `json:"clr_optins"`
  4445. SetlTime string `json:"setl_time"`
  4446. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4447. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4448. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4449. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4450. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4451. ActPayDedc float64 `json:"act_pay_dedc"`
  4452. HifpPay float64 `json:"hifp_pay"`
  4453. Lfpay float64 `json:"selfpay"`
  4454. CvlservPay float64 `json:"cvlserv_pay"`
  4455. HifesPay float64 `json:"hifes_pay"`
  4456. HifmiPay float64 `json:"hifmi_pay"`
  4457. HifobPay float64 `json:"hifob_pay"`
  4458. MafPay float64 `json:"maf_pay"`
  4459. OthPay float64 `json:"oth_pay"`
  4460. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4461. PsnPartAmt float64 `json:"psn_part_amt"`
  4462. AcctPay float64 `json:"acct_pay"`
  4463. Balc float64 `json:"balc"`
  4464. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4465. HospPartAmt float64 `json:"hosp_part_amt"`
  4466. MedinsSetlID string `json:"medins_setl_id"`
  4467. PdnCashPay string `json:"pdn_cash_pay"`
  4468. } `json:"setlinfo"`
  4469. } `json:"output"`
  4470. RefmsgTime string `json:"refmsg_time"`
  4471. RespondTime string `json:"respond_time"`
  4472. Signtype interface{} `json:"signtype"`
  4473. WarnMsg interface{} `json:"warn_msg"`
  4474. }
  4475. type ResultSeventeen struct {
  4476. ErrMsg string `json:"err_msg"`
  4477. InfRefmsgid string `json:"inf_refmsgid"`
  4478. Infcode int64 `json:"infcode"`
  4479. Output struct {
  4480. SetlListId string `json:"setl_list_id"`
  4481. } `json:"output"`
  4482. RefmsgTime string `json:"refmsg_time"`
  4483. RespondTime string `json:"respond_time"`
  4484. Signtype string `json:"signtype"`
  4485. WarnInfo string `json:"warn_info"`
  4486. }
  4487. type ResultSeventeenOther struct {
  4488. ErrMsg string `json:"err_msg"`
  4489. InfRefmsgid string `json:"inf_refmsgid"`
  4490. Infcode string `json:"infcode"`
  4491. Output struct {
  4492. SetlListId string `json:"setl_list_id"`
  4493. } `json:"output"`
  4494. RefmsgTime string `json:"refmsg_time"`
  4495. RespondTime string `json:"respond_time"`
  4496. Signtype string `json:"signtype"`
  4497. WarnInfo string `json:"warn_info"`
  4498. }
  4499. type Result90991 struct {
  4500. ErrMsg string `json:"err_msg"`
  4501. InfRefmsgid string `json:"inf_refmsgid"`
  4502. Infcode int64 `json:"infcode"`
  4503. Output struct {
  4504. Result struct {
  4505. PsnNo string `json:"psn_no"`
  4506. CardStat string `json:"card_stat"`
  4507. Certno string `json:"certno"`
  4508. PsnName string `json:"psn_name"`
  4509. CheckStat string `json:"check_stat"`
  4510. SscnoCheckStat string `json:"sscno_check_stat"`
  4511. } `json:"result"`
  4512. } `json:"output"`
  4513. RefmsgTime string `json:"refmsg_time"`
  4514. RespondTime string `json:"respond_time"`
  4515. Signtype interface{} `json:"signtype"`
  4516. WarnInfo interface{} `json:"warn_info"`
  4517. }
  4518. type Result90100 struct {
  4519. ErrMsg string `json:"err_msg"`
  4520. InfRefmsgid string `json:"inf_refmsgid"`
  4521. Infcode int64 `json:"infcode"`
  4522. Output struct {
  4523. PoolareaNo string `json:"poolarea_no"`
  4524. PoolareaNoName string `json:"poolarea_no_name"`
  4525. Insutype string `json:"insutype"`
  4526. InsutypeName string `json:"insutype_name"`
  4527. ClctType string `json:"clct_type"`
  4528. ClctTypeName string `json:"clct_type_name"`
  4529. ClctFlag string `json:"clct_flag"`
  4530. ClctFlagName string `json:"clct_flag_name"`
  4531. AccrymBegn string `json:"accrym_begn"`
  4532. AccrymEnd string `json:"accrym_end"`
  4533. ClctTime string `json:"clct_time"`
  4534. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  4535. } `json:"output"`
  4536. RefmsgTime string `json:"refmsg_time"`
  4537. RespondTime string `json:"respond_time"`
  4538. Signtype interface{} `json:"signtype"`
  4539. WarnInfo interface{} `json:"warn_info"`
  4540. }
  4541. type Custom struct {
  4542. DetItemFeeSumamt string
  4543. Cut string
  4544. FeedetlSn string
  4545. Price string
  4546. MedListCodg string
  4547. Type int64
  4548. AdviceId int64
  4549. ProjectId int64
  4550. ItemId int64
  4551. }
  4552. type Result5301 struct {
  4553. ErrMsg string `json:"err_msg"`
  4554. InfRefmsgid string `json:"inf_refmsgid"`
  4555. Infcode int64 `json:"infcode"`
  4556. Output struct {
  4557. Result []struct {
  4558. OpspDiseCode string `json:"opsp_dise_code"`
  4559. OpspDiseName string `json:"opsp_dise_name"`
  4560. Begndate string `json:"begndate"`
  4561. Enddate string `json:"enddate"`
  4562. } `json:"feedetail"`
  4563. } `json:"output"`
  4564. RefmsgTime string `json:"refmsg_time"`
  4565. RespondTime string `json:"respond_time"`
  4566. Signtype interface{} `json:"signtype"`
  4567. WarnInfo interface{} `json:"warn_info"`
  4568. }
  4569. type Result5301For10265 struct {
  4570. ErrMsg string `json:"err_msg"`
  4571. InfRefmsgid string `json:"inf_refmsgid"`
  4572. Infcode string `json:"infcode"`
  4573. Output struct {
  4574. Result []struct {
  4575. OpspDiseCode string `json:"opsp_dise_code"`
  4576. OpspDiseName string `json:"opsp_dise_name"`
  4577. Begndate string `json:"begndate"`
  4578. Enddate string `json:"enddate"`
  4579. } `json:"feedetail"`
  4580. } `json:"output"`
  4581. RefmsgTime string `json:"refmsg_time"`
  4582. RespondTime string `json:"respond_time"`
  4583. Signtype interface{} `json:"signtype"`
  4584. WarnInfo interface{} `json:"warn_info"`
  4585. }
  4586. //获取个人信息----挂号-----上传就诊信息
  4587. func (c *HisApiController) GetRegisterInfo() {
  4588. id, _ := c.GetInt64("id")
  4589. record_time := c.GetString("record_time")
  4590. settlementValue, _ := c.GetInt64("settlement_value")
  4591. medical_insurance_card := c.GetString("medical_insurance_card")
  4592. name := c.GetString("name")
  4593. id_card_type, _ := c.GetInt64("id_card_type")
  4594. certificates, _ := c.GetInt64("certificates")
  4595. medical_care, _ := c.GetInt64("medical_care")
  4596. birthday := c.GetString("birthday")
  4597. id_card := c.GetString("id_card")
  4598. register_type, _ := c.GetInt64("register")
  4599. doctor, _ := c.GetInt64("doctor")
  4600. department, _ := c.GetInt64("department")
  4601. gender, _ := c.GetInt64("sex")
  4602. registration_fee, _ := c.GetFloat("registration_fee")
  4603. medical_expenses, _ := c.GetFloat("medical_expenses")
  4604. social_type, _ := c.GetInt64("social_type")
  4605. med_type := c.GetString("social_type")
  4606. admin_user_id, _ := c.GetInt64("admin_user_id")
  4607. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4608. timeLayout := "2006-01-02"
  4609. loc, _ := time.LoadLocation("Local")
  4610. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4611. birthUnix := birthdays.Unix()
  4612. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4613. if err != nil {
  4614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4615. return
  4616. }
  4617. recordDateTime := theTime.Unix()
  4618. adminInfo := c.GetAdminUserInfo()
  4619. var patient service.Patients
  4620. if id == 0 {
  4621. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4622. } else {
  4623. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4624. }
  4625. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4626. if patientPrescription.ID == 0 {
  4627. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4628. }
  4629. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4630. if patient.ID == 0 {
  4631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4632. return
  4633. }
  4634. if len(patient.IdCardNo) == 0 {
  4635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4636. return
  4637. }
  4638. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4639. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4640. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4641. //就诊结算未完成,不能进行二次挂号
  4642. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4643. if len(his) >= 1 {
  4644. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  4645. if len(his) >= 1 && order.ID == 0 {
  4646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  4647. return
  4648. }
  4649. }
  4650. //var register_log string
  4651. if config.IsOpen == 1 {
  4652. var res ResultTwo
  4653. var res10265 ResultTwo10265
  4654. var PsnNo string
  4655. var PsnCertType string
  4656. var Certno string
  4657. var PsnName string
  4658. var Gend string
  4659. var Naty string
  4660. var Brdy string
  4661. var Age float64
  4662. var infoStr string
  4663. var idetinfoStr string
  4664. var infocode int64
  4665. var verify_number string
  4666. fmt.Println(verify_number)
  4667. if miConfig.MdtrtareaAdmvs == "421300" {
  4668. psn_info, _ := service.GetPsnByPatientId(id)
  4669. PsnNo = psn_info.PsnNo
  4670. PsnCertType = psn_info.PsnCertType
  4671. Certno = psn_info.Certno
  4672. PsnName = psn_info.PsnName
  4673. Gend = psn_info.Gend
  4674. Naty = psn_info.Naty
  4675. Brdy = psn_info.Brdy
  4676. Age = psn_info.Age
  4677. infoStr = psn_info.Insuinfo
  4678. idetinfoStr = psn_info.Idetinfo
  4679. infocode = 0
  4680. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4681. psn_info, _ := service.GetPsnByPatientId(id)
  4682. PsnNo = psn_info.PsnNo
  4683. PsnCertType = psn_info.PsnCertType
  4684. Certno = psn_info.Certno
  4685. PsnName = psn_info.PsnName
  4686. Gend = psn_info.Gend
  4687. Naty = psn_info.Naty
  4688. Brdy = psn_info.Brdy
  4689. Age = psn_info.Age
  4690. infoStr = psn_info.Insuinfo
  4691. idetinfoStr = psn_info.Idetinfo
  4692. infocode = 0
  4693. verify_number = psn_info.VerifyNumber
  4694. } else {
  4695. var result string
  4696. var requestLog string
  4697. if miConfig.UserOrgId == 10138 {
  4698. 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)
  4699. } else {
  4700. 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)
  4701. }
  4702. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4703. if miConfig.Code == "H15049901371" {
  4704. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4705. utils.ErrorLog("解析失败:%v", err)
  4706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4707. return
  4708. }
  4709. res.ErrMsg = res10265.ErrMsg
  4710. //res.Output = res10265.Output
  4711. res.InfRefmsgid = res10265.InfRefmsgid
  4712. } else {
  4713. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4714. utils.ErrorLog("解析失败:%v", err)
  4715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4716. return
  4717. }
  4718. }
  4719. PsnNo = res.Output[0].Baseinfo.PsnNo
  4720. PsnCertType = res.Output[0].Baseinfo.PsnCertType
  4721. Certno = res.Output[0].Baseinfo.Certno
  4722. PsnName = res.Output[0].Baseinfo.PsnName
  4723. Gend = res.Output[0].Baseinfo.Gend
  4724. Naty = res.Output[0].Baseinfo.Naty
  4725. Brdy = res.Output[0].Baseinfo.Brdy
  4726. Age = res.Output[0].Baseinfo.Age
  4727. Iinfos, _ := json.Marshal(res.Output[0].Iinfo)
  4728. Idetinfos, _ := json.Marshal(res.Output[0].Idetinfo)
  4729. infoStr = string(Iinfos)
  4730. idetinfoStr = string(Idetinfos)
  4731. if miConfig.Code == "H15049901371" {
  4732. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  4733. } else {
  4734. infocode = res.Infcode
  4735. }
  4736. }
  4737. if infocode == 0 {
  4738. his := models.VMHisPatient{
  4739. Name: name,
  4740. Gender: gender,
  4741. Birthday: birthUnix,
  4742. MedicalTreatmentType: medical_care,
  4743. IdType: certificates,
  4744. IdCardNo: id_card,
  4745. BalanceAccountsType: settlementValue,
  4746. SocialType: social_type,
  4747. MedicalInsuranceNumber: medical_insurance_card,
  4748. RegisterType: register_type,
  4749. RegisterCost: registration_fee,
  4750. TreatmentCost: medical_expenses,
  4751. Status: 1,
  4752. Ctime: time.Now().Unix(),
  4753. Mtime: time.Now().Unix(),
  4754. PsnNo: PsnNo,
  4755. PsnCertType: PsnCertType,
  4756. Certno: Certno,
  4757. PsnName: PsnName,
  4758. Gend: Gend,
  4759. Naty: Naty,
  4760. Brdy: Brdy,
  4761. Age: Age,
  4762. Iinfo: infoStr,
  4763. Idetinfo: idetinfoStr,
  4764. PatientId: patient.ID,
  4765. RecordDate: theTime.Unix(),
  4766. UserOrgId: adminInfo.CurrentOrgId,
  4767. AdminUserId: admin_user_id,
  4768. IsReturn: 1,
  4769. IdCardType: id_card_type,
  4770. Doctor: doctor,
  4771. Departments: department,
  4772. }
  4773. timestamp := time.Now().Unix()
  4774. tempTime := time.Unix(timestamp, 0)
  4775. timeFormat := tempTime.Format("20060102150405")
  4776. chrgBchno := rand.Intn(100000) + 10000
  4777. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4778. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  4779. department, _ := service.GetDepartMentDetail(department)
  4780. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  4781. IdCardNo := ""
  4782. if id_card_type == 1 {
  4783. // IdCardNo = medical_insurance_card
  4784. IdCardNo = patient.IdCardNo
  4785. } else {
  4786. IdCardNo = patient.IdCardNo
  4787. }
  4788. var rf []*ResultFive
  4789. json.Unmarshal([]byte(his.Iinfo), &rf)
  4790. var insutypes []*ResultFive
  4791. var insutype string
  4792. var insuplc_admdvs_temp string
  4793. var is390 int = 0
  4794. var is310 int = 0
  4795. for _, item := range rf {
  4796. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4797. insutypes = append(insutypes, item)
  4798. }
  4799. }
  4800. if len(insutypes) == 1 {
  4801. insutype = insutypes[0].Insutype
  4802. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4803. } else {
  4804. for _, i := range insutypes {
  4805. if i.Insutype == "390" {
  4806. is390 = 1
  4807. }
  4808. if i.Insutype == "310" {
  4809. is310 = 1
  4810. }
  4811. }
  4812. }
  4813. if is390 == 1 {
  4814. insutype = "390"
  4815. }
  4816. if is310 == 1 {
  4817. insutype = "310"
  4818. }
  4819. if len(insutypes) == 0 {
  4820. insutype = "310"
  4821. }
  4822. if len(insutypes) == 2 {
  4823. insutype = med_type
  4824. }
  4825. if len(med_type) > 0 {
  4826. insutype = med_type
  4827. }
  4828. //for _, item := range rf {
  4829. // if item.Insutype == insutype {
  4830. // insuplc_admdvs = item.InsuplcAdmdvs
  4831. // }
  4832. //}
  4833. var infocode int64
  4834. var resThree ResultThree
  4835. var resThree10265 ResultThree10265
  4836. if len(insuplc_admdvs) == 0 {
  4837. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  4838. } else {
  4839. insuplc_admdvs_temp = insuplc_admdvs
  4840. }
  4841. if miConfig.MdtrtareaAdmvs == "421300" {
  4842. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  4843. "&org_name=" + miConfig.OrgName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4844. "&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
  4845. resp, requestErr := http.Get(api)
  4846. if requestErr != nil {
  4847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4848. return
  4849. }
  4850. body, ioErr := ioutil.ReadAll(resp.Body)
  4851. if ioErr != nil {
  4852. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4854. return
  4855. }
  4856. var respJSON map[string]interface{}
  4857. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4858. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4860. return
  4861. }
  4862. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4863. result, _ := json.Marshal(respJSON)
  4864. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4865. utils.ErrorLog("解析失败:%v", err)
  4866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4867. return
  4868. }
  4869. infocode = resThree.Infcode
  4870. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4871. psn_info, _ := service.GetPsnByPatientId(id)
  4872. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4873. var cert_no string
  4874. if id_card_type == 3 {
  4875. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  4876. cert_no = IdCardNo
  4877. } else if id_card_type == 4 {
  4878. cert_no = IdCardNo
  4879. psn_info.VerifyNumber = psn_info.VerifyNumber
  4880. } else {
  4881. bas := strings.Split(psn_info.CardInfo, "|")
  4882. cert_no = bas[2]
  4883. }
  4884. var api string
  4885. if miConfig.MdtrtareaAdmvs == "320921" {
  4886. api = "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4887. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4888. "&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
  4889. } else {
  4890. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4891. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4892. "&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
  4893. }
  4894. resp, requestErr := http.Get(api)
  4895. if requestErr != nil {
  4896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4897. return
  4898. }
  4899. body, ioErr := ioutil.ReadAll(resp.Body)
  4900. if ioErr != nil {
  4901. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4903. return
  4904. }
  4905. var respJSON map[string]interface{}
  4906. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4907. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4909. return
  4910. }
  4911. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4912. result, _ := json.Marshal(respJSON)
  4913. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4914. utils.ErrorLog("解析失败:%v", err)
  4915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4916. return
  4917. }
  4918. resThree.ErrMsg = resThree10265.ErrMsg
  4919. resThree.Output = resThree10265.Output
  4920. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4921. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4922. } else {
  4923. 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)
  4924. saveLog(result, requestLog, "2201A", "挂号")
  4925. if miConfig.Code == "H15049901371" {
  4926. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4927. utils.ErrorLog("解析失败:%v", err)
  4928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4929. return
  4930. }
  4931. resThree.ErrMsg = resThree10265.ErrMsg
  4932. resThree.Output = resThree10265.Output
  4933. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4934. } else {
  4935. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4936. utils.ErrorLog("解析失败:%v", err)
  4937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4938. return
  4939. }
  4940. }
  4941. if miConfig.Code == "H15049901371" {
  4942. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4943. } else {
  4944. infocode = resThree.Infcode
  4945. }
  4946. }
  4947. if infocode != 0 {
  4948. adminUser := c.GetAdminUserInfo()
  4949. errlog := &models.HisOrderError{
  4950. UserOrgId: adminUser.CurrentOrgId,
  4951. Ctime: time.Now().Unix(),
  4952. Mtime: time.Now().Unix(),
  4953. ErrMsg: resThree.ErrMsg,
  4954. Status: 1,
  4955. PatientId: id,
  4956. RecordTime: recordDateTime,
  4957. Stage: 2,
  4958. }
  4959. service.CreateErrMsgLog(errlog)
  4960. c.ServeSuccessJSON(map[string]interface{}{
  4961. "failed_code": -10,
  4962. "msg": resThree.ErrMsg,
  4963. })
  4964. return
  4965. }
  4966. his.Number = resThree.Output.Data.MdtrtID
  4967. his.PsnNo = resThree.Output.Data.PsnNo
  4968. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  4969. his.IdCardNo = patient.IdCardNo
  4970. his.PhoneNumber = patient.Phone
  4971. his.UserOrgId = adminInfo.CurrentOrgId
  4972. his.Insutype = insutype
  4973. his.Ctime = time.Now().Unix()
  4974. his.Mtime = time.Now().Unix()
  4975. his.InsuplcAdmdvs = insuplc_admdvs_temp
  4976. his.Status = 1
  4977. service.UpdateHisPatientStatus(&his)
  4978. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  4979. c.ServeSuccessJSON(map[string]interface{}{
  4980. "his_info": his,
  4981. })
  4982. } else {
  4983. adminUser := c.GetAdminUserInfo()
  4984. errlog := &models.HisOrderError{
  4985. UserOrgId: adminUser.CurrentOrgId,
  4986. Ctime: time.Now().Unix(),
  4987. Mtime: time.Now().Unix(),
  4988. ErrMsg: res.ErrMsg,
  4989. Status: 1,
  4990. PatientId: id,
  4991. RecordTime: recordDateTime,
  4992. Stage: 1,
  4993. }
  4994. service.CreateErrMsgLog(errlog)
  4995. c.ServeSuccessJSON(map[string]interface{}{
  4996. "failed_code": -10,
  4997. "msg": res.ErrMsg,
  4998. })
  4999. return
  5000. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  5001. }
  5002. }
  5003. }
  5004. //上传明细----预结算----确认订单
  5005. func (c *HisApiController) GetUploadInfo() {
  5006. id, _ := c.GetInt64("id")
  5007. record_time := c.GetString("record_time")
  5008. his_patient_id, _ := c.GetInt64("his_patient_id")
  5009. order_id, _ := c.GetInt64("order_id")
  5010. pay_way, _ := c.GetInt64("pay_way")
  5011. pay_price, _ := c.GetFloat("pay_price")
  5012. pay_card_no := c.GetString("pay_card_no")
  5013. token := c.GetString("token")
  5014. discount_price, _ := c.GetFloat("discount_price")
  5015. preferential_price, _ := c.GetFloat("preferential_price")
  5016. reality_price, _ := c.GetFloat("reality_price")
  5017. found_price, _ := c.GetFloat("found_price")
  5018. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  5019. private_price, _ := c.GetFloat("private_price")
  5020. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5021. admin_user_id, _ := c.GetInt64("admin_user_id")
  5022. fapiao_code := c.GetString("fapiao_code")
  5023. fapiao_number := c.GetString("fapiao_number")
  5024. diagnosis_id := c.GetString("diagnosis")
  5025. sick_type, _ := c.GetInt64("sick_type")
  5026. reg_type, _ := c.GetInt64("p_type")
  5027. begin_time := c.GetString("begin_time")
  5028. id_str := c.GetString("ids")
  5029. ids_arr := strings.Split(id_str, ",")
  5030. timeLayout := "2006-01-02"
  5031. loc, _ := time.LoadLocation("Local")
  5032. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5033. if err != nil {
  5034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5035. return
  5036. }
  5037. recordDateTime := theTime.Unix()
  5038. adminUser := c.GetAdminUserInfo()
  5039. var tempOrder models.HisOrder
  5040. tempOrder, _ = service.GetHisOrderByID(order_id)
  5041. var prescriptions []*models.HisPrescription
  5042. var start_time int64
  5043. var end_time int64
  5044. //押金模块
  5045. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  5046. tmp_decimal := c.GetString("tmp_decimal")
  5047. var decimal float64 //本次使用的押金
  5048. var errmsg error
  5049. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  5050. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  5051. return
  5052. }
  5053. if len(tmp_decimal) > 0 {
  5054. if tmp_decimal[0] == 45 {
  5055. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  5056. return
  5057. }
  5058. }
  5059. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  5060. fmt.Println(errs)
  5061. decimal = tt
  5062. //if adminUser.CurrentOrgId == 10106{
  5063. // if len(fapiao_code) == 0{
  5064. // fapiao_code = "144072080589"
  5065. // }
  5066. // if len(fapiao_number) == 0{
  5067. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  5068. // if order.ID == 0{
  5069. // fapiao_number = "00001520"
  5070. // }else{
  5071. // //fapiao_code = "00001520"
  5072. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  5073. // var zero string
  5074. // if fpNumber >= 1000{
  5075. // zero = "0000" + strconv.Itoa(fpNumber)
  5076. // }else if fpNumber >= 10000{
  5077. // zero = "000" + strconv.Itoa(fpNumber)
  5078. // } else if fpNumber >= 100000{
  5079. // zero = "00" + strconv.Itoa(fpNumber)
  5080. // } else if fpNumber >= 1000000{
  5081. // zero = "0" + strconv.Itoa(fpNumber)
  5082. // }else {
  5083. // zero = strconv.Itoa(fpNumber)
  5084. // }
  5085. // fapiao_number = zero
  5086. // }
  5087. // }
  5088. //}
  5089. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5090. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5091. var patientPrescription models.HisPrescriptionInfo
  5092. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5093. if patientPrescription.ID == 0 {
  5094. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5095. }
  5096. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5097. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5098. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5099. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5100. var config []*models.HisXtDiagnoseConfig
  5101. for _, item := range diagnosis_ids {
  5102. id, _ := strconv.ParseInt(item, 10, 64)
  5103. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5104. config = append(config, &diagnosisConfig)
  5105. }
  5106. sickConfig, _ := service.FindSickById(sick_type)
  5107. //if tempOrder.ID == 0 {
  5108. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  5109. //}
  5110. if tempOrder.ID == 0 {
  5111. var result string
  5112. var requestLog string
  5113. var res2 ResultSix
  5114. var ressix10265 ResultSix10265
  5115. if miConfig.MdtrtareaAdmvs == "421300" {
  5116. data := make(map[string]interface{})
  5117. client := &http.Client{}
  5118. data["psn_no"] = his.PsnNo
  5119. data["mdtrt_id"] = his.Number
  5120. data["doctor"] = roles.UserName
  5121. data["department"] = department.Name
  5122. data["org_name"] = miConfig.OrgName
  5123. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5124. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5125. data["fixmedins_code"] = miConfig.Code
  5126. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5127. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5128. data["secret_key"] = miConfig.SecretKey
  5129. data["sick_code"] = sickConfig.CountryCode
  5130. data["sick_name"] = sickConfig.ClassName
  5131. data["dept"] = strconv.FormatInt(department.ID, 10)
  5132. data["config"] = config
  5133. data["begin_time"] = begin_time
  5134. bytesData, _ := json.Marshal(data)
  5135. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5136. resp, _ := client.Do(req)
  5137. defer resp.Body.Close()
  5138. body, ioErr := ioutil.ReadAll(resp.Body)
  5139. if ioErr != nil {
  5140. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5142. return
  5143. }
  5144. var respJSON map[string]interface{}
  5145. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5146. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5148. return
  5149. }
  5150. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5151. userJSONBytes, _ := json.Marshal(respJSON)
  5152. fmt.Println("log")
  5153. fmt.Println(string(userJSONBytes))
  5154. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5155. utils.ErrorLog("解析失败:%v", err)
  5156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5157. return
  5158. }
  5159. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5160. //江苏地区国家医保医疗类别
  5161. //职工透析:医疗类别选特殊情况门诊9933
  5162. //居民血透门慢: 医疗类别选门诊慢病1402
  5163. //var med_type string
  5164. //if his.Insutype == "310" {
  5165. // if reg_type == 14 {
  5166. // med_type = "9933"
  5167. // } else if reg_type == 11 {
  5168. // med_type = "11"
  5169. //
  5170. // }
  5171. //} else if his.Insutype == "390" {
  5172. // if reg_type == 14 {
  5173. // med_type = "1402"
  5174. // } else if reg_type == 11 {
  5175. // med_type = "11"
  5176. // }
  5177. //}
  5178. data := make(map[string]interface{})
  5179. client := &http.Client{}
  5180. data["psn_no"] = his.PsnNo
  5181. data["mdtrt_id"] = his.Number
  5182. data["doctor"] = roles.UserName
  5183. data["department"] = department.Name
  5184. data["org_name"] = miConfig.OrgName
  5185. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5186. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5187. data["fixmedins_code"] = miConfig.Code
  5188. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5189. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5190. data["secret_key"] = miConfig.SecretKey
  5191. data["sick_code"] = sickConfig.CountryCode
  5192. data["sick_name"] = sickConfig.ClassName
  5193. data["url"] = miConfig.Url
  5194. data["ak"] = miConfig.AccessKey
  5195. data["begin_time"] = begin_time
  5196. data["cainfo"] = miConfig.Cainfo
  5197. data["dept"] = strconv.FormatInt(department.ID, 10)
  5198. data["config"] = config
  5199. bytesData, _ := json.Marshal(data)
  5200. var req *http.Request
  5201. if miConfig.MdtrtareaAdmvs == "320921" {
  5202. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5203. //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 +
  5204. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  5205. } else {
  5206. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5207. }
  5208. resp, _ := client.Do(req)
  5209. defer resp.Body.Close()
  5210. body, ioErr := ioutil.ReadAll(resp.Body)
  5211. if ioErr != nil {
  5212. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5214. return
  5215. }
  5216. var respJSON map[string]interface{}
  5217. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5218. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5220. return
  5221. }
  5222. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5223. userJSONBytes, _ := json.Marshal(respJSON)
  5224. fmt.Println("log")
  5225. fmt.Println(string(userJSONBytes))
  5226. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5227. utils.ErrorLog("解析失败:%v", err)
  5228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5229. return
  5230. }
  5231. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5232. // res2.Output = ressix10265.Output
  5233. res2.ErrMsg = ressix10265.ErrMsg
  5234. res2.Cainfo = ressix10265.Cainfo
  5235. res2.WarnMsg = ressix10265.WarnMsg
  5236. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5237. res2.Infcode = infocode
  5238. } else {
  5239. if miConfig.MdtrtareaAdmvs == "440781" { //
  5240. 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)
  5241. } else {
  5242. if miConfig.Code == "H15049901371" {
  5243. //赤峰地区国家医保医疗类别
  5244. //职工透析:医疗类别选特殊情况门诊990502
  5245. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5246. var med_type string
  5247. if his.Insutype == "390" {
  5248. if reg_type == 14 {
  5249. med_type = "9933"
  5250. } else if reg_type == 11 {
  5251. med_type = "11"
  5252. }
  5253. } else if his.Insutype == "310" {
  5254. if reg_type == 14 {
  5255. med_type = "990502"
  5256. } else if reg_type == 11 {
  5257. med_type = "11"
  5258. }
  5259. }
  5260. 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)
  5261. } else {
  5262. var med_type string
  5263. if reg_type == 14 {
  5264. med_type = "141009"
  5265. 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)
  5266. } else if reg_type == 11 {
  5267. med_type = "11"
  5268. // sickConfig.ClassName = sic
  5269. // sickConfig.ContentCode = ""
  5270. 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)
  5271. }
  5272. }
  5273. }
  5274. saveLog(result, requestLog, "2203", "上传就诊信息")
  5275. var respJSON2 map[string]interface{}
  5276. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5277. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5279. return
  5280. }
  5281. userJSONBytes2, _ := json.Marshal(respJSON2)
  5282. if miConfig.Code == "H15049901371" {
  5283. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  5284. utils.ErrorLog("解析失败:%v", err)
  5285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5286. return
  5287. }
  5288. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5289. // res2.Output = ressix10265.Output
  5290. res2.ErrMsg = ressix10265.ErrMsg
  5291. res2.Cainfo = ressix10265.Cainfo
  5292. res2.WarnMsg = ressix10265.WarnMsg
  5293. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5294. res2.Infcode = infocode
  5295. } else {
  5296. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5297. utils.ErrorLog("解析失败:%v", err)
  5298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5299. return
  5300. }
  5301. }
  5302. }
  5303. if res2.Infcode != 0 {
  5304. adminUser := c.GetAdminUserInfo()
  5305. errlog := &models.HisOrderError{
  5306. UserOrgId: adminUser.CurrentOrgId,
  5307. Ctime: time.Now().Unix(),
  5308. Mtime: time.Now().Unix(),
  5309. ErrMsg: res2.ErrMsg,
  5310. Status: 1,
  5311. PatientId: id,
  5312. RecordTime: recordDateTime,
  5313. Stage: 3,
  5314. }
  5315. service.CreateErrMsgLog(errlog)
  5316. c.ServeSuccessJSON(map[string]interface{}{
  5317. "failed_code": -10,
  5318. "msg": res2.ErrMsg,
  5319. })
  5320. return
  5321. } else {
  5322. his.Diagnosis = diagnosis_id
  5323. his.SickType = sickConfig.ID
  5324. //var p_type int64
  5325. //if reg_type == 1111 || reg_type == 1112 {
  5326. // p_type = 11
  5327. //
  5328. //}
  5329. his.PType = fmt.Sprintf("%d", reg_type)
  5330. service.UpdateHisPatientThree(&his)
  5331. data := make(map[string]interface{})
  5332. if settle_accounts_type == 1 { //日结
  5333. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5334. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5335. } else {
  5336. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5337. }
  5338. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  5339. data["pre"] = prescriptions
  5340. } else { //月结
  5341. start_time_str := c.GetString("start_time")
  5342. end_time_str := c.GetString("end_time")
  5343. timeLayout := "2006-01-02"
  5344. loc, _ := time.LoadLocation("Local")
  5345. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5346. if err != nil {
  5347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5348. return
  5349. }
  5350. recordStartTime := theStartTime.Unix()
  5351. start_time = recordStartTime
  5352. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5353. if err != nil {
  5354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5355. return
  5356. }
  5357. recordEndTime := theEndTime.Unix()
  5358. end_time = recordEndTime
  5359. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5360. data["pre"] = prescriptions
  5361. }
  5362. timestamp := time.Now().Unix()
  5363. tempTime := time.Unix(timestamp, 0)
  5364. timeFormat := tempTime.Format("20060102150405")
  5365. chrgBchno := rand.Intn(100000) + 10000
  5366. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5367. strconv.FormatInt(his.PatientId, 10)
  5368. client := &http.Client{}
  5369. data["psn_no"] = his.PsnNo
  5370. data["mdtrt_id"] = his.Number
  5371. data["chrg_bchno"] = chrg_bchno
  5372. data["org_name"] = miConfig.OrgName
  5373. data["doctor"] = roles.UserName
  5374. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5375. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5376. data["fixmedins_code"] = miConfig.Code
  5377. //if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  5378. // data["dept_code"] = "15"
  5379. //} else {
  5380. data["dept_code"] = department.Number
  5381. //}
  5382. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5383. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5384. data["secret_key"] = miConfig.SecretKey
  5385. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5386. data["url"] = miConfig.Url
  5387. data["ak"] = miConfig.AccessKey
  5388. data["new_doctor_name"] = patientPrescription.Doctor
  5389. data["diag_code"] = sickConfig.CountryCode
  5390. data["cainfo"] = miConfig.Cainfo
  5391. var ids []int64
  5392. for _, item := range prescriptions {
  5393. ids = append(ids, item.ID)
  5394. }
  5395. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5396. if config.IsOpen == 1 { //对接了医保,走医保流程
  5397. var res ResultFour
  5398. var resFour10265 ResultFour10265
  5399. if miConfig.MdtrtareaAdmvs == "421300" {
  5400. bytesData, _ := json.Marshal(data)
  5401. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5402. resp, _ := client.Do(req)
  5403. defer resp.Body.Close()
  5404. body, ioErr := ioutil.ReadAll(resp.Body)
  5405. if ioErr != nil {
  5406. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5408. return
  5409. }
  5410. var respJSON map[string]interface{}
  5411. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5412. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5414. return
  5415. }
  5416. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5417. userJSONBytes, _ := json.Marshal(respJSON)
  5418. fmt.Println("log")
  5419. fmt.Println(string(userJSONBytes))
  5420. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5421. utils.ErrorLog("解析失败:%v", err)
  5422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5423. return
  5424. }
  5425. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5426. bytesData, _ := json.Marshal(data)
  5427. var req *http.Request
  5428. if miConfig.MdtrtareaAdmvs == "320921" {
  5429. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5430. } else {
  5431. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5432. }
  5433. resp, _ := client.Do(req)
  5434. defer resp.Body.Close()
  5435. body, ioErr := ioutil.ReadAll(resp.Body)
  5436. if ioErr != nil {
  5437. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5439. return
  5440. }
  5441. var respJSON map[string]interface{}
  5442. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5443. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5445. return
  5446. }
  5447. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5448. userJSONBytes, _ := json.Marshal(respJSON)
  5449. fmt.Println("log")
  5450. fmt.Println(string(userJSONBytes))
  5451. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5452. utils.ErrorLog("解析失败:%v", err)
  5453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5454. return
  5455. }
  5456. res.InfRefmsgid = resFour10265.InfRefmsgid
  5457. res.Output = resFour10265.Output
  5458. res.ErrMsg = resFour10265.ErrMsg
  5459. res.Cainfo = resFour10265.Cainfo
  5460. res.WarnMsg = resFour10265.WarnMsg
  5461. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5462. res.Infcode = infocode
  5463. } else {
  5464. if miConfig.Code == "H15049901371" {
  5465. 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)
  5466. var dat map[string]interface{}
  5467. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5468. fmt.Println(dat)
  5469. } else {
  5470. fmt.Println(err)
  5471. }
  5472. saveLog(result, request_log, "2204", "上传费用明细")
  5473. userJSONBytes, _ := json.Marshal(dat)
  5474. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5475. utils.ErrorLog("解析失败:%v", err)
  5476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5477. return
  5478. }
  5479. res.InfRefmsgid = resFour10265.InfRefmsgid
  5480. res.Output = resFour10265.Output
  5481. res.ErrMsg = resFour10265.ErrMsg
  5482. res.Cainfo = resFour10265.Cainfo
  5483. res.WarnMsg = resFour10265.WarnMsg
  5484. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5485. res.Infcode = infocode
  5486. } else {
  5487. 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)
  5488. var dat map[string]interface{}
  5489. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5490. fmt.Println(dat)
  5491. } else {
  5492. fmt.Println(err)
  5493. }
  5494. saveLog(result, request_log, "2204", "上传费用明细")
  5495. userJSONBytes, _ := json.Marshal(dat)
  5496. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5497. utils.ErrorLog("解析失败:%v", err)
  5498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5499. return
  5500. }
  5501. }
  5502. }
  5503. if res.Infcode == 0 {
  5504. order := &models.HisOrder{
  5505. UserOrgId: adminUser.CurrentOrgId,
  5506. HisPatientId: his.ID,
  5507. PatientId: his.PatientId,
  5508. SettleAccountsDate: recordDateTime,
  5509. MdtrtId: his.Number,
  5510. PsnNo: his.PsnNo,
  5511. MedType: strconv.FormatInt(reg_type, 10),
  5512. Ctime: time.Now().Unix(),
  5513. Mtime: time.Now().Unix(),
  5514. Status: 1,
  5515. Number: chrg_bchno,
  5516. Infcode: res.Infcode,
  5517. WarnMsg: res.WarnMsg,
  5518. Cainfo: res.Cainfo,
  5519. ErrMsg: res.ErrMsg,
  5520. RespondTime: res.RefmsgTime,
  5521. InfRefmsgid: res.InfRefmsgid,
  5522. OrderStatus: 1,
  5523. PayWay: pay_way,
  5524. PayPrice: pay_price,
  5525. PayCardNo: pay_card_no,
  5526. DiscountPrice: discount_price,
  5527. PreferentialPrice: preferential_price,
  5528. RealityPrice: reality_price,
  5529. FoundPrice: found_price,
  5530. MedicalInsurancePrice: medical_insurance_price,
  5531. PrivatePrice: private_price,
  5532. IsMedicineInsurance: 1,
  5533. SettleType: settle_accounts_type,
  5534. SettleStartTime: start_time,
  5535. SettleEndTime: end_time,
  5536. Creator: roles.AdminUserId,
  5537. Modify: roles.AdminUserId,
  5538. FaPiaoNumber: fapiao_number,
  5539. FaPiaoCode: fapiao_code,
  5540. PType: 2,
  5541. Diagnosis: diagnosis_id,
  5542. }
  5543. err = service.CreateOrder(order)
  5544. if err != nil {
  5545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5546. return
  5547. }
  5548. for _, item := range res.Output.Result {
  5549. temp := strings.Split(item.FeedetlSn, "-")
  5550. var advice_id int64 = 0
  5551. var project_id int64 = 0
  5552. var types int64 = 0
  5553. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5554. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5555. if temp[1] == "1" {
  5556. advice_id = id
  5557. project_id = 0
  5558. } else if temp[1] == "2" {
  5559. advice_id = 0
  5560. project_id = id
  5561. }
  5562. info := &models.HisOrderInfo{
  5563. OrderNumber: order.Number,
  5564. FeedetlSn: item.FeedetlSn,
  5565. UploadDate: time.Now().Unix(),
  5566. AdviceId: advice_id,
  5567. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5568. Cnt: item.Cnt,
  5569. Pric: float64(item.Pric),
  5570. PatientId: his.PatientId,
  5571. PricUplmtAmt: item.PricUplmtAmt,
  5572. SelfpayProp: item.SelfpayProp,
  5573. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5574. OverlmtAmt: item.OverlmtAmt,
  5575. PreselfpayAmt: item.PreselfpayAmt,
  5576. BasMednFlag: item.BasMednFlag,
  5577. MedChrgitmType: item.MedChrgitmType,
  5578. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5579. Status: 1,
  5580. Memo: item.Memo,
  5581. Mtime: time.Now().Unix(),
  5582. InscpScpAmt: item.InscpScpAmt,
  5583. DrtReimFlag: item.DrtReimFlag,
  5584. Ctime: time.Now().Unix(),
  5585. ListSpItemFlag: item.ListSpItemFlag,
  5586. ChldMedcFlag: item.ChldMedcFlag,
  5587. LmtUsedFlag: item.LmtUsedFlag,
  5588. ChrgitmLv: item.ChrgitmLv,
  5589. UserOrgId: adminUser.CurrentOrgId,
  5590. HisPatientId: his.ID,
  5591. OrderId: order.ID,
  5592. ProjectId: project_id,
  5593. Type: types,
  5594. }
  5595. service.CreateOrderInfo(info)
  5596. }
  5597. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5598. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5599. var total float64
  5600. for _, item := range prescriptions {
  5601. if item.Type == 1 { //药品
  5602. for _, subItem := range item.HisDoctorAdviceInfo {
  5603. total = total + (subItem.Price * subItem.PrescribingNumber)
  5604. }
  5605. }
  5606. if item.Type == 2 { //项目
  5607. for _, subItem := range item.HisPrescriptionProject {
  5608. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5609. total = total + (subItem.Price * cnt)
  5610. }
  5611. }
  5612. }
  5613. for _, item := range prescriptions {
  5614. for _, subItem := range item.HisAdditionalCharge {
  5615. total = total + (subItem.Price * float64(subItem.Count))
  5616. }
  5617. }
  5618. var allTotal string
  5619. if adminUser.CurrentOrgId == 9919 {
  5620. allTotal = fmt.Sprintf("%.4f", total)
  5621. } else {
  5622. allTotal = fmt.Sprintf("%.4f", total)
  5623. }
  5624. if res.Infcode == 0 {
  5625. var rf []*ResultFive
  5626. json.Unmarshal([]byte(his.Iinfo), &rf)
  5627. chrg_bchno := chrg_bchno
  5628. cert_no := his.Certno
  5629. var insutypes []string
  5630. var insutype string
  5631. var is390 int = 0
  5632. var is310 int = 0
  5633. for _, item := range rf {
  5634. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5635. insutypes = append(insutypes, item.Insutype)
  5636. }
  5637. }
  5638. if len(insutypes) == 1 {
  5639. insutype = insutypes[0]
  5640. } else {
  5641. for _, i := range insutypes {
  5642. if i == "390" {
  5643. is390 = 1
  5644. }
  5645. if i == "310" {
  5646. is310 = 1
  5647. }
  5648. }
  5649. }
  5650. if is390 == 1 {
  5651. insutype = "390"
  5652. }
  5653. if is310 == 1 {
  5654. insutype = "310"
  5655. }
  5656. if len(insutypes) == 0 {
  5657. insutype = "310"
  5658. }
  5659. if len(insutypes) == 2 {
  5660. insutype = strconv.FormatInt(his.SocialType, 10)
  5661. }
  5662. insutype = strconv.FormatInt(his.SocialType, 10)
  5663. //insutype = "390"
  5664. if his.IdCardType == 1 {
  5665. // cert_no = his.MedicalInsuranceNumber
  5666. cert_no = his.Certno
  5667. } else {
  5668. cert_no = his.Certno
  5669. }
  5670. var res models.GZResult2207
  5671. var resSeven10265 ResultSeven10265
  5672. var src_resquest string
  5673. var result2 string
  5674. var acct_used_flag string
  5675. fmt.Println("pay_way")
  5676. fmt.Println(pay_way)
  5677. fmt.Println("pay_way")
  5678. if pay_way == 5 {
  5679. acct_used_flag = "1"
  5680. } else {
  5681. acct_used_flag = "0"
  5682. }
  5683. if miConfig.MdtrtareaAdmvs == "421300" {
  5684. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5685. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5686. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5687. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5688. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5689. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5690. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5691. resp, requestErr := http.Get(api)
  5692. if requestErr != nil {
  5693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5694. return
  5695. }
  5696. body, ioErr := ioutil.ReadAll(resp.Body)
  5697. if ioErr != nil {
  5698. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5700. return
  5701. }
  5702. var respJSON map[string]interface{}
  5703. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5704. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5706. return
  5707. }
  5708. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5709. result, _ := json.Marshal(respJSON)
  5710. if miConfig.Code == "H15049901371" {
  5711. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5712. utils.ErrorLog("解析失败:%v", err)
  5713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5714. return
  5715. }
  5716. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5717. // res.Output = resSeven10265.Output
  5718. res.ErrMsg = resSeven10265.ErrMsg
  5719. res.Cainfo = resSeven10265.Cainfo
  5720. // res.WarnMsg = resSeven10265.WarnMsg
  5721. // infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5722. // res.Infcode = infocode
  5723. } else {
  5724. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5725. utils.ErrorLog("解析失败:%v", err)
  5726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5727. return
  5728. }
  5729. }
  5730. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5731. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5732. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5733. bas := strings.Split(psn_info.CardInfo, "|")
  5734. if his.IdCardType == 1 {
  5735. cert_no = bas[2]
  5736. } else if his.IdCardType == 3 {
  5737. cert_no = his.Certno
  5738. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  5739. } else if his.IdCardType == 4 {
  5740. cert_no = his.Certno
  5741. psn_info.VerifyNumber = token
  5742. }
  5743. var api string
  5744. if miConfig.MdtrtareaAdmvs == "320921" {
  5745. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5746. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5747. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5748. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5749. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5750. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5751. "&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
  5752. } else {
  5753. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5754. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5755. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5756. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5757. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5758. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5759. "&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
  5760. }
  5761. resp, requestErr := http.Get(api)
  5762. if requestErr != nil {
  5763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5764. return
  5765. }
  5766. body, ioErr := ioutil.ReadAll(resp.Body)
  5767. if ioErr != nil {
  5768. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5770. return
  5771. }
  5772. var respJSON map[string]interface{}
  5773. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5774. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5776. return
  5777. }
  5778. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5779. result, _ := json.Marshal(respJSON)
  5780. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5781. utils.ErrorLog("解析失败:%v", err)
  5782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5783. return
  5784. }
  5785. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5786. // res.Output = resSeven10265.Output
  5787. res.ErrMsg = resSeven10265.ErrMsg
  5788. res.Cainfo = resSeven10265.Cainfo
  5789. // res.WarnMsg = resSeven10265.WarnMsg
  5790. // infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5791. // res.Infcode = infocode
  5792. } else {
  5793. if miConfig.Code == "H15049901371" {
  5794. //赤峰地区国家医保医疗类别
  5795. //职工透析:医疗类别选特殊情况门诊990502
  5796. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5797. var med_type string
  5798. if his.Insutype == "390" {
  5799. if reg_type == 14 {
  5800. med_type = "9933"
  5801. } else if reg_type == 11 {
  5802. med_type = "11"
  5803. }
  5804. } else if his.Insutype == "310" {
  5805. if reg_type == 14 {
  5806. med_type = "990502"
  5807. } else if reg_type == 11 {
  5808. med_type = "11"
  5809. }
  5810. }
  5811. 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)
  5812. } else {
  5813. var med_type string
  5814. if reg_type == 14 {
  5815. med_type = "141009"
  5816. } else if reg_type == 11 {
  5817. med_type = "11"
  5818. }
  5819. 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)
  5820. }
  5821. //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)
  5822. var dat map[string]interface{}
  5823. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5824. fmt.Println(dat)
  5825. } else {
  5826. fmt.Println(err)
  5827. }
  5828. saveLog(result2, src_resquest, "2207", "结算")
  5829. userJSONBytes, _ := json.Marshal(dat)
  5830. if miConfig.Code == "H15049901371" {
  5831. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5832. utils.ErrorLog("解析失败:%v", err)
  5833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5834. return
  5835. }
  5836. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5837. // res.Output = resSeven10265.Output
  5838. res.ErrMsg = resSeven10265.ErrMsg
  5839. res.Cainfo = resSeven10265.Cainfo
  5840. // res.WarnMsg = resSeven10265.WarnMsg
  5841. // infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5842. // res.Infcode = infocode
  5843. } else {
  5844. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5845. utils.ErrorLog("解析失败:%v", err)
  5846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5847. return
  5848. }
  5849. }
  5850. }
  5851. if res.Infcode != 0 {
  5852. errlog := &models.HisOrderError{
  5853. UserOrgId: adminUser.CurrentOrgId,
  5854. Ctime: time.Now().Unix(),
  5855. Mtime: time.Now().Unix(),
  5856. Number: chrg_bchno,
  5857. ErrMsg: res.ErrMsg,
  5858. Status: 1,
  5859. PatientId: id,
  5860. RecordTime: recordDateTime,
  5861. Stage: 6,
  5862. }
  5863. service.CreateErrMsgLog(errlog)
  5864. c.ServeSuccessJSON(map[string]interface{}{
  5865. "failed_code": -10,
  5866. "msg": res.ErrMsg,
  5867. })
  5868. return
  5869. } else {
  5870. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5871. order.OrderStatus = 2
  5872. order.Status = 1
  5873. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5874. order.SetlId = res.Output.Setlinfo.SetlID
  5875. order.PsnNo = res.Output.Setlinfo.PsnNo
  5876. order.PsnName = res.Output.Setlinfo.PsnName
  5877. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5878. order.Certno = res.Output.Setlinfo.Certno
  5879. order.Gend = res.Output.Setlinfo.Gend
  5880. order.Naty = res.Output.Setlinfo.Naty
  5881. order.Age = res.Output.Setlinfo.Age
  5882. order.Insutype = res.Output.Setlinfo.Insutype
  5883. order.PsnType = res.Output.Setlinfo.PsnType
  5884. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5885. order.SetlTime = res.Output.Setlinfo.SetlTime
  5886. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5887. if res.Output.Setlinfo.MedType == "140101" {
  5888. order.MedType = "14"
  5889. } else {
  5890. order.MedType = res.Output.Setlinfo.MedType
  5891. }
  5892. if reg_type == 1112 {
  5893. order.MedType = "1112"
  5894. }
  5895. if reg_type == 1111 {
  5896. order.MedType = "1111"
  5897. }
  5898. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5899. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5900. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5901. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5902. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5903. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5904. order.HifpPay = res.Output.Setlinfo.HifpPay
  5905. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5906. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5907. order.HifesPay = res.Output.Setlinfo.HifesPay
  5908. order.HifobPay = res.Output.Setlinfo.HifobPay
  5909. order.MafPay = res.Output.Setlinfo.MafPay
  5910. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5911. order.OthPay = res.Output.Setlinfo.OthPay
  5912. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5913. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5914. order.AcctPay = res.Output.Setlinfo.AcctPay
  5915. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5916. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5917. order.Balc = res.Output.Setlinfo.Balc
  5918. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5919. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5920. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5921. order.ClrType = res.Output.Setlinfo.ClrType
  5922. order.ClrWay = res.Output.Setlinfo.ClrWay
  5923. order.Creator = order.Creator
  5924. order.Modify = roles.AdminUserId
  5925. order.RequestLog = src_resquest
  5926. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5927. detailStr := string(setlDetail)
  5928. order.SetlDetail = detailStr
  5929. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5930. err = service.UpDateOrder(order)
  5931. if err == nil {
  5932. //判断是否使用了押金
  5933. if dec_way == "true" {
  5934. tmpstring := strconv.FormatInt(order.ID, 10)
  5935. order.Decimal = decimal
  5936. service.UpDateOrder(order)
  5937. //扣押金
  5938. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  5939. if errmsg != nil {
  5940. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  5941. return
  5942. }
  5943. }
  5944. c.ServeSuccessJSON(map[string]interface{}{
  5945. "msg": "结算成功",
  5946. })
  5947. } else {
  5948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5949. return
  5950. }
  5951. }
  5952. } else {
  5953. adminUser := c.GetAdminUserInfo()
  5954. errlog := &models.HisOrderError{
  5955. UserOrgId: adminUser.CurrentOrgId,
  5956. Ctime: time.Now().Unix(),
  5957. Mtime: time.Now().Unix(),
  5958. ErrMsg: res.ErrMsg,
  5959. Status: 1,
  5960. PatientId: id,
  5961. RecordTime: recordDateTime,
  5962. Stage: 4,
  5963. }
  5964. service.CreateErrMsgLog(errlog)
  5965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5966. return
  5967. }
  5968. } else {
  5969. adminUser := c.GetAdminUserInfo()
  5970. errlog := &models.HisOrderError{
  5971. UserOrgId: adminUser.CurrentOrgId,
  5972. Ctime: time.Now().Unix(),
  5973. Mtime: time.Now().Unix(),
  5974. ErrMsg: res.ErrMsg,
  5975. Status: 1,
  5976. PatientId: id,
  5977. RecordTime: recordDateTime,
  5978. Stage: 4,
  5979. }
  5980. service.CreateErrMsgLog(errlog)
  5981. c.ServeSuccessJSON(map[string]interface{}{
  5982. "failed_code": -10,
  5983. "msg": res.ErrMsg,
  5984. })
  5985. return
  5986. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5987. //return
  5988. }
  5989. }
  5990. }
  5991. } else if tempOrder.ID > 0 {
  5992. if tempOrder.IsPre == 1 {
  5993. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  5994. var rf []*ResultFive
  5995. json.Unmarshal([]byte(his.Iinfo), &rf)
  5996. chrg_bchno := tempOrder.Number
  5997. cert_no := his.Certno
  5998. var insutypes []string
  5999. var insutype string
  6000. var is390 int = 0
  6001. var is310 int = 0
  6002. for _, item := range rf {
  6003. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6004. insutypes = append(insutypes, item.Insutype)
  6005. }
  6006. }
  6007. if len(insutypes) == 1 {
  6008. insutype = insutypes[0]
  6009. } else {
  6010. for _, i := range insutypes {
  6011. if i == "390" {
  6012. is390 = 1
  6013. }
  6014. if i == "310" {
  6015. is310 = 1
  6016. }
  6017. }
  6018. }
  6019. if is390 == 1 {
  6020. insutype = "390"
  6021. }
  6022. if is310 == 1 {
  6023. insutype = "310"
  6024. }
  6025. if len(insutypes) == 0 {
  6026. insutype = "310"
  6027. }
  6028. if len(insutypes) == 2 {
  6029. insutype = strconv.FormatInt(his.SocialType, 64)
  6030. }
  6031. //insutype = "390"
  6032. if his.IdCardType == 1 {
  6033. // cert_no = his.MedicalInsuranceNumber
  6034. cert_no = his.Certno
  6035. } else {
  6036. cert_no = his.Certno
  6037. }
  6038. var res ResultSeven
  6039. var resSeven10265 ResultSeven10265
  6040. var src_resquest string
  6041. var result2 string
  6042. var acct_used_flag string
  6043. fmt.Println("pay_way")
  6044. fmt.Println(pay_way)
  6045. fmt.Println("pay_way")
  6046. if pay_way == 5 {
  6047. acct_used_flag = "1"
  6048. } else {
  6049. acct_used_flag = "0"
  6050. }
  6051. if miConfig.MdtrtareaAdmvs == "421300" {
  6052. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6053. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6054. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6055. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6056. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6057. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6058. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  6059. resp, requestErr := http.Get(api)
  6060. if requestErr != nil {
  6061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6062. return
  6063. }
  6064. body, ioErr := ioutil.ReadAll(resp.Body)
  6065. if ioErr != nil {
  6066. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6068. return
  6069. }
  6070. var respJSON map[string]interface{}
  6071. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6072. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6074. return
  6075. }
  6076. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6077. result, _ := json.Marshal(respJSON)
  6078. fmt.Println("log")
  6079. fmt.Println(string(result))
  6080. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6081. utils.ErrorLog("解析失败:%v", err)
  6082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6083. return
  6084. }
  6085. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6086. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6087. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6088. //psn_info, _ := service.GetPsnByPatientId(id)
  6089. bas := strings.Split(psn_info.CardInfo, "|")
  6090. if his.IdCardType == 1 {
  6091. cert_no = bas[2]
  6092. } else {
  6093. cert_no = bas[1]
  6094. }
  6095. //江苏地区国家医保医疗类别
  6096. //职工透析:医疗类别选特殊情况门诊9933
  6097. //居民血透门慢: 医疗类别选门诊慢病1402
  6098. //var med_type string
  6099. //if his.Insutype == "310" {
  6100. // if reg_type == 14 {
  6101. // med_type = "9933"
  6102. // } else if reg_type == 11 {
  6103. // med_type = "11"
  6104. //
  6105. // }
  6106. //} else if his.Insutype == "390" {
  6107. // if reg_type == 14 {
  6108. // med_type = "1402"
  6109. // } else if reg_type == 11 {
  6110. // med_type = "11"
  6111. // }
  6112. //}
  6113. var api string
  6114. if miConfig.MdtrtareaAdmvs == "320921" {
  6115. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6116. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6117. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6118. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6119. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6120. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6121. "&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
  6122. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6123. } else {
  6124. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6125. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6126. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6127. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6128. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6129. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6130. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6131. "&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
  6132. }
  6133. resp, requestErr := http.Get(api)
  6134. if requestErr != nil {
  6135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6136. return
  6137. }
  6138. body, ioErr := ioutil.ReadAll(resp.Body)
  6139. if ioErr != nil {
  6140. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6142. return
  6143. }
  6144. var respJSON map[string]interface{}
  6145. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6146. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6148. return
  6149. }
  6150. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6151. result, _ := json.Marshal(respJSON)
  6152. fmt.Println("log")
  6153. fmt.Println(string(result))
  6154. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6155. utils.ErrorLog("解析失败:%v", err)
  6156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6157. return
  6158. }
  6159. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6160. res.Output = resSeven10265.Output
  6161. res.ErrMsg = resSeven10265.ErrMsg
  6162. res.Cainfo = resSeven10265.Cainfo
  6163. res.WarnMsg = resSeven10265.WarnMsg
  6164. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6165. res.Infcode = infocode
  6166. } else {
  6167. var src_resquest string
  6168. if miConfig.Code == "H15049901371" {
  6169. //赤峰地区国家医保医疗类别
  6170. //职工透析:医疗类别选特殊情况门诊990502
  6171. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6172. var med_type string
  6173. if his.Insutype == "390" {
  6174. if reg_type == 14 {
  6175. med_type = "9933"
  6176. } else if reg_type == 11 {
  6177. med_type = "11"
  6178. }
  6179. } else if his.Insutype == "310" {
  6180. if reg_type == 14 {
  6181. med_type = "990502"
  6182. } else if reg_type == 11 {
  6183. med_type = "11"
  6184. }
  6185. }
  6186. 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)
  6187. } else {
  6188. var med_type string
  6189. if reg_type == 14 {
  6190. med_type = "14"
  6191. } else if reg_type == 11 {
  6192. med_type = "11"
  6193. }
  6194. 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)
  6195. }
  6196. var dat map[string]interface{}
  6197. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6198. fmt.Println(dat)
  6199. } else {
  6200. fmt.Println(err)
  6201. }
  6202. saveLog(result2, src_resquest, "2207", "结算")
  6203. userJSONBytes, _ := json.Marshal(dat)
  6204. if miConfig.Code == "H15049901371" {
  6205. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6206. utils.ErrorLog("解析失败:%v", err)
  6207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6208. return
  6209. }
  6210. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6211. res.Output = resSeven10265.Output
  6212. res.ErrMsg = resSeven10265.ErrMsg
  6213. res.Cainfo = resSeven10265.Cainfo
  6214. res.WarnMsg = resSeven10265.WarnMsg
  6215. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6216. res.Infcode = infocode
  6217. } else {
  6218. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6219. utils.ErrorLog("解析失败:%v", err)
  6220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6221. return
  6222. }
  6223. }
  6224. }
  6225. if res.Infcode != 0 {
  6226. errlog := &models.HisOrderError{
  6227. UserOrgId: adminUser.CurrentOrgId,
  6228. Ctime: time.Now().Unix(),
  6229. Mtime: time.Now().Unix(),
  6230. Number: chrg_bchno,
  6231. ErrMsg: res.ErrMsg,
  6232. Status: 1,
  6233. PatientId: id,
  6234. RecordTime: recordDateTime,
  6235. Stage: 6,
  6236. }
  6237. service.CreateErrMsgLog(errlog)
  6238. c.ServeSuccessJSON(map[string]interface{}{
  6239. "failed_code": -10,
  6240. "msg": res.ErrMsg,
  6241. })
  6242. return
  6243. } else {
  6244. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6245. order.OrderStatus = 2
  6246. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6247. order.SetlId = res.Output.Setlinfo.SetlID
  6248. order.PsnNo = res.Output.Setlinfo.PsnNo
  6249. order.PsnName = res.Output.Setlinfo.PsnName
  6250. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6251. order.Certno = res.Output.Setlinfo.Certno
  6252. order.Gend = res.Output.Setlinfo.Gend
  6253. order.Naty = res.Output.Setlinfo.Naty
  6254. order.Age = res.Output.Setlinfo.Age
  6255. order.Insutype = res.Output.Setlinfo.Insutype
  6256. order.PsnType = res.Output.Setlinfo.PsnType
  6257. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6258. order.SetlTime = res.Output.Setlinfo.SetlTime
  6259. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6260. //order.MedType = res.Output.Setlinfo.MedType
  6261. if reg_type == 1112 {
  6262. order.MedType = "1112"
  6263. }
  6264. if reg_type == 1111 {
  6265. order.MedType = "1111"
  6266. }
  6267. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6268. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6269. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6270. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6271. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6272. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6273. order.HifpPay = res.Output.Setlinfo.HifpPay
  6274. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6275. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6276. order.HifesPay = res.Output.Setlinfo.HifesPay
  6277. order.HifobPay = res.Output.Setlinfo.HifobPay
  6278. order.MafPay = res.Output.Setlinfo.MafPay
  6279. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6280. order.OthPay = res.Output.Setlinfo.OthPay
  6281. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6282. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6283. order.AcctPay = res.Output.Setlinfo.AcctPay
  6284. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6285. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6286. order.Balc = res.Output.Setlinfo.Balc
  6287. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6288. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6289. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6290. order.ClrWay = res.Output.Setlinfo.ClrWay
  6291. order.Creator = order.Creator
  6292. order.Modify = roles.AdminUserId
  6293. order.RequestLog = src_resquest
  6294. order.Diagnosis = diagnosis_id
  6295. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6296. detailStr := string(setlDetail)
  6297. order.SetlDetail = detailStr
  6298. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6299. err = service.UpDateOrder(order)
  6300. if err == nil {
  6301. //判断是否使用了押金
  6302. if dec_way == "true" {
  6303. tmpstring := strconv.FormatInt(order.ID, 10)
  6304. //扣押金
  6305. order.Decimal = decimal
  6306. service.UpDateOrder(order)
  6307. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6308. if errmsg != nil {
  6309. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6310. return
  6311. }
  6312. }
  6313. c.ServeSuccessJSON(map[string]interface{}{
  6314. "msg": "结算成功",
  6315. })
  6316. } else {
  6317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6318. return
  6319. }
  6320. }
  6321. }
  6322. }
  6323. }
  6324. //func (c *HisApiController) GetPreUploadInfo() {
  6325. // id, _ := c.GetInt64("id")
  6326. // record_time := c.GetString("record_time")
  6327. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6328. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6329. //
  6330. // timeLayout := "2006-01-02"
  6331. // loc, _ := time.LoadLocation("Local")
  6332. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6333. // if err != nil {
  6334. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6335. // return
  6336. // }
  6337. // recordDateTime := theTime.Unix()
  6338. // adminUser := c.GetAdminUserInfo()
  6339. //
  6340. // var prescriptions []*models.HisPrescription
  6341. //
  6342. // var start_time int64
  6343. // var end_time int64
  6344. //
  6345. // data := make(map[string]interface{})
  6346. // if settle_accounts_type == 1 { //日结
  6347. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6348. // data["pre"] = prescriptions
  6349. //
  6350. // } else { //月结
  6351. // start_time_str := c.GetString("start_time")
  6352. // end_time_str := c.GetString("end_time")
  6353. // timeLayout := "2006-01-02"
  6354. // loc, _ := time.LoadLocation("Local")
  6355. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6356. // if err != nil {
  6357. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6358. // return
  6359. // }
  6360. // recordStartTime := theStartTime.Unix()
  6361. // start_time = recordStartTime
  6362. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6363. // if err != nil {
  6364. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6365. // return
  6366. // }
  6367. // recordEndTime := theEndTime.Unix()
  6368. // end_time = recordEndTime
  6369. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6370. // data["pre"] = prescriptions
  6371. //
  6372. // }
  6373. //
  6374. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6375. //
  6376. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6377. // timestamp := time.Now().Unix()
  6378. // tempTime := time.Unix(timestamp, 0)
  6379. // timeFormat := tempTime.Format("20060102150405")
  6380. // chrgBchno := rand.Intn(100000) + 10000
  6381. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6382. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6383. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6384. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6385. // strconv.FormatInt(his.PatientId, 10)
  6386. // client := &http.Client{}
  6387. // data["psn_no"] = his.PsnNo
  6388. // data["mdtrt_id"] = his.Number
  6389. // data["chrg_bchno"] = chrg_bchno
  6390. // data["org_name"] = miConfig.OrgName
  6391. // data["doctor"] = roles.UserName
  6392. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6393. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6394. // data["fixmedins_code"] = miConfig.Code
  6395. // data["dept_code"] = department.Number
  6396. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6397. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6398. // data["secret_key"] = miConfig.SecretKey
  6399. // var ids []int64
  6400. //
  6401. // for _, item := range prescriptions {
  6402. // ids = append(ids, item.ID)
  6403. // }
  6404. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6405. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6406. // bytesData, _ := json.Marshal(data)
  6407. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  6408. // resp, _ := client.Do(req)
  6409. // defer resp.Body.Close()
  6410. // body, ioErr := ioutil.ReadAll(resp.Body)
  6411. // if ioErr != nil {
  6412. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6413. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6414. // return
  6415. // }
  6416. // var respJSON map[string]interface{}
  6417. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6418. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6419. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6420. // return
  6421. // }
  6422. //
  6423. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6424. // userJSONBytes, _ := json.Marshal(respJSON)
  6425. // var res ResultFour
  6426. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6427. // utils.ErrorLog("解析失败:%v", err)
  6428. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6429. // return
  6430. // }
  6431. //
  6432. // if res.Infcode == 0 {
  6433. // order := &models.HisOrder{
  6434. // UserOrgId: adminUser.CurrentOrgId,
  6435. // HisPatientId: his.ID,
  6436. // PatientId: his.PatientId,
  6437. // SettleAccountsDate: recordDateTime,
  6438. // Ctime: time.Now().Unix(),
  6439. // Mtime: time.Now().Unix(),
  6440. // Status: 1,
  6441. // Number: chrg_bchno,
  6442. // Infcode: res.Infcode,
  6443. // WarnMsg: res.WarnMsg,
  6444. // Cainfo: res.Cainfo,
  6445. // ErrMsg: res.ErrMsg,
  6446. // RespondTime: res.RefmsgTime,
  6447. // InfRefmsgid: res.InfRefmsgid,
  6448. // OrderStatus: 1,
  6449. // IsMedicineInsurance: 1,
  6450. // SettleType: settle_accounts_type,
  6451. // SettleStartTime: start_time,
  6452. // SettleEndTime: end_time,
  6453. // Creator: roles.ID,
  6454. // Modify: roles.ID,
  6455. // PType: 2,
  6456. // }
  6457. // err = service.CreateOrder(order)
  6458. // if err != nil {
  6459. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6460. // return
  6461. // }
  6462. //
  6463. // for _, item := range res.Output.Result {
  6464. // temp := strings.Split(item.FeedetlSn, "-")
  6465. // var advice_id int64 = 0
  6466. // var project_id int64 = 0
  6467. // var types int64 = 0
  6468. //
  6469. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  6470. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  6471. //
  6472. // if temp[1] == "1" {
  6473. // advice_id = id
  6474. // project_id = 0
  6475. // } else if temp[1] == "2" {
  6476. // advice_id = 0
  6477. // project_id = id
  6478. // }
  6479. //
  6480. // info := &models.HisOrderInfo{
  6481. // OrderNumber: order.Number,
  6482. // FeedetlSn: item.FeedetlSn,
  6483. // UploadDate: time.Now().Unix(),
  6484. // AdviceId: advice_id,
  6485. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  6486. // Cnt: item.Cnt,
  6487. // Pric: float64(item.Pric),
  6488. // PatientId: his.PatientId,
  6489. // PricUplmtAmt: item.PricUplmtAmt,
  6490. // SelfpayProp: item.SelfpayProp,
  6491. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6492. // OverlmtAmt: item.OverlmtAmt,
  6493. // PreselfpayAmt: item.PreselfpayAmt,
  6494. // BasMednFlag: item.BasMednFlag,
  6495. // MedChrgitmType: item.MedChrgitmType,
  6496. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  6497. // Status: 1,
  6498. // Memo: item.Memo,
  6499. // Mtime: time.Now().Unix(),
  6500. // InscpScpAmt: item.InscpScpAmt,
  6501. // DrtReimFlag: item.DrtReimFlag,
  6502. // Ctime: time.Now().Unix(),
  6503. // ListSpItemFlag: item.ListSpItemFlag,
  6504. // ChldMedcFlag: item.ChldMedcFlag,
  6505. // LmtUsedFlag: item.LmtUsedFlag,
  6506. // ChrgitmLv: item.ChrgitmLv,
  6507. // UserOrgId: adminUser.CurrentOrgId,
  6508. // HisPatientId: his.ID,
  6509. // OrderId: order.ID,
  6510. // ProjectId: project_id,
  6511. // Type: types,
  6512. // }
  6513. // service.CreateOrderInfo(info)
  6514. //
  6515. // }
  6516. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6517. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  6518. //
  6519. // var total float64
  6520. // for _, item := range prescriptions {
  6521. // if item.Type == 1 { //药品
  6522. // for _, subItem := range item.HisDoctorAdviceInfo {
  6523. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6524. // }
  6525. // }
  6526. // if item.Type == 2 { //项目
  6527. // for _, subItem := range item.HisPrescriptionProject {
  6528. // total = total + (subItem.Price * float64(subItem.Count))
  6529. // }
  6530. // }
  6531. // }
  6532. //
  6533. // for _, item := range prescriptions {
  6534. // for _, subItem := range item.HisAdditionalCharge {
  6535. // total = total + (subItem.Price * float64(subItem.Count))
  6536. // }
  6537. // }
  6538. //
  6539. // allTotal := fmt.Sprintf("%.2f", total)
  6540. // if res.Infcode == 0 {
  6541. // var rf []*ResultFive
  6542. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6543. // psn_no := his.PsnNo
  6544. // mdtrt_id := his.Number
  6545. // chrg_bchno := chrg_bchno
  6546. // cert_no := his.Certno
  6547. // insutype := rf[0].Insutype
  6548. //
  6549. // if his.IdCardType == 1 {
  6550. // cert_no = his.MedicalInsuranceNumber
  6551. //
  6552. // } else {
  6553. //
  6554. // cert_no = his.Certno
  6555. //
  6556. // }
  6557. //
  6558. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  6559. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  6560. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  6561. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  6562. // resp, requestErr := http.Get(api)
  6563. // if requestErr != nil {
  6564. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6565. // return
  6566. // }
  6567. // defer resp.Body.Close()
  6568. // body, ioErr := ioutil.ReadAll(resp.Body)
  6569. // if ioErr != nil {
  6570. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6571. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6572. // return
  6573. // }
  6574. // var respJSON map[string]interface{}
  6575. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6576. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6577. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6578. // return
  6579. // }
  6580. // fmt.Println(respJSON)
  6581. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6582. // userJSONBytes, _ := json.Marshal(respJSON)
  6583. // var res ResultSeven
  6584. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6585. // utils.ErrorLog("解析失败:%v", err)
  6586. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6587. // return
  6588. // }
  6589. // if res.Infcode != 0 {
  6590. // errlog := &models.HisOrderError{
  6591. // UserOrgId: adminUser.CurrentOrgId,
  6592. // Ctime: time.Now().Unix(),
  6593. // Mtime: time.Now().Unix(),
  6594. // Number: chrg_bchno,
  6595. // ErrMsg: res.ErrMsg,
  6596. // Status: 1,
  6597. // PatientId: id,
  6598. // RecordTime: recordDateTime,
  6599. // Stage: 7,
  6600. // }
  6601. // service.CreateErrMsgLog(errlog)
  6602. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6603. // return
  6604. // } else {
  6605. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6606. // order.OrderStatus = 1
  6607. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6608. // order.SetlId = res.Output.Setlinfo.SetlID
  6609. // order.PsnNo = res.Output.Setlinfo.PsnNo
  6610. // order.PsnName = res.Output.Setlinfo.PsnName
  6611. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6612. // order.Certno = res.Output.Setlinfo.Certno
  6613. // order.Gend = res.Output.Setlinfo.Gend
  6614. // order.Naty = res.Output.Setlinfo.Naty
  6615. // order.Age = res.Output.Setlinfo.Age
  6616. // order.Insutype = res.Output.Setlinfo.Insutype
  6617. // order.PsnType = res.Output.Setlinfo.PsnType
  6618. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6619. // order.SetlTime = res.Output.Setlinfo.SetlTime
  6620. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6621. // order.MedType = res.Output.Setlinfo.MedType
  6622. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6623. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6624. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6625. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6626. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6627. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6628. // order.HifpPay = res.Output.Setlinfo.HifpPay
  6629. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6630. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6631. // order.HifesPay = res.Output.Setlinfo.HifesPay
  6632. // order.HifobPay = res.Output.Setlinfo.HifobPay
  6633. // order.MafPay = res.Output.Setlinfo.MafPay
  6634. // order.OthPay = res.Output.Setlinfo.OthPay
  6635. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6636. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6637. // order.AcctPay = res.Output.Setlinfo.AcctPay
  6638. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6639. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6640. // order.Balc = res.Output.Setlinfo.Balc
  6641. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6642. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6643. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6644. // order.ClrWay = res.Output.Setlinfo.ClrWay
  6645. // order.Creator = order.Creator
  6646. // order.Modify = roles.ID
  6647. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6648. // detailStr := string(setlDetail)
  6649. // order.SetlDetail = detailStr
  6650. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6651. // err = service.UpDateOrder(order)
  6652. // if err == nil {
  6653. // c.ServeSuccessJSON(map[string]interface{}{
  6654. // "msg": "预结算成功",
  6655. // })
  6656. // } else {
  6657. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6658. // return
  6659. // }
  6660. // }
  6661. // } else {
  6662. // adminUser := c.GetAdminUserInfo()
  6663. // errlog := &models.HisOrderError{
  6664. // UserOrgId: adminUser.CurrentOrgId,
  6665. // Ctime: time.Now().Unix(),
  6666. // Mtime: time.Now().Unix(),
  6667. // ErrMsg: res.ErrMsg,
  6668. // Status: 1,
  6669. // PatientId: id,
  6670. // RecordTime: recordDateTime,
  6671. // Stage: 4,
  6672. // }
  6673. // service.CreateErrMsgLog(errlog)
  6674. //
  6675. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6676. // return
  6677. // }
  6678. // } else {
  6679. // adminUser := c.GetAdminUserInfo()
  6680. // errlog := &models.HisOrderError{
  6681. // UserOrgId: adminUser.CurrentOrgId,
  6682. // Ctime: time.Now().Unix(),
  6683. // Mtime: time.Now().Unix(),
  6684. // ErrMsg: res.ErrMsg,
  6685. // Status: 1,
  6686. // PatientId: id,
  6687. // RecordTime: recordDateTime,
  6688. // Stage: 4,
  6689. // }
  6690. // service.CreateErrMsgLog(errlog)
  6691. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6692. // return
  6693. // }
  6694. //
  6695. // } else {
  6696. // var total float64
  6697. // for _, item := range prescriptions {
  6698. // if item.Type == 1 { //药品
  6699. // for _, subItem := range item.HisDoctorAdviceInfo {
  6700. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6701. // }
  6702. // }
  6703. // if item.Type == 2 { //项目
  6704. // for _, subItem := range item.HisPrescriptionProject {
  6705. // total = total + (subItem.Price * float64(subItem.Count))
  6706. // }
  6707. // }
  6708. //
  6709. // for _, subItem := range item.HisAdditionalCharge {
  6710. // total = total + (subItem.Price * float64(subItem.Count))
  6711. // }
  6712. // }
  6713. //
  6714. // allTotal := fmt.Sprintf("%.2f", total)
  6715. // totals, _ := strconv.ParseFloat(allTotal, 64)
  6716. // order := &models.HisOrder{
  6717. // UserOrgId: adminUser.CurrentOrgId,
  6718. // HisPatientId: his.ID,
  6719. // PatientId: id,
  6720. // SettleAccountsDate: recordDateTime,
  6721. // Ctime: time.Now().Unix(),
  6722. // Mtime: time.Now().Unix(),
  6723. // Status: 1,
  6724. // OrderStatus: 2,
  6725. // Number: chrg_bchno,
  6726. // MedfeeSumamt: totals,
  6727. // }
  6728. // err = service.CreateOrder(order)
  6729. // if err != nil {
  6730. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6731. // return
  6732. // }
  6733. //
  6734. // var customs []*Custom
  6735. // for _, item := range prescriptions {
  6736. //
  6737. // if item.Type == 1 { //药品
  6738. // for _, subItem := range item.HisDoctorAdviceInfo {
  6739. // cus := &Custom{
  6740. // AdviceId: subItem.ID,
  6741. // ProjectId: 0,
  6742. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  6743. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  6744. // FeedetlSn: subItem.FeedetlSn,
  6745. // Price: fmt.Sprintf("%.2f", subItem.Price),
  6746. // MedListCodg: subItem.MedListCodg,
  6747. // Type: 1,
  6748. // }
  6749. // customs = append(customs, cus)
  6750. // }
  6751. // }
  6752. //
  6753. // if item.Type == 2 { //项目
  6754. // for _, subItem := range item.HisPrescriptionProject {
  6755. //
  6756. // cus := &Custom{
  6757. // AdviceId: 0,
  6758. // ProjectId: subItem.ID,
  6759. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  6760. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  6761. // FeedetlSn: subItem.FeedetlSn,
  6762. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  6763. // MedListCodg: subItem.MedListCodg,
  6764. // Type: 2,
  6765. // }
  6766. //
  6767. // customs = append(customs, cus)
  6768. // }
  6769. // }
  6770. //
  6771. // for _, item := range item.HisAdditionalCharge {
  6772. // cus := &Custom{
  6773. // ItemId: item.ID,
  6774. // AdviceId: 0,
  6775. // ProjectId: 0,
  6776. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  6777. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  6778. // FeedetlSn: item.FeedetlSn,
  6779. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  6780. // MedListCodg: item.XtHisAddtionConfig.Code,
  6781. // Type: 3,
  6782. // }
  6783. //
  6784. // customs = append(customs, cus)
  6785. // }
  6786. //
  6787. // }
  6788. //
  6789. // for _, item := range customs {
  6790. // var advice_id int64 = 0
  6791. // var project_id int64 = 0
  6792. // var item_id int64 = 0
  6793. //
  6794. // var types int64 = 0
  6795. //
  6796. // if item.Type == 1 {
  6797. // advice_id = item.AdviceId
  6798. // project_id = 0
  6799. // item_id = 0
  6800. // } else if item.Type == 2 {
  6801. // advice_id = 0
  6802. // item_id = 0
  6803. //
  6804. // project_id = item.ProjectId
  6805. // } else if item.Type == 3 {
  6806. // advice_id = 0
  6807. // item_id = item.ItemId
  6808. // project_id = 0
  6809. // }
  6810. //
  6811. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  6812. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  6813. // pric, _ := strconv.ParseFloat(item.Price, 32)
  6814. //
  6815. // info := &models.HisOrderInfo{
  6816. // OrderNumber: order.Number,
  6817. // UploadDate: time.Now().Unix(),
  6818. // AdviceId: advice_id,
  6819. // DetItemFeeSumamt: detItemFeeSumamt,
  6820. // Cnt: cut,
  6821. // Pric: pric,
  6822. // PatientId: id,
  6823. // Status: 1,
  6824. // Mtime: time.Now().Unix(),
  6825. // Ctime: time.Now().Unix(),
  6826. // UserOrgId: adminUser.CurrentOrgId,
  6827. // HisPatientId: his.ID,
  6828. // OrderId: order.ID,
  6829. // ProjectId: project_id,
  6830. // Type: types,
  6831. // ItemId: item_id,
  6832. // }
  6833. // service.CreateOrderInfo(info)
  6834. // }
  6835. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6836. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6837. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  6838. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6839. // if err == nil {
  6840. // c.ServeSuccessJSON(map[string]interface{}{
  6841. // "msg": "结算成功",
  6842. // })
  6843. // } else {
  6844. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6845. // return
  6846. // }
  6847. // }
  6848. //}
  6849. //上传明细-预结算-
  6850. func (c *HisApiController) GetPreUploadInfo() {
  6851. id, _ := c.GetInt64("id")
  6852. record_time := c.GetString("record_time")
  6853. his_patient_id, _ := c.GetInt64("his_patient_id")
  6854. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6855. admin_user_id, _ := c.GetInt64("admin_user_id")
  6856. diagnosis_id := c.GetString("diagnosis")
  6857. sick_type, _ := c.GetInt64("sick_type")
  6858. reg_type, _ := c.GetInt64("p_type")
  6859. begin_time := c.GetString("begin_time")
  6860. id_str := c.GetString("ids")
  6861. ids_arr := strings.Split(id_str, ",")
  6862. timeLayout := "2006-01-02"
  6863. loc, _ := time.LoadLocation("Local")
  6864. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6865. if err != nil {
  6866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6867. return
  6868. }
  6869. recordDateTime := theTime.Unix()
  6870. adminUser := c.GetAdminUserInfo()
  6871. diagnosis_ids := strings.Split(diagnosis_id, ",")
  6872. var config []*models.HisXtDiagnoseConfig
  6873. for _, item := range diagnosis_ids {
  6874. id, _ := strconv.ParseInt(item, 10, 64)
  6875. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6876. config = append(config, &diagnosisConfig)
  6877. }
  6878. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  6879. sickConfig, _ := service.FindSickById(sick_type)
  6880. var prescriptions []*models.HisPrescription
  6881. var start_time int64
  6882. var end_time int64
  6883. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6884. fmt.Println(his_patient_id)
  6885. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6886. timestamp := time.Now().Unix()
  6887. tempTime := time.Unix(timestamp, 0)
  6888. timeFormat := tempTime.Format("20060102150405")
  6889. chrgBchno := rand.Intn(100000) + 10000
  6890. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6891. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6892. var patientPrescription models.HisPrescriptionInfo
  6893. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6894. if patientPrescription.ID == 0 {
  6895. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6896. }
  6897. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6898. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6899. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6900. strconv.FormatInt(his.PatientId, 10)
  6901. var res2 ResultSix
  6902. var resSix10265 ResultSix10265
  6903. var time_stamp string
  6904. if miConfig.MdtrtareaAdmvs == "421300" {
  6905. data := make(map[string]interface{})
  6906. client := &http.Client{}
  6907. data["psn_no"] = his.PsnNo
  6908. data["mdtrt_id"] = his.Number
  6909. data["doctor"] = roles.UserName
  6910. data["department"] = department.Name
  6911. data["org_name"] = miConfig.OrgName
  6912. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6913. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6914. data["fixmedins_code"] = miConfig.Code
  6915. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6916. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6917. data["secret_key"] = miConfig.SecretKey
  6918. data["sick_code"] = sickConfig.CountryCode
  6919. data["sick_name"] = sickConfig.ClassName
  6920. data["begin_time"] = begin_time
  6921. data["dept"] = strconv.FormatInt(department.ID, 10)
  6922. data["config"] = config
  6923. fmt.Println(data)
  6924. bytesData, _ := json.Marshal(data)
  6925. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  6926. resp, _ := client.Do(req)
  6927. defer resp.Body.Close()
  6928. body, ioErr := ioutil.ReadAll(resp.Body)
  6929. if ioErr != nil {
  6930. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6932. return
  6933. }
  6934. var respJSON map[string]interface{}
  6935. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6936. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6938. return
  6939. }
  6940. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6941. userJSONBytes, _ := json.Marshal(respJSON)
  6942. fmt.Println("log")
  6943. fmt.Println(string(userJSONBytes))
  6944. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6945. utils.ErrorLog("解析失败:%v", err)
  6946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6947. return
  6948. }
  6949. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6950. //江苏地区国家医保医疗类别
  6951. //职工透析:医疗类别选特殊情况门诊9933
  6952. //居民血透门慢: 医疗类别选门诊慢病1402
  6953. //var med_type string
  6954. //if his.Insutype == "310" {
  6955. // if reg_type == 14 {
  6956. // med_type = "9933"
  6957. // } else if reg_type == 11 {
  6958. // med_type = "11"
  6959. //
  6960. // }
  6961. //} else if his.Insutype == "390" {
  6962. // if reg_type == 14 {
  6963. // med_type = "1402"
  6964. // } else if reg_type == 11 {
  6965. // med_type = "11"
  6966. // }
  6967. //}
  6968. data := make(map[string]interface{})
  6969. client := &http.Client{}
  6970. data["psn_no"] = his.PsnNo
  6971. data["mdtrt_id"] = his.Number
  6972. data["doctor"] = roles.UserName
  6973. data["department"] = department.Name
  6974. data["org_name"] = miConfig.OrgName
  6975. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6976. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6977. data["fixmedins_code"] = miConfig.Code
  6978. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6979. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6980. data["secret_key"] = miConfig.SecretKey
  6981. data["sick_code"] = sickConfig.CountryCode
  6982. data["sick_name"] = sickConfig.ClassName
  6983. data["begin_time"] = begin_time
  6984. data["dept"] = strconv.FormatInt(department.ID, 10)
  6985. data["config"] = config
  6986. data["url"] = miConfig.Url
  6987. data["ak"] = miConfig.AccessKey
  6988. data["cainfo"] = miConfig.Cainfo
  6989. bytesData, _ := json.Marshal(data)
  6990. var req *http.Request
  6991. if miConfig.MdtrtareaAdmvs == "320921" {
  6992. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6993. //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 +
  6994. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  6995. } else {
  6996. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6997. }
  6998. resp, _ := client.Do(req)
  6999. defer resp.Body.Close()
  7000. body, ioErr := ioutil.ReadAll(resp.Body)
  7001. if ioErr != nil {
  7002. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7004. return
  7005. }
  7006. var respJSON map[string]interface{}
  7007. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7008. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7010. return
  7011. }
  7012. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  7013. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  7014. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  7015. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7016. userJSONBytes, _ := json.Marshal(respJSON)
  7017. fmt.Println("log")
  7018. fmt.Println(string(userJSONBytes))
  7019. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7020. utils.ErrorLog("解析失败:%v", err)
  7021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7022. return
  7023. }
  7024. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7025. // res2.Output = resSix10265.Output
  7026. res2.ErrMsg = resSix10265.ErrMsg
  7027. res2.Cainfo = resSix10265.Cainfo
  7028. res2.WarnMsg = resSix10265.WarnMsg
  7029. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7030. res2.Infcode = infocode
  7031. } else {
  7032. var result string
  7033. var requestLog string
  7034. if miConfig.MdtrtareaAdmvs == "440781" { //
  7035. 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)
  7036. } else {
  7037. if miConfig.Code == "H15049901371" {
  7038. //赤峰地区国家医保医疗类别
  7039. //职工透析:医疗类别选特殊情况门诊990502
  7040. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7041. var med_type string
  7042. if his.Insutype == "390" {
  7043. if reg_type == 14 {
  7044. med_type = "9933"
  7045. } else if reg_type == 11 {
  7046. med_type = "11"
  7047. }
  7048. } else if his.Insutype == "310" {
  7049. if reg_type == 14 {
  7050. med_type = "990502"
  7051. } else if reg_type == 11 {
  7052. med_type = "11"
  7053. }
  7054. }
  7055. 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)
  7056. } else {
  7057. var med_type string
  7058. if reg_type == 14 {
  7059. med_type = "14"
  7060. 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)
  7061. } else if reg_type == 11 {
  7062. med_type = "11"
  7063. // sickConfig.ClassName = "普通门诊"
  7064. // sickConfig.ContentCode = "11"
  7065. 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)
  7066. }
  7067. }
  7068. saveLog(result, requestLog, "2203", "上传就诊信息")
  7069. var respJSON2 map[string]interface{}
  7070. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7071. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7073. return
  7074. }
  7075. userJSONBytes2, _ := json.Marshal(respJSON2)
  7076. if miConfig.Code == "H15049901371" {
  7077. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  7078. utils.ErrorLog("解析失败:%v", err)
  7079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7080. return
  7081. }
  7082. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7083. // res2.Output = resSix10265.Output
  7084. res2.ErrMsg = resSix10265.ErrMsg
  7085. res2.Cainfo = resSix10265.Cainfo
  7086. res2.WarnMsg = resSix10265.WarnMsg
  7087. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7088. res2.Infcode = infocode
  7089. } else {
  7090. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7091. utils.ErrorLog("解析失败:%v", err)
  7092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7093. return
  7094. }
  7095. }
  7096. }
  7097. }
  7098. if res2.Infcode != 0 {
  7099. adminUser := c.GetAdminUserInfo()
  7100. errlog := &models.HisOrderError{
  7101. UserOrgId: adminUser.CurrentOrgId,
  7102. Ctime: time.Now().Unix(),
  7103. Mtime: time.Now().Unix(),
  7104. ErrMsg: res2.ErrMsg,
  7105. Status: 1,
  7106. PatientId: id,
  7107. RecordTime: recordDateTime,
  7108. Stage: 3,
  7109. }
  7110. service.CreateErrMsgLog(errlog)
  7111. c.ServeSuccessJSON(map[string]interface{}{
  7112. "failed_code": -10,
  7113. "msg": res2.ErrMsg,
  7114. })
  7115. return
  7116. } else {
  7117. his.Diagnosis = diagnosis_id
  7118. his.SickType = sickConfig.ID
  7119. his.PType = fmt.Sprintf("%d", reg_type)
  7120. service.UpdateHisPatientThree(&his)
  7121. data := make(map[string]interface{})
  7122. if settle_accounts_type == 1 { //日结
  7123. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  7124. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  7125. } else {
  7126. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  7127. }
  7128. data["pre"] = prescriptions
  7129. } else { //月结
  7130. start_time_str := c.GetString("start_time")
  7131. end_time_str := c.GetString("end_time")
  7132. timeLayout := "2006-01-02"
  7133. loc, _ := time.LoadLocation("Local")
  7134. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7135. if err != nil {
  7136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7137. return
  7138. }
  7139. recordStartTime := theStartTime.Unix()
  7140. start_time = recordStartTime
  7141. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7142. if err != nil {
  7143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7144. return
  7145. }
  7146. recordEndTime := theEndTime.Unix()
  7147. end_time = recordEndTime
  7148. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  7149. data["pre"] = prescriptions
  7150. }
  7151. client := &http.Client{}
  7152. data["psn_no"] = his.PsnNo
  7153. data["mdtrt_id"] = his.Number
  7154. data["chrg_bchno"] = chrg_bchno
  7155. data["org_name"] = miConfig.OrgName
  7156. data["doctor"] = roles.UserName
  7157. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  7158. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  7159. data["fixmedins_code"] = miConfig.Code
  7160. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  7161. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  7162. data["dept_code"] = "15"
  7163. } else {
  7164. data["dept_code"] = department.Number
  7165. }
  7166. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7167. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7168. data["secret_key"] = miConfig.SecretKey
  7169. data["url"] = miConfig.Url
  7170. data["ak"] = miConfig.AccessKey
  7171. data["new_doctor_name"] = patientPrescription.Doctor
  7172. data["diag_code"] = sickConfig.CountryCode
  7173. data["time_stamp"] = time_stamp
  7174. data["cainfo"] = miConfig.Cainfo
  7175. var ids []int64
  7176. for _, item := range prescriptions {
  7177. ids = append(ids, item.ID)
  7178. }
  7179. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7180. if config.IsOpen == 1 { //对接了医保,走医保流程
  7181. var res ResultFour
  7182. var resFour10265 ResultFour10265
  7183. if miConfig.MdtrtareaAdmvs == "421300" {
  7184. bytesData, _ := json.Marshal(data)
  7185. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  7186. resp, _ := client.Do(req)
  7187. defer resp.Body.Close()
  7188. body, ioErr := ioutil.ReadAll(resp.Body)
  7189. if ioErr != nil {
  7190. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7192. return
  7193. }
  7194. var respJSON map[string]interface{}
  7195. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7196. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7198. return
  7199. }
  7200. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7201. userJSONBytes, _ := json.Marshal(respJSON)
  7202. fmt.Println("log")
  7203. fmt.Println(string(userJSONBytes))
  7204. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7205. utils.ErrorLog("解析失败:%v", err)
  7206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7207. return
  7208. }
  7209. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7210. bytesData, _ := json.Marshal(data)
  7211. var req *http.Request
  7212. if miConfig.MdtrtareaAdmvs == "320921" {
  7213. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7214. } else {
  7215. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7216. }
  7217. resp, _ := client.Do(req)
  7218. defer resp.Body.Close()
  7219. body, ioErr := ioutil.ReadAll(resp.Body)
  7220. if ioErr != nil {
  7221. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7223. return
  7224. }
  7225. var respJSON map[string]interface{}
  7226. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7227. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7229. return
  7230. }
  7231. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7232. userJSONBytes, _ := json.Marshal(respJSON)
  7233. fmt.Println("log")
  7234. fmt.Println(string(userJSONBytes))
  7235. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7236. utils.ErrorLog("解析失败:%v", err)
  7237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7238. return
  7239. }
  7240. res.InfRefmsgid = resFour10265.InfRefmsgid
  7241. res.Output = resFour10265.Output
  7242. res.ErrMsg = resFour10265.ErrMsg
  7243. res.Cainfo = resFour10265.Cainfo
  7244. res.WarnMsg = resFour10265.WarnMsg
  7245. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7246. res.Infcode = infocode
  7247. } else {
  7248. if miConfig.Code == "H15049901371" {
  7249. 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)
  7250. var dat map[string]interface{}
  7251. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7252. fmt.Println(dat)
  7253. } else {
  7254. fmt.Println(err)
  7255. }
  7256. saveLog(result, request_log, "2204", "上传费用明细")
  7257. userJSONBytes, _ := json.Marshal(dat)
  7258. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7259. utils.ErrorLog("解析失败:%v", err)
  7260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7261. return
  7262. }
  7263. res.InfRefmsgid = resFour10265.InfRefmsgid
  7264. res.Output = resFour10265.Output
  7265. res.ErrMsg = resFour10265.ErrMsg
  7266. res.Cainfo = resFour10265.Cainfo
  7267. res.WarnMsg = resFour10265.WarnMsg
  7268. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7269. res.Infcode = infocode
  7270. } else {
  7271. 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)
  7272. var dat map[string]interface{}
  7273. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7274. fmt.Println(dat)
  7275. } else {
  7276. fmt.Println(err)
  7277. }
  7278. saveLog(result, request_log, "2204", "上传费用明细")
  7279. userJSONBytes, _ := json.Marshal(dat)
  7280. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7281. utils.ErrorLog("解析失败:%v", err)
  7282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7283. return
  7284. }
  7285. }
  7286. }
  7287. if res.Infcode == 0 {
  7288. order := &models.HisOrder{
  7289. UserOrgId: adminUser.CurrentOrgId,
  7290. HisPatientId: his.ID,
  7291. PatientId: his.PatientId,
  7292. SettleAccountsDate: recordDateTime,
  7293. Ctime: time.Now().Unix(),
  7294. Mtime: time.Now().Unix(),
  7295. MdtrtId: his.Number,
  7296. PsnNo: his.PsnNo,
  7297. MedType: strconv.FormatInt(reg_type, 10),
  7298. Status: 1,
  7299. Number: chrg_bchno,
  7300. Infcode: res.Infcode,
  7301. WarnMsg: res.WarnMsg,
  7302. Cainfo: res.Cainfo,
  7303. ErrMsg: res.ErrMsg,
  7304. RespondTime: res.RefmsgTime,
  7305. InfRefmsgid: res.InfRefmsgid,
  7306. OrderStatus: 1,
  7307. IsMedicineInsurance: 1,
  7308. SettleType: settle_accounts_type,
  7309. SettleStartTime: start_time,
  7310. SettleEndTime: end_time,
  7311. Creator: roles.AdminUserId,
  7312. Modify: roles.AdminUserId,
  7313. PType: 2,
  7314. Diagnosis: diagnosis_id,
  7315. }
  7316. err = service.CreateOrder(order)
  7317. if err != nil {
  7318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7319. return
  7320. }
  7321. for _, item := range res.Output.Result {
  7322. temp := strings.Split(item.FeedetlSn, "-")
  7323. var advice_id int64 = 0
  7324. var project_id int64 = 0
  7325. var types int64 = 0
  7326. id, _ := strconv.ParseInt(temp[2], 10, 64)
  7327. types, _ = strconv.ParseInt(temp[1], 10, 64)
  7328. if temp[1] == "1" {
  7329. advice_id = id
  7330. project_id = 0
  7331. } else if temp[1] == "2" {
  7332. advice_id = 0
  7333. project_id = id
  7334. }
  7335. info := &models.HisOrderInfo{
  7336. OrderNumber: order.Number,
  7337. FeedetlSn: item.FeedetlSn,
  7338. UploadDate: time.Now().Unix(),
  7339. AdviceId: advice_id,
  7340. DetItemFeeSumamt: item.DetItemFeeSumamt,
  7341. Cnt: item.Cnt,
  7342. Pric: float64(item.Pric),
  7343. PatientId: his.PatientId,
  7344. PricUplmtAmt: item.PricUplmtAmt,
  7345. SelfpayProp: item.SelfpayProp,
  7346. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7347. OverlmtAmt: item.OverlmtAmt,
  7348. PreselfpayAmt: item.PreselfpayAmt,
  7349. BasMednFlag: item.BasMednFlag,
  7350. MedChrgitmType: item.MedChrgitmType,
  7351. HiNegoDrugFlag: item.HiNegoDrugFlag,
  7352. Status: 1,
  7353. Memo: item.Memo,
  7354. Mtime: time.Now().Unix(),
  7355. InscpScpAmt: item.InscpScpAmt,
  7356. DrtReimFlag: item.DrtReimFlag,
  7357. Ctime: time.Now().Unix(),
  7358. ListSpItemFlag: item.ListSpItemFlag,
  7359. ChldMedcFlag: item.ChldMedcFlag,
  7360. LmtUsedFlag: item.LmtUsedFlag,
  7361. ChrgitmLv: item.ChrgitmLv,
  7362. UserOrgId: adminUser.CurrentOrgId,
  7363. HisPatientId: his.ID,
  7364. OrderId: order.ID,
  7365. ProjectId: project_id,
  7366. Type: types,
  7367. }
  7368. service.CreateOrderInfo(info)
  7369. }
  7370. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7371. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  7372. var total float64
  7373. for _, item := range prescriptions {
  7374. if item.Type == 1 { //药品
  7375. for _, subItem := range item.HisDoctorAdviceInfo {
  7376. total = total + (subItem.Price * subItem.PrescribingNumber)
  7377. }
  7378. }
  7379. if item.Type == 2 { //项目
  7380. for _, subItem := range item.HisPrescriptionProject {
  7381. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7382. total = total + (subItem.Price * cnt)
  7383. }
  7384. }
  7385. }
  7386. for _, item := range prescriptions {
  7387. for _, subItem := range item.HisAdditionalCharge {
  7388. total = total + (subItem.Price * float64(subItem.Count))
  7389. }
  7390. }
  7391. allTotal := fmt.Sprintf("%.4f", total)
  7392. if res.Infcode == 0 {
  7393. var rf []*ResultFive
  7394. json.Unmarshal([]byte(his.Iinfo), &rf)
  7395. chrg_bchno := chrg_bchno
  7396. cert_no := his.Certno
  7397. var insutypes []string
  7398. var insutype string
  7399. var is390 int = 0
  7400. var is310 int = 0
  7401. for _, item := range rf {
  7402. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7403. insutypes = append(insutypes, item.Insutype)
  7404. }
  7405. }
  7406. if len(insutypes) == 1 {
  7407. insutype = insutypes[0]
  7408. } else {
  7409. for _, i := range insutypes {
  7410. if i == "390" {
  7411. is390 = 1
  7412. }
  7413. if i == "310" {
  7414. is310 = 1
  7415. }
  7416. }
  7417. }
  7418. if is390 == 1 {
  7419. insutype = "390"
  7420. }
  7421. if is310 == 1 {
  7422. insutype = "310"
  7423. }
  7424. if len(insutypes) == 0 {
  7425. insutype = "310"
  7426. }
  7427. if len(insutypes) == 2 {
  7428. insutype = strconv.FormatInt(his.SocialType, 64)
  7429. }
  7430. //insutype = "390"
  7431. if his.IdCardType == 1 {
  7432. cert_no = his.MedicalInsuranceNumber
  7433. } else {
  7434. cert_no = his.Certno
  7435. }
  7436. var res models.GZResult2206
  7437. var resSeven10265 ResultSeven10265
  7438. if miConfig.MdtrtareaAdmvs == "421300" {
  7439. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7440. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7441. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7442. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7443. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7444. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7445. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  7446. resp, requestErr := http.Get(api)
  7447. if requestErr != nil {
  7448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7449. return
  7450. }
  7451. body, ioErr := ioutil.ReadAll(resp.Body)
  7452. if ioErr != nil {
  7453. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7455. return
  7456. }
  7457. var respJSON map[string]interface{}
  7458. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7459. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7461. return
  7462. }
  7463. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7464. result, _ := json.Marshal(respJSON)
  7465. fmt.Println("log")
  7466. fmt.Println(string(result))
  7467. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7468. utils.ErrorLog("解析失败:%v", err)
  7469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7470. return
  7471. }
  7472. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7473. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7474. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7475. bas := strings.Split(psn_info.CardInfo, "|")
  7476. if his.IdCardType == 1 {
  7477. cert_no = bas[2]
  7478. } else {
  7479. cert_no = bas[1]
  7480. }
  7481. //江苏地区国家医保医疗类别
  7482. //职工透析:医疗类别选特殊情况门诊9933
  7483. //居民血透门慢: 医疗类别选门诊慢病1402
  7484. //var med_type string
  7485. //if his.Insutype == "310" {
  7486. // if reg_type == 14 {
  7487. // med_type = "9933"
  7488. // } else if reg_type == 11 {
  7489. // med_type = "11"
  7490. //
  7491. // }
  7492. //} else if his.Insutype == "390" {
  7493. // if reg_type == 14 {
  7494. // med_type = "1402"
  7495. // } else if reg_type == 11 {
  7496. // med_type = "11"
  7497. // }
  7498. //}
  7499. var api string
  7500. if miConfig.MdtrtareaAdmvs == "320921" {
  7501. api = "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7502. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7503. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7504. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7505. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7506. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7507. "&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
  7508. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7509. } else {
  7510. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7511. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7512. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7513. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7514. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7515. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7516. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7517. "&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
  7518. }
  7519. resp, requestErr := http.Get(api)
  7520. if requestErr != nil {
  7521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7522. return
  7523. }
  7524. body, ioErr := ioutil.ReadAll(resp.Body)
  7525. if ioErr != nil {
  7526. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7528. return
  7529. }
  7530. var respJSON map[string]interface{}
  7531. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7532. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7534. return
  7535. }
  7536. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7537. result, _ := json.Marshal(respJSON)
  7538. fmt.Println("log")
  7539. fmt.Println(string(result))
  7540. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7541. utils.ErrorLog("解析失败:%v", err)
  7542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7543. return
  7544. }
  7545. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7546. // res.Output = resSeven10265.Output
  7547. res.ErrMsg = resSeven10265.ErrMsg
  7548. res.Cainfo = resSeven10265.Cainfo
  7549. // res.WarnMsg = resSeven10265.WarnMsg
  7550. // infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7551. // res.Infcode = infocode
  7552. } else {
  7553. var result string
  7554. var request_log string
  7555. if miConfig.Code == "H15049901371" {
  7556. //赤峰地区国家医保医疗类别
  7557. //职工透析:医疗类别选特殊情况门诊990502
  7558. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7559. var med_type string
  7560. if his.Insutype == "390" {
  7561. if reg_type == 14 {
  7562. med_type = "9933"
  7563. } else if reg_type == 11 {
  7564. med_type = "11"
  7565. }
  7566. } else if his.Insutype == "310" {
  7567. if reg_type == 14 {
  7568. med_type = "990502"
  7569. } else if reg_type == 11 {
  7570. med_type = "11"
  7571. }
  7572. }
  7573. 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)
  7574. } else {
  7575. var med_type string
  7576. if reg_type == 14 {
  7577. med_type = "141009"
  7578. } else if reg_type == 11 {
  7579. med_type = "11"
  7580. }
  7581. 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)
  7582. }
  7583. var dat map[string]interface{}
  7584. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7585. fmt.Println(dat)
  7586. } else {
  7587. fmt.Println(err)
  7588. }
  7589. saveLog(result, request_log, "2206", "预结算")
  7590. //userJSONBytes, _ := json.Marshal(dat)
  7591. //
  7592. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7593. // utils.ErrorLog("解析失败:%v", err)
  7594. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7595. // return
  7596. //}
  7597. userJSONBytes, _ := json.Marshal(dat)
  7598. if miConfig.Code == "H15049901371" {
  7599. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7600. utils.ErrorLog("解析失败:%v", err)
  7601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7602. return
  7603. }
  7604. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7605. // res.Output = resSeven10265.Output
  7606. res.ErrMsg = resSeven10265.ErrMsg
  7607. res.Cainfo = resSeven10265.Cainfo
  7608. // res.WarnMsg = resSeven10265.WarnMsg
  7609. // infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7610. // res.Infcode = infocode
  7611. } else {
  7612. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7613. utils.ErrorLog("解析失败:%v", err)
  7614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7615. return
  7616. }
  7617. }
  7618. }
  7619. if res.Infcode != 0 {
  7620. errlog := &models.HisOrderError{
  7621. UserOrgId: adminUser.CurrentOrgId,
  7622. Ctime: time.Now().Unix(),
  7623. Mtime: time.Now().Unix(),
  7624. Number: chrg_bchno,
  7625. ErrMsg: res.ErrMsg,
  7626. Status: 1,
  7627. PatientId: id,
  7628. RecordTime: recordDateTime,
  7629. Stage: 20,
  7630. }
  7631. service.CreateErrMsgLog(errlog)
  7632. c.ServeSuccessJSON(map[string]interface{}{
  7633. "failed_code": -10,
  7634. "msg": res.ErrMsg,
  7635. })
  7636. return
  7637. } else {
  7638. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7639. order.OrderStatus = 1
  7640. order.IsPre = 1
  7641. order.Status = 1
  7642. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7643. // order.SetlId = res.Output.Setlinfo.SetlID
  7644. order.PsnNo = res.Output.Setlinfo.PsnNo
  7645. order.PsnName = res.Output.Setlinfo.PsnName
  7646. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7647. order.Certno = res.Output.Setlinfo.Certno
  7648. order.Gend = res.Output.Setlinfo.Gend
  7649. order.Naty = res.Output.Setlinfo.Naty
  7650. order.Age = res.Output.Setlinfo.Age
  7651. order.Insutype = res.Output.Setlinfo.Insutype
  7652. order.PsnType = res.Output.Setlinfo.PsnType
  7653. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7654. order.SetlTime = res.Output.Setlinfo.SetlTime
  7655. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7656. if res.Output.Setlinfo.MedType == "140101" {
  7657. order.MedType = "14"
  7658. } else {
  7659. order.MedType = res.Output.Setlinfo.MedType
  7660. }
  7661. if reg_type == 1112 {
  7662. order.MedType = "1112"
  7663. }
  7664. if reg_type == 1111 {
  7665. order.MedType = "1111"
  7666. }
  7667. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7668. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7669. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7670. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7671. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7672. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7673. order.HifpPay = res.Output.Setlinfo.HifpPay
  7674. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7675. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7676. order.HifesPay = res.Output.Setlinfo.HifesPay
  7677. order.HifobPay = res.Output.Setlinfo.HifobPay
  7678. order.MafPay = res.Output.Setlinfo.MafPay
  7679. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  7680. order.OthPay = res.Output.Setlinfo.OthPay
  7681. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7682. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7683. order.AcctPay = res.Output.Setlinfo.AcctPay
  7684. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7685. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7686. order.Balc = res.Output.Setlinfo.Balc
  7687. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7688. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7689. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7690. order.ClrWay = res.Output.Setlinfo.ClrWay
  7691. order.Creator = order.Creator
  7692. order.Modify = roles.AdminUserId
  7693. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7694. detailStr := string(setlDetail)
  7695. order.SetlDetail = detailStr
  7696. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7697. err = service.UpDateOrder(order)
  7698. if err == nil {
  7699. c.ServeSuccessJSON(map[string]interface{}{
  7700. "msg": "预结算成功",
  7701. })
  7702. } else {
  7703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7704. return
  7705. }
  7706. }
  7707. } else {
  7708. adminUser := c.GetAdminUserInfo()
  7709. errlog := &models.HisOrderError{
  7710. UserOrgId: adminUser.CurrentOrgId,
  7711. Ctime: time.Now().Unix(),
  7712. Mtime: time.Now().Unix(),
  7713. ErrMsg: res.ErrMsg,
  7714. Status: 1,
  7715. PatientId: id,
  7716. RecordTime: recordDateTime,
  7717. Stage: 4,
  7718. }
  7719. service.CreateErrMsgLog(errlog)
  7720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7721. return
  7722. }
  7723. } else {
  7724. adminUser := c.GetAdminUserInfo()
  7725. errlog := &models.HisOrderError{
  7726. UserOrgId: adminUser.CurrentOrgId,
  7727. Ctime: time.Now().Unix(),
  7728. Mtime: time.Now().Unix(),
  7729. ErrMsg: res.ErrMsg,
  7730. Status: 1,
  7731. PatientId: id,
  7732. RecordTime: recordDateTime,
  7733. Stage: 4,
  7734. }
  7735. service.CreateErrMsgLog(errlog)
  7736. c.ServeSuccessJSON(map[string]interface{}{
  7737. "failed_code": -10,
  7738. "msg": res.ErrMsg,
  7739. })
  7740. return
  7741. }
  7742. }
  7743. }
  7744. }
  7745. //func (c *HisApiController) GetSettleInfo() {
  7746. // id, _ := c.GetInt64("id")
  7747. // order_id, _ := c.GetInt64("order_id")
  7748. //
  7749. // record_time := c.GetString("record_time")
  7750. // pay_way, _ := c.GetInt64("pay_way")
  7751. // pay_price, _ := c.GetFloat("pay_price")
  7752. // pay_card_no := c.GetString("pay_card_no")
  7753. // discount_price, _ := c.GetFloat("discount_price")
  7754. // preferential_price, _ := c.GetFloat("preferential_price")
  7755. // reality_price, _ := c.GetFloat("reality_price")
  7756. // found_price, _ := c.GetFloat("found_price")
  7757. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  7758. // private_price, _ := c.GetFloat("private_price")
  7759. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7760. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7761. //
  7762. // timeLayout := "2006-01-02"
  7763. // loc, _ := time.LoadLocation("Local")
  7764. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7765. // if err != nil {
  7766. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7767. // return
  7768. // }
  7769. // recordDateTime := theTime.Unix()
  7770. // adminUser := c.GetAdminUserInfo()
  7771. //
  7772. // var prescriptions []*models.HisPrescription
  7773. //
  7774. // data := make(map[string]interface{})
  7775. // if settle_accounts_type == 1 { //日结
  7776. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  7777. // data["pre"] = prescriptions
  7778. //
  7779. // } else { //月结
  7780. // start_time_str := c.GetString("start_time")
  7781. // end_time_str := c.GetString("end_time")
  7782. // timeLayout := "2006-01-02"
  7783. // loc, _ := time.LoadLocation("Local")
  7784. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7785. // if err != nil {
  7786. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7787. // return
  7788. // }
  7789. // recordStartTime := theStartTime.Unix()
  7790. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7791. // if err != nil {
  7792. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7793. // return
  7794. // }
  7795. // recordEndTime := theEndTime.Unix()
  7796. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  7797. // data["pre"] = prescriptions
  7798. //
  7799. // }
  7800. //
  7801. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7802. //
  7803. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7804. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7805. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7806. // strconv.FormatInt(his.PatientId, 10)
  7807. //
  7808. // order_src, _ := service.GetHisOrderByID(order_id)
  7809. //
  7810. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7811. // if config.IsOpen == 1 { //对接了医保,走医保流程
  7812. //
  7813. // var total float64
  7814. // for _, item := range prescriptions {
  7815. // if item.Type == 1 { //药品
  7816. // for _, subItem := range item.HisDoctorAdviceInfo {
  7817. // total = total + (subItem.Price * subItem.PrescribingNumber)
  7818. // }
  7819. // }
  7820. // if item.Type == 2 { //项目
  7821. // for _, subItem := range item.HisPrescriptionProject {
  7822. // total = total + (subItem.Price * float64(subItem.Count))
  7823. // }
  7824. // }
  7825. // }
  7826. //
  7827. // for _, item := range prescriptions {
  7828. // for _, subItem := range item.HisAdditionalCharge {
  7829. // total = total + (subItem.Price * float64(subItem.Count))
  7830. // }
  7831. // }
  7832. //
  7833. // allTotal := fmt.Sprintf("%.2f", total)
  7834. // var rf []*ResultFive
  7835. // json.Unmarshal([]byte(his.Iinfo), &rf)
  7836. // psn_no := order_src.PsnNo
  7837. // mdtrt_id := order_src.MdtrtId
  7838. // chrg_bchno := order_src.Number
  7839. // cert_no := order_src.Certno
  7840. // insutype := rf[0].Insutype
  7841. //
  7842. // if his.IdCardType == 1 {
  7843. // cert_no = his.MedicalInsuranceNumber
  7844. // } else {
  7845. // cert_no = his.Certno
  7846. // }
  7847. //
  7848. // 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)
  7849. // var dat map[string]interface{}
  7850. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7851. // fmt.Println(dat)
  7852. // } else {
  7853. // fmt.Println(err)
  7854. // }
  7855. //
  7856. // userJSONBytes, _ := json.Marshal(dat)
  7857. //
  7858. //
  7859. //
  7860. // var res ResultSeven
  7861. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7862. // utils.ErrorLog("解析失败:%v", err)
  7863. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7864. // return
  7865. // }
  7866. // if res.Infcode == -1 {
  7867. // errlog := &models.HisOrderError{
  7868. // UserOrgId: adminUser.CurrentOrgId,
  7869. // Ctime: time.Now().Unix(),
  7870. // Mtime: time.Now().Unix(),
  7871. // Number: chrg_bchno,
  7872. // ErrMsg: res.ErrMsg,
  7873. // Status: 1,
  7874. // PatientId: id,
  7875. // RecordTime: recordDateTime,
  7876. // Stage: 6,
  7877. // }
  7878. // service.CreateErrMsgLog(errlog)
  7879. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7880. // return
  7881. // } else {
  7882. // order_src.OrderStatus = 2
  7883. // order_src.PayWay = pay_way
  7884. // order_src.PayPrice = pay_price
  7885. // order_src.PayCardNo = pay_card_no
  7886. // order_src.DiscountPrice = discount_price
  7887. // order_src.PreferentialPrice = preferential_price
  7888. // order_src.RealityPrice = reality_price
  7889. // order_src.FoundPrice = found_price
  7890. // order_src.MedicalInsurancePrice = medical_insurance_price
  7891. // order_src.PrivatePrice = private_price
  7892. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  7893. // order_src.SetlId = res.Output.Setlinfo.SetlID
  7894. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  7895. // order_src.PsnName = res.Output.Setlinfo.PsnName
  7896. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  7897. // order_src.Certno = res.Output.Setlinfo.Certno
  7898. // order_src.Gend = res.Output.Setlinfo.Gend
  7899. // order_src.Naty = res.Output.Setlinfo.Naty
  7900. // order_src.Age = res.Output.Setlinfo.Age
  7901. // order_src.Insutype = res.Output.Setlinfo.Insutype
  7902. // order_src.PsnType = res.Output.Setlinfo.PsnType
  7903. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7904. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  7905. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7906. // order_src.MedType = res.Output.Setlinfo.MedType
  7907. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7908. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7909. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7910. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7911. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7912. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7913. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  7914. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  7915. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7916. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  7917. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  7918. // order_src.MafPay = res.Output.Setlinfo.MafPay
  7919. // order_src.OthPay = res.Output.Setlinfo.OthPay
  7920. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7921. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7922. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  7923. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7924. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7925. // order_src.Balc = res.Output.Setlinfo.Balc
  7926. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7927. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7928. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  7929. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  7930. // order_src.Creator = order_src.Creator
  7931. // order_src.Modify = roles.ID
  7932. // order_src.RequestLog = src_resquest
  7933. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7934. // detailStr := string(setlDetail)
  7935. // order_src.SetlDetail = detailStr
  7936. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7937. // err = service.UpDateOrder(order_src)
  7938. //
  7939. // if err == nil {
  7940. // c.ServeSuccessJSON(map[string]interface{}{
  7941. // "msg": "结算成功",
  7942. // })
  7943. // } else {
  7944. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7945. // return
  7946. // }
  7947. // }
  7948. // }
  7949. //}
  7950. //退款
  7951. func (c *HisApiController) Refund() {
  7952. order_id, _ := c.GetInt64("order_id")
  7953. admin_user_id, _ := c.GetInt64("admin_user_id")
  7954. adminUser := c.GetAdminUserInfo()
  7955. var order models.HisOrder
  7956. order, _ = service.GetHisOrderByID(order_id)
  7957. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7958. if order.ID == 0 {
  7959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7960. return
  7961. }
  7962. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7963. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7964. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7965. if config.IsOpen == 1 { //对接了医保,走医保流程
  7966. var res ResultFourteen
  7967. var resSixteen10265 ResultSixteen10265
  7968. var src_resquest string
  7969. var result string
  7970. if miConfig.MdtrtareaAdmvs == "421300" {
  7971. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  7972. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7973. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7974. resp3, requestErr3 := http.Get(api3)
  7975. if requestErr3 != nil {
  7976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7977. return
  7978. }
  7979. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7980. if ioErr3 != nil {
  7981. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7983. return
  7984. }
  7985. var respJSON3 map[string]interface{}
  7986. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7987. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7989. return
  7990. }
  7991. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7992. userJSONBytes3, _ := json.Marshal(respJSON3)
  7993. fmt.Println("log")
  7994. fmt.Println(string(userJSONBytes3))
  7995. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  7996. utils.ErrorLog("解析失败:%v", err)
  7997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7998. return
  7999. }
  8000. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8001. var api3 string
  8002. if miConfig.MdtrtareaAdmvs == "320921" {
  8003. api3 = "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  8004. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8005. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8006. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8007. } else {
  8008. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8009. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  8010. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8011. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8012. }
  8013. resp3, requestErr3 := http.Get(api3)
  8014. if requestErr3 != nil {
  8015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8016. return
  8017. }
  8018. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8019. if ioErr3 != nil {
  8020. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8022. return
  8023. }
  8024. var respJSON3 map[string]interface{}
  8025. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8026. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8028. return
  8029. }
  8030. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8031. userJSONBytes3, _ := json.Marshal(respJSON3)
  8032. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  8033. utils.ErrorLog("解析失败:%v", err)
  8034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8035. return
  8036. }
  8037. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  8038. // res.Output = resSixteen10265.Output
  8039. res.ErrMsg = resSixteen10265.ErrMsg
  8040. // res.Cainfo = resSixteen10265.Cainfo
  8041. // res.WarnMsg = resSixteen10265.WarnMsg
  8042. // infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  8043. // res.Infcode = infocode
  8044. } else {
  8045. if miConfig.Code == "H15049901371" {
  8046. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  8047. var dat map[string]interface{}
  8048. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8049. fmt.Println(dat)
  8050. } else {
  8051. fmt.Println(err)
  8052. }
  8053. saveLog(result, src_resquest, "2208", "退费")
  8054. userJSONBytes, _ := json.Marshal(dat)
  8055. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  8056. utils.ErrorLog("解析失败:%v", err)
  8057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8058. return
  8059. }
  8060. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  8061. // res.Output = resSixteen10265.Output
  8062. res.ErrMsg = resSixteen10265.ErrMsg
  8063. // res.Cainfo = resSixteen10265.Cainfo
  8064. // res.WarnMsg = resSixteen10265.WarnMsg
  8065. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  8066. res.Infcode = infocode
  8067. } else {
  8068. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  8069. var dat map[string]interface{}
  8070. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8071. fmt.Println(dat)
  8072. } else {
  8073. fmt.Println(err)
  8074. }
  8075. saveLog(result, src_resquest, "2208", "退费")
  8076. userJSONBytes, _ := json.Marshal(dat)
  8077. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8078. utils.ErrorLog("解析失败:%v", err)
  8079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8080. return
  8081. }
  8082. }
  8083. }
  8084. if res.Infcode == 0 {
  8085. var res2 ResultSix
  8086. var resSix10265 ResultSix10265
  8087. if miConfig.MdtrtareaAdmvs == "421300" {
  8088. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8089. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8090. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8091. resp3, requestErr3 := http.Get(api3)
  8092. if requestErr3 != nil {
  8093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8094. return
  8095. }
  8096. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8097. if ioErr3 != nil {
  8098. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8100. return
  8101. }
  8102. var respJSON3 map[string]interface{}
  8103. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8104. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8106. return
  8107. }
  8108. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8109. userJSONBytes3, _ := json.Marshal(respJSON3)
  8110. fmt.Println("log")
  8111. fmt.Println(string(userJSONBytes3))
  8112. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8113. utils.ErrorLog("解析失败:%v", err)
  8114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8115. return
  8116. }
  8117. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8118. var api3 string
  8119. if miConfig.MdtrtareaAdmvs == "320921" {
  8120. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8121. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8122. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8123. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8124. } else {
  8125. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8126. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8127. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8128. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8129. }
  8130. resp3, requestErr3 := http.Get(api3)
  8131. if requestErr3 != nil {
  8132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8133. return
  8134. }
  8135. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8136. if ioErr3 != nil {
  8137. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8139. return
  8140. }
  8141. var respJSON3 map[string]interface{}
  8142. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8143. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8145. return
  8146. }
  8147. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8148. userJSONBytes3, _ := json.Marshal(respJSON3)
  8149. fmt.Println("log")
  8150. fmt.Println(string(userJSONBytes3))
  8151. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8152. utils.ErrorLog("解析失败:%v", err)
  8153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8154. return
  8155. }
  8156. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8157. // res2.Output = resSix10265.Output
  8158. res2.ErrMsg = resSix10265.ErrMsg
  8159. res2.Cainfo = resSix10265.Cainfo
  8160. res2.WarnMsg = resSix10265.WarnMsg
  8161. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8162. res2.Infcode = infocode
  8163. } else {
  8164. if miConfig.Code == "H15049901371" {
  8165. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8166. var dat map[string]interface{}
  8167. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8168. fmt.Println(dat)
  8169. } else {
  8170. fmt.Println(err)
  8171. }
  8172. saveLog(result2, src_request, "2205", "撤销明细")
  8173. userJSONBytes, _ := json.Marshal(dat)
  8174. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  8175. utils.ErrorLog("解析失败:%v", err)
  8176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8177. return
  8178. }
  8179. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8180. // res2.Output = resSix10265.Output
  8181. res2.ErrMsg = resSix10265.ErrMsg
  8182. res2.Cainfo = resSix10265.Cainfo
  8183. res2.WarnMsg = resSix10265.WarnMsg
  8184. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8185. res2.Infcode = infocode
  8186. } else {
  8187. order_infos, _ := service.GetHisOrderInfoByNumberFour(order.Number)
  8188. for _, item := range order_infos {
  8189. result2, src_request := service.Gdyb2205ForGz(order.PsnNo, order.MdtrtId, item.FeedetlSn, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8190. var dat map[string]interface{}
  8191. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8192. fmt.Println(dat)
  8193. } else {
  8194. fmt.Println(err)
  8195. }
  8196. saveLog(result2, src_request, "2205", "撤销明细")
  8197. userJSONBytes, _ := json.Marshal(dat)
  8198. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8199. utils.ErrorLog("解析失败:%v", err)
  8200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8201. return
  8202. }
  8203. }
  8204. }
  8205. }
  8206. if res2.Infcode == 0 {
  8207. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  8208. if err == nil {
  8209. //当押金不为零时产生退费记录
  8210. if order.Decimal != 0 {
  8211. tmp := strconv.FormatInt(order.ID, 10)
  8212. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  8213. if err != nil {
  8214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8215. return
  8216. }
  8217. }
  8218. c.ServeSuccessJSON(map[string]interface{}{
  8219. "msg": "退费成功",
  8220. })
  8221. } else {
  8222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8223. return
  8224. }
  8225. } else {
  8226. c.ServeSuccessJSON(map[string]interface{}{
  8227. "code": -10,
  8228. "msg": res2.ErrMsg,
  8229. })
  8230. }
  8231. } else {
  8232. c.ServeSuccessJSON(map[string]interface{}{
  8233. "code": -10,
  8234. "msg": res.ErrMsg,
  8235. })
  8236. }
  8237. }
  8238. }
  8239. func (c *HisApiController) RefundNumber() {
  8240. record_time := c.GetString("record_time")
  8241. //patient_id, _ := c.GetInt64("patient_id")
  8242. admin_user_id, _ := c.GetInt64("admin_user_id")
  8243. his_patient_id, _ := c.GetInt64("id")
  8244. timeLayout := "2006-01-02"
  8245. loc, _ := time.LoadLocation("Local")
  8246. adminUser := c.GetAdminUserInfo()
  8247. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8248. fmt.Println(err)
  8249. if err != nil {
  8250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8251. return
  8252. }
  8253. recordDateTime := theTime.Unix()
  8254. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8255. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  8256. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8257. //order, _ := service.GetHisOrderByID(order_id)
  8258. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8259. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8260. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8261. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  8262. if count > 0 {
  8263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  8264. return
  8265. }
  8266. if config.IsOpen == 1 { //对接了医保,走医保流程
  8267. var res2 ResultSix
  8268. var resSix10265 ResultSix10265
  8269. if miConfig.MdtrtareaAdmvs == "421300" {
  8270. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  8271. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8272. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8273. resp3, requestErr3 := http.Get(api3)
  8274. if requestErr3 != nil {
  8275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8276. return
  8277. }
  8278. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8279. if ioErr3 != nil {
  8280. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8282. return
  8283. }
  8284. var respJSON3 map[string]interface{}
  8285. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8286. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8288. return
  8289. }
  8290. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8291. userJSONBytes3, _ := json.Marshal(respJSON3)
  8292. fmt.Println("log")
  8293. fmt.Println(string(userJSONBytes3))
  8294. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8295. utils.ErrorLog("解析失败:%v", err)
  8296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8297. return
  8298. }
  8299. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8300. var api3 string
  8301. if miConfig.MdtrtareaAdmvs == "320921" {
  8302. api3 = "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8303. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8304. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8305. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8306. } else {
  8307. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8308. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8309. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8310. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8311. }
  8312. resp3, requestErr3 := http.Get(api3)
  8313. if requestErr3 != nil {
  8314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8315. return
  8316. }
  8317. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8318. if ioErr3 != nil {
  8319. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8321. return
  8322. }
  8323. var respJSON3 map[string]interface{}
  8324. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8325. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8327. return
  8328. }
  8329. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8330. userJSONBytes3, _ := json.Marshal(respJSON3)
  8331. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8332. utils.ErrorLog("解析失败:%v", err)
  8333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8334. return
  8335. }
  8336. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8337. // res2.Output = resSix10265.Output
  8338. res2.ErrMsg = resSix10265.ErrMsg
  8339. res2.Cainfo = resSix10265.Cainfo
  8340. res2.WarnMsg = resSix10265.WarnMsg
  8341. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8342. res2.Infcode = infocode
  8343. } else {
  8344. var api3 string
  8345. if miConfig.Code == "H15049901371" {
  8346. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8347. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8348. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8349. } else {
  8350. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8351. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8352. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8353. }
  8354. resp3, requestErr3 := http.Get(api3)
  8355. if requestErr3 != nil {
  8356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8357. return
  8358. }
  8359. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8360. if ioErr3 != nil {
  8361. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8363. return
  8364. }
  8365. var respJSON3 map[string]interface{}
  8366. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8367. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8369. return
  8370. }
  8371. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8372. userJSONBytes3, _ := json.Marshal(respJSON3)
  8373. if miConfig.Code == "H15049901371" {
  8374. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8375. utils.ErrorLog("解析失败:%v", err)
  8376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8377. return
  8378. }
  8379. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8380. // res2.Output = resSix10265.Output
  8381. res2.ErrMsg = resSix10265.ErrMsg
  8382. res2.Cainfo = resSix10265.Cainfo
  8383. res2.WarnMsg = resSix10265.WarnMsg
  8384. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8385. res2.Infcode = infocode
  8386. } else {
  8387. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8388. utils.ErrorLog("解析失败:%v", err)
  8389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8390. return
  8391. }
  8392. }
  8393. }
  8394. if res2.Infcode == 0 {
  8395. if err == nil {
  8396. c.ServeSuccessJSON(map[string]interface{}{
  8397. "msg": "退号成功",
  8398. })
  8399. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  8400. } else {
  8401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8402. return
  8403. }
  8404. } else {
  8405. c.ServeSuccessJSON(map[string]interface{}{
  8406. "code": -10,
  8407. "msg": res2.ErrMsg,
  8408. })
  8409. }
  8410. } else {
  8411. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  8412. //if err == nil {
  8413. // c.ServeSuccessJSON(map[string]interface{}{
  8414. // "msg": "退费成功",
  8415. // })
  8416. //} else {
  8417. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8418. // return
  8419. //}
  8420. }
  8421. }
  8422. func (c *HisApiController) RefundDetail() {
  8423. order_id, _ := c.GetInt64("order_id")
  8424. admin_user_id, _ := c.GetInt64("admin_user_id")
  8425. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8426. number := c.GetString("number")
  8427. record_time := c.GetString("record_time")
  8428. patient_id, _ := c.GetInt64("patient_id")
  8429. //med_type, _ := c.GetInt64("med_type")
  8430. timeLayout := "2006-01-02"
  8431. loc, _ := time.LoadLocation("Local")
  8432. adminUser := c.GetAdminUserInfo()
  8433. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8434. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8435. fmt.Println(err)
  8436. if err != nil {
  8437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8438. return
  8439. }
  8440. recordDateTime := theTime.Unix()
  8441. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8442. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8443. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8444. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8445. var order models.HisOrder
  8446. order, _ = service.GetHisOrderByID(order_id)
  8447. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8448. if config.IsOpen == 1 { //对接了医保,走医保流程
  8449. var res2 ResultSix
  8450. if miConfig.MdtrtareaAdmvs == "421300" {
  8451. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8452. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8453. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8454. resp3, requestErr3 := http.Get(api3)
  8455. if requestErr3 != nil {
  8456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8457. return
  8458. }
  8459. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8460. if ioErr3 != nil {
  8461. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8463. return
  8464. }
  8465. var respJSON3 map[string]interface{}
  8466. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8467. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8469. return
  8470. }
  8471. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8472. userJSONBytes3, _ := json.Marshal(respJSON3)
  8473. fmt.Println("log")
  8474. fmt.Println(string(userJSONBytes3))
  8475. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8476. utils.ErrorLog("解析失败:%v", err)
  8477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8478. return
  8479. }
  8480. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8481. if err == nil {
  8482. c.ServeSuccessJSON(map[string]interface{}{
  8483. "msg": "撤销明细成功",
  8484. })
  8485. return
  8486. } else {
  8487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8488. return
  8489. }
  8490. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8491. var resSix10265 ResultSix10265
  8492. var api3 string
  8493. if miConfig.MdtrtareaAdmvs == "320921" {
  8494. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8495. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8496. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8497. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8498. } else {
  8499. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8500. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8501. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8502. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8503. }
  8504. resp3, requestErr3 := http.Get(api3)
  8505. if requestErr3 != nil {
  8506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8507. return
  8508. }
  8509. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8510. if ioErr3 != nil {
  8511. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8513. return
  8514. }
  8515. var respJSON3 map[string]interface{}
  8516. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8517. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8519. return
  8520. }
  8521. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8522. userJSONBytes3, _ := json.Marshal(respJSON3)
  8523. fmt.Println("log")
  8524. fmt.Println(string(userJSONBytes3))
  8525. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8526. utils.ErrorLog("解析失败:%v", err)
  8527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8528. return
  8529. }
  8530. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8531. // res2.Output = resSix10265.Output
  8532. res2.ErrMsg = resSix10265.ErrMsg
  8533. res2.Cainfo = resSix10265.Cainfo
  8534. res2.WarnMsg = resSix10265.WarnMsg
  8535. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8536. res2.Infcode = infocode
  8537. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8538. if err == nil {
  8539. c.ServeSuccessJSON(map[string]interface{}{
  8540. "msg": "撤销明细成功",
  8541. })
  8542. return
  8543. } else {
  8544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8545. return
  8546. }
  8547. } else {
  8548. order_infos, _ := service.GetHisOrderInfoByNumberFour(order.Number)
  8549. for _, item := range order_infos {
  8550. result2, src_request := service.Gdyb2205ForGz(order.PsnNo, order.MdtrtId, item.FeedetlSn, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8551. var dat map[string]interface{}
  8552. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8553. fmt.Println(dat)
  8554. } else {
  8555. fmt.Println(err)
  8556. }
  8557. saveLog(result2, src_request, "2205", "撤销明细")
  8558. userJSONBytes, _ := json.Marshal(dat)
  8559. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8560. utils.ErrorLog("解析失败:%v", err)
  8561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8562. return
  8563. }
  8564. }
  8565. }
  8566. }
  8567. }
  8568. //对账
  8569. func (c *HisApiController) GetCheckAccount() {
  8570. start_time := c.GetString("start_time")
  8571. end_time := c.GetString("end_time")
  8572. insutype := c.GetString("insutype")
  8573. clr_type := c.GetString("clr_type")
  8574. clr_org := c.GetString("clr_optins")
  8575. admin_user_id, _ := c.GetInt64("admin_user_id")
  8576. adminUser := c.GetAdminUserInfo()
  8577. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8578. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8579. if len(clr_org) == 0 {
  8580. clr_org = miConfig.MdtrtareaAdmvs
  8581. }
  8582. timeLayout := "2006-01-02"
  8583. loc, _ := time.LoadLocation("Local")
  8584. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8585. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8586. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  8587. fixmedins_setl_cnt := int64(len(orders))
  8588. var medfee_sumamt float64
  8589. var acct_pay float64
  8590. var fund_pay_sumamt float64
  8591. for _, item := range orders {
  8592. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8593. acct_pay = acct_pay + item.AcctPay
  8594. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8595. }
  8596. var user_name string
  8597. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8598. if role.ID == 0 {
  8599. user_name = "xxx"
  8600. } else {
  8601. user_name = role.UserName
  8602. }
  8603. var res ResultEight
  8604. var res10188 ResultEightFor10188
  8605. if config.IsOpen == 1 {
  8606. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8607. api := "http://192.168.3.111:9532/" + "jsyb/3201?" +
  8608. "insutype=" + insutype +
  8609. "&clr_type=" + "11" +
  8610. "&setl_optins=" + clr_org +
  8611. "&stmt_begndate=" + start_time +
  8612. "&stm_enddate=" + end_time +
  8613. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8614. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8615. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8616. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8617. "&fixmedins_code=" + miConfig.Code +
  8618. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8619. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8620. "&secret_key=" + miConfig.SecretKey +
  8621. "&org_name=" + miConfig.OrgName +
  8622. "&doctor=" + user_name +
  8623. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8624. fmt.Println(api)
  8625. resp, requestErr := http.Get(api)
  8626. if requestErr != nil {
  8627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8628. return
  8629. }
  8630. body, ioErr := ioutil.ReadAll(resp.Body)
  8631. fmt.Println(body)
  8632. if ioErr != nil {
  8633. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8635. return
  8636. }
  8637. var respJSON map[string]interface{}
  8638. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8639. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8641. return
  8642. }
  8643. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8644. userJSONBytes, _ := json.Marshal(respJSON)
  8645. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8646. utils.ErrorLog("解析失败:%v", err)
  8647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8648. return
  8649. }
  8650. res.InfRefmsgid = res10188.InfRefmsgid
  8651. res.Output = res10188.Output
  8652. res.ErrMsg = res10188.ErrMsg
  8653. res.Cainfo = res10188.Cainfo
  8654. res.WarnMsg = res10188.WarnMsg
  8655. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8656. res.Infcode = infocode
  8657. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8658. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  8659. "insutype=" + insutype +
  8660. "&clr_type=" + "21" +
  8661. "&setl_optins=" + clr_org +
  8662. "&stmt_begndate=" + start_time +
  8663. "&stm_enddate=" + end_time +
  8664. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8665. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8666. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8667. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8668. "&fixmedins_code=" + miConfig.Code +
  8669. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8670. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8671. "&secret_key=" + miConfig.SecretKey +
  8672. "&org_name=" + miConfig.OrgName +
  8673. "&doctor=" + user_name
  8674. resp, requestErr := http.Get(api)
  8675. if requestErr != nil {
  8676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8677. return
  8678. }
  8679. body, ioErr := ioutil.ReadAll(resp.Body)
  8680. if ioErr != nil {
  8681. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8683. return
  8684. }
  8685. var respJSON map[string]interface{}
  8686. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8687. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8689. return
  8690. }
  8691. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8692. result, _ := json.Marshal(respJSON)
  8693. fmt.Println("log")
  8694. fmt.Println(string(result))
  8695. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  8696. utils.ErrorLog("解析失败:%v", err)
  8697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8698. return
  8699. }
  8700. res.InfRefmsgid = res10188.InfRefmsgid
  8701. res.Output = res10188.Output
  8702. res.ErrMsg = res10188.ErrMsg
  8703. res.Cainfo = res10188.Cainfo
  8704. res.WarnMsg = res10188.WarnMsg
  8705. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8706. res.Infcode = infocode
  8707. } else {
  8708. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8709. "insutype=" + insutype +
  8710. "&clr_type=" + clr_type +
  8711. "&setl_optins=" + "440104" +
  8712. "&stmt_begndate=" + start_time +
  8713. "&stm_enddate=" + end_time +
  8714. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8715. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8716. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8717. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8718. "&fixmedins_code=" + miConfig.Code +
  8719. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8720. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8721. "&secret_key=" + miConfig.SecretKey +
  8722. "&org_name=" + miConfig.OrgName +
  8723. "&doctor=" + user_name
  8724. fmt.Println(api)
  8725. resp, requestErr := http.Get(api)
  8726. if requestErr != nil {
  8727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8728. return
  8729. }
  8730. body, ioErr := ioutil.ReadAll(resp.Body)
  8731. fmt.Println(body)
  8732. if ioErr != nil {
  8733. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8735. return
  8736. }
  8737. var respJSON map[string]interface{}
  8738. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8739. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8741. return
  8742. }
  8743. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8744. userJSONBytes, _ := json.Marshal(respJSON)
  8745. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8746. utils.ErrorLog("解析失败:%v", err)
  8747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8748. return
  8749. }
  8750. }
  8751. if res.Infcode == 0 {
  8752. if res.Output.Stmtinfo.StmtRslt == "0" {
  8753. micc := &models.MedicalInsuranceCostCompare{
  8754. StartTime: startime.Unix(),
  8755. EndTime: endtime.Unix(),
  8756. Insutype: insutype,
  8757. CheckType: 1,
  8758. Num: fixmedins_setl_cnt,
  8759. Mtime: time.Now().Unix(),
  8760. Status: 1,
  8761. UserOrgId: adminUser.CurrentOrgId,
  8762. CostTotal: medfee_sumamt,
  8763. FuncTotal: fund_pay_sumamt,
  8764. PsnPay: acct_pay,
  8765. Creator: admin_user_id,
  8766. Ctime: time.Now().Unix(),
  8767. ClrType: clr_type,
  8768. }
  8769. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  8770. if err == nil {
  8771. c.ServeSuccessJSON(map[string]interface{}{
  8772. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8773. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8774. })
  8775. } else {
  8776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8777. }
  8778. } else {
  8779. c.ServeSuccessJSON(map[string]interface{}{
  8780. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8781. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8782. })
  8783. }
  8784. } else {
  8785. c.ServeSuccessJSON(map[string]interface{}{
  8786. "code": -10,
  8787. "msg": res.ErrMsg,
  8788. })
  8789. }
  8790. }
  8791. }
  8792. func (c *HisApiController) Check310() {
  8793. adminUser := c.GetAdminUserInfo()
  8794. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8795. var user_name string
  8796. user_name = "高慧裕"
  8797. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8798. "insutype=" + "310" +
  8799. "&clr_type=" + "" +
  8800. "&setl_optins=" + "441202" +
  8801. "&stmt_begndate=" + "2022-03-01" +
  8802. "&stm_enddate=" + "2022-03-31" +
  8803. "&medfee_sumamt=" + "194930.12" +
  8804. "&fund_pay_sumamt=" + "188741.46" +
  8805. "&acct_pay=" + "0" +
  8806. "&fixmedins_setl_cnt=" + "452" +
  8807. "&fixmedins_code=" + miConfig.Code +
  8808. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8809. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8810. "&secret_key=" + miConfig.SecretKey +
  8811. "&org_name=" + miConfig.OrgName +
  8812. "&doctor=" + user_name
  8813. fmt.Println(api)
  8814. resp, requestErr := http.Get(api)
  8815. if requestErr != nil {
  8816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8817. return
  8818. }
  8819. body, ioErr := ioutil.ReadAll(resp.Body)
  8820. fmt.Println(body)
  8821. if ioErr != nil {
  8822. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8824. return
  8825. }
  8826. var respJSON map[string]interface{}
  8827. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8828. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8830. return
  8831. }
  8832. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8833. userJSONBytes, _ := json.Marshal(respJSON)
  8834. var res ResultEight
  8835. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8836. utils.ErrorLog("解析失败:%v", err)
  8837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8838. return
  8839. }
  8840. }
  8841. func (c *HisApiController) Check390() {
  8842. adminUser := c.GetAdminUserInfo()
  8843. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8844. var user_name string
  8845. user_name = "高慧裕"
  8846. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8847. "insutype=" + "390" +
  8848. "&clr_type=" + "" +
  8849. "&setl_optins=" + "441202" +
  8850. "&stmt_begndate=" + "2022-03-01" +
  8851. "&stm_enddate=" + "2022-03-31" +
  8852. "&medfee_sumamt=" + "1068448.89" +
  8853. "&fund_pay_sumamt=" + "1014677.62" +
  8854. "&acct_pay=" + "0" +
  8855. "&fixmedins_setl_cnt=" + "1950" +
  8856. "&fixmedins_code=" + miConfig.Code +
  8857. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8858. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8859. "&secret_key=" + miConfig.SecretKey +
  8860. "&org_name=" + miConfig.OrgName +
  8861. "&doctor=" + user_name
  8862. fmt.Println(api)
  8863. resp, requestErr := http.Get(api)
  8864. if requestErr != nil {
  8865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8866. return
  8867. }
  8868. body, ioErr := ioutil.ReadAll(resp.Body)
  8869. fmt.Println(body)
  8870. if ioErr != nil {
  8871. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8873. return
  8874. }
  8875. var respJSON map[string]interface{}
  8876. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8877. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8879. return
  8880. }
  8881. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8882. userJSONBytes, _ := json.Marshal(respJSON)
  8883. var res ResultEight
  8884. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8885. utils.ErrorLog("解析失败:%v", err)
  8886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8887. return
  8888. }
  8889. }
  8890. //对账明细
  8891. func (c *HisApiController) GetCheckDetailAccount() {
  8892. start_time := c.GetString("start_time")
  8893. end_time := c.GetString("end_time")
  8894. admin_user_id, _ := c.GetInt64("admin_user_id")
  8895. adminUser := c.GetAdminUserInfo()
  8896. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8897. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8898. timeLayout := "2006-01-02"
  8899. loc, _ := time.LoadLocation("Local")
  8900. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8901. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8902. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  8903. rand.Seed(time.Now().UnixNano())
  8904. num := rand.Intn(30000)
  8905. Mkdir(miConfig.OrgName)
  8906. file := strconv.FormatInt(int64(num), 10)
  8907. file_name := file + ".txt"
  8908. zip_name := file + ".zip"
  8909. zip_path := miConfig.OrgName + "/" + zip_name
  8910. file_path := miConfig.OrgName + "/" + file_name
  8911. decimal.DivisionPrecision = 2
  8912. var medfee_sumamt float64
  8913. var psn_cash_pay float64
  8914. var fund_pay_sumamt float64
  8915. fixmedins_setl_cnt := int64(len(orders))
  8916. for _, item := range orders {
  8917. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8918. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  8919. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8920. }
  8921. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  8922. defer f.Close()
  8923. if err != nil {
  8924. fmt.Println(err.Error())
  8925. } else {
  8926. for _, item := range orders {
  8927. var refd_setl_flag string
  8928. if item.OrderStatus == 2 {
  8929. refd_setl_flag = "0"
  8930. var str string
  8931. str = item.SetlId + " " +
  8932. item.MdtrtId + " " +
  8933. item.PsnNo + " " +
  8934. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8935. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8936. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  8937. _, err = f.Write([]byte(str))
  8938. }
  8939. if item.OrderStatus == 3 {
  8940. var str string
  8941. str = item.SetlId + " " +
  8942. item.MdtrtId + " " +
  8943. item.PsnNo + " " +
  8944. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8945. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8946. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  8947. _, err = f.Write([]byte(str))
  8948. var str2 string
  8949. str2 = item.SetlId + " " +
  8950. item.MdtrtId + " " +
  8951. item.PsnNo + " " +
  8952. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  8953. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  8954. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  8955. _, err = f.Write([]byte(str2))
  8956. }
  8957. }
  8958. }
  8959. Zip(file_path, zip_path)
  8960. fmt.Println(ReadFile(zip_path))
  8961. fmt.Println(string(ReadFile(zip_path)))
  8962. if config.IsOpen == 1 {
  8963. var user_name string
  8964. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8965. if role.ID == 0 {
  8966. user_name = "管理员"
  8967. } else {
  8968. user_name = role.UserName
  8969. }
  8970. baseParams := models.BaseParams{
  8971. SecretKey: miConfig.SecretKey,
  8972. FixmedinsCode: miConfig.Code,
  8973. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8974. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8975. OrgName: miConfig.OrgName,
  8976. Doctor: user_name,
  8977. }
  8978. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  8979. var dat map[string]interface{}
  8980. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8981. fmt.Println(dat)
  8982. } else {
  8983. fmt.Println(err)
  8984. }
  8985. userJSONBytes, _ := json.Marshal(dat)
  8986. var res ResultNine
  8987. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8988. utils.ErrorLog("解析失败:%v", err)
  8989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8990. return
  8991. }
  8992. if res.Infcode == 0 {
  8993. fileNo := res.Output.FileQuryNo
  8994. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  8995. "file_qury_no=" + fileNo +
  8996. "&setl_optins=" + "定点医保中心" +
  8997. "&stmt_begndate=" + start_time +
  8998. "&stm_enddate=" + end_time +
  8999. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  9000. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  9001. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  9002. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  9003. "&fixmedins_code=" + miConfig.Code +
  9004. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9005. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9006. "&secret_key=" + miConfig.SecretKey +
  9007. "&org_name=" + miConfig.OrgName +
  9008. "&doctor=" + user_name
  9009. resp, requestErr := http.Get(api)
  9010. if requestErr != nil {
  9011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9012. return
  9013. }
  9014. body, ioErr := ioutil.ReadAll(resp.Body)
  9015. if ioErr != nil {
  9016. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9018. return
  9019. }
  9020. var respJSON map[string]interface{}
  9021. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9022. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9024. return
  9025. }
  9026. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9027. userJSONBytes, _ := json.Marshal(respJSON)
  9028. var res ResultTen
  9029. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9030. utils.ErrorLog("解析失败:%v", err)
  9031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9032. return
  9033. }
  9034. if res.Infcode == 0 {
  9035. service.Gdyb9102(baseParams, zip_name, fileNo)
  9036. micc := &models.MedicalInsuranceCostCompare{
  9037. StartTime: startime.Unix(),
  9038. EndTime: endtime.Unix(),
  9039. Insutype: "0",
  9040. CheckType: 2,
  9041. Num: fixmedins_setl_cnt,
  9042. Mtime: time.Now().Unix(),
  9043. Status: 1,
  9044. UserOrgId: adminUser.CurrentOrgId,
  9045. CostTotal: medfee_sumamt,
  9046. FuncTotal: fund_pay_sumamt,
  9047. PsnPay: psn_cash_pay,
  9048. Creator: admin_user_id,
  9049. Ctime: time.Now().Unix(),
  9050. }
  9051. service.CreateMedicalInsuranceCostCompareRecord(micc)
  9052. c.ServeSuccessJSON(map[string]interface{}{
  9053. "msg": "明细对账成功",
  9054. })
  9055. }
  9056. } else {
  9057. }
  9058. }
  9059. }
  9060. type CustomOrderInfo struct {
  9061. Name string
  9062. Spec string
  9063. Unit string
  9064. Count float64
  9065. Price float64
  9066. Total float64
  9067. }
  9068. func (c *HisApiController) GetSettleAccounts() {
  9069. //id, _ := c.GetInt64("id")
  9070. //record_time := c.GetString("record_time")
  9071. order_id, _ := c.GetInt64("order_id")
  9072. admin_user_id, _ := c.GetInt64("admin_user_id")
  9073. //timeLayout := "2006-01-02"
  9074. //loc, _ := time.LoadLocation("Local")
  9075. //
  9076. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9077. //if err != nil {
  9078. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9079. // return
  9080. //}
  9081. //recordDateTime := theTime.Unix()
  9082. adminUser := c.GetAdminUserInfo()
  9083. order, _ := service.GetHisOrderByID(order_id)
  9084. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9085. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  9086. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  9087. orderInfos = append(orderInfos, orderInfos_two...)
  9088. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9089. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  9090. var diagnosis_ids []string
  9091. if his.ID > 0 {
  9092. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  9093. } else {
  9094. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  9095. }
  9096. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  9097. var dia_config []*models.HisXtDiagnoseConfig
  9098. var name string
  9099. for _, item := range diagnosis_ids {
  9100. id, _ := strconv.ParseInt(item, 10, 64)
  9101. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9102. dia_config = append(dia_config, &diagnosisConfig)
  9103. if len(name) == 0 {
  9104. name = diagnosisConfig.ClassName
  9105. } else {
  9106. name = name + "," + diagnosisConfig.ClassName
  9107. }
  9108. }
  9109. var bedCostTotal float64 = 0 //床位总费
  9110. var bedCostSelfTotal float64 = 0 //床位自费
  9111. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  9112. var operationCostTotal float64 = 0 //手术费
  9113. var operationCostSelfTotal float64 = 0 //手术费
  9114. var operationCostPartSelfTotal float64 = 0 //手术费
  9115. var otherCostTotal float64 = 0 //其他费用
  9116. var otherCostSelfTotal float64 = 0 //其他费用
  9117. var otherCostPartSelfTotal float64 = 0 //其他费用
  9118. var materialCostTotal float64 = 0 //材料费
  9119. var materialCostSelfTotal float64 = 0 //材料费
  9120. var materialCostPartSelfTotal float64 = 0 //材料费
  9121. var westernMedicineCostTotal float64 = 0 //西药费
  9122. var westernMedicineCostSelfTotal float64 = 0 //西药费
  9123. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  9124. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  9125. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  9126. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  9127. var checkCostTotal float64 = 0 //检查费
  9128. var checkCostSelfTotal float64 = 0 //检查费
  9129. var checkCostPartSelfTotal float64 = 0 //检查费
  9130. var laboratoryCostTotal float64 = 0 //化验费
  9131. var laboratoryCostSelfTotal float64 = 0 //化验费
  9132. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  9133. var treatCostTotal float64 = 0 //治疗费用
  9134. var treatCostSelfTotal float64 = 0 //治疗费用
  9135. var treatCostPartSelfTotal float64 = 0 //治疗费用
  9136. decimal.DivisionPrecision = 2
  9137. for _, item := range orderInfos {
  9138. if item.MedChrgitmType == "01" { //床位费
  9139. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9140. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9141. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9142. }
  9143. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  9144. if item.MedChrgitmType == "03" { //检查费
  9145. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9146. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9147. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9148. }
  9149. } else {
  9150. if item.MedChrgitmType == "03" { //检查费
  9151. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9152. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9153. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9154. }
  9155. }
  9156. if item.MedChrgitmType == "04" { //化验费
  9157. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9158. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9159. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9160. }
  9161. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  9162. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9163. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9164. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9165. }
  9166. if item.MedChrgitmType == "06" { //手术费
  9167. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9168. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9169. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9170. }
  9171. if item.MedChrgitmType == "08" { //材料费
  9172. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9173. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9174. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9175. }
  9176. if item.MedChrgitmType == "09" { //西药费
  9177. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9178. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9179. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9180. }
  9181. if item.MedChrgitmType == "11" { //中成费
  9182. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9183. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9184. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9185. }
  9186. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  9187. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9188. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9189. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9190. }
  9191. }
  9192. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9193. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9194. var user_name string
  9195. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9196. if role.ID == 0 {
  9197. user_name = "管理员"
  9198. } else {
  9199. user_name = role.UserName
  9200. }
  9201. baseParams := models.BaseParams{
  9202. SecretKey: miConfig.SecretKey,
  9203. FixmedinsCode: miConfig.Code,
  9204. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9205. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9206. OrgName: miConfig.OrgName,
  9207. Doctor: user_name,
  9208. }
  9209. businessParams := models.BusinessParams{
  9210. PsnNo: order.PsnNo,
  9211. MdtrtId: order.MdtrtId,
  9212. SetlId: order.SetlId,
  9213. }
  9214. var res ResultEleven
  9215. var resEleven10265 ResultEleven10265
  9216. if config.IsOpen == 1 {
  9217. if miConfig.MdtrtareaAdmvs == "421300" {
  9218. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9219. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9220. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9221. resp, requestErr := http.Get(api)
  9222. if requestErr != nil {
  9223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9224. return
  9225. }
  9226. body, ioErr := ioutil.ReadAll(resp.Body)
  9227. if ioErr != nil {
  9228. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9230. return
  9231. }
  9232. var respJSON map[string]interface{}
  9233. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9234. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9236. return
  9237. }
  9238. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9239. result, _ := json.Marshal(respJSON)
  9240. fmt.Println("log")
  9241. fmt.Println(string(result))
  9242. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9243. utils.ErrorLog("解析失败:%v", err)
  9244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9245. return
  9246. }
  9247. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9248. var api string
  9249. if miConfig.MdtrtareaAdmvs == "320921" {
  9250. api = "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9251. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9252. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9253. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9254. } else {
  9255. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9256. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9257. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9258. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9259. }
  9260. resp, requestErr := http.Get(api)
  9261. if requestErr != nil {
  9262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9263. return
  9264. }
  9265. body, ioErr := ioutil.ReadAll(resp.Body)
  9266. if ioErr != nil {
  9267. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9269. return
  9270. }
  9271. var respJSON map[string]interface{}
  9272. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9273. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9275. return
  9276. }
  9277. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9278. result, _ := json.Marshal(respJSON)
  9279. fmt.Println("log")
  9280. fmt.Println(string(result))
  9281. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9282. utils.ErrorLog("解析失败:%v", err)
  9283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9284. return
  9285. }
  9286. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9287. res.Output = resEleven10265.Output
  9288. res.ErrMsg = resEleven10265.ErrMsg
  9289. res.Cainfo = resEleven10265.Cainfo
  9290. res.WarnMsg = resEleven10265.WarnMsg
  9291. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9292. res.Infcode = infocode
  9293. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9294. fmt.Println("~~~~~~~")
  9295. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9296. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9297. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9298. resp, requestErr := http.Get(api)
  9299. if requestErr != nil {
  9300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9301. return
  9302. }
  9303. body, ioErr := ioutil.ReadAll(resp.Body)
  9304. if ioErr != nil {
  9305. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9307. return
  9308. }
  9309. var respJSON map[string]interface{}
  9310. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9311. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9313. return
  9314. }
  9315. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9316. result, _ := json.Marshal(respJSON)
  9317. fmt.Println("log")
  9318. fmt.Println(string(result))
  9319. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9320. utils.ErrorLog("解析失败:%v", err)
  9321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9322. return
  9323. }
  9324. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9325. res.Output = resEleven10265.Output
  9326. res.ErrMsg = resEleven10265.ErrMsg
  9327. res.Cainfo = resEleven10265.Cainfo
  9328. res.WarnMsg = resEleven10265.WarnMsg
  9329. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9330. res.Infcode = infocode
  9331. } else {
  9332. result := service.Gdyb5203(baseParams, businessParams)
  9333. //service.Gdyb5204(baseParams, businessParams)
  9334. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  9335. var dat map[string]interface{}
  9336. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9337. fmt.Println(dat)
  9338. } else {
  9339. fmt.Println(err)
  9340. }
  9341. userJSONBytes, _ := json.Marshal(dat)
  9342. if miConfig.Code == "H15049901371" {
  9343. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  9344. utils.ErrorLog("解析失败:%v", err)
  9345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9346. return
  9347. }
  9348. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9349. res.Output = resEleven10265.Output
  9350. res.ErrMsg = resEleven10265.ErrMsg
  9351. res.Cainfo = resEleven10265.Cainfo
  9352. res.WarnMsg = resEleven10265.WarnMsg
  9353. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9354. res.Infcode = infocode
  9355. } else {
  9356. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9357. utils.ErrorLog("解析失败:%v", err)
  9358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9359. return
  9360. }
  9361. }
  9362. }
  9363. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9364. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  9365. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  9366. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9367. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  9368. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9369. var doctor_name string
  9370. if roles.ID == 0 {
  9371. doctor_name = "管理员"
  9372. } else {
  9373. doctor_name = roles.UserName
  9374. }
  9375. yiliao_leibie := ""
  9376. switch order.MedType {
  9377. case "11":
  9378. yiliao_leibie = "普通门诊"
  9379. break
  9380. case "12":
  9381. yiliao_leibie = "门诊挂号"
  9382. break
  9383. case "13":
  9384. yiliao_leibie = "急诊"
  9385. break
  9386. case "14":
  9387. yiliao_leibie = "门诊特殊病"
  9388. break
  9389. case "15":
  9390. yiliao_leibie = "门诊统筹"
  9391. break
  9392. case "16":
  9393. yiliao_leibie = "门诊慢性病"
  9394. break
  9395. case "21":
  9396. yiliao_leibie = "普通住院"
  9397. break
  9398. }
  9399. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9400. if res.Infcode == 0 {
  9401. c.ServeSuccessJSON(map[string]interface{}{
  9402. "diagnosis": name,
  9403. "order_infos": orderInfos,
  9404. "number": order.MdtrtId,
  9405. "date": order.SettleAccountsDate,
  9406. "charge_admin": charge_admin,
  9407. "printor_admin": printor_admin,
  9408. "info": res.Output.Setlinfo,
  9409. "order": order,
  9410. "bedCostTotal": bedCostTotal,
  9411. "bedCostSelfTotal": bedCostSelfTotal,
  9412. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  9413. "operationCostTotal": operationCostTotal,
  9414. "operationCostSelfTotal": operationCostSelfTotal,
  9415. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  9416. "otherCostTotal": otherCostTotal,
  9417. "otherCostSelfTotal": otherCostSelfTotal,
  9418. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  9419. "materialCostTotal": materialCostTotal,
  9420. "materialCostSelfTotal": materialCostSelfTotal,
  9421. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  9422. "westernMedicineCostTotal": westernMedicineCostTotal,
  9423. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  9424. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  9425. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  9426. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  9427. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  9428. "checkCostTotal": checkCostTotal,
  9429. "checkCostSelfTotal": checkCostSelfTotal,
  9430. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  9431. "laboratoryCostTotal": laboratoryCostTotal,
  9432. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  9433. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  9434. "treatCostTotal": treatCostTotal,
  9435. "treatCostSelfTotal": treatCostSelfTotal,
  9436. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  9437. "doctor_info": doctor_info,
  9438. "doctor_code": adminRole_two.DoctorCode,
  9439. "doctor_name": doctor_name,
  9440. "health_card_no": order.PsnNo,
  9441. "department": departments.Name,
  9442. "yiliao_leibie": yiliao_leibie,
  9443. "after_money": order.AccountPrice,
  9444. "patient": patient,
  9445. "org_name": miConfig.OrgName,
  9446. "org_code": miConfig.Code,
  9447. "order_number": order.Number,
  9448. "his_hospital": his_hospital,
  9449. "his": his,
  9450. "dia_config": dia_config,
  9451. //"check_order_info": cus_slice,
  9452. })
  9453. }
  9454. }
  9455. }
  9456. func (c *HisApiController) CheckTreatment() {
  9457. patient_id, _ := c.GetInt64("patient_id")
  9458. id_card_no := c.GetString("id_card_no")
  9459. insutype := c.GetString("insutype")
  9460. med_type := c.GetString("med_type")
  9461. admin_user_id, _ := c.GetInt64("admin_user_id")
  9462. adminUser := c.GetAdminUserInfo()
  9463. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9464. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9465. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9466. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9467. if miConfig.MdtrtareaAdmvs == "421300" {
  9468. var res ResultTwo
  9469. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  9470. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9471. "&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)
  9472. resp, requestErr := http.Get(api)
  9473. if requestErr != nil {
  9474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9475. return
  9476. }
  9477. body, ioErr := ioutil.ReadAll(resp.Body)
  9478. if ioErr != nil {
  9479. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9481. return
  9482. }
  9483. var respJSON map[string]interface{}
  9484. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9485. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9487. return
  9488. }
  9489. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9490. result, _ := json.Marshal(respJSON)
  9491. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9492. utils.ErrorLog("解析失败:%v", err)
  9493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9494. return
  9495. }
  9496. if res.Infcode == 0 {
  9497. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  9498. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9499. "&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
  9500. resp, requestErr := http.Get(api)
  9501. if requestErr != nil {
  9502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9503. return
  9504. }
  9505. body, ioErr := ioutil.ReadAll(resp.Body)
  9506. if ioErr != nil {
  9507. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9509. return
  9510. }
  9511. var respJSON map[string]interface{}
  9512. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9513. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9515. return
  9516. }
  9517. var res Result2001
  9518. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9519. result2, _ := json.Marshal(respJSON)
  9520. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9521. utils.ErrorLog("解析失败:%v", err)
  9522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9523. return
  9524. }
  9525. if res.Infcode == 0 {
  9526. c.ServeSuccessJSON(map[string]interface{}{
  9527. "msg": res.Output.Trtinfo,
  9528. })
  9529. }
  9530. } else {
  9531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9532. return
  9533. }
  9534. } else {
  9535. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9536. var dat map[string]interface{}
  9537. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9538. fmt.Println(dat)
  9539. } else {
  9540. fmt.Println(err)
  9541. }
  9542. userJSONBytes, _ := json.Marshal(dat)
  9543. var res ResultTwo
  9544. var res10265 ResultTwo10265
  9545. if miConfig.Code == "H15049901371" {
  9546. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9547. utils.ErrorLog("解析失败:%v", err)
  9548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9549. return
  9550. }
  9551. res.ErrMsg = res10265.ErrMsg
  9552. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9553. res.Infcode = infocode
  9554. //res.Output = res10265.Output
  9555. res.InfRefmsgid = res10265.InfRefmsgid
  9556. } else {
  9557. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9558. utils.ErrorLog("解析失败:%v", err)
  9559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9560. return
  9561. }
  9562. }
  9563. var user_name string
  9564. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  9565. if role.ID == 0 {
  9566. user_name = "xxx"
  9567. } else {
  9568. user_name = role.UserName
  9569. }
  9570. baseParams := models.BaseParams{
  9571. SecretKey: miConfig.SecretKey,
  9572. FixmedinsCode: miConfig.Code,
  9573. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9574. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9575. OrgName: miConfig.OrgName,
  9576. Doctor: user_name,
  9577. }
  9578. if config.IsOpen == 1 {
  9579. if miConfig.Code == "H15049901371" {
  9580. if med_type == "14" {
  9581. if insutype == "390" {
  9582. med_type = "9933"
  9583. } else if insutype == "310" {
  9584. med_type = "990502"
  9585. }
  9586. } else if med_type == "11" {
  9587. med_type = "11"
  9588. }
  9589. }
  9590. result := service.Gdyb2001(baseParams, res.Output[0].Baseinfo.PsnNo, insutype, med_type)
  9591. var dat map[string]interface{}
  9592. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9593. fmt.Println(dat)
  9594. } else {
  9595. fmt.Println(err)
  9596. }
  9597. var res Result2001
  9598. var res10265 Result2001Org10265
  9599. if miConfig.Code == "H15049901371" {
  9600. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9601. utils.ErrorLog("解析失败:%v", err)
  9602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9603. return
  9604. }
  9605. res.ErrMsg = res10265.ErrMsg
  9606. res.Output = res10265.Output
  9607. res.InfRefmsgid = res10265.InfRefmsgid
  9608. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9609. res.Infcode = infocode
  9610. } else {
  9611. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9612. utils.ErrorLog("解析失败:%v", err)
  9613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9614. return
  9615. }
  9616. }
  9617. if res.Infcode == 0 {
  9618. c.ServeSuccessJSON(map[string]interface{}{
  9619. "msg": res.Output.Trtinfo,
  9620. })
  9621. }
  9622. }
  9623. }
  9624. }
  9625. //func (c *HisApiController) PutRecord() {
  9626. // id, _ := c.GetInt64("id")
  9627. // record_time := c.GetString("record_time")
  9628. // timeLayout := "2006-01-02"
  9629. // loc, _ := time.LoadLocation("Local")
  9630. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9631. // if err != nil {
  9632. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9633. // return
  9634. // }
  9635. // recordDateTime := theTime.Unix()
  9636. //
  9637. // adminInfo := c.GetAdminUserInfo()
  9638. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  9639. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9640. //
  9641. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9642. //
  9643. // fmt.Println(miConfig.SecretKey)
  9644. //
  9645. // if patient == nil {
  9646. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9647. // return
  9648. // }
  9649. // if len(patient.IdCardNo) == 0 {
  9650. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  9651. // return
  9652. // }
  9653. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  9654. // if config.IsOpen == 1 {
  9655. // 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
  9656. // resp, requestErr := http.Get(api)
  9657. // if requestErr != nil {
  9658. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9659. // return
  9660. // }
  9661. // defer resp.Body.Close()
  9662. // body, ioErr := ioutil.ReadAll(resp.Body)
  9663. // if ioErr != nil {
  9664. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9665. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9666. // return
  9667. // }
  9668. // var respJSON map[string]interface{}
  9669. //
  9670. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9671. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9672. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9673. // return
  9674. // }
  9675. //
  9676. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9677. // userJSONBytes, _ := json.Marshal(userJSON)
  9678. // var res ResultTwo
  9679. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9680. // utils.ErrorLog("解析失败:%v", err)
  9681. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9682. // return
  9683. // }
  9684. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9685. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9686. // infoStr := string(Iinfos)
  9687. // idetinfoStr := string(Idetinfos)
  9688. //
  9689. // if res.Infcode == 0 {
  9690. // his := models.VMHisPatient{
  9691. // Status: 1,
  9692. // Ctime: time.Now().Unix(),
  9693. // Mtime: time.Now().Unix(),
  9694. // PsnNo: res.Output.Baseinfo.PsnNo,
  9695. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  9696. // Certno: res.Output.Baseinfo.Certno,
  9697. // PsnName: res.Output.Baseinfo.PsnName,
  9698. // Gend: res.Output.Baseinfo.Gend,
  9699. // Naty: res.Output.Baseinfo.Naty,
  9700. // Brdy: res.Output.Baseinfo.Brdy,
  9701. // Age: res.Output.Baseinfo.Age,
  9702. // Iinfo: infoStr,
  9703. // Idetinfo: idetinfoStr,
  9704. // PatientId: patient.ID,
  9705. // RecordDate: theTime.Unix(),
  9706. // UserOrgId: adminInfo.CurrentOrgId,
  9707. // AdminUserId: adminInfo.AdminUser.Id,
  9708. // IsReturn: 1,
  9709. // }
  9710. //
  9711. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  9712. // //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")
  9713. // //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")
  9714. //
  9715. // //var dat map[string]interface{}
  9716. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9717. // // fmt.Println(dat)
  9718. // //} else {
  9719. // // fmt.Println(err)
  9720. // //}
  9721. //
  9722. // var dat2 map[string]interface{}
  9723. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9724. // fmt.Println(dat2)
  9725. // } else {
  9726. // fmt.Println(err)
  9727. // }
  9728. //
  9729. // } else {
  9730. // adminUser := c.GetAdminUserInfo()
  9731. // errlog := &models.HisOrderError{
  9732. // UserOrgId: adminUser.CurrentOrgId,
  9733. // Ctime: time.Now().Unix(),
  9734. // Mtime: time.Now().Unix(),
  9735. // ErrMsg: res.ErrMsg,
  9736. // Status: 1,
  9737. // PatientId: id,
  9738. // RecordTime: recordDateTime,
  9739. // Stage: 1,
  9740. // }
  9741. // service.CreateErrMsgLog(errlog)
  9742. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  9743. // return
  9744. // }
  9745. // }
  9746. //
  9747. //}
  9748. //func (c *HisApiController) GetUploadDiag() {
  9749. // id, _ := c.GetInt64("id")
  9750. // record_time := c.GetString("record_time")
  9751. //
  9752. // diagnosis_id, _ := c.GetInt64("diagnosis")
  9753. // sick_type, _ := c.GetInt64("sick_type")
  9754. // reg_type, _ := c.GetInt64("reg_type")
  9755. //
  9756. // timeLayout := "2006-01-02"
  9757. // loc, _ := time.LoadLocation("Local")
  9758. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9759. // if err != nil {
  9760. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9761. // return
  9762. // }
  9763. //
  9764. // var patientPrescription models.HisPrescriptionInfo
  9765. // recordDateTime := theTime.Unix()
  9766. // adminInfo := c.GetAdminUserInfo()
  9767. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9768. //
  9769. // if patientPrescription.ID == 0 {
  9770. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9771. // }
  9772. //
  9773. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9774. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9775. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9776. // sickConfig, _ := service.FindSickById(sick_type)
  9777. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9778. //
  9779. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  9780. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  9781. // "&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 +
  9782. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  9783. // resp2, requestErr2 := http.Get(api2)
  9784. // if requestErr2 != nil {
  9785. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9786. // return
  9787. // }
  9788. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  9789. // if ioErr2 != nil {
  9790. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  9791. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9792. // return
  9793. // }
  9794. // var respJSON2 map[string]interface{}
  9795. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  9796. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9797. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9798. // return
  9799. // }
  9800. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9801. // userJSONBytes2, _ := json.Marshal(respJSON2)
  9802. //
  9803. // var res2 ResultSix
  9804. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9805. // utils.ErrorLog("解析失败:%v", err)
  9806. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9807. // return
  9808. // }
  9809. // if res2.Infcode != 0 {
  9810. // adminUser := c.GetAdminUserInfo()
  9811. // errlog := &models.HisOrderError{
  9812. // UserOrgId: adminUser.CurrentOrgId,
  9813. // Ctime: time.Now().Unix(),
  9814. // Mtime: time.Now().Unix(),
  9815. // ErrMsg: res2.ErrMsg,
  9816. // Status: 1,
  9817. // PatientId: id,
  9818. // RecordTime: recordDateTime,
  9819. // Stage: 3,
  9820. // }
  9821. // service.CreateErrMsgLog(errlog)
  9822. //
  9823. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  9824. // return
  9825. // }
  9826. //
  9827. // c.ServeSuccessJSON(map[string]interface{}{
  9828. // "msg": "上传成功",
  9829. // })
  9830. //
  9831. //}
  9832. type QueryResult struct {
  9833. ID int64
  9834. Name string
  9835. Code string
  9836. List_type_code string
  9837. }
  9838. func (c *HisApiController) GetCheckCode() {
  9839. ids_str := c.GetString("ids")
  9840. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9841. ids_arr := strings.Split(ids_str, ",")
  9842. var queryResult []QueryResult
  9843. ids := make([]int64, 0)
  9844. for _, item := range ids_arr {
  9845. id, _ := strconv.ParseInt(item, 10, 64)
  9846. ids = append(ids, id)
  9847. }
  9848. if record_type == 1 {
  9849. drugs, _ := service.GetBatchDrugList(ids)
  9850. for _, item := range drugs {
  9851. result := QueryResult{
  9852. ID: item.ID,
  9853. Name: item.DrugName,
  9854. Code: item.MedicalInsuranceNumber,
  9855. List_type_code: "101",
  9856. }
  9857. queryResult = append(queryResult, result)
  9858. }
  9859. } else if record_type == 2 {
  9860. goods, _ := service.GetBatchGoodInformationList(ids)
  9861. for _, item := range goods {
  9862. result := QueryResult{
  9863. ID: item.ID,
  9864. Name: item.GoodName,
  9865. Code: item.MedicalInsuranceNumber,
  9866. List_type_code: "301",
  9867. }
  9868. queryResult = append(queryResult, result)
  9869. }
  9870. } else if record_type == 3 {
  9871. projects, _ := service.GetBathchMyPorjecgList(ids)
  9872. for _, item := range projects {
  9873. result := QueryResult{
  9874. ID: item.ID,
  9875. Name: item.ProjectName,
  9876. Code: item.MedicalCode,
  9877. List_type_code: "201",
  9878. }
  9879. queryResult = append(queryResult, result)
  9880. }
  9881. }
  9882. admin_user_id, _ := c.GetInt64("admin_user_id")
  9883. adminUser := c.GetAdminUserInfo()
  9884. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9885. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9886. var user_name string
  9887. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9888. if role.ID == 0 {
  9889. user_name = "xxx"
  9890. } else {
  9891. user_name = role.UserName
  9892. }
  9893. baseParams := &models.BaseParams{
  9894. SecretKey: miConfig.SecretKey,
  9895. FixmedinsCode: miConfig.Code,
  9896. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9897. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9898. OrgName: miConfig.OrgName,
  9899. Doctor: user_name,
  9900. }
  9901. if config.IsOpen == 1 {
  9902. for _, item := range queryResult {
  9903. var result string
  9904. if record_type == 1 {
  9905. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9906. } else if record_type == 2 {
  9907. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9908. } else if record_type == 3 {
  9909. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9910. }
  9911. var dat map[string]interface{}
  9912. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9913. fmt.Println(dat)
  9914. } else {
  9915. fmt.Println(err)
  9916. }
  9917. userJSONBytes, _ := json.Marshal(dat)
  9918. var res ResultSix
  9919. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9920. utils.ErrorLog("解析失败:%v", err)
  9921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9922. return
  9923. }
  9924. if res.Infcode == 0 {
  9925. if record_type == 1 {
  9926. service.UpdateBaseDrugById(item.ID)
  9927. } else if record_type == 2 {
  9928. service.UpdateGoodInformaitonByDetail(item.ID)
  9929. } else if record_type == 3 {
  9930. service.UpdateProjectById(item.ID)
  9931. }
  9932. c.ServeSuccessJSON(map[string]interface{}{
  9933. "failed_code": 0,
  9934. "msg": "目录对照成功",
  9935. })
  9936. } else {
  9937. c.ServeSuccessJSON(map[string]interface{}{
  9938. "failed_code": -10,
  9939. "msg": res.ErrMsg,
  9940. })
  9941. }
  9942. }
  9943. }
  9944. }
  9945. func (c *HisApiController) UnCheckCode() {
  9946. ids_str := c.GetString("ids")
  9947. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9948. admin_user_id, _ := c.GetInt64("admin_user_id")
  9949. ids_arr := strings.Split(ids_str, ",")
  9950. var queryResult []QueryResult
  9951. ids := make([]int64, 0)
  9952. for _, item := range ids_arr {
  9953. id, _ := strconv.ParseInt(item, 10, 64)
  9954. ids = append(ids, id)
  9955. }
  9956. if record_type == 1 {
  9957. drugs, _ := service.GetBatchDrugList(ids)
  9958. for _, item := range drugs {
  9959. result := QueryResult{
  9960. ID: item.ID,
  9961. Name: item.DrugName,
  9962. Code: item.MedicalInsuranceNumber,
  9963. List_type_code: "101",
  9964. }
  9965. queryResult = append(queryResult, result)
  9966. }
  9967. } else if record_type == 2 {
  9968. goods, _ := service.GetBatchGoodInformationList(ids)
  9969. for _, item := range goods {
  9970. result := QueryResult{
  9971. ID: item.ID,
  9972. Name: item.GoodName,
  9973. Code: item.MedicalInsuranceNumber,
  9974. List_type_code: "301",
  9975. }
  9976. queryResult = append(queryResult, result)
  9977. }
  9978. } else if record_type == 3 {
  9979. projects, _ := service.GetBathchMyPorjecgList(ids)
  9980. for _, item := range projects {
  9981. result := QueryResult{
  9982. ID: item.ID,
  9983. Name: item.ProjectName,
  9984. Code: item.MedicalCode,
  9985. List_type_code: "201",
  9986. }
  9987. queryResult = append(queryResult, result)
  9988. }
  9989. }
  9990. adminUser := c.GetAdminUserInfo()
  9991. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9992. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9993. var user_name string
  9994. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9995. if role.ID == 0 {
  9996. user_name = "xxx"
  9997. } else {
  9998. user_name = role.UserName
  9999. }
  10000. baseParams := &models.BaseParams{
  10001. SecretKey: miConfig.SecretKey,
  10002. FixmedinsCode: miConfig.Code,
  10003. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  10004. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  10005. OrgName: miConfig.OrgName,
  10006. Doctor: user_name,
  10007. }
  10008. if config.IsOpen == 1 {
  10009. for _, item := range queryResult {
  10010. var result string
  10011. if record_type == 1 {
  10012. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10013. } else if record_type == 2 {
  10014. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10015. } else if record_type == 3 {
  10016. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10017. }
  10018. var dat2 map[string]interface{}
  10019. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  10020. fmt.Println(dat2)
  10021. } else {
  10022. fmt.Println(err)
  10023. }
  10024. userJSONBytes, _ := json.Marshal(dat2)
  10025. var res ResultSix
  10026. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10027. utils.ErrorLog("解析失败:%v", err)
  10028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10029. return
  10030. }
  10031. if res.Infcode == 0 {
  10032. if record_type == 1 {
  10033. service.UpdateDrugByIdDetail(item.ID)
  10034. } else if record_type == 2 {
  10035. service.UpdateGoodInfoById(item.ID)
  10036. } else if record_type == 3 {
  10037. service.UpdateMyProjectById(item.ID)
  10038. }
  10039. c.ServeSuccessJSON(map[string]interface{}{
  10040. "failed_code": 0,
  10041. "msg": "撤销目录对照成功",
  10042. })
  10043. } else {
  10044. c.ServeSuccessJSON(map[string]interface{}{
  10045. "failed_code": -10,
  10046. "msg": res.ErrMsg,
  10047. })
  10048. }
  10049. }
  10050. }
  10051. }
  10052. func (c *HisApiController) GetPatientInfo() {
  10053. id_card_no := c.GetString("id_card_no")
  10054. admin_user_id, _ := c.GetInt64("admin_user_id")
  10055. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  10056. if patient.ID == 0 {
  10057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  10058. return
  10059. }
  10060. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10061. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10062. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  10063. if config.IsOpen == 1 {
  10064. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  10065. var dat map[string]interface{}
  10066. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10067. fmt.Println(dat)
  10068. } else {
  10069. fmt.Println(err)
  10070. }
  10071. userJSONBytes, _ := json.Marshal(dat)
  10072. var res ResultTwo
  10073. var res10265 ResultTwo10265
  10074. if miConfig.Code == "H15049901371" {
  10075. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10076. utils.ErrorLog("解析失败:%v", err)
  10077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10078. return
  10079. }
  10080. res.ErrMsg = res10265.ErrMsg
  10081. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10082. res.Infcode = infocode
  10083. //res.Output = res10265.Output
  10084. res.InfRefmsgid = res10265.InfRefmsgid
  10085. } else {
  10086. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10087. utils.ErrorLog("解析失败:%v", err)
  10088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10089. return
  10090. }
  10091. }
  10092. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10093. // utils.ErrorLog("解析失败:%v", err)
  10094. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10095. // return
  10096. //}
  10097. if res.Infcode != 0 {
  10098. c.ServeSuccessJSON(map[string]interface{}{
  10099. "failed_code": -10,
  10100. "msg": res.ErrMsg,
  10101. })
  10102. } else {
  10103. c.ServeSuccessJSON(map[string]interface{}{
  10104. "failed_code": 0,
  10105. "info": res,
  10106. })
  10107. }
  10108. }
  10109. }
  10110. func (c *HisApiController) PsnPutOnRecord() {
  10111. record_type, _ := c.GetInt64("type")
  10112. patient_id, _ := c.GetInt64("patient_id")
  10113. admin_user_id, _ := c.GetInt64("admin_user_id")
  10114. start_time := c.GetString("start_time")
  10115. end_time := c.GetString("end_time")
  10116. adminUser := c.GetAdminUserInfo()
  10117. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10118. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10119. var patients []*models.Patients
  10120. if record_type == 1 { //全部备案
  10121. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  10122. patients = append(patients, patient...)
  10123. } else { //单个备案
  10124. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10125. patients = append(patients, patient)
  10126. }
  10127. var user_name string
  10128. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10129. if role.ID == 0 {
  10130. user_name = "xxx"
  10131. } else {
  10132. user_name = role.UserName
  10133. }
  10134. if config.IsOpen == 1 {
  10135. for _, item := range patients {
  10136. 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
  10137. resp, requestErr := http.Get(api)
  10138. if requestErr != nil {
  10139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10140. return
  10141. }
  10142. defer resp.Body.Close()
  10143. body, ioErr := ioutil.ReadAll(resp.Body)
  10144. if ioErr != nil {
  10145. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10147. return
  10148. }
  10149. var respJSON map[string]interface{}
  10150. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10151. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10153. return
  10154. }
  10155. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10156. userJSONBytes, _ := json.Marshal(userJSON)
  10157. var res ResultTwo
  10158. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10159. utils.ErrorLog("解析失败:%v", err)
  10160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10161. return
  10162. }
  10163. if res.Infcode == 0 {
  10164. result := service.Gdyb2505(res.Output[0].Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  10165. var dat map[string]interface{}
  10166. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10167. fmt.Println(dat)
  10168. } else {
  10169. fmt.Println(err)
  10170. }
  10171. userJSONBytes, _ := json.Marshal(dat)
  10172. var res2 ResultThirteen
  10173. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10174. utils.ErrorLog("解析失败:%v", err)
  10175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10176. return
  10177. }
  10178. if res2.Infcode == 0 {
  10179. psnResult := &models.GdybPsnRecord{
  10180. UserOrgId: adminUser.CurrentOrgId,
  10181. PatientId: item.ID,
  10182. PsnNo: res.Output[0].Baseinfo.PsnNo,
  10183. Ctime: time.Now().Unix(),
  10184. Mtime: time.Now().Unix(),
  10185. Status: 1,
  10186. IsCancel: 1,
  10187. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10188. }
  10189. service.CreatePsnRecord(psnResult)
  10190. } else {
  10191. c.ServeSuccessJSON(map[string]interface{}{
  10192. "failed_code": -10,
  10193. "msg": res2.ErrMsg,
  10194. })
  10195. return
  10196. }
  10197. }
  10198. }
  10199. }
  10200. }
  10201. func (c *HisApiController) PsnUnPutOnRecord() {
  10202. id, _ := c.GetInt64("id")
  10203. //record_type, _ := c.GetInt64("type")
  10204. admin_user_id, _ := c.GetInt64("admin_user_id")
  10205. adminUser := c.GetAdminUserInfo()
  10206. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10207. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10208. var user_name string
  10209. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10210. if role.ID == 0 {
  10211. user_name = "xxx"
  10212. } else {
  10213. user_name = role.UserName
  10214. }
  10215. psn_record, _ := service.GetPsnRecordById(id)
  10216. if psn_record.ID == 0 {
  10217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10218. return
  10219. }
  10220. if config.IsOpen == 1 {
  10221. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10222. var dat map[string]interface{}
  10223. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10224. fmt.Println(dat)
  10225. } else {
  10226. fmt.Println(err)
  10227. }
  10228. userJSONBytes, _ := json.Marshal(dat)
  10229. var res ResultFourteen
  10230. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10231. utils.ErrorLog("解析失败:%v", err)
  10232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10233. return
  10234. }
  10235. if res.Infcode == 0 {
  10236. psn_record.IsCancel = 2
  10237. service.CreatePsnRecord(&psn_record)
  10238. } else {
  10239. c.ServeSuccessJSON(map[string]interface{}{
  10240. "failed_code": -10,
  10241. "msg": res.ErrMsg,
  10242. })
  10243. return
  10244. }
  10245. }
  10246. }
  10247. func (c *HisApiController) PsnPutNCDSOnRecord() {
  10248. patient_id, _ := c.GetInt64("patient_id")
  10249. insutype_two := c.GetString("insutype")
  10250. psn_no := c.GetString("psn_no")
  10251. doctor_id, _ := c.GetInt64("doctor_id")
  10252. sick_id, _ := c.GetInt64("sick_id")
  10253. department_id, _ := c.GetInt64("department_id")
  10254. start_time := c.GetString("start_time")
  10255. end_time := c.GetString("end_time")
  10256. check_time := c.GetString("check_time")
  10257. adminUser := c.GetAdminUserInfo()
  10258. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10259. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10260. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10261. sick, _ := service.FindSickById(sick_id)
  10262. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10263. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10264. var res ResultTwo
  10265. var res10265 ResultTwo10265
  10266. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10267. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  10268. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  10269. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  10270. "&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
  10271. resp, requestErr := http.Get(api)
  10272. if requestErr != nil {
  10273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10274. return
  10275. }
  10276. body, ioErr := ioutil.ReadAll(resp.Body)
  10277. if ioErr != nil {
  10278. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10280. return
  10281. }
  10282. var respJSON map[string]interface{}
  10283. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10284. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10286. return
  10287. }
  10288. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10289. result, _ := json.Marshal(respJSON)
  10290. fmt.Println("log")
  10291. fmt.Println(string(result))
  10292. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10293. utils.ErrorLog("解析失败:%v", err)
  10294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10295. return
  10296. }
  10297. res.ErrMsg = res10265.ErrMsg
  10298. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10299. res.Infcode = infocode
  10300. //res.Output = res10265.Output
  10301. res.InfRefmsgid = res10265.InfRefmsgid
  10302. } else {
  10303. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10304. if miConfig.Code == "H15049901371" {
  10305. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10306. utils.ErrorLog("解析失败:%v", err)
  10307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10308. return
  10309. }
  10310. res.ErrMsg = res10265.ErrMsg
  10311. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10312. res.Infcode = infocode
  10313. //res.Output = res10265.Output
  10314. res.InfRefmsgid = res10265.InfRefmsgid
  10315. } else {
  10316. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10317. utils.ErrorLog("解析失败:%v", err)
  10318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10319. return
  10320. }
  10321. }
  10322. }
  10323. Iinfos, _ := json.Marshal(res.Output[0].Iinfo)
  10324. infoStr := string(Iinfos)
  10325. var rf []*ResultFive
  10326. json.Unmarshal([]byte(infoStr), &rf)
  10327. var insuplc_admdvs string
  10328. var insutype string
  10329. var is390 int = 0
  10330. var is310 int = 0
  10331. var insutypes []*ResultFive
  10332. for _, item := range rf {
  10333. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10334. insutypes = append(insutypes, item)
  10335. }
  10336. }
  10337. if len(insutypes) == 1 {
  10338. insutype = insutypes[0].Insutype
  10339. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10340. } else {
  10341. for _, i := range insutypes {
  10342. if i.Insutype == "390" {
  10343. is390 = 1
  10344. }
  10345. if i.Insutype == "310" {
  10346. is310 = 1
  10347. }
  10348. }
  10349. }
  10350. if is390 == 1 {
  10351. insutype = "390"
  10352. }
  10353. if is310 == 1 {
  10354. insutype = "310"
  10355. }
  10356. if len(insutypes) == 2 {
  10357. insutype = insutype_two
  10358. }
  10359. if len(insutypes) == 0 {
  10360. insutype = "310"
  10361. }
  10362. insutype = insutype_two
  10363. fmt.Println(insutype)
  10364. for _, item := range rf {
  10365. fmt.Println(item.Insutype)
  10366. fmt.Println(insutype)
  10367. if item.Insutype == insutype {
  10368. fmt.Println(item.Insutype)
  10369. fmt.Println(insutype)
  10370. insuplc_admdvs = item.InsuplcAdmdvs
  10371. }
  10372. }
  10373. fmt.Println(insuplc_admdvs)
  10374. var res2 ResultThirteen
  10375. var res10265_2 ResultThirteen10265
  10376. if config.IsOpen == 1 {
  10377. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10378. } else {
  10379. 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)
  10380. var dat map[string]interface{}
  10381. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10382. fmt.Println(dat)
  10383. } else {
  10384. fmt.Println(err)
  10385. }
  10386. userJSONBytes, _ := json.Marshal(dat)
  10387. if miConfig.Code == "H15049901371" {
  10388. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  10389. utils.ErrorLog("解析失败:%v", err)
  10390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10391. return
  10392. }
  10393. res2.ErrMsg = res10265_2.ErrMsg
  10394. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  10395. res2.Infcode = infocode
  10396. res2.Output = res10265_2.Output
  10397. res2.InfRefmsgid = res10265_2.InfRefmsgid
  10398. } else {
  10399. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10400. utils.ErrorLog("解析失败:%v", err)
  10401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10402. return
  10403. }
  10404. }
  10405. }
  10406. if res2.Infcode == 0 {
  10407. psnResult := &models.GdybPsnNcdsRecord{
  10408. UserOrgId: adminUser.CurrentOrgId,
  10409. PatientId: patient.ID,
  10410. PsnNo: psn_no,
  10411. DoctorId: doctor.AdminUserId,
  10412. DepartmentId: department_id,
  10413. SickType: sick_id,
  10414. Insutype: insutype,
  10415. Ctime: time.Now().Unix(),
  10416. Mtime: time.Now().Unix(),
  10417. Status: 1,
  10418. IsCancel: 1,
  10419. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10420. }
  10421. service.CreatePsnNCDSRecord(psnResult)
  10422. c.ServeSuccessJSON(map[string]interface{}{
  10423. "failed_code": 0,
  10424. "msg": "备案成功",
  10425. "result": psnResult,
  10426. })
  10427. } else {
  10428. c.ServeSuccessJSON(map[string]interface{}{
  10429. "failed_code": -10,
  10430. "msg": res2.ErrMsg,
  10431. })
  10432. return
  10433. }
  10434. }
  10435. }
  10436. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  10437. id, _ := c.GetInt64("id")
  10438. admin_user_id, _ := c.GetInt64("admin_user_id")
  10439. adminUser := c.GetAdminUserInfo()
  10440. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10441. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10442. //config, _ := service.Ge(adminUser.CurrentOrgId)
  10443. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  10444. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10445. //var user_name string
  10446. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10447. //if role.ID == 0 {
  10448. // user_name = "xxx"
  10449. //} else {
  10450. // user_name = role.UserName
  10451. //}
  10452. psn_record, _ := service.GetPsnNCDSRecordById(id)
  10453. if psn_record.ID == 0 {
  10454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10455. return
  10456. }
  10457. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10458. var res ResultTwo
  10459. var res10265 ResultTwo10265
  10460. if miConfig.Code == "H15049901371" {
  10461. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10462. utils.ErrorLog("解析失败:%v", err)
  10463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10464. return
  10465. }
  10466. res.ErrMsg = res10265.ErrMsg
  10467. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10468. res.Infcode = infocode
  10469. //res.Output = res10265.Output
  10470. res.InfRefmsgid = res10265.InfRefmsgid
  10471. } else {
  10472. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10473. utils.ErrorLog("解析失败:%v", err)
  10474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10475. return
  10476. }
  10477. }
  10478. Iinfos, _ := json.Marshal(res.Output[0].Iinfo)
  10479. infoStr := string(Iinfos)
  10480. var rf []*ResultFive
  10481. json.Unmarshal([]byte(infoStr), &rf)
  10482. var insuplc_admdvs string
  10483. var insutype string
  10484. var is390 int = 0
  10485. var is310 int = 0
  10486. var insutypes []*ResultFive
  10487. for _, item := range rf {
  10488. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10489. insutypes = append(insutypes, item)
  10490. }
  10491. }
  10492. if len(insutypes) == 1 {
  10493. insutype = insutypes[0].Insutype
  10494. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10495. } else {
  10496. for _, i := range insutypes {
  10497. if i.Insutype == "390" {
  10498. is390 = 1
  10499. }
  10500. if i.Insutype == "310" {
  10501. is310 = 1
  10502. }
  10503. }
  10504. }
  10505. if is390 == 1 {
  10506. insutype = "390"
  10507. }
  10508. if is310 == 1 {
  10509. insutype = "310"
  10510. }
  10511. if len(insutypes) == 0 {
  10512. insutype = "310"
  10513. }
  10514. insutype = psn_record.Insutype
  10515. for _, item := range rf {
  10516. if item.Insutype == insutype {
  10517. insuplc_admdvs = item.InsuplcAdmdvs
  10518. }
  10519. }
  10520. if config.IsOpen == 1 {
  10521. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10522. var dat map[string]interface{}
  10523. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10524. fmt.Println(dat)
  10525. } else {
  10526. fmt.Println(err)
  10527. }
  10528. userJSONBytes, _ := json.Marshal(dat)
  10529. var res ResultFourteen
  10530. var res10265 ResultFourteen10265
  10531. if miConfig.Code == "H15049901371" {
  10532. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10533. utils.ErrorLog("解析失败:%v", err)
  10534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10535. return
  10536. }
  10537. res.ErrMsg = res10265.ErrMsg
  10538. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10539. res.Infcode = infocode
  10540. res.Output = res10265.Output
  10541. res.InfRefmsgid = res10265.InfRefmsgid
  10542. } else {
  10543. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10544. utils.ErrorLog("解析失败:%v", err)
  10545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10546. return
  10547. }
  10548. }
  10549. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10550. // utils.ErrorLog("解析失败:%v", err)
  10551. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10552. // return
  10553. //}
  10554. if res.Infcode == 0 {
  10555. psn_record.IsCancel = 2
  10556. service.CreatePsnNCDSRecord(&psn_record)
  10557. c.ServeSuccessJSON(map[string]interface{}{
  10558. "failed_code": 0,
  10559. "msg": "撤销备案成功",
  10560. })
  10561. } else {
  10562. c.ServeSuccessJSON(map[string]interface{}{
  10563. "failed_code": -10,
  10564. "msg": res.ErrMsg,
  10565. })
  10566. return
  10567. }
  10568. }
  10569. }
  10570. func (c *HisApiController) TestTest() {
  10571. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  10572. fmt.Println(patient.Iinfo)
  10573. }
  10574. type CustomData struct {
  10575. MsgId string
  10576. PsnNo string
  10577. Info string
  10578. }
  10579. func (c *HisApiController) ReversalData() {
  10580. var customData []*CustomData
  10581. custom := &CustomData{
  10582. MsgId: "H44022900158202103301714472004",
  10583. PsnNo: "44020000001101329945",
  10584. Info: "2207",
  10585. }
  10586. customData = append(customData, custom)
  10587. custom1 := &CustomData{
  10588. MsgId: "H4402290015820210330172057803",
  10589. PsnNo: "44020000001101161813",
  10590. Info: "2207",
  10591. }
  10592. customData = append(customData, custom1)
  10593. custom2 := &CustomData{
  10594. MsgId: "H44022900158202103301705198813",
  10595. PsnNo: "44190000133097375417",
  10596. Info: "2207",
  10597. }
  10598. customData = append(customData, custom2)
  10599. custom3 := &CustomData{
  10600. MsgId: "H44022900158202103301715524756",
  10601. PsnNo: "44020000001100187221",
  10602. Info: "2207",
  10603. }
  10604. customData = append(customData, custom3)
  10605. custom4 := &CustomData{
  10606. MsgId: "H44022900158202103301730376224",
  10607. PsnNo: "44020000001101959155",
  10608. Info: "2207",
  10609. }
  10610. customData = append(customData, custom4)
  10611. custom5 := &CustomData{
  10612. MsgId: "H44022900158202103301748008725",
  10613. PsnNo: "44020000001104246641",
  10614. Info: "2207",
  10615. }
  10616. customData = append(customData, custom5)
  10617. custom6 := &CustomData{
  10618. MsgId: "H44022900158202103301718096755",
  10619. PsnNo: "44020000001102211860",
  10620. Info: "2207",
  10621. }
  10622. customData = append(customData, custom6)
  10623. custom7 := &CustomData{
  10624. MsgId: "H44022900158202103301736551640",
  10625. PsnNo: "44020000001102687718",
  10626. Info: "2207",
  10627. }
  10628. customData = append(customData, custom7)
  10629. custom8 := &CustomData{
  10630. MsgId: "H44022900158202103301743097676",
  10631. PsnNo: "44020000001102127785",
  10632. Info: "2207",
  10633. }
  10634. customData = append(customData, custom8)
  10635. custom9 := &CustomData{
  10636. MsgId: "H44022900158202103301712304203",
  10637. PsnNo: "44020000001101518097",
  10638. Info: "2207",
  10639. }
  10640. customData = append(customData, custom9)
  10641. custom10 := &CustomData{
  10642. MsgId: "H44022900158202103301738448785",
  10643. PsnNo: "44020000001100500813",
  10644. Info: "2207",
  10645. }
  10646. customData = append(customData, custom10)
  10647. custom11 := &CustomData{
  10648. MsgId: "H44022900158202103301732455843",
  10649. PsnNo: "44020000001102690557",
  10650. Info: "2207",
  10651. }
  10652. customData = append(customData, custom11)
  10653. custom12 := &CustomData{
  10654. MsgId: "H44022900158202103301745421708",
  10655. PsnNo: "44020000001102211928",
  10656. Info: "2207",
  10657. }
  10658. customData = append(customData, custom12)
  10659. custom1212 := &CustomData{
  10660. MsgId: "H440229001582021033017351627",
  10661. PsnNo: "44020000001102481733",
  10662. Info: "2207",
  10663. }
  10664. customData = append(customData, custom1212)
  10665. custom13 := &CustomData{
  10666. MsgId: "H44022900158202103301740327951",
  10667. PsnNo: "44020000001103174866",
  10668. Info: "2207",
  10669. }
  10670. customData = append(customData, custom13)
  10671. custom14 := &CustomData{
  10672. MsgId: "H4402290015820210330174922668",
  10673. PsnNo: "44020000001102927272",
  10674. Info: "2207",
  10675. }
  10676. customData = append(customData, custom14)
  10677. custom15 := &CustomData{
  10678. MsgId: "H44022900158202103301752362273",
  10679. PsnNo: "44020000001102942890",
  10680. Info: "2207",
  10681. }
  10682. customData = append(customData, custom15)
  10683. custom16 := &CustomData{
  10684. MsgId: "H44022900158202103301751082917",
  10685. PsnNo: "44020000001101662162",
  10686. Info: "2207",
  10687. }
  10688. customData = append(customData, custom16)
  10689. custom17 := &CustomData{
  10690. MsgId: "H44022900158202103301754147728",
  10691. PsnNo: "44020000000229014511",
  10692. Info: "2207",
  10693. }
  10694. customData = append(customData, custom17)
  10695. adminUser := c.GetAdminUserInfo()
  10696. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10697. for _, item := range customData {
  10698. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10699. fmt.Println(result)
  10700. }
  10701. }
  10702. func (c *HisApiController) GetAllopatry() {
  10703. year := c.GetString("year")
  10704. month := c.GetString("month")
  10705. admin_user_id, _ := c.GetInt64("admin_user_id")
  10706. adminUser := c.GetAdminUserInfo()
  10707. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10708. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10709. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10710. var dat map[string]interface{}
  10711. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10712. fmt.Println(dat)
  10713. } else {
  10714. fmt.Println(err)
  10715. }
  10716. userJSONBytes, _ := json.Marshal(dat)
  10717. var res models.Result9001
  10718. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10719. utils.ErrorLog("解析失败:%v", err)
  10720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10721. return
  10722. }
  10723. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "")
  10724. var dat2 map[string]interface{}
  10725. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10726. fmt.Println(dat)
  10727. } else {
  10728. fmt.Println(err)
  10729. }
  10730. userJSONBytes2, _ := json.Marshal(dat2)
  10731. var res2 models.Result3260
  10732. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10733. utils.ErrorLog("解析失败:%v", err)
  10734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10735. return
  10736. }
  10737. if res2.Infcode == 0 {
  10738. c.ServeSuccessJSON(map[string]interface{}{
  10739. "list": res2.Output.Data,
  10740. })
  10741. return
  10742. } else {
  10743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10744. return
  10745. }
  10746. }
  10747. func (c *HisApiController) ComfirmAllopatry() {
  10748. year := c.GetString("year")
  10749. month := c.GetString("month")
  10750. admin_user_id, _ := c.GetInt64("admin_user_id")
  10751. adminUser := c.GetAdminUserInfo()
  10752. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10753. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10754. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10755. var dat map[string]interface{}
  10756. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10757. fmt.Println(dat)
  10758. } else {
  10759. fmt.Println(err)
  10760. }
  10761. userJSONBytes, _ := json.Marshal(dat)
  10762. var res models.Result9001
  10763. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10764. utils.ErrorLog("解析失败:%v", err)
  10765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10766. return
  10767. }
  10768. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "")
  10769. var dat2 map[string]interface{}
  10770. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10771. fmt.Println(dat)
  10772. } else {
  10773. fmt.Println(err)
  10774. }
  10775. userJSONBytes2, _ := json.Marshal(dat2)
  10776. var res2 models.Result3260
  10777. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10778. utils.ErrorLog("解析失败:%v", err)
  10779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10780. return
  10781. }
  10782. if res2.Infcode == 0 {
  10783. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  10784. var dat map[string]interface{}
  10785. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10786. fmt.Println(dat)
  10787. } else {
  10788. fmt.Println(err)
  10789. }
  10790. userJSONBytes, _ := json.Marshal(dat)
  10791. var res3 models.Result3261
  10792. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  10793. utils.ErrorLog("解析失败:%v", err)
  10794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10795. return
  10796. }
  10797. if res3.Infcode == 0 {
  10798. record := &models.HisYidiClearRecord{
  10799. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10800. Ctime: time.Now().Unix(),
  10801. Mtime: time.Now().Unix(),
  10802. Status: 1,
  10803. MsgId: msgId,
  10804. }
  10805. service.SaveClearRecord(record)
  10806. c.ServeSuccessJSON(map[string]interface{}{
  10807. "msg": "提取成功",
  10808. })
  10809. }
  10810. }
  10811. }
  10812. func (c *HisApiController) RefundAllopatry() {
  10813. year := c.GetString("year")
  10814. month := c.GetString("month")
  10815. id, _ := c.GetInt64("id")
  10816. admin_user_id, _ := c.GetInt64("admin_user_id")
  10817. adminUser := c.GetAdminUserInfo()
  10818. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10819. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10820. record, _ := service.GetClearRecordById(id)
  10821. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  10822. var dat map[string]interface{}
  10823. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10824. fmt.Println(dat)
  10825. } else {
  10826. fmt.Println(err)
  10827. }
  10828. userJSONBytes, _ := json.Marshal(dat)
  10829. var empty ResultFourteen
  10830. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  10831. utils.ErrorLog("解析失败:%v", err)
  10832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10833. return
  10834. }
  10835. if empty.Infcode == 0 {
  10836. c.ServeSuccessJSON(map[string]interface{}{
  10837. "msg": "撤销成功",
  10838. })
  10839. return
  10840. }
  10841. }
  10842. func (c *HisApiController) ReversalOtherData() {
  10843. var customData []*CustomData
  10844. custom := &CustomData{
  10845. MsgId: "H44022900158202103301714472004",
  10846. PsnNo: "44020000001101329945",
  10847. Info: "2208",
  10848. }
  10849. customData = append(customData, custom)
  10850. custom1 := &CustomData{
  10851. MsgId: "H4402290015820210330172057803",
  10852. PsnNo: "44020000001101161813",
  10853. Info: "2208",
  10854. }
  10855. customData = append(customData, custom1)
  10856. custom2 := &CustomData{
  10857. MsgId: "H44022900158202103301705198813",
  10858. PsnNo: "44190000133097375417",
  10859. Info: "2208",
  10860. }
  10861. customData = append(customData, custom2)
  10862. custom3 := &CustomData{
  10863. MsgId: "H44022900158202103301715524756",
  10864. PsnNo: "44020000001100187221",
  10865. Info: "2208",
  10866. }
  10867. customData = append(customData, custom3)
  10868. custom4 := &CustomData{
  10869. MsgId: "H44022900158202103301730376224",
  10870. PsnNo: "44020000001101959155",
  10871. Info: "2208",
  10872. }
  10873. customData = append(customData, custom4)
  10874. custom5 := &CustomData{
  10875. MsgId: "H44022900158202103301748008725",
  10876. PsnNo: "44020000001104246641",
  10877. Info: "2208",
  10878. }
  10879. customData = append(customData, custom5)
  10880. custom6 := &CustomData{
  10881. MsgId: "H44022900158202103301718096755",
  10882. PsnNo: "44020000001102211860",
  10883. Info: "2208",
  10884. }
  10885. customData = append(customData, custom6)
  10886. custom7 := &CustomData{
  10887. MsgId: "H44022900158202103301736551640",
  10888. PsnNo: "44020000001102687718",
  10889. Info: "2208",
  10890. }
  10891. customData = append(customData, custom7)
  10892. custom8 := &CustomData{
  10893. MsgId: "H44022900158202103301743097676",
  10894. PsnNo: "44020000001102127785",
  10895. Info: "2208",
  10896. }
  10897. customData = append(customData, custom8)
  10898. custom9 := &CustomData{
  10899. MsgId: "H44022900158202103301712304203",
  10900. PsnNo: "44020000001101518097",
  10901. Info: "2208",
  10902. }
  10903. customData = append(customData, custom9)
  10904. custom10 := &CustomData{
  10905. MsgId: "H44022900158202103301738448785",
  10906. PsnNo: "44020000001100500813",
  10907. Info: "2208",
  10908. }
  10909. customData = append(customData, custom10)
  10910. custom11 := &CustomData{
  10911. MsgId: "H44022900158202103301732455843",
  10912. PsnNo: "44020000001102690557",
  10913. Info: "2208",
  10914. }
  10915. customData = append(customData, custom11)
  10916. custom12 := &CustomData{
  10917. MsgId: "H44022900158202103301745421708",
  10918. PsnNo: "44020000001102211928",
  10919. Info: "2208",
  10920. }
  10921. customData = append(customData, custom12)
  10922. custom1212 := &CustomData{
  10923. MsgId: "H440229001582021033017351627",
  10924. PsnNo: "44020000001102481733",
  10925. Info: "2208",
  10926. }
  10927. customData = append(customData, custom1212)
  10928. custom13 := &CustomData{
  10929. MsgId: "H44022900158202103301740327951",
  10930. PsnNo: "44020000001103174866",
  10931. Info: "2208",
  10932. }
  10933. customData = append(customData, custom13)
  10934. custom14 := &CustomData{
  10935. MsgId: "H4402290015820210330174922668",
  10936. PsnNo: "44020000001102927272",
  10937. Info: "2208",
  10938. }
  10939. customData = append(customData, custom14)
  10940. custom15 := &CustomData{
  10941. MsgId: "H44022900158202103301752362273",
  10942. PsnNo: "44020000001102942890",
  10943. Info: "2208",
  10944. }
  10945. customData = append(customData, custom15)
  10946. custom16 := &CustomData{
  10947. MsgId: "H44022900158202103301751082917",
  10948. PsnNo: "44020000001101662162",
  10949. Info: "2208",
  10950. }
  10951. customData = append(customData, custom16)
  10952. custom17 := &CustomData{
  10953. MsgId: "H44022900158202103301754147728",
  10954. PsnNo: "44020000000229014511",
  10955. Info: "2208",
  10956. }
  10957. customData = append(customData, custom17)
  10958. adminUser := c.GetAdminUserInfo()
  10959. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10960. for _, item := range customData {
  10961. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10962. fmt.Println(result)
  10963. }
  10964. }
  10965. func PathExists(path string) (bool, error) {
  10966. _, err := os.Stat(path)
  10967. if err == nil {
  10968. return true, nil
  10969. }
  10970. if os.IsNotExist(err) {
  10971. return false, nil
  10972. }
  10973. return false, err
  10974. }
  10975. //创建文件夹
  10976. func Mkdir(dir string) {
  10977. // 创建文件夹
  10978. exist, err := PathExists(dir)
  10979. if err != nil {
  10980. fmt.Println(err.Error())
  10981. } else {
  10982. if exist {
  10983. fmt.Println(dir + "文件夹已存在!")
  10984. } else {
  10985. // 文件夹名称,权限
  10986. err := os.Mkdir(dir, os.ModePerm)
  10987. if err != nil {
  10988. fmt.Println(dir+"文件夹创建失败:", err.Error())
  10989. } else {
  10990. fmt.Println(dir + "文件夹创建成功!")
  10991. }
  10992. }
  10993. }
  10994. }
  10995. //压缩文件
  10996. func Zip(srcFile string, destZip string) error {
  10997. zipfile, err := os.Create(destZip)
  10998. if err != nil {
  10999. return err
  11000. }
  11001. defer zipfile.Close()
  11002. archive := zip.NewWriter(zipfile)
  11003. defer archive.Close()
  11004. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  11005. if err != nil {
  11006. return err
  11007. }
  11008. header, err := zip.FileInfoHeader(info)
  11009. if err != nil {
  11010. return err
  11011. }
  11012. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  11013. // header.Name = path
  11014. if info.IsDir() {
  11015. header.Name += "/"
  11016. } else {
  11017. header.Method = zip.Deflate
  11018. }
  11019. writer, err := archive.CreateHeader(header)
  11020. if err != nil {
  11021. return err
  11022. }
  11023. if !info.IsDir() {
  11024. file, err := os.Open(path)
  11025. if err != nil {
  11026. return err
  11027. }
  11028. defer file.Close()
  11029. _, err = io.Copy(writer, file)
  11030. }
  11031. return err
  11032. })
  11033. return err
  11034. }
  11035. func ReadFile(filePath string) []byte {
  11036. f, err := os.Open(filePath)
  11037. if err != nil {
  11038. fmt.Println("read file fail", err)
  11039. return nil
  11040. }
  11041. defer f.Close()
  11042. fd, err := ioutil.ReadAll(f)
  11043. if err != nil {
  11044. fmt.Println("read to fd fail", err)
  11045. return nil
  11046. }
  11047. return fd
  11048. }
  11049. func saveLog(result string, request string, infno string, desc string) {
  11050. org_id, _ := beego.AppConfig.Int64("org_id")
  11051. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  11052. dir := miConfig.OrgName + "日志"
  11053. utils.Mkdir(dir)
  11054. month := time.Unix(1557042972, 0).Format("1")
  11055. year := time.Now().Format("2006")
  11056. month = time.Now().Format("01")
  11057. day := time.Now().Format("02")
  11058. hour := time.Now().Format("15")
  11059. min := time.Now().Format("04")
  11060. sec := time.Now().Format("05")
  11061. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  11062. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  11063. file_name := file + ".txt"
  11064. file_path := miConfig.OrgName + "日志" + "/" + file_name
  11065. exist, _ := utils.PathExists(file_path)
  11066. if exist { //存在
  11067. fmt.Println("存在")
  11068. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  11069. if err != nil {
  11070. fmt.Println("read fail")
  11071. }
  11072. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  11073. n, _ := f.Seek(0, 2)
  11074. _, err = f.WriteAt([]byte(content), n)
  11075. } else { //不存在
  11076. fmt.Println("文件不存在,创建文件")
  11077. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  11078. defer f.Close()
  11079. if err != nil {
  11080. } else {
  11081. _, err = f.Write([]byte("记录日志"))
  11082. }
  11083. }
  11084. }
  11085. type Charset string
  11086. const (
  11087. UTF8 = Charset("UTF-8")
  11088. GB18030 = Charset("GB18030")
  11089. )
  11090. func ConvertToString(src string, srcCode string, tagCode string) string {
  11091. srcCoder := mahonia.NewDecoder(srcCode)
  11092. srcResult := srcCoder.ConvertString(src)
  11093. tagCoder := mahonia.NewDecoder(tagCode)
  11094. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  11095. result := string(cdata)
  11096. return result
  11097. }
  11098. func (c *HisApiController) ReadEleCard() {
  11099. id_card_type, _ := c.GetInt64("id_card_type")
  11100. admin_user_id, _ := c.GetInt64("admin_user_id")
  11101. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  11102. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11103. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11104. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11105. var api string
  11106. if miConfig.MdtrtareaAdmvs == "320921" {
  11107. 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 +
  11108. "&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
  11109. fmt.Println(api)
  11110. } else {
  11111. 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 +
  11112. "&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)
  11113. }
  11114. resp, requestErr := http.Get(api)
  11115. if requestErr != nil {
  11116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11117. return
  11118. }
  11119. body, ioErr := ioutil.ReadAll(resp.Body)
  11120. if ioErr != nil {
  11121. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11123. return
  11124. }
  11125. var respJSON map[string]interface{}
  11126. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11127. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11129. return
  11130. }
  11131. var status string
  11132. status = respJSON["data"].(map[string]interface{})["status"].(string)
  11133. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  11134. var token string
  11135. var res ResultTwo //1101结果
  11136. var res10265 ResultTwo10265 //1101结果
  11137. if status == "0" { //读卡成功
  11138. var card_info string //卡信息
  11139. var busi_card_info string
  11140. token = respJSON["data"].(map[string]interface{})["token"].(string)
  11141. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  11142. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  11143. fmt.Println(card_info)
  11144. fmt.Println(busi_card_info)
  11145. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  11146. result, _ := json.Marshal(respJSON)
  11147. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11148. utils.ErrorLog("解析失败:%v", err)
  11149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11150. return
  11151. }
  11152. res.ErrMsg = res10265.ErrMsg
  11153. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11154. res.Infcode = infocode
  11155. //res.Output = res10265.Output
  11156. res.InfRefmsgid = res10265.InfRefmsgid
  11157. if res.Infcode == 0 {
  11158. c.ServeSuccessJSON(map[string]interface{}{
  11159. "number": token,
  11160. })
  11161. }
  11162. } else {
  11163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11164. return
  11165. }
  11166. } else { //读卡失败
  11167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11168. return
  11169. }
  11170. }