his_api_controller.go 342KB

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