his_api_controller.go 341KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457
  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. var ids []int64
  3328. for _, item := range prescriptions {
  3329. ids = append(ids, item.ID)
  3330. }
  3331. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3332. if config.IsOpen == 1 { //对接了医保,走医保流程
  3333. var res ResultFour
  3334. var resFour10265 ResultFour10265
  3335. if miConfig.MdtrtareaAdmvs == "421300" {
  3336. bytesData, _ := json.Marshal(data)
  3337. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  3338. resp, _ := client.Do(req)
  3339. defer resp.Body.Close()
  3340. body, ioErr := ioutil.ReadAll(resp.Body)
  3341. if ioErr != nil {
  3342. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3344. return
  3345. }
  3346. var respJSON map[string]interface{}
  3347. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3348. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3350. return
  3351. }
  3352. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3353. userJSONBytes, _ := json.Marshal(respJSON)
  3354. fmt.Println("log")
  3355. fmt.Println(string(userJSONBytes))
  3356. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3357. utils.ErrorLog("解析失败:%v", err)
  3358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3359. return
  3360. }
  3361. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3362. bytesData, _ := json.Marshal(data)
  3363. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  3364. resp, _ := client.Do(req)
  3365. defer resp.Body.Close()
  3366. body, ioErr := ioutil.ReadAll(resp.Body)
  3367. if ioErr != nil {
  3368. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3370. return
  3371. }
  3372. var respJSON map[string]interface{}
  3373. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3374. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3376. return
  3377. }
  3378. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3379. userJSONBytes, _ := json.Marshal(respJSON)
  3380. fmt.Println("log")
  3381. fmt.Println(string(userJSONBytes))
  3382. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  3383. utils.ErrorLog("解析失败:%v", err)
  3384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3385. return
  3386. }
  3387. res.InfRefmsgid = resFour10265.InfRefmsgid
  3388. res.Output = resFour10265.Output
  3389. res.ErrMsg = resFour10265.ErrMsg
  3390. res.Cainfo = resFour10265.Cainfo
  3391. res.WarnMsg = resFour10265.WarnMsg
  3392. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  3393. res.Infcode = infocode
  3394. } else {
  3395. if miConfig.Code == "H15049901371" {
  3396. 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)
  3397. var dat map[string]interface{}
  3398. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3399. fmt.Println(dat)
  3400. } else {
  3401. fmt.Println(err)
  3402. }
  3403. saveLog(result, request_log, "2204", "上传费用明细")
  3404. userJSONBytes, _ := json.Marshal(dat)
  3405. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  3406. utils.ErrorLog("解析失败:%v", err)
  3407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3408. return
  3409. }
  3410. res.InfRefmsgid = resFour10265.InfRefmsgid
  3411. res.Output = resFour10265.Output
  3412. res.ErrMsg = resFour10265.ErrMsg
  3413. res.Cainfo = resFour10265.Cainfo
  3414. res.WarnMsg = resFour10265.WarnMsg
  3415. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  3416. res.Infcode = infocode
  3417. } else {
  3418. 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)
  3419. var dat map[string]interface{}
  3420. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3421. fmt.Println(dat)
  3422. } else {
  3423. fmt.Println(err)
  3424. }
  3425. saveLog(result, request_log, "2204", "上传费用明细")
  3426. userJSONBytes, _ := json.Marshal(dat)
  3427. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3428. utils.ErrorLog("解析失败:%v", err)
  3429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3430. return
  3431. }
  3432. }
  3433. }
  3434. if res.Infcode == 0 {
  3435. order := &models.HisOrder{
  3436. UserOrgId: adminUser.CurrentOrgId,
  3437. HisPatientId: his.ID,
  3438. PatientId: his.PatientId,
  3439. SettleAccountsDate: recordDateTime,
  3440. Ctime: time.Now().Unix(),
  3441. Mtime: time.Now().Unix(),
  3442. Status: 1,
  3443. Number: chrg_bchno,
  3444. Infcode: res.Infcode,
  3445. WarnMsg: res.WarnMsg,
  3446. Cainfo: res.Cainfo,
  3447. ErrMsg: res.ErrMsg,
  3448. RespondTime: res.RefmsgTime,
  3449. InfRefmsgid: res.InfRefmsgid,
  3450. OrderStatus: 1,
  3451. PayWay: pay_way,
  3452. PayPrice: pay_price,
  3453. PayCardNo: pay_card_no,
  3454. DiscountPrice: discount_price,
  3455. PreferentialPrice: preferential_price,
  3456. RealityPrice: reality_price,
  3457. FoundPrice: found_price,
  3458. MedicalInsurancePrice: medical_insurance_price,
  3459. PrivatePrice: private_price,
  3460. IsMedicineInsurance: 1,
  3461. SettleType: settle_accounts_type,
  3462. SettleStartTime: start_time,
  3463. SettleEndTime: end_time,
  3464. Creator: roles.AdminUserId,
  3465. Modify: roles.AdminUserId,
  3466. FaPiaoNumber: fapiao_number,
  3467. FaPiaoCode: fapiao_code,
  3468. PType: 2,
  3469. Diagnosis: diagnosis_id,
  3470. }
  3471. err = service.CreateOrder(order)
  3472. if err != nil {
  3473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  3474. return
  3475. }
  3476. for _, item := range res.Output.Result {
  3477. temp := strings.Split(item.FeedetlSn, "-")
  3478. var advice_id int64 = 0
  3479. var project_id int64 = 0
  3480. var types int64 = 0
  3481. id, _ := strconv.ParseInt(temp[2], 10, 64)
  3482. types, _ = strconv.ParseInt(temp[1], 10, 64)
  3483. if temp[1] == "1" {
  3484. advice_id = id
  3485. project_id = 0
  3486. } else if temp[1] == "2" {
  3487. advice_id = 0
  3488. project_id = id
  3489. }
  3490. info := &models.HisOrderInfo{
  3491. OrderNumber: order.Number,
  3492. FeedetlSn: item.FeedetlSn,
  3493. UploadDate: time.Now().Unix(),
  3494. AdviceId: advice_id,
  3495. DetItemFeeSumamt: item.DetItemFeeSumamt,
  3496. Cnt: item.Cnt,
  3497. Pric: float64(item.Pric),
  3498. PatientId: his.PatientId,
  3499. PricUplmtAmt: item.PricUplmtAmt,
  3500. SelfpayProp: item.SelfpayProp,
  3501. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  3502. OverlmtAmt: item.OverlmtAmt,
  3503. PreselfpayAmt: item.PreselfpayAmt,
  3504. BasMednFlag: item.BasMednFlag,
  3505. MedChrgitmType: item.MedChrgitmType,
  3506. HiNegoDrugFlag: item.HiNegoDrugFlag,
  3507. Status: 1,
  3508. Memo: item.Memo,
  3509. Mtime: time.Now().Unix(),
  3510. InscpScpAmt: item.InscpScpAmt,
  3511. DrtReimFlag: item.DrtReimFlag,
  3512. Ctime: time.Now().Unix(),
  3513. ListSpItemFlag: item.ListSpItemFlag,
  3514. ChldMedcFlag: item.ChldMedcFlag,
  3515. LmtUsedFlag: item.LmtUsedFlag,
  3516. ChrgitmLv: item.ChrgitmLv,
  3517. UserOrgId: adminUser.CurrentOrgId,
  3518. HisPatientId: his.ID,
  3519. OrderId: order.ID,
  3520. ProjectId: project_id,
  3521. Type: types,
  3522. }
  3523. service.CreateOrderInfo(info)
  3524. }
  3525. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  3526. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  3527. var total float64
  3528. for _, item := range prescriptions {
  3529. if item.Type == 1 { //药品
  3530. for _, subItem := range item.HisDoctorAdviceInfo {
  3531. total = total + (subItem.Price * subItem.PrescribingNumber)
  3532. }
  3533. }
  3534. if item.Type == 2 { //项目
  3535. for _, subItem := range item.HisPrescriptionProject {
  3536. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  3537. total = total + (subItem.Price * cnt)
  3538. }
  3539. }
  3540. }
  3541. for _, item := range prescriptions {
  3542. for _, subItem := range item.HisAdditionalCharge {
  3543. total = total + (subItem.Price * float64(subItem.Count))
  3544. }
  3545. }
  3546. var allTotal string
  3547. if adminUser.CurrentOrgId == 9919 {
  3548. allTotal = fmt.Sprintf("%.4f", total)
  3549. } else {
  3550. allTotal = fmt.Sprintf("%.4f", total)
  3551. }
  3552. if res.Infcode == 0 {
  3553. var rf []*ResultFive
  3554. json.Unmarshal([]byte(his.Iinfo), &rf)
  3555. chrg_bchno := chrg_bchno
  3556. cert_no := his.Certno
  3557. var insutypes []string
  3558. var insutype string
  3559. var is390 int = 0
  3560. var is310 int = 0
  3561. for _, item := range rf {
  3562. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3563. insutypes = append(insutypes, item.Insutype)
  3564. }
  3565. }
  3566. if len(insutypes) == 1 {
  3567. insutype = insutypes[0]
  3568. } else {
  3569. for _, i := range insutypes {
  3570. if i == "390" {
  3571. is390 = 1
  3572. }
  3573. if i == "310" {
  3574. is310 = 1
  3575. }
  3576. }
  3577. }
  3578. if is390 == 1 {
  3579. insutype = "390"
  3580. }
  3581. if is310 == 1 {
  3582. insutype = "310"
  3583. }
  3584. if len(insutypes) == 0 {
  3585. insutype = "310"
  3586. }
  3587. if len(insutypes) == 2 {
  3588. insutype = strconv.FormatInt(his.SocialType, 10)
  3589. }
  3590. insutype = strconv.FormatInt(his.SocialType, 10)
  3591. //insutype = "390"
  3592. if his.IdCardType == 1 {
  3593. // cert_no = his.MedicalInsuranceNumber
  3594. cert_no = his.Certno
  3595. } else {
  3596. cert_no = his.Certno
  3597. }
  3598. var res ResultSeven
  3599. var resSeven10265 ResultSeven10265
  3600. var src_resquest string
  3601. var result2 string
  3602. var acct_used_flag string
  3603. fmt.Println("pay_way")
  3604. fmt.Println(pay_way)
  3605. fmt.Println("pay_way")
  3606. if pay_way == 4 {
  3607. acct_used_flag = "1"
  3608. } else {
  3609. acct_used_flag = "0"
  3610. }
  3611. if miConfig.MdtrtareaAdmvs == "421300" {
  3612. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3613. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3614. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3615. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3616. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3617. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3618. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  3619. resp, requestErr := http.Get(api)
  3620. if requestErr != nil {
  3621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3622. return
  3623. }
  3624. body, ioErr := ioutil.ReadAll(resp.Body)
  3625. if ioErr != nil {
  3626. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3628. return
  3629. }
  3630. var respJSON map[string]interface{}
  3631. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3632. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3634. return
  3635. }
  3636. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3637. result, _ := json.Marshal(respJSON)
  3638. if miConfig.Code == "H15049901371" {
  3639. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  3640. utils.ErrorLog("解析失败:%v", err)
  3641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3642. return
  3643. }
  3644. res.InfRefmsgid = resSeven10265.InfRefmsgid
  3645. res.Output = resSeven10265.Output
  3646. res.ErrMsg = resSeven10265.ErrMsg
  3647. res.Cainfo = resSeven10265.Cainfo
  3648. res.WarnMsg = resSeven10265.WarnMsg
  3649. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  3650. res.Infcode = infocode
  3651. } else {
  3652. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3653. utils.ErrorLog("解析失败:%v", err)
  3654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3655. return
  3656. }
  3657. }
  3658. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3659. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  3660. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  3661. api := "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3662. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3663. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3664. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3665. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3666. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3667. "&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
  3668. resp, requestErr := http.Get(api)
  3669. if requestErr != nil {
  3670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3671. return
  3672. }
  3673. body, ioErr := ioutil.ReadAll(resp.Body)
  3674. if ioErr != nil {
  3675. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3677. return
  3678. }
  3679. var respJSON map[string]interface{}
  3680. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3681. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3683. return
  3684. }
  3685. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3686. result, _ := json.Marshal(respJSON)
  3687. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  3688. utils.ErrorLog("解析失败:%v", err)
  3689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3690. return
  3691. }
  3692. res.InfRefmsgid = resSeven10265.InfRefmsgid
  3693. res.Output = resSeven10265.Output
  3694. res.ErrMsg = resSeven10265.ErrMsg
  3695. res.Cainfo = resSeven10265.Cainfo
  3696. res.WarnMsg = resSeven10265.WarnMsg
  3697. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  3698. res.Infcode = infocode
  3699. } else {
  3700. if miConfig.Code == "H15049901371" {
  3701. //赤峰地区国家医保医疗类别
  3702. //职工透析:医疗类别选特殊情况门诊990502
  3703. //居民定额血透门慢: 医疗类别选门诊慢病140104
  3704. var med_type string
  3705. if his.Insutype == "390" {
  3706. if reg_type == 14 {
  3707. med_type = "9933"
  3708. } else if reg_type == 11 {
  3709. med_type = "11"
  3710. }
  3711. } else if his.Insutype == "310" {
  3712. if reg_type == 14 {
  3713. med_type = "990502"
  3714. } else if reg_type == 11 {
  3715. med_type = "11"
  3716. }
  3717. }
  3718. 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)
  3719. } else {
  3720. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  3721. }
  3722. //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)
  3723. var dat map[string]interface{}
  3724. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  3725. fmt.Println(dat)
  3726. } else {
  3727. fmt.Println(err)
  3728. }
  3729. saveLog(result2, src_resquest, "2207", "结算")
  3730. userJSONBytes, _ := json.Marshal(dat)
  3731. if miConfig.Code == "H15049901371" {
  3732. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  3733. utils.ErrorLog("解析失败:%v", err)
  3734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3735. return
  3736. }
  3737. res.InfRefmsgid = resSeven10265.InfRefmsgid
  3738. res.Output = resSeven10265.Output
  3739. res.ErrMsg = resSeven10265.ErrMsg
  3740. res.Cainfo = resSeven10265.Cainfo
  3741. res.WarnMsg = resSeven10265.WarnMsg
  3742. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  3743. res.Infcode = infocode
  3744. } else {
  3745. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3746. utils.ErrorLog("解析失败:%v", err)
  3747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3748. return
  3749. }
  3750. }
  3751. }
  3752. if res.Infcode != 0 {
  3753. errlog := &models.HisOrderError{
  3754. UserOrgId: adminUser.CurrentOrgId,
  3755. Ctime: time.Now().Unix(),
  3756. Mtime: time.Now().Unix(),
  3757. Number: chrg_bchno,
  3758. ErrMsg: res.ErrMsg,
  3759. Status: 1,
  3760. PatientId: id,
  3761. RecordTime: recordDateTime,
  3762. Stage: 6,
  3763. }
  3764. service.CreateErrMsgLog(errlog)
  3765. c.ServeSuccessJSON(map[string]interface{}{
  3766. "failed_code": -10,
  3767. "msg": res.ErrMsg,
  3768. })
  3769. return
  3770. } else {
  3771. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  3772. order.OrderStatus = 2
  3773. order.Status = 1
  3774. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  3775. order.SetlId = res.Output.Setlinfo.SetlID
  3776. order.PsnNo = res.Output.Setlinfo.PsnNo
  3777. order.PsnName = res.Output.Setlinfo.PsnName
  3778. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  3779. order.Certno = res.Output.Setlinfo.Certno
  3780. order.Gend = res.Output.Setlinfo.Gend
  3781. order.Naty = res.Output.Setlinfo.Naty
  3782. order.Age = res.Output.Setlinfo.Age
  3783. order.Insutype = res.Output.Setlinfo.Insutype
  3784. order.PsnType = res.Output.Setlinfo.PsnType
  3785. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  3786. order.SetlTime = res.Output.Setlinfo.SetlTime
  3787. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  3788. if res.Output.Setlinfo.MedType == "140101" {
  3789. order.MedType = "14"
  3790. } else {
  3791. order.MedType = res.Output.Setlinfo.MedType
  3792. }
  3793. if reg_type == 1112 {
  3794. order.MedType = "1112"
  3795. }
  3796. if reg_type == 1111 {
  3797. order.MedType = "1111"
  3798. }
  3799. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  3800. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  3801. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  3802. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  3803. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  3804. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  3805. order.HifpPay = res.Output.Setlinfo.HifpPay
  3806. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  3807. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  3808. order.HifesPay = res.Output.Setlinfo.HifesPay
  3809. order.HifobPay = res.Output.Setlinfo.HifobPay
  3810. order.MafPay = res.Output.Setlinfo.MafPay
  3811. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  3812. order.OthPay = res.Output.Setlinfo.OthPay
  3813. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  3814. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  3815. order.AcctPay = res.Output.Setlinfo.AcctPay
  3816. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  3817. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  3818. order.Balc = res.Output.Setlinfo.Balc
  3819. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  3820. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  3821. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  3822. order.ClrType = res.Output.Setlinfo.ClrType
  3823. order.ClrWay = res.Output.Setlinfo.ClrWay
  3824. order.Creator = order.Creator
  3825. order.Modify = roles.AdminUserId
  3826. order.RequestLog = src_resquest
  3827. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  3828. detailStr := string(setlDetail)
  3829. order.SetlDetail = detailStr
  3830. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  3831. err = service.UpDateOrder(order)
  3832. if err == nil {
  3833. c.ServeSuccessJSON(map[string]interface{}{
  3834. "msg": "结算成功",
  3835. })
  3836. } else {
  3837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3838. return
  3839. }
  3840. }
  3841. } else {
  3842. adminUser := c.GetAdminUserInfo()
  3843. errlog := &models.HisOrderError{
  3844. UserOrgId: adminUser.CurrentOrgId,
  3845. Ctime: time.Now().Unix(),
  3846. Mtime: time.Now().Unix(),
  3847. ErrMsg: res.ErrMsg,
  3848. Status: 1,
  3849. PatientId: id,
  3850. RecordTime: recordDateTime,
  3851. Stage: 4,
  3852. }
  3853. service.CreateErrMsgLog(errlog)
  3854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  3855. return
  3856. }
  3857. } else {
  3858. adminUser := c.GetAdminUserInfo()
  3859. errlog := &models.HisOrderError{
  3860. UserOrgId: adminUser.CurrentOrgId,
  3861. Ctime: time.Now().Unix(),
  3862. Mtime: time.Now().Unix(),
  3863. ErrMsg: res.ErrMsg,
  3864. Status: 1,
  3865. PatientId: id,
  3866. RecordTime: recordDateTime,
  3867. Stage: 4,
  3868. }
  3869. service.CreateErrMsgLog(errlog)
  3870. c.ServeSuccessJSON(map[string]interface{}{
  3871. "failed_code": -10,
  3872. "msg": res.ErrMsg,
  3873. })
  3874. return
  3875. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  3876. //return
  3877. }
  3878. }
  3879. }
  3880. } else if tempOrder.ID > 0 {
  3881. if tempOrder.IsPre == 1 {
  3882. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  3883. var rf []*ResultFive
  3884. json.Unmarshal([]byte(his.Iinfo), &rf)
  3885. chrg_bchno := tempOrder.Number
  3886. cert_no := his.Certno
  3887. var insutypes []string
  3888. var insutype string
  3889. var is390 int = 0
  3890. var is310 int = 0
  3891. for _, item := range rf {
  3892. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3893. insutypes = append(insutypes, item.Insutype)
  3894. }
  3895. }
  3896. if len(insutypes) == 1 {
  3897. insutype = insutypes[0]
  3898. } else {
  3899. for _, i := range insutypes {
  3900. if i == "390" {
  3901. is390 = 1
  3902. }
  3903. if i == "310" {
  3904. is310 = 1
  3905. }
  3906. }
  3907. }
  3908. if is390 == 1 {
  3909. insutype = "390"
  3910. }
  3911. if is310 == 1 {
  3912. insutype = "310"
  3913. }
  3914. if len(insutypes) == 0 {
  3915. insutype = "310"
  3916. }
  3917. if len(insutypes) == 2 {
  3918. insutype = strconv.FormatInt(his.SocialType, 64)
  3919. }
  3920. //insutype = "390"
  3921. if his.IdCardType == 1 {
  3922. // cert_no = his.MedicalInsuranceNumber
  3923. cert_no = his.Certno
  3924. } else {
  3925. cert_no = his.Certno
  3926. }
  3927. var res ResultSeven
  3928. var resSeven10265 ResultSeven10265
  3929. var src_resquest string
  3930. var result2 string
  3931. var acct_used_flag string
  3932. fmt.Println("pay_way")
  3933. fmt.Println(pay_way)
  3934. fmt.Println("pay_way")
  3935. if pay_way == 4 {
  3936. acct_used_flag = "1"
  3937. } else {
  3938. acct_used_flag = "0"
  3939. }
  3940. if miConfig.MdtrtareaAdmvs == "421300" {
  3941. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3942. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3943. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3944. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3945. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3946. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3947. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  3948. resp, requestErr := http.Get(api)
  3949. if requestErr != nil {
  3950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3951. return
  3952. }
  3953. body, ioErr := ioutil.ReadAll(resp.Body)
  3954. if ioErr != nil {
  3955. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3957. return
  3958. }
  3959. var respJSON map[string]interface{}
  3960. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3961. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3963. return
  3964. }
  3965. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3966. result, _ := json.Marshal(respJSON)
  3967. fmt.Println("log")
  3968. fmt.Println(string(result))
  3969. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3970. utils.ErrorLog("解析失败:%v", err)
  3971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3972. return
  3973. }
  3974. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3975. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  3976. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  3977. api := "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3978. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3979. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3980. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3981. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3982. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3983. "&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
  3984. resp, requestErr := http.Get(api)
  3985. if requestErr != nil {
  3986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3987. return
  3988. }
  3989. body, ioErr := ioutil.ReadAll(resp.Body)
  3990. if ioErr != nil {
  3991. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3993. return
  3994. }
  3995. var respJSON map[string]interface{}
  3996. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3997. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3999. return
  4000. }
  4001. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4002. result, _ := json.Marshal(respJSON)
  4003. fmt.Println("log")
  4004. fmt.Println(string(result))
  4005. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4006. utils.ErrorLog("解析失败:%v", err)
  4007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4008. return
  4009. }
  4010. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4011. res.Output = resSeven10265.Output
  4012. res.ErrMsg = resSeven10265.ErrMsg
  4013. res.Cainfo = resSeven10265.Cainfo
  4014. res.WarnMsg = resSeven10265.WarnMsg
  4015. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4016. res.Infcode = infocode
  4017. } else {
  4018. var src_resquest string
  4019. if miConfig.Code == "H15049901371" {
  4020. //赤峰地区国家医保医疗类别
  4021. //职工透析:医疗类别选特殊情况门诊990502
  4022. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4023. var med_type string
  4024. if his.Insutype == "390" {
  4025. if reg_type == 14 {
  4026. med_type = "9933"
  4027. } else if reg_type == 11 {
  4028. med_type = "11"
  4029. }
  4030. } else if his.Insutype == "310" {
  4031. if reg_type == 14 {
  4032. med_type = "990502"
  4033. } else if reg_type == 11 {
  4034. med_type = "11"
  4035. }
  4036. }
  4037. 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)
  4038. } else {
  4039. 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)
  4040. }
  4041. var dat map[string]interface{}
  4042. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4043. fmt.Println(dat)
  4044. } else {
  4045. fmt.Println(err)
  4046. }
  4047. saveLog(result2, src_resquest, "2207", "结算")
  4048. userJSONBytes, _ := json.Marshal(dat)
  4049. if miConfig.Code == "H15049901371" {
  4050. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4051. utils.ErrorLog("解析失败:%v", err)
  4052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4053. return
  4054. }
  4055. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4056. res.Output = resSeven10265.Output
  4057. res.ErrMsg = resSeven10265.ErrMsg
  4058. res.Cainfo = resSeven10265.Cainfo
  4059. res.WarnMsg = resSeven10265.WarnMsg
  4060. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4061. res.Infcode = infocode
  4062. } else {
  4063. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4064. utils.ErrorLog("解析失败:%v", err)
  4065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4066. return
  4067. }
  4068. }
  4069. }
  4070. if res.Infcode != 0 {
  4071. errlog := &models.HisOrderError{
  4072. UserOrgId: adminUser.CurrentOrgId,
  4073. Ctime: time.Now().Unix(),
  4074. Mtime: time.Now().Unix(),
  4075. Number: chrg_bchno,
  4076. ErrMsg: res.ErrMsg,
  4077. Status: 1,
  4078. PatientId: id,
  4079. RecordTime: recordDateTime,
  4080. Stage: 6,
  4081. }
  4082. service.CreateErrMsgLog(errlog)
  4083. c.ServeSuccessJSON(map[string]interface{}{
  4084. "failed_code": -10,
  4085. "msg": res.ErrMsg,
  4086. })
  4087. return
  4088. } else {
  4089. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4090. order.OrderStatus = 2
  4091. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4092. order.SetlId = res.Output.Setlinfo.SetlID
  4093. order.PsnNo = res.Output.Setlinfo.PsnNo
  4094. order.PsnName = res.Output.Setlinfo.PsnName
  4095. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4096. order.Certno = res.Output.Setlinfo.Certno
  4097. order.Gend = res.Output.Setlinfo.Gend
  4098. order.Naty = res.Output.Setlinfo.Naty
  4099. order.Age = res.Output.Setlinfo.Age
  4100. order.Insutype = res.Output.Setlinfo.Insutype
  4101. order.PsnType = res.Output.Setlinfo.PsnType
  4102. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4103. order.SetlTime = res.Output.Setlinfo.SetlTime
  4104. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4105. //order.MedType = res.Output.Setlinfo.MedType
  4106. if reg_type == 1112 {
  4107. order.MedType = "1112"
  4108. }
  4109. if reg_type == 1111 {
  4110. order.MedType = "1111"
  4111. }
  4112. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4113. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4114. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4115. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4116. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4117. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4118. order.HifpPay = res.Output.Setlinfo.HifpPay
  4119. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4120. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4121. order.HifesPay = res.Output.Setlinfo.HifesPay
  4122. order.HifobPay = res.Output.Setlinfo.HifobPay
  4123. order.MafPay = res.Output.Setlinfo.MafPay
  4124. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4125. order.OthPay = res.Output.Setlinfo.OthPay
  4126. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4127. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4128. order.AcctPay = res.Output.Setlinfo.AcctPay
  4129. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4130. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4131. order.Balc = res.Output.Setlinfo.Balc
  4132. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4133. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4134. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4135. order.ClrWay = res.Output.Setlinfo.ClrWay
  4136. order.Creator = order.Creator
  4137. order.Modify = roles.AdminUserId
  4138. order.RequestLog = src_resquest
  4139. order.Diagnosis = diagnosis_id
  4140. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4141. detailStr := string(setlDetail)
  4142. order.SetlDetail = detailStr
  4143. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4144. err = service.UpDateOrder(order)
  4145. if err == nil {
  4146. c.ServeSuccessJSON(map[string]interface{}{
  4147. "msg": "结算成功",
  4148. })
  4149. } else {
  4150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4151. return
  4152. }
  4153. }
  4154. }
  4155. }
  4156. }
  4157. //func (c *HisApiController) GetPreUploadInfo() {
  4158. // id, _ := c.GetInt64("id")
  4159. // record_time := c.GetString("record_time")
  4160. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4161. // admin_user_id, _ := c.GetInt64("admin_user_id")
  4162. //
  4163. // timeLayout := "2006-01-02"
  4164. // loc, _ := time.LoadLocation("Local")
  4165. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4166. // if err != nil {
  4167. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4168. // return
  4169. // }
  4170. // recordDateTime := theTime.Unix()
  4171. // adminUser := c.GetAdminUserInfo()
  4172. //
  4173. // var prescriptions []*models.HisPrescription
  4174. //
  4175. // var start_time int64
  4176. // var end_time int64
  4177. //
  4178. // data := make(map[string]interface{})
  4179. // if settle_accounts_type == 1 { //日结
  4180. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  4181. // data["pre"] = prescriptions
  4182. //
  4183. // } else { //月结
  4184. // start_time_str := c.GetString("start_time")
  4185. // end_time_str := c.GetString("end_time")
  4186. // timeLayout := "2006-01-02"
  4187. // loc, _ := time.LoadLocation("Local")
  4188. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4189. // if err != nil {
  4190. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4191. // return
  4192. // }
  4193. // recordStartTime := theStartTime.Unix()
  4194. // start_time = recordStartTime
  4195. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4196. // if err != nil {
  4197. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4198. // return
  4199. // }
  4200. // recordEndTime := theEndTime.Unix()
  4201. // end_time = recordEndTime
  4202. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  4203. // data["pre"] = prescriptions
  4204. //
  4205. // }
  4206. //
  4207. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4208. //
  4209. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4210. // timestamp := time.Now().Unix()
  4211. // tempTime := time.Unix(timestamp, 0)
  4212. // timeFormat := tempTime.Format("20060102150405")
  4213. // chrgBchno := rand.Intn(100000) + 10000
  4214. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4215. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4216. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4217. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4218. // strconv.FormatInt(his.PatientId, 10)
  4219. // client := &http.Client{}
  4220. // data["psn_no"] = his.PsnNo
  4221. // data["mdtrt_id"] = his.Number
  4222. // data["chrg_bchno"] = chrg_bchno
  4223. // data["org_name"] = miConfig.OrgName
  4224. // data["doctor"] = roles.UserName
  4225. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4226. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4227. // data["fixmedins_code"] = miConfig.Code
  4228. // data["dept_code"] = department.Number
  4229. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4230. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4231. // data["secret_key"] = miConfig.SecretKey
  4232. // var ids []int64
  4233. //
  4234. // for _, item := range prescriptions {
  4235. // ids = append(ids, item.ID)
  4236. // }
  4237. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4238. // if config.IsOpen == 1 { //对接了医保,走医保流程
  4239. // bytesData, _ := json.Marshal(data)
  4240. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  4241. // resp, _ := client.Do(req)
  4242. // defer resp.Body.Close()
  4243. // body, ioErr := ioutil.ReadAll(resp.Body)
  4244. // if ioErr != nil {
  4245. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4246. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4247. // return
  4248. // }
  4249. // var respJSON map[string]interface{}
  4250. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4251. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4252. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4253. // return
  4254. // }
  4255. //
  4256. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4257. // userJSONBytes, _ := json.Marshal(respJSON)
  4258. // var res ResultFour
  4259. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4260. // utils.ErrorLog("解析失败:%v", err)
  4261. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4262. // return
  4263. // }
  4264. //
  4265. // if res.Infcode == 0 {
  4266. // order := &models.HisOrder{
  4267. // UserOrgId: adminUser.CurrentOrgId,
  4268. // HisPatientId: his.ID,
  4269. // PatientId: his.PatientId,
  4270. // SettleAccountsDate: recordDateTime,
  4271. // Ctime: time.Now().Unix(),
  4272. // Mtime: time.Now().Unix(),
  4273. // Status: 1,
  4274. // Number: chrg_bchno,
  4275. // Infcode: res.Infcode,
  4276. // WarnMsg: res.WarnMsg,
  4277. // Cainfo: res.Cainfo,
  4278. // ErrMsg: res.ErrMsg,
  4279. // RespondTime: res.RefmsgTime,
  4280. // InfRefmsgid: res.InfRefmsgid,
  4281. // OrderStatus: 1,
  4282. // IsMedicineInsurance: 1,
  4283. // SettleType: settle_accounts_type,
  4284. // SettleStartTime: start_time,
  4285. // SettleEndTime: end_time,
  4286. // Creator: roles.ID,
  4287. // Modify: roles.ID,
  4288. // PType: 2,
  4289. // }
  4290. // err = service.CreateOrder(order)
  4291. // if err != nil {
  4292. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4293. // return
  4294. // }
  4295. //
  4296. // for _, item := range res.Output.Result {
  4297. // temp := strings.Split(item.FeedetlSn, "-")
  4298. // var advice_id int64 = 0
  4299. // var project_id int64 = 0
  4300. // var types int64 = 0
  4301. //
  4302. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  4303. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  4304. //
  4305. // if temp[1] == "1" {
  4306. // advice_id = id
  4307. // project_id = 0
  4308. // } else if temp[1] == "2" {
  4309. // advice_id = 0
  4310. // project_id = id
  4311. // }
  4312. //
  4313. // info := &models.HisOrderInfo{
  4314. // OrderNumber: order.Number,
  4315. // FeedetlSn: item.FeedetlSn,
  4316. // UploadDate: time.Now().Unix(),
  4317. // AdviceId: advice_id,
  4318. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  4319. // Cnt: item.Cnt,
  4320. // Pric: float64(item.Pric),
  4321. // PatientId: his.PatientId,
  4322. // PricUplmtAmt: item.PricUplmtAmt,
  4323. // SelfpayProp: item.SelfpayProp,
  4324. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4325. // OverlmtAmt: item.OverlmtAmt,
  4326. // PreselfpayAmt: item.PreselfpayAmt,
  4327. // BasMednFlag: item.BasMednFlag,
  4328. // MedChrgitmType: item.MedChrgitmType,
  4329. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  4330. // Status: 1,
  4331. // Memo: item.Memo,
  4332. // Mtime: time.Now().Unix(),
  4333. // InscpScpAmt: item.InscpScpAmt,
  4334. // DrtReimFlag: item.DrtReimFlag,
  4335. // Ctime: time.Now().Unix(),
  4336. // ListSpItemFlag: item.ListSpItemFlag,
  4337. // ChldMedcFlag: item.ChldMedcFlag,
  4338. // LmtUsedFlag: item.LmtUsedFlag,
  4339. // ChrgitmLv: item.ChrgitmLv,
  4340. // UserOrgId: adminUser.CurrentOrgId,
  4341. // HisPatientId: his.ID,
  4342. // OrderId: order.ID,
  4343. // ProjectId: project_id,
  4344. // Type: types,
  4345. // }
  4346. // service.CreateOrderInfo(info)
  4347. //
  4348. // }
  4349. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4350. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  4351. //
  4352. // var total float64
  4353. // for _, item := range prescriptions {
  4354. // if item.Type == 1 { //药品
  4355. // for _, subItem := range item.HisDoctorAdviceInfo {
  4356. // total = total + (subItem.Price * subItem.PrescribingNumber)
  4357. // }
  4358. // }
  4359. // if item.Type == 2 { //项目
  4360. // for _, subItem := range item.HisPrescriptionProject {
  4361. // total = total + (subItem.Price * float64(subItem.Count))
  4362. // }
  4363. // }
  4364. // }
  4365. //
  4366. // for _, item := range prescriptions {
  4367. // for _, subItem := range item.HisAdditionalCharge {
  4368. // total = total + (subItem.Price * float64(subItem.Count))
  4369. // }
  4370. // }
  4371. //
  4372. // allTotal := fmt.Sprintf("%.2f", total)
  4373. // if res.Infcode == 0 {
  4374. // var rf []*ResultFive
  4375. // json.Unmarshal([]byte(his.Iinfo), &rf)
  4376. // psn_no := his.PsnNo
  4377. // mdtrt_id := his.Number
  4378. // chrg_bchno := chrg_bchno
  4379. // cert_no := his.Certno
  4380. // insutype := rf[0].Insutype
  4381. //
  4382. // if his.IdCardType == 1 {
  4383. // cert_no = his.MedicalInsuranceNumber
  4384. //
  4385. // } else {
  4386. //
  4387. // cert_no = his.Certno
  4388. //
  4389. // }
  4390. //
  4391. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  4392. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  4393. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  4394. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  4395. // resp, requestErr := http.Get(api)
  4396. // if requestErr != nil {
  4397. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4398. // return
  4399. // }
  4400. // defer resp.Body.Close()
  4401. // body, ioErr := ioutil.ReadAll(resp.Body)
  4402. // if ioErr != nil {
  4403. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4404. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4405. // return
  4406. // }
  4407. // var respJSON map[string]interface{}
  4408. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4409. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4410. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4411. // return
  4412. // }
  4413. // fmt.Println(respJSON)
  4414. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4415. // userJSONBytes, _ := json.Marshal(respJSON)
  4416. // var res ResultSeven
  4417. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4418. // utils.ErrorLog("解析失败:%v", err)
  4419. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4420. // return
  4421. // }
  4422. // if res.Infcode != 0 {
  4423. // errlog := &models.HisOrderError{
  4424. // UserOrgId: adminUser.CurrentOrgId,
  4425. // Ctime: time.Now().Unix(),
  4426. // Mtime: time.Now().Unix(),
  4427. // Number: chrg_bchno,
  4428. // ErrMsg: res.ErrMsg,
  4429. // Status: 1,
  4430. // PatientId: id,
  4431. // RecordTime: recordDateTime,
  4432. // Stage: 7,
  4433. // }
  4434. // service.CreateErrMsgLog(errlog)
  4435. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4436. // return
  4437. // } else {
  4438. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4439. // order.OrderStatus = 1
  4440. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4441. // order.SetlId = res.Output.Setlinfo.SetlID
  4442. // order.PsnNo = res.Output.Setlinfo.PsnNo
  4443. // order.PsnName = res.Output.Setlinfo.PsnName
  4444. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4445. // order.Certno = res.Output.Setlinfo.Certno
  4446. // order.Gend = res.Output.Setlinfo.Gend
  4447. // order.Naty = res.Output.Setlinfo.Naty
  4448. // order.Age = res.Output.Setlinfo.Age
  4449. // order.Insutype = res.Output.Setlinfo.Insutype
  4450. // order.PsnType = res.Output.Setlinfo.PsnType
  4451. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4452. // order.SetlTime = res.Output.Setlinfo.SetlTime
  4453. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4454. // order.MedType = res.Output.Setlinfo.MedType
  4455. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4456. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4457. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4458. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4459. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4460. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4461. // order.HifpPay = res.Output.Setlinfo.HifpPay
  4462. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4463. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4464. // order.HifesPay = res.Output.Setlinfo.HifesPay
  4465. // order.HifobPay = res.Output.Setlinfo.HifobPay
  4466. // order.MafPay = res.Output.Setlinfo.MafPay
  4467. // order.OthPay = res.Output.Setlinfo.OthPay
  4468. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4469. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4470. // order.AcctPay = res.Output.Setlinfo.AcctPay
  4471. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4472. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4473. // order.Balc = res.Output.Setlinfo.Balc
  4474. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4475. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4476. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4477. // order.ClrWay = res.Output.Setlinfo.ClrWay
  4478. // order.Creator = order.Creator
  4479. // order.Modify = roles.ID
  4480. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4481. // detailStr := string(setlDetail)
  4482. // order.SetlDetail = detailStr
  4483. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4484. // err = service.UpDateOrder(order)
  4485. // if err == nil {
  4486. // c.ServeSuccessJSON(map[string]interface{}{
  4487. // "msg": "预结算成功",
  4488. // })
  4489. // } else {
  4490. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4491. // return
  4492. // }
  4493. // }
  4494. // } else {
  4495. // adminUser := c.GetAdminUserInfo()
  4496. // errlog := &models.HisOrderError{
  4497. // UserOrgId: adminUser.CurrentOrgId,
  4498. // Ctime: time.Now().Unix(),
  4499. // Mtime: time.Now().Unix(),
  4500. // ErrMsg: res.ErrMsg,
  4501. // Status: 1,
  4502. // PatientId: id,
  4503. // RecordTime: recordDateTime,
  4504. // Stage: 4,
  4505. // }
  4506. // service.CreateErrMsgLog(errlog)
  4507. //
  4508. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4509. // return
  4510. // }
  4511. // } else {
  4512. // adminUser := c.GetAdminUserInfo()
  4513. // errlog := &models.HisOrderError{
  4514. // UserOrgId: adminUser.CurrentOrgId,
  4515. // Ctime: time.Now().Unix(),
  4516. // Mtime: time.Now().Unix(),
  4517. // ErrMsg: res.ErrMsg,
  4518. // Status: 1,
  4519. // PatientId: id,
  4520. // RecordTime: recordDateTime,
  4521. // Stage: 4,
  4522. // }
  4523. // service.CreateErrMsgLog(errlog)
  4524. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  4525. // return
  4526. // }
  4527. //
  4528. // } else {
  4529. // var total float64
  4530. // for _, item := range prescriptions {
  4531. // if item.Type == 1 { //药品
  4532. // for _, subItem := range item.HisDoctorAdviceInfo {
  4533. // total = total + (subItem.Price * subItem.PrescribingNumber)
  4534. // }
  4535. // }
  4536. // if item.Type == 2 { //项目
  4537. // for _, subItem := range item.HisPrescriptionProject {
  4538. // total = total + (subItem.Price * float64(subItem.Count))
  4539. // }
  4540. // }
  4541. //
  4542. // for _, subItem := range item.HisAdditionalCharge {
  4543. // total = total + (subItem.Price * float64(subItem.Count))
  4544. // }
  4545. // }
  4546. //
  4547. // allTotal := fmt.Sprintf("%.2f", total)
  4548. // totals, _ := strconv.ParseFloat(allTotal, 64)
  4549. // order := &models.HisOrder{
  4550. // UserOrgId: adminUser.CurrentOrgId,
  4551. // HisPatientId: his.ID,
  4552. // PatientId: id,
  4553. // SettleAccountsDate: recordDateTime,
  4554. // Ctime: time.Now().Unix(),
  4555. // Mtime: time.Now().Unix(),
  4556. // Status: 1,
  4557. // OrderStatus: 2,
  4558. // Number: chrg_bchno,
  4559. // MedfeeSumamt: totals,
  4560. // }
  4561. // err = service.CreateOrder(order)
  4562. // if err != nil {
  4563. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4564. // return
  4565. // }
  4566. //
  4567. // var customs []*Custom
  4568. // for _, item := range prescriptions {
  4569. //
  4570. // if item.Type == 1 { //药品
  4571. // for _, subItem := range item.HisDoctorAdviceInfo {
  4572. // cus := &Custom{
  4573. // AdviceId: subItem.ID,
  4574. // ProjectId: 0,
  4575. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  4576. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  4577. // FeedetlSn: subItem.FeedetlSn,
  4578. // Price: fmt.Sprintf("%.2f", subItem.Price),
  4579. // MedListCodg: subItem.MedListCodg,
  4580. // Type: 1,
  4581. // }
  4582. // customs = append(customs, cus)
  4583. // }
  4584. // }
  4585. //
  4586. // if item.Type == 2 { //项目
  4587. // for _, subItem := range item.HisPrescriptionProject {
  4588. //
  4589. // cus := &Custom{
  4590. // AdviceId: 0,
  4591. // ProjectId: subItem.ID,
  4592. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  4593. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  4594. // FeedetlSn: subItem.FeedetlSn,
  4595. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  4596. // MedListCodg: subItem.MedListCodg,
  4597. // Type: 2,
  4598. // }
  4599. //
  4600. // customs = append(customs, cus)
  4601. // }
  4602. // }
  4603. //
  4604. // for _, item := range item.HisAdditionalCharge {
  4605. // cus := &Custom{
  4606. // ItemId: item.ID,
  4607. // AdviceId: 0,
  4608. // ProjectId: 0,
  4609. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  4610. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  4611. // FeedetlSn: item.FeedetlSn,
  4612. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  4613. // MedListCodg: item.XtHisAddtionConfig.Code,
  4614. // Type: 3,
  4615. // }
  4616. //
  4617. // customs = append(customs, cus)
  4618. // }
  4619. //
  4620. // }
  4621. //
  4622. // for _, item := range customs {
  4623. // var advice_id int64 = 0
  4624. // var project_id int64 = 0
  4625. // var item_id int64 = 0
  4626. //
  4627. // var types int64 = 0
  4628. //
  4629. // if item.Type == 1 {
  4630. // advice_id = item.AdviceId
  4631. // project_id = 0
  4632. // item_id = 0
  4633. // } else if item.Type == 2 {
  4634. // advice_id = 0
  4635. // item_id = 0
  4636. //
  4637. // project_id = item.ProjectId
  4638. // } else if item.Type == 3 {
  4639. // advice_id = 0
  4640. // item_id = item.ItemId
  4641. // project_id = 0
  4642. // }
  4643. //
  4644. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  4645. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  4646. // pric, _ := strconv.ParseFloat(item.Price, 32)
  4647. //
  4648. // info := &models.HisOrderInfo{
  4649. // OrderNumber: order.Number,
  4650. // UploadDate: time.Now().Unix(),
  4651. // AdviceId: advice_id,
  4652. // DetItemFeeSumamt: detItemFeeSumamt,
  4653. // Cnt: cut,
  4654. // Pric: pric,
  4655. // PatientId: id,
  4656. // Status: 1,
  4657. // Mtime: time.Now().Unix(),
  4658. // Ctime: time.Now().Unix(),
  4659. // UserOrgId: adminUser.CurrentOrgId,
  4660. // HisPatientId: his.ID,
  4661. // OrderId: order.ID,
  4662. // ProjectId: project_id,
  4663. // Type: types,
  4664. // ItemId: item_id,
  4665. // }
  4666. // service.CreateOrderInfo(info)
  4667. // }
  4668. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4669. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4670. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  4671. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4672. // if err == nil {
  4673. // c.ServeSuccessJSON(map[string]interface{}{
  4674. // "msg": "结算成功",
  4675. // })
  4676. // } else {
  4677. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4678. // return
  4679. // }
  4680. // }
  4681. //}
  4682. //上传明细-预结算-
  4683. func (c *HisApiController) GetPreUploadInfo() {
  4684. id, _ := c.GetInt64("id")
  4685. record_time := c.GetString("record_time")
  4686. his_patient_id, _ := c.GetInt64("his_patient_id")
  4687. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4688. admin_user_id, _ := c.GetInt64("admin_user_id")
  4689. diagnosis_id := c.GetString("diagnosis")
  4690. sick_type, _ := c.GetInt64("sick_type")
  4691. reg_type, _ := c.GetInt64("p_type")
  4692. begin_time := c.GetString("begin_time")
  4693. id_str := c.GetString("ids")
  4694. ids_arr := strings.Split(id_str, ",")
  4695. timeLayout := "2006-01-02"
  4696. loc, _ := time.LoadLocation("Local")
  4697. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4698. if err != nil {
  4699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4700. return
  4701. }
  4702. recordDateTime := theTime.Unix()
  4703. adminUser := c.GetAdminUserInfo()
  4704. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4705. var config []*models.HisXtDiagnoseConfig
  4706. for _, item := range diagnosis_ids {
  4707. id, _ := strconv.ParseInt(item, 10, 64)
  4708. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4709. config = append(config, &diagnosisConfig)
  4710. }
  4711. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  4712. sickConfig, _ := service.FindSickById(sick_type)
  4713. var prescriptions []*models.HisPrescription
  4714. var start_time int64
  4715. var end_time int64
  4716. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4717. fmt.Println(his_patient_id)
  4718. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4719. timestamp := time.Now().Unix()
  4720. tempTime := time.Unix(timestamp, 0)
  4721. timeFormat := tempTime.Format("20060102150405")
  4722. chrgBchno := rand.Intn(100000) + 10000
  4723. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4724. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4725. var patientPrescription models.HisPrescriptionInfo
  4726. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4727. if patientPrescription.ID == 0 {
  4728. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4729. }
  4730. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4731. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4732. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4733. strconv.FormatInt(his.PatientId, 10)
  4734. var res2 ResultSix
  4735. var resSix10265 ResultSix10265
  4736. var time_stamp int64
  4737. if miConfig.InsuplcAdmdvs == "421300" {
  4738. data := make(map[string]interface{})
  4739. client := &http.Client{}
  4740. data["psn_no"] = his.PsnNo
  4741. data["mdtrt_id"] = his.Number
  4742. data["doctor"] = roles.UserName
  4743. data["department"] = department.Name
  4744. data["org_name"] = miConfig.OrgName
  4745. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4746. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4747. data["fixmedins_code"] = miConfig.Code
  4748. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4749. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4750. data["secret_key"] = miConfig.SecretKey
  4751. data["sick_code"] = sickConfig.CountryCode
  4752. data["sick_name"] = sickConfig.ClassName
  4753. data["begin_time"] = begin_time
  4754. data["dept"] = strconv.FormatInt(department.ID, 10)
  4755. data["config"] = config
  4756. fmt.Println(data)
  4757. bytesData, _ := json.Marshal(data)
  4758. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  4759. resp, _ := client.Do(req)
  4760. defer resp.Body.Close()
  4761. body, ioErr := ioutil.ReadAll(resp.Body)
  4762. if ioErr != nil {
  4763. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4765. return
  4766. }
  4767. var respJSON map[string]interface{}
  4768. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4769. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4771. return
  4772. }
  4773. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4774. userJSONBytes, _ := json.Marshal(respJSON)
  4775. fmt.Println("log")
  4776. fmt.Println(string(userJSONBytes))
  4777. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4778. utils.ErrorLog("解析失败:%v", err)
  4779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4780. return
  4781. }
  4782. } else if miConfig.InsuplcAdmdvs == "320921" {
  4783. data := make(map[string]interface{})
  4784. client := &http.Client{}
  4785. data["psn_no"] = his.PsnNo
  4786. data["mdtrt_id"] = his.Number
  4787. data["doctor"] = roles.UserName
  4788. data["department"] = department.Name
  4789. data["org_name"] = miConfig.OrgName
  4790. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4791. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4792. data["fixmedins_code"] = miConfig.Code
  4793. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4794. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4795. data["secret_key"] = miConfig.SecretKey
  4796. data["sick_code"] = sickConfig.CountryCode
  4797. data["sick_name"] = sickConfig.ClassName
  4798. data["begin_time"] = begin_time
  4799. data["dept"] = strconv.FormatInt(department.ID, 10)
  4800. data["config"] = config
  4801. data["url"] = miConfig.Url
  4802. data["ak"] = miConfig.ChannelNumber
  4803. fmt.Println(data)
  4804. bytesData, _ := json.Marshal(data)
  4805. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4806. resp, _ := client.Do(req)
  4807. defer resp.Body.Close()
  4808. body, ioErr := ioutil.ReadAll(resp.Body)
  4809. if ioErr != nil {
  4810. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4812. return
  4813. }
  4814. var respJSON map[string]interface{}
  4815. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4816. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4818. return
  4819. }
  4820. fmt.Println("-------")
  4821. fmt.Println(respJSON["data"])
  4822. fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"])
  4823. fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(float64))
  4824. fmt.Println("-------")
  4825. //time_stamp = int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64))
  4826. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4827. userJSONBytes, _ := json.Marshal(respJSON)
  4828. fmt.Println("log")
  4829. fmt.Println(string(userJSONBytes))
  4830. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  4831. utils.ErrorLog("解析失败:%v", err)
  4832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4833. return
  4834. }
  4835. res2.InfRefmsgid = resSix10265.InfRefmsgid
  4836. res2.Output = resSix10265.Output
  4837. res2.ErrMsg = resSix10265.ErrMsg
  4838. res2.Cainfo = resSix10265.Cainfo
  4839. res2.WarnMsg = resSix10265.WarnMsg
  4840. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  4841. res2.Infcode = infocode
  4842. } else {
  4843. var result string
  4844. var requestLog string
  4845. if miConfig.InsuplcAdmdvs == "440781" { //
  4846. 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)
  4847. } else {
  4848. if miConfig.Code == "H15049901371" {
  4849. //赤峰地区国家医保医疗类别
  4850. //职工透析:医疗类别选特殊情况门诊990502
  4851. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4852. var med_type string
  4853. if his.Insutype == "390" {
  4854. if reg_type == 14 {
  4855. med_type = "9933"
  4856. } else if reg_type == 11 {
  4857. med_type = "11"
  4858. }
  4859. } else if his.Insutype == "310" {
  4860. if reg_type == 14 {
  4861. med_type = "990502"
  4862. } else if reg_type == 11 {
  4863. med_type = "11"
  4864. }
  4865. }
  4866. 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)
  4867. } else {
  4868. 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)
  4869. }
  4870. saveLog(result, requestLog, "2203", "上传就诊信息")
  4871. var respJSON2 map[string]interface{}
  4872. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4873. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4875. return
  4876. }
  4877. userJSONBytes2, _ := json.Marshal(respJSON2)
  4878. if miConfig.Code == "H15049901371" {
  4879. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  4880. utils.ErrorLog("解析失败:%v", err)
  4881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4882. return
  4883. }
  4884. res2.InfRefmsgid = resSix10265.InfRefmsgid
  4885. res2.Output = resSix10265.Output
  4886. res2.ErrMsg = resSix10265.ErrMsg
  4887. res2.Cainfo = resSix10265.Cainfo
  4888. res2.WarnMsg = resSix10265.WarnMsg
  4889. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  4890. res2.Infcode = infocode
  4891. } else {
  4892. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4893. utils.ErrorLog("解析失败:%v", err)
  4894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4895. return
  4896. }
  4897. }
  4898. }
  4899. }
  4900. if res2.Infcode != 0 {
  4901. adminUser := c.GetAdminUserInfo()
  4902. errlog := &models.HisOrderError{
  4903. UserOrgId: adminUser.CurrentOrgId,
  4904. Ctime: time.Now().Unix(),
  4905. Mtime: time.Now().Unix(),
  4906. ErrMsg: res2.ErrMsg,
  4907. Status: 1,
  4908. PatientId: id,
  4909. RecordTime: recordDateTime,
  4910. Stage: 3,
  4911. }
  4912. service.CreateErrMsgLog(errlog)
  4913. c.ServeSuccessJSON(map[string]interface{}{
  4914. "failed_code": -10,
  4915. "msg": res2.ErrMsg,
  4916. })
  4917. return
  4918. } else {
  4919. his.Diagnosis = diagnosis_id
  4920. his.SickType = sickConfig.ID
  4921. his.PType = fmt.Sprintf("%d", reg_type)
  4922. service.UpdateHisPatientThree(&his)
  4923. data := make(map[string]interface{})
  4924. if settle_accounts_type == 1 { //日结
  4925. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  4926. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  4927. } else {
  4928. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  4929. }
  4930. data["pre"] = prescriptions
  4931. } else { //月结
  4932. start_time_str := c.GetString("start_time")
  4933. end_time_str := c.GetString("end_time")
  4934. timeLayout := "2006-01-02"
  4935. loc, _ := time.LoadLocation("Local")
  4936. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4937. if err != nil {
  4938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4939. return
  4940. }
  4941. recordStartTime := theStartTime.Unix()
  4942. start_time = recordStartTime
  4943. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4944. if err != nil {
  4945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4946. return
  4947. }
  4948. recordEndTime := theEndTime.Unix()
  4949. end_time = recordEndTime
  4950. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  4951. data["pre"] = prescriptions
  4952. }
  4953. client := &http.Client{}
  4954. data["psn_no"] = his.PsnNo
  4955. data["mdtrt_id"] = his.Number
  4956. data["chrg_bchno"] = chrg_bchno
  4957. data["org_name"] = miConfig.OrgName
  4958. data["doctor"] = roles.UserName
  4959. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4960. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4961. data["fixmedins_code"] = miConfig.Code
  4962. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  4963. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  4964. data["dept_code"] = "15"
  4965. } else {
  4966. data["dept_code"] = department.Number
  4967. }
  4968. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4969. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4970. data["secret_key"] = miConfig.SecretKey
  4971. data["url"] = miConfig.Url
  4972. data["ak"] = miConfig.ChannelNumber
  4973. data["new_doctor_name"] = patientPrescription.Doctor
  4974. data["diag_code"] = sickConfig.CountryCode
  4975. data["time_stamp"] = time_stamp
  4976. var ids []int64
  4977. for _, item := range prescriptions {
  4978. ids = append(ids, item.ID)
  4979. }
  4980. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4981. if config.IsOpen == 1 { //对接了医保,走医保流程
  4982. var res ResultFour
  4983. var resFour10265 ResultFour10265
  4984. if miConfig.MdtrtareaAdmvs == "421300" {
  4985. bytesData, _ := json.Marshal(data)
  4986. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  4987. resp, _ := client.Do(req)
  4988. defer resp.Body.Close()
  4989. body, ioErr := ioutil.ReadAll(resp.Body)
  4990. if ioErr != nil {
  4991. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4993. return
  4994. }
  4995. var respJSON map[string]interface{}
  4996. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4997. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4999. return
  5000. }
  5001. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5002. userJSONBytes, _ := json.Marshal(respJSON)
  5003. fmt.Println("log")
  5004. fmt.Println(string(userJSONBytes))
  5005. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5006. utils.ErrorLog("解析失败:%v", err)
  5007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5008. return
  5009. }
  5010. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5011. bytesData, _ := json.Marshal(data)
  5012. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5013. resp, _ := client.Do(req)
  5014. defer resp.Body.Close()
  5015. body, ioErr := ioutil.ReadAll(resp.Body)
  5016. if ioErr != nil {
  5017. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5019. return
  5020. }
  5021. var respJSON map[string]interface{}
  5022. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5023. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5025. return
  5026. }
  5027. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5028. userJSONBytes, _ := json.Marshal(respJSON)
  5029. fmt.Println("log")
  5030. fmt.Println(string(userJSONBytes))
  5031. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5032. utils.ErrorLog("解析失败:%v", err)
  5033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5034. return
  5035. }
  5036. res.InfRefmsgid = resFour10265.InfRefmsgid
  5037. res.Output = resFour10265.Output
  5038. res.ErrMsg = resFour10265.ErrMsg
  5039. res.Cainfo = resFour10265.Cainfo
  5040. res.WarnMsg = resFour10265.WarnMsg
  5041. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5042. res.Infcode = infocode
  5043. } else {
  5044. if miConfig.Code == "H15049901371" {
  5045. 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)
  5046. var dat map[string]interface{}
  5047. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5048. fmt.Println(dat)
  5049. } else {
  5050. fmt.Println(err)
  5051. }
  5052. saveLog(result, request_log, "2204", "上传费用明细")
  5053. userJSONBytes, _ := json.Marshal(dat)
  5054. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5055. utils.ErrorLog("解析失败:%v", err)
  5056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5057. return
  5058. }
  5059. res.InfRefmsgid = resFour10265.InfRefmsgid
  5060. res.Output = resFour10265.Output
  5061. res.ErrMsg = resFour10265.ErrMsg
  5062. res.Cainfo = resFour10265.Cainfo
  5063. res.WarnMsg = resFour10265.WarnMsg
  5064. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5065. res.Infcode = infocode
  5066. } else {
  5067. 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)
  5068. var dat map[string]interface{}
  5069. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5070. fmt.Println(dat)
  5071. } else {
  5072. fmt.Println(err)
  5073. }
  5074. saveLog(result, request_log, "2204", "上传费用明细")
  5075. userJSONBytes, _ := json.Marshal(dat)
  5076. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5077. utils.ErrorLog("解析失败:%v", err)
  5078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5079. return
  5080. }
  5081. }
  5082. }
  5083. if res.Infcode == 0 {
  5084. order := &models.HisOrder{
  5085. UserOrgId: adminUser.CurrentOrgId,
  5086. HisPatientId: his.ID,
  5087. PatientId: his.PatientId,
  5088. SettleAccountsDate: recordDateTime,
  5089. Ctime: time.Now().Unix(),
  5090. Mtime: time.Now().Unix(),
  5091. Status: 1,
  5092. Number: chrg_bchno,
  5093. Infcode: res.Infcode,
  5094. WarnMsg: res.WarnMsg,
  5095. Cainfo: res.Cainfo,
  5096. ErrMsg: res.ErrMsg,
  5097. RespondTime: res.RefmsgTime,
  5098. InfRefmsgid: res.InfRefmsgid,
  5099. OrderStatus: 1,
  5100. IsMedicineInsurance: 1,
  5101. SettleType: settle_accounts_type,
  5102. SettleStartTime: start_time,
  5103. SettleEndTime: end_time,
  5104. Creator: roles.AdminUserId,
  5105. Modify: roles.AdminUserId,
  5106. PType: 2,
  5107. Diagnosis: diagnosis_id,
  5108. }
  5109. err = service.CreateOrder(order)
  5110. if err != nil {
  5111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5112. return
  5113. }
  5114. for _, item := range res.Output.Result {
  5115. temp := strings.Split(item.FeedetlSn, "-")
  5116. var advice_id int64 = 0
  5117. var project_id int64 = 0
  5118. var types int64 = 0
  5119. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5120. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5121. if temp[1] == "1" {
  5122. advice_id = id
  5123. project_id = 0
  5124. } else if temp[1] == "2" {
  5125. advice_id = 0
  5126. project_id = id
  5127. }
  5128. info := &models.HisOrderInfo{
  5129. OrderNumber: order.Number,
  5130. FeedetlSn: item.FeedetlSn,
  5131. UploadDate: time.Now().Unix(),
  5132. AdviceId: advice_id,
  5133. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5134. Cnt: item.Cnt,
  5135. Pric: float64(item.Pric),
  5136. PatientId: his.PatientId,
  5137. PricUplmtAmt: item.PricUplmtAmt,
  5138. SelfpayProp: item.SelfpayProp,
  5139. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5140. OverlmtAmt: item.OverlmtAmt,
  5141. PreselfpayAmt: item.PreselfpayAmt,
  5142. BasMednFlag: item.BasMednFlag,
  5143. MedChrgitmType: item.MedChrgitmType,
  5144. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5145. Status: 1,
  5146. Memo: item.Memo,
  5147. Mtime: time.Now().Unix(),
  5148. InscpScpAmt: item.InscpScpAmt,
  5149. DrtReimFlag: item.DrtReimFlag,
  5150. Ctime: time.Now().Unix(),
  5151. ListSpItemFlag: item.ListSpItemFlag,
  5152. ChldMedcFlag: item.ChldMedcFlag,
  5153. LmtUsedFlag: item.LmtUsedFlag,
  5154. ChrgitmLv: item.ChrgitmLv,
  5155. UserOrgId: adminUser.CurrentOrgId,
  5156. HisPatientId: his.ID,
  5157. OrderId: order.ID,
  5158. ProjectId: project_id,
  5159. Type: types,
  5160. }
  5161. service.CreateOrderInfo(info)
  5162. }
  5163. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5164. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5165. var total float64
  5166. for _, item := range prescriptions {
  5167. if item.Type == 1 { //药品
  5168. for _, subItem := range item.HisDoctorAdviceInfo {
  5169. total = total + (subItem.Price * subItem.PrescribingNumber)
  5170. }
  5171. }
  5172. if item.Type == 2 { //项目
  5173. for _, subItem := range item.HisPrescriptionProject {
  5174. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5175. total = total + (subItem.Price * cnt)
  5176. }
  5177. }
  5178. }
  5179. for _, item := range prescriptions {
  5180. for _, subItem := range item.HisAdditionalCharge {
  5181. total = total + (subItem.Price * float64(subItem.Count))
  5182. }
  5183. }
  5184. allTotal := fmt.Sprintf("%.4f", total)
  5185. if res.Infcode == 0 {
  5186. var rf []*ResultFive
  5187. json.Unmarshal([]byte(his.Iinfo), &rf)
  5188. chrg_bchno := chrg_bchno
  5189. cert_no := his.Certno
  5190. var insutypes []string
  5191. var insutype string
  5192. var is390 int = 0
  5193. var is310 int = 0
  5194. for _, item := range rf {
  5195. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5196. insutypes = append(insutypes, item.Insutype)
  5197. }
  5198. }
  5199. if len(insutypes) == 1 {
  5200. insutype = insutypes[0]
  5201. } else {
  5202. for _, i := range insutypes {
  5203. if i == "390" {
  5204. is390 = 1
  5205. }
  5206. if i == "310" {
  5207. is310 = 1
  5208. }
  5209. }
  5210. }
  5211. if is390 == 1 {
  5212. insutype = "390"
  5213. }
  5214. if is310 == 1 {
  5215. insutype = "310"
  5216. }
  5217. if len(insutypes) == 0 {
  5218. insutype = "310"
  5219. }
  5220. if len(insutypes) == 2 {
  5221. insutype = strconv.FormatInt(his.SocialType, 64)
  5222. }
  5223. //insutype = "390"
  5224. if his.IdCardType == 1 {
  5225. cert_no = his.MedicalInsuranceNumber
  5226. } else {
  5227. cert_no = his.Certno
  5228. }
  5229. var res ResultSeven
  5230. var resSeven10265 ResultSeven10265
  5231. if miConfig.MdtrtareaAdmvs == "421300" {
  5232. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5233. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5234. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5235. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5236. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5237. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5238. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  5239. resp, requestErr := http.Get(api)
  5240. if requestErr != nil {
  5241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5242. return
  5243. }
  5244. body, ioErr := ioutil.ReadAll(resp.Body)
  5245. if ioErr != nil {
  5246. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5248. return
  5249. }
  5250. var respJSON map[string]interface{}
  5251. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5252. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5254. return
  5255. }
  5256. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5257. result, _ := json.Marshal(respJSON)
  5258. fmt.Println("log")
  5259. fmt.Println(string(result))
  5260. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5261. utils.ErrorLog("解析失败:%v", err)
  5262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5263. return
  5264. }
  5265. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5266. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5267. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5268. api := "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5269. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5270. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5271. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5272. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5273. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5274. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + psn_info.VerifyNumber
  5275. resp, requestErr := http.Get(api)
  5276. if requestErr != nil {
  5277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5278. return
  5279. }
  5280. body, ioErr := ioutil.ReadAll(resp.Body)
  5281. if ioErr != nil {
  5282. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5284. return
  5285. }
  5286. var respJSON map[string]interface{}
  5287. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5288. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5290. return
  5291. }
  5292. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5293. result, _ := json.Marshal(respJSON)
  5294. fmt.Println("log")
  5295. fmt.Println(string(result))
  5296. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5297. utils.ErrorLog("解析失败:%v", err)
  5298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5299. return
  5300. }
  5301. } else {
  5302. var result string
  5303. var request_log string
  5304. if miConfig.Code == "H15049901371" {
  5305. //赤峰地区国家医保医疗类别
  5306. //职工透析:医疗类别选特殊情况门诊990502
  5307. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5308. var med_type string
  5309. if his.Insutype == "390" {
  5310. if reg_type == 14 {
  5311. med_type = "9933"
  5312. } else if reg_type == 11 {
  5313. med_type = "11"
  5314. }
  5315. } else if his.Insutype == "310" {
  5316. if reg_type == 14 {
  5317. med_type = "990502"
  5318. } else if reg_type == 11 {
  5319. med_type = "11"
  5320. }
  5321. }
  5322. 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)
  5323. } else {
  5324. 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)
  5325. }
  5326. var dat map[string]interface{}
  5327. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5328. fmt.Println(dat)
  5329. } else {
  5330. fmt.Println(err)
  5331. }
  5332. saveLog(result, request_log, "2206", "预结算")
  5333. //userJSONBytes, _ := json.Marshal(dat)
  5334. //
  5335. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5336. // utils.ErrorLog("解析失败:%v", err)
  5337. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5338. // return
  5339. //}
  5340. userJSONBytes, _ := json.Marshal(dat)
  5341. if miConfig.Code == "H15049901371" {
  5342. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5343. utils.ErrorLog("解析失败:%v", err)
  5344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5345. return
  5346. }
  5347. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5348. res.Output = resSeven10265.Output
  5349. res.ErrMsg = resSeven10265.ErrMsg
  5350. res.Cainfo = resSeven10265.Cainfo
  5351. res.WarnMsg = resSeven10265.WarnMsg
  5352. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5353. res.Infcode = infocode
  5354. } else {
  5355. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5356. utils.ErrorLog("解析失败:%v", err)
  5357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5358. return
  5359. }
  5360. }
  5361. }
  5362. if res.Infcode != 0 {
  5363. errlog := &models.HisOrderError{
  5364. UserOrgId: adminUser.CurrentOrgId,
  5365. Ctime: time.Now().Unix(),
  5366. Mtime: time.Now().Unix(),
  5367. Number: chrg_bchno,
  5368. ErrMsg: res.ErrMsg,
  5369. Status: 1,
  5370. PatientId: id,
  5371. RecordTime: recordDateTime,
  5372. Stage: 20,
  5373. }
  5374. service.CreateErrMsgLog(errlog)
  5375. c.ServeSuccessJSON(map[string]interface{}{
  5376. "failed_code": -10,
  5377. "msg": res.ErrMsg,
  5378. })
  5379. return
  5380. } else {
  5381. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5382. order.OrderStatus = 1
  5383. order.IsPre = 1
  5384. order.Status = 1
  5385. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5386. order.SetlId = res.Output.Setlinfo.SetlID
  5387. order.PsnNo = res.Output.Setlinfo.PsnNo
  5388. order.PsnName = res.Output.Setlinfo.PsnName
  5389. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5390. order.Certno = res.Output.Setlinfo.Certno
  5391. order.Gend = res.Output.Setlinfo.Gend
  5392. order.Naty = res.Output.Setlinfo.Naty
  5393. order.Age = res.Output.Setlinfo.Age
  5394. order.Insutype = res.Output.Setlinfo.Insutype
  5395. order.PsnType = res.Output.Setlinfo.PsnType
  5396. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5397. order.SetlTime = res.Output.Setlinfo.SetlTime
  5398. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5399. if res.Output.Setlinfo.MedType == "140101" {
  5400. order.MedType = "14"
  5401. } else {
  5402. order.MedType = res.Output.Setlinfo.MedType
  5403. }
  5404. if reg_type == 1112 {
  5405. order.MedType = "1112"
  5406. }
  5407. if reg_type == 1111 {
  5408. order.MedType = "1111"
  5409. }
  5410. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5411. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5412. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5413. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5414. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5415. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5416. order.HifpPay = res.Output.Setlinfo.HifpPay
  5417. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5418. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5419. order.HifesPay = res.Output.Setlinfo.HifesPay
  5420. order.HifobPay = res.Output.Setlinfo.HifobPay
  5421. order.MafPay = res.Output.Setlinfo.MafPay
  5422. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5423. order.OthPay = res.Output.Setlinfo.OthPay
  5424. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5425. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5426. order.AcctPay = res.Output.Setlinfo.AcctPay
  5427. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5428. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5429. order.Balc = res.Output.Setlinfo.Balc
  5430. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5431. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5432. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5433. order.ClrWay = res.Output.Setlinfo.ClrWay
  5434. order.Creator = order.Creator
  5435. order.Modify = roles.AdminUserId
  5436. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5437. detailStr := string(setlDetail)
  5438. order.SetlDetail = detailStr
  5439. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5440. err = service.UpDateOrder(order)
  5441. if err == nil {
  5442. c.ServeSuccessJSON(map[string]interface{}{
  5443. "msg": "预结算成功",
  5444. })
  5445. } else {
  5446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5447. return
  5448. }
  5449. }
  5450. } else {
  5451. adminUser := c.GetAdminUserInfo()
  5452. errlog := &models.HisOrderError{
  5453. UserOrgId: adminUser.CurrentOrgId,
  5454. Ctime: time.Now().Unix(),
  5455. Mtime: time.Now().Unix(),
  5456. ErrMsg: res.ErrMsg,
  5457. Status: 1,
  5458. PatientId: id,
  5459. RecordTime: recordDateTime,
  5460. Stage: 4,
  5461. }
  5462. service.CreateErrMsgLog(errlog)
  5463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5464. return
  5465. }
  5466. } else {
  5467. adminUser := c.GetAdminUserInfo()
  5468. errlog := &models.HisOrderError{
  5469. UserOrgId: adminUser.CurrentOrgId,
  5470. Ctime: time.Now().Unix(),
  5471. Mtime: time.Now().Unix(),
  5472. ErrMsg: res.ErrMsg,
  5473. Status: 1,
  5474. PatientId: id,
  5475. RecordTime: recordDateTime,
  5476. Stage: 4,
  5477. }
  5478. service.CreateErrMsgLog(errlog)
  5479. c.ServeSuccessJSON(map[string]interface{}{
  5480. "failed_code": -10,
  5481. "msg": res.ErrMsg,
  5482. })
  5483. return
  5484. }
  5485. }
  5486. }
  5487. }
  5488. //func (c *HisApiController) GetSettleInfo() {
  5489. // id, _ := c.GetInt64("id")
  5490. // order_id, _ := c.GetInt64("order_id")
  5491. //
  5492. // record_time := c.GetString("record_time")
  5493. // pay_way, _ := c.GetInt64("pay_way")
  5494. // pay_price, _ := c.GetFloat("pay_price")
  5495. // pay_card_no := c.GetString("pay_card_no")
  5496. // discount_price, _ := c.GetFloat("discount_price")
  5497. // preferential_price, _ := c.GetFloat("preferential_price")
  5498. // reality_price, _ := c.GetFloat("reality_price")
  5499. // found_price, _ := c.GetFloat("found_price")
  5500. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  5501. // private_price, _ := c.GetFloat("private_price")
  5502. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5503. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5504. //
  5505. // timeLayout := "2006-01-02"
  5506. // loc, _ := time.LoadLocation("Local")
  5507. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5508. // if err != nil {
  5509. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5510. // return
  5511. // }
  5512. // recordDateTime := theTime.Unix()
  5513. // adminUser := c.GetAdminUserInfo()
  5514. //
  5515. // var prescriptions []*models.HisPrescription
  5516. //
  5517. // data := make(map[string]interface{})
  5518. // if settle_accounts_type == 1 { //日结
  5519. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  5520. // data["pre"] = prescriptions
  5521. //
  5522. // } else { //月结
  5523. // start_time_str := c.GetString("start_time")
  5524. // end_time_str := c.GetString("end_time")
  5525. // timeLayout := "2006-01-02"
  5526. // loc, _ := time.LoadLocation("Local")
  5527. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5528. // if err != nil {
  5529. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5530. // return
  5531. // }
  5532. // recordStartTime := theStartTime.Unix()
  5533. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5534. // if err != nil {
  5535. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5536. // return
  5537. // }
  5538. // recordEndTime := theEndTime.Unix()
  5539. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  5540. // data["pre"] = prescriptions
  5541. //
  5542. // }
  5543. //
  5544. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5545. //
  5546. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5547. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5548. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5549. // strconv.FormatInt(his.PatientId, 10)
  5550. //
  5551. // order_src, _ := service.GetHisOrderByID(order_id)
  5552. //
  5553. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5554. // if config.IsOpen == 1 { //对接了医保,走医保流程
  5555. //
  5556. // var total float64
  5557. // for _, item := range prescriptions {
  5558. // if item.Type == 1 { //药品
  5559. // for _, subItem := range item.HisDoctorAdviceInfo {
  5560. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5561. // }
  5562. // }
  5563. // if item.Type == 2 { //项目
  5564. // for _, subItem := range item.HisPrescriptionProject {
  5565. // total = total + (subItem.Price * float64(subItem.Count))
  5566. // }
  5567. // }
  5568. // }
  5569. //
  5570. // for _, item := range prescriptions {
  5571. // for _, subItem := range item.HisAdditionalCharge {
  5572. // total = total + (subItem.Price * float64(subItem.Count))
  5573. // }
  5574. // }
  5575. //
  5576. // allTotal := fmt.Sprintf("%.2f", total)
  5577. // var rf []*ResultFive
  5578. // json.Unmarshal([]byte(his.Iinfo), &rf)
  5579. // psn_no := order_src.PsnNo
  5580. // mdtrt_id := order_src.MdtrtId
  5581. // chrg_bchno := order_src.Number
  5582. // cert_no := order_src.Certno
  5583. // insutype := rf[0].Insutype
  5584. //
  5585. // if his.IdCardType == 1 {
  5586. // cert_no = his.MedicalInsuranceNumber
  5587. // } else {
  5588. // cert_no = his.Certno
  5589. // }
  5590. //
  5591. // 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)
  5592. // var dat map[string]interface{}
  5593. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5594. // fmt.Println(dat)
  5595. // } else {
  5596. // fmt.Println(err)
  5597. // }
  5598. //
  5599. // userJSONBytes, _ := json.Marshal(dat)
  5600. //
  5601. //
  5602. //
  5603. // var res ResultSeven
  5604. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5605. // utils.ErrorLog("解析失败:%v", err)
  5606. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5607. // return
  5608. // }
  5609. // if res.Infcode == -1 {
  5610. // errlog := &models.HisOrderError{
  5611. // UserOrgId: adminUser.CurrentOrgId,
  5612. // Ctime: time.Now().Unix(),
  5613. // Mtime: time.Now().Unix(),
  5614. // Number: chrg_bchno,
  5615. // ErrMsg: res.ErrMsg,
  5616. // Status: 1,
  5617. // PatientId: id,
  5618. // RecordTime: recordDateTime,
  5619. // Stage: 6,
  5620. // }
  5621. // service.CreateErrMsgLog(errlog)
  5622. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5623. // return
  5624. // } else {
  5625. // order_src.OrderStatus = 2
  5626. // order_src.PayWay = pay_way
  5627. // order_src.PayPrice = pay_price
  5628. // order_src.PayCardNo = pay_card_no
  5629. // order_src.DiscountPrice = discount_price
  5630. // order_src.PreferentialPrice = preferential_price
  5631. // order_src.RealityPrice = reality_price
  5632. // order_src.FoundPrice = found_price
  5633. // order_src.MedicalInsurancePrice = medical_insurance_price
  5634. // order_src.PrivatePrice = private_price
  5635. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  5636. // order_src.SetlId = res.Output.Setlinfo.SetlID
  5637. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  5638. // order_src.PsnName = res.Output.Setlinfo.PsnName
  5639. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  5640. // order_src.Certno = res.Output.Setlinfo.Certno
  5641. // order_src.Gend = res.Output.Setlinfo.Gend
  5642. // order_src.Naty = res.Output.Setlinfo.Naty
  5643. // order_src.Age = res.Output.Setlinfo.Age
  5644. // order_src.Insutype = res.Output.Setlinfo.Insutype
  5645. // order_src.PsnType = res.Output.Setlinfo.PsnType
  5646. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5647. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  5648. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5649. // order_src.MedType = res.Output.Setlinfo.MedType
  5650. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5651. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5652. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5653. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5654. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5655. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5656. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  5657. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  5658. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5659. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  5660. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  5661. // order_src.MafPay = res.Output.Setlinfo.MafPay
  5662. // order_src.OthPay = res.Output.Setlinfo.OthPay
  5663. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5664. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5665. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  5666. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5667. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5668. // order_src.Balc = res.Output.Setlinfo.Balc
  5669. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5670. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5671. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  5672. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  5673. // order_src.Creator = order_src.Creator
  5674. // order_src.Modify = roles.ID
  5675. // order_src.RequestLog = src_resquest
  5676. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5677. // detailStr := string(setlDetail)
  5678. // order_src.SetlDetail = detailStr
  5679. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5680. // err = service.UpDateOrder(order_src)
  5681. //
  5682. // if err == nil {
  5683. // c.ServeSuccessJSON(map[string]interface{}{
  5684. // "msg": "结算成功",
  5685. // })
  5686. // } else {
  5687. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5688. // return
  5689. // }
  5690. // }
  5691. // }
  5692. //}
  5693. //退款
  5694. func (c *HisApiController) Refund() {
  5695. order_id, _ := c.GetInt64("order_id")
  5696. admin_user_id, _ := c.GetInt64("admin_user_id")
  5697. adminUser := c.GetAdminUserInfo()
  5698. var order models.HisOrder
  5699. order, _ = service.GetHisOrderByID(order_id)
  5700. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5701. if order.ID == 0 {
  5702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5703. return
  5704. }
  5705. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  5706. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5707. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5708. if config.IsOpen == 1 { //对接了医保,走医保流程
  5709. var res ResultSixteen
  5710. var resSixteen10265 ResultSixteen10265
  5711. var src_resquest string
  5712. var result string
  5713. if miConfig.MdtrtareaAdmvs == "421300" {
  5714. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  5715. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5716. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5717. resp3, requestErr3 := http.Get(api3)
  5718. if requestErr3 != nil {
  5719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5720. return
  5721. }
  5722. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5723. if ioErr3 != nil {
  5724. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5726. return
  5727. }
  5728. var respJSON3 map[string]interface{}
  5729. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5730. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5732. return
  5733. }
  5734. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5735. userJSONBytes3, _ := json.Marshal(respJSON3)
  5736. fmt.Println("log")
  5737. fmt.Println(string(userJSONBytes3))
  5738. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  5739. utils.ErrorLog("解析失败:%v", err)
  5740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5741. return
  5742. }
  5743. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5744. api3 := "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  5745. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5746. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  5747. resp3, requestErr3 := http.Get(api3)
  5748. if requestErr3 != nil {
  5749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5750. return
  5751. }
  5752. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5753. if ioErr3 != nil {
  5754. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5756. return
  5757. }
  5758. var respJSON3 map[string]interface{}
  5759. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5760. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5762. return
  5763. }
  5764. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5765. userJSONBytes3, _ := json.Marshal(respJSON3)
  5766. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  5767. utils.ErrorLog("解析失败:%v", err)
  5768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5769. return
  5770. }
  5771. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  5772. res.Output = resSixteen10265.Output
  5773. res.ErrMsg = resSixteen10265.ErrMsg
  5774. res.Cainfo = resSixteen10265.Cainfo
  5775. res.WarnMsg = resSixteen10265.WarnMsg
  5776. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  5777. res.Infcode = infocode
  5778. } else {
  5779. if miConfig.Code == "H15049901371" {
  5780. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  5781. var dat map[string]interface{}
  5782. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5783. fmt.Println(dat)
  5784. } else {
  5785. fmt.Println(err)
  5786. }
  5787. saveLog(result, src_resquest, "2208", "退费")
  5788. userJSONBytes, _ := json.Marshal(dat)
  5789. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  5790. utils.ErrorLog("解析失败:%v", err)
  5791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5792. return
  5793. }
  5794. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  5795. res.Output = resSixteen10265.Output
  5796. res.ErrMsg = resSixteen10265.ErrMsg
  5797. res.Cainfo = resSixteen10265.Cainfo
  5798. res.WarnMsg = resSixteen10265.WarnMsg
  5799. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  5800. res.Infcode = infocode
  5801. } else {
  5802. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  5803. var dat map[string]interface{}
  5804. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5805. fmt.Println(dat)
  5806. } else {
  5807. fmt.Println(err)
  5808. }
  5809. saveLog(result, src_resquest, "2208", "退费")
  5810. userJSONBytes, _ := json.Marshal(dat)
  5811. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5812. utils.ErrorLog("解析失败:%v", err)
  5813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5814. return
  5815. }
  5816. }
  5817. }
  5818. if res.Infcode == 0 {
  5819. var res2 ResultSix
  5820. var resSix10265 ResultSix10265
  5821. if miConfig.MdtrtareaAdmvs == "421300" {
  5822. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  5823. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5824. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5825. resp3, requestErr3 := http.Get(api3)
  5826. if requestErr3 != nil {
  5827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5828. return
  5829. }
  5830. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5831. if ioErr3 != nil {
  5832. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5834. return
  5835. }
  5836. var respJSON3 map[string]interface{}
  5837. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5838. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5840. return
  5841. }
  5842. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5843. userJSONBytes3, _ := json.Marshal(respJSON3)
  5844. fmt.Println("log")
  5845. fmt.Println(string(userJSONBytes3))
  5846. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  5847. utils.ErrorLog("解析失败:%v", err)
  5848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5849. return
  5850. }
  5851. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5852. api3 := "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  5853. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5854. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  5855. resp3, requestErr3 := http.Get(api3)
  5856. if requestErr3 != nil {
  5857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5858. return
  5859. }
  5860. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5861. if ioErr3 != nil {
  5862. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5864. return
  5865. }
  5866. var respJSON3 map[string]interface{}
  5867. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5868. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5870. return
  5871. }
  5872. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5873. userJSONBytes3, _ := json.Marshal(respJSON3)
  5874. fmt.Println("log")
  5875. fmt.Println(string(userJSONBytes3))
  5876. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  5877. utils.ErrorLog("解析失败:%v", err)
  5878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5879. return
  5880. }
  5881. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5882. res2.Output = resSix10265.Output
  5883. res2.ErrMsg = resSix10265.ErrMsg
  5884. res2.Cainfo = resSix10265.Cainfo
  5885. res2.WarnMsg = resSix10265.WarnMsg
  5886. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5887. res2.Infcode = infocode
  5888. } else {
  5889. if miConfig.Code == "H15049901371" {
  5890. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  5891. var dat map[string]interface{}
  5892. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5893. fmt.Println(dat)
  5894. } else {
  5895. fmt.Println(err)
  5896. }
  5897. saveLog(result2, src_request, "2205", "撤销明细")
  5898. userJSONBytes, _ := json.Marshal(dat)
  5899. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  5900. utils.ErrorLog("解析失败:%v", err)
  5901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5902. return
  5903. }
  5904. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5905. res2.Output = resSix10265.Output
  5906. res2.ErrMsg = resSix10265.ErrMsg
  5907. res2.Cainfo = resSix10265.Cainfo
  5908. res2.WarnMsg = resSix10265.WarnMsg
  5909. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5910. res2.Infcode = infocode
  5911. } else {
  5912. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  5913. var dat map[string]interface{}
  5914. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5915. fmt.Println(dat)
  5916. } else {
  5917. fmt.Println(err)
  5918. }
  5919. saveLog(result2, src_request, "2205", "撤销明细")
  5920. userJSONBytes, _ := json.Marshal(dat)
  5921. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5922. utils.ErrorLog("解析失败:%v", err)
  5923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5924. return
  5925. }
  5926. }
  5927. }
  5928. if res2.Infcode == 0 {
  5929. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  5930. if err == nil {
  5931. c.ServeSuccessJSON(map[string]interface{}{
  5932. "msg": "退费成功",
  5933. })
  5934. } else {
  5935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5936. return
  5937. }
  5938. } else {
  5939. c.ServeSuccessJSON(map[string]interface{}{
  5940. "code": -10,
  5941. "msg": res2.ErrMsg,
  5942. })
  5943. }
  5944. } else {
  5945. c.ServeSuccessJSON(map[string]interface{}{
  5946. "code": -10,
  5947. "msg": res.ErrMsg,
  5948. })
  5949. }
  5950. }
  5951. }
  5952. func (c *HisApiController) RefundNumber() {
  5953. record_time := c.GetString("record_time")
  5954. //patient_id, _ := c.GetInt64("patient_id")
  5955. admin_user_id, _ := c.GetInt64("admin_user_id")
  5956. his_patient_id, _ := c.GetInt64("id")
  5957. timeLayout := "2006-01-02"
  5958. loc, _ := time.LoadLocation("Local")
  5959. adminUser := c.GetAdminUserInfo()
  5960. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5961. fmt.Println(err)
  5962. if err != nil {
  5963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5964. return
  5965. }
  5966. recordDateTime := theTime.Unix()
  5967. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5968. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  5969. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5970. //order, _ := service.GetHisOrderByID(order_id)
  5971. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5972. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5973. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5974. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  5975. if count > 0 {
  5976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  5977. return
  5978. }
  5979. if config.IsOpen == 1 { //对接了医保,走医保流程
  5980. var res2 ResultSix
  5981. var resSix10265 ResultSix10265
  5982. if miConfig.MdtrtareaAdmvs == "421300" {
  5983. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  5984. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5985. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5986. resp3, requestErr3 := http.Get(api3)
  5987. if requestErr3 != nil {
  5988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5989. return
  5990. }
  5991. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5992. if ioErr3 != nil {
  5993. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5995. return
  5996. }
  5997. var respJSON3 map[string]interface{}
  5998. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5999. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6001. return
  6002. }
  6003. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6004. userJSONBytes3, _ := json.Marshal(respJSON3)
  6005. fmt.Println("log")
  6006. fmt.Println(string(userJSONBytes3))
  6007. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6008. utils.ErrorLog("解析失败:%v", err)
  6009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6010. return
  6011. }
  6012. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6013. api3 := "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  6014. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6015. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  6016. resp3, requestErr3 := http.Get(api3)
  6017. if requestErr3 != nil {
  6018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6019. return
  6020. }
  6021. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6022. if ioErr3 != nil {
  6023. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6025. return
  6026. }
  6027. var respJSON3 map[string]interface{}
  6028. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6029. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6031. return
  6032. }
  6033. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6034. userJSONBytes3, _ := json.Marshal(respJSON3)
  6035. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6036. utils.ErrorLog("解析失败:%v", err)
  6037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6038. return
  6039. }
  6040. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6041. res2.Output = resSix10265.Output
  6042. res2.ErrMsg = resSix10265.ErrMsg
  6043. res2.Cainfo = resSix10265.Cainfo
  6044. res2.WarnMsg = resSix10265.WarnMsg
  6045. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6046. res2.Infcode = infocode
  6047. } else {
  6048. var api3 string
  6049. if miConfig.Code == "H15049901371" {
  6050. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  6051. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6052. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6053. } else {
  6054. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  6055. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6056. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6057. }
  6058. resp3, requestErr3 := http.Get(api3)
  6059. if requestErr3 != nil {
  6060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6061. return
  6062. }
  6063. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6064. if ioErr3 != nil {
  6065. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6067. return
  6068. }
  6069. var respJSON3 map[string]interface{}
  6070. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6071. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6073. return
  6074. }
  6075. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6076. userJSONBytes3, _ := json.Marshal(respJSON3)
  6077. if miConfig.Code == "H15049901371" {
  6078. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6079. utils.ErrorLog("解析失败:%v", err)
  6080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6081. return
  6082. }
  6083. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6084. res2.Output = resSix10265.Output
  6085. res2.ErrMsg = resSix10265.ErrMsg
  6086. res2.Cainfo = resSix10265.Cainfo
  6087. res2.WarnMsg = resSix10265.WarnMsg
  6088. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6089. res2.Infcode = infocode
  6090. } else {
  6091. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6092. utils.ErrorLog("解析失败:%v", err)
  6093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6094. return
  6095. }
  6096. }
  6097. }
  6098. if res2.Infcode == 0 {
  6099. if err == nil {
  6100. c.ServeSuccessJSON(map[string]interface{}{
  6101. "msg": "退号成功",
  6102. })
  6103. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  6104. } else {
  6105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6106. return
  6107. }
  6108. } else {
  6109. c.ServeSuccessJSON(map[string]interface{}{
  6110. "code": -10,
  6111. "msg": res2.ErrMsg,
  6112. })
  6113. }
  6114. } else {
  6115. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  6116. //if err == nil {
  6117. // c.ServeSuccessJSON(map[string]interface{}{
  6118. // "msg": "退费成功",
  6119. // })
  6120. //} else {
  6121. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6122. // return
  6123. //}
  6124. }
  6125. }
  6126. func (c *HisApiController) RefundDetail() {
  6127. order_id, _ := c.GetInt64("order_id")
  6128. //admin_user_id, _ := c.GetInt64("admin_user_id")
  6129. //his_patient_id, _ := c.GetInt64("his_patient_id")
  6130. number := c.GetString("number")
  6131. record_time := c.GetString("record_time")
  6132. patient_id, _ := c.GetInt64("patient_id")
  6133. timeLayout := "2006-01-02"
  6134. loc, _ := time.LoadLocation("Local")
  6135. adminUser := c.GetAdminUserInfo()
  6136. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6137. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6138. fmt.Println(err)
  6139. if err != nil {
  6140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6141. return
  6142. }
  6143. recordDateTime := theTime.Unix()
  6144. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6145. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6146. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6147. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6148. var order models.HisOrder
  6149. order, _ = service.GetHisOrderByID(order_id)
  6150. if order.ID == 0 {
  6151. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  6152. }
  6153. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6154. if config.IsOpen == 1 { //对接了医保,走医保流程
  6155. var res2 ResultSix
  6156. if miConfig.MdtrtareaAdmvs == "421300" {
  6157. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  6158. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6159. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6160. resp3, requestErr3 := http.Get(api3)
  6161. if requestErr3 != nil {
  6162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6163. return
  6164. }
  6165. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6166. if ioErr3 != nil {
  6167. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6169. return
  6170. }
  6171. var respJSON3 map[string]interface{}
  6172. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6173. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6175. return
  6176. }
  6177. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6178. userJSONBytes3, _ := json.Marshal(respJSON3)
  6179. fmt.Println("log")
  6180. fmt.Println(string(userJSONBytes3))
  6181. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6182. utils.ErrorLog("解析失败:%v", err)
  6183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6184. return
  6185. }
  6186. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6187. if err == nil {
  6188. c.ServeSuccessJSON(map[string]interface{}{
  6189. "msg": "撤销明细成功",
  6190. })
  6191. return
  6192. } else {
  6193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6194. return
  6195. }
  6196. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6197. var resSix10265 ResultSix10265
  6198. api3 := "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6199. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6200. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  6201. resp3, requestErr3 := http.Get(api3)
  6202. if requestErr3 != nil {
  6203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6204. return
  6205. }
  6206. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6207. if ioErr3 != nil {
  6208. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6210. return
  6211. }
  6212. var respJSON3 map[string]interface{}
  6213. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6214. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6216. return
  6217. }
  6218. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6219. userJSONBytes3, _ := json.Marshal(respJSON3)
  6220. fmt.Println("log")
  6221. fmt.Println(string(userJSONBytes3))
  6222. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6223. utils.ErrorLog("解析失败:%v", err)
  6224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6225. return
  6226. }
  6227. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6228. res2.Output = resSix10265.Output
  6229. res2.ErrMsg = resSix10265.ErrMsg
  6230. res2.Cainfo = resSix10265.Cainfo
  6231. res2.WarnMsg = resSix10265.WarnMsg
  6232. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6233. res2.Infcode = infocode
  6234. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6235. if err == nil {
  6236. c.ServeSuccessJSON(map[string]interface{}{
  6237. "msg": "撤销明细成功",
  6238. })
  6239. return
  6240. } else {
  6241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6242. return
  6243. }
  6244. } else {
  6245. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  6246. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6247. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6248. resp2, requestErr2 := http.Get(api2)
  6249. if requestErr2 != nil {
  6250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6251. return
  6252. }
  6253. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6254. if ioErr2 != nil {
  6255. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6257. return
  6258. }
  6259. var respJSON2 map[string]interface{}
  6260. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  6261. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6263. return
  6264. }
  6265. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6266. if err == nil {
  6267. c.ServeSuccessJSON(map[string]interface{}{
  6268. "msg": "撤销明细成功",
  6269. })
  6270. return
  6271. } else {
  6272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6273. return
  6274. }
  6275. }
  6276. } else {
  6277. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6278. if err == nil {
  6279. c.ServeSuccessJSON(map[string]interface{}{
  6280. "msg": "退费成功",
  6281. })
  6282. } else {
  6283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6284. return
  6285. }
  6286. }
  6287. }
  6288. //对账
  6289. func (c *HisApiController) GetCheckAccount() {
  6290. start_time := c.GetString("start_time")
  6291. end_time := c.GetString("end_time")
  6292. insutype := c.GetString("insutype")
  6293. clr_type := c.GetString("clr_type")
  6294. clr_org := c.GetString("clr_optins")
  6295. admin_user_id, _ := c.GetInt64("admin_user_id")
  6296. adminUser := c.GetAdminUserInfo()
  6297. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6298. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6299. if len(clr_org) == 0 {
  6300. clr_org = miConfig.MdtrtareaAdmvs
  6301. }
  6302. timeLayout := "2006-01-02"
  6303. loc, _ := time.LoadLocation("Local")
  6304. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  6305. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  6306. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_org, clr_type)
  6307. fixmedins_setl_cnt := int64(len(orders))
  6308. var medfee_sumamt float64
  6309. var acct_pay float64
  6310. var fund_pay_sumamt float64
  6311. for _, item := range orders {
  6312. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  6313. acct_pay = acct_pay + item.AcctPay
  6314. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  6315. }
  6316. var user_name string
  6317. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6318. if role.ID == 0 {
  6319. user_name = "xxx"
  6320. } else {
  6321. user_name = role.UserName
  6322. }
  6323. if config.IsOpen == 1 {
  6324. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  6325. "insutype=" + insutype +
  6326. "&clr_type=" + clr_type +
  6327. "&setl_optins=" + clr_org +
  6328. "&stmt_begndate=" + start_time +
  6329. "&stm_enddate=" + end_time +
  6330. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  6331. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  6332. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  6333. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  6334. "&fixmedins_code=" + miConfig.Code +
  6335. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  6336. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6337. "&secret_key=" + miConfig.SecretKey +
  6338. "&org_name=" + miConfig.OrgName +
  6339. "&doctor=" + user_name
  6340. fmt.Println(api)
  6341. resp, requestErr := http.Get(api)
  6342. if requestErr != nil {
  6343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6344. return
  6345. }
  6346. body, ioErr := ioutil.ReadAll(resp.Body)
  6347. fmt.Println(body)
  6348. if ioErr != nil {
  6349. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6351. return
  6352. }
  6353. var respJSON map[string]interface{}
  6354. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6355. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6357. return
  6358. }
  6359. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6360. userJSONBytes, _ := json.Marshal(respJSON)
  6361. var res ResultEight
  6362. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6363. utils.ErrorLog("解析失败:%v", err)
  6364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6365. return
  6366. }
  6367. if res.Infcode == 0 {
  6368. if res.Output.Stmtinfo.StmtRslt == "0" {
  6369. micc := &models.MedicalInsuranceCostCompare{
  6370. StartTime: startime.Unix(),
  6371. EndTime: endtime.Unix(),
  6372. Insutype: insutype,
  6373. CheckType: 1,
  6374. Num: fixmedins_setl_cnt,
  6375. Mtime: time.Now().Unix(),
  6376. Status: 1,
  6377. UserOrgId: adminUser.CurrentOrgId,
  6378. CostTotal: medfee_sumamt,
  6379. FuncTotal: fund_pay_sumamt,
  6380. PsnPay: acct_pay,
  6381. Creator: admin_user_id,
  6382. Ctime: time.Now().Unix(),
  6383. }
  6384. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  6385. if err == nil {
  6386. c.ServeSuccessJSON(map[string]interface{}{
  6387. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  6388. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  6389. })
  6390. } else {
  6391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6392. }
  6393. } else {
  6394. c.ServeSuccessJSON(map[string]interface{}{
  6395. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  6396. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  6397. })
  6398. }
  6399. } else {
  6400. c.ServeSuccessJSON(map[string]interface{}{
  6401. "code": -10,
  6402. "msg": res.ErrMsg,
  6403. })
  6404. }
  6405. }
  6406. }
  6407. func (c *HisApiController) Check310() {
  6408. adminUser := c.GetAdminUserInfo()
  6409. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6410. var user_name string
  6411. user_name = "高慧裕"
  6412. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  6413. "insutype=" + "310" +
  6414. "&clr_type=" + "11" +
  6415. "&setl_optins=" + "441202" +
  6416. "&stmt_begndate=" + "2022-02-01" +
  6417. "&stm_enddate=" + "2022-02-28" +
  6418. "&medfee_sumamt=" + "155812.88" +
  6419. "&fund_pay_sumamt=" + "151026.15" +
  6420. "&acct_pay=" + "0" +
  6421. "&fixmedins_setl_cnt=" + "73" +
  6422. "&fixmedins_code=" + miConfig.Code +
  6423. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  6424. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6425. "&secret_key=" + miConfig.SecretKey +
  6426. "&org_name=" + miConfig.OrgName +
  6427. "&doctor=" + user_name
  6428. fmt.Println(api)
  6429. resp, requestErr := http.Get(api)
  6430. if requestErr != nil {
  6431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6432. return
  6433. }
  6434. body, ioErr := ioutil.ReadAll(resp.Body)
  6435. fmt.Println(body)
  6436. if ioErr != nil {
  6437. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6439. return
  6440. }
  6441. var respJSON map[string]interface{}
  6442. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6443. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6445. return
  6446. }
  6447. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6448. userJSONBytes, _ := json.Marshal(respJSON)
  6449. var res ResultEight
  6450. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6451. utils.ErrorLog("解析失败:%v", err)
  6452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6453. return
  6454. }
  6455. }
  6456. func (c *HisApiController) Check390() {
  6457. adminUser := c.GetAdminUserInfo()
  6458. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6459. var user_name string
  6460. user_name = "高慧裕"
  6461. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  6462. "insutype=" + "390" +
  6463. "&clr_type=" + "11" +
  6464. "&setl_optins=" + "441202" +
  6465. "&stmt_begndate=" + "2022-02-01" +
  6466. "&stm_enddate=" + "2022-02-28" +
  6467. "&medfee_sumamt=" + "933920.08" +
  6468. "&fund_pay_sumamt=" + "887153.34" +
  6469. "&acct_pay=" + "0" +
  6470. "&fixmedins_setl_cnt=" + "396" +
  6471. "&fixmedins_code=" + miConfig.Code +
  6472. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  6473. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6474. "&secret_key=" + miConfig.SecretKey +
  6475. "&org_name=" + miConfig.OrgName +
  6476. "&doctor=" + user_name
  6477. fmt.Println(api)
  6478. resp, requestErr := http.Get(api)
  6479. if requestErr != nil {
  6480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6481. return
  6482. }
  6483. body, ioErr := ioutil.ReadAll(resp.Body)
  6484. fmt.Println(body)
  6485. if ioErr != nil {
  6486. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6488. return
  6489. }
  6490. var respJSON map[string]interface{}
  6491. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6492. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6494. return
  6495. }
  6496. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6497. userJSONBytes, _ := json.Marshal(respJSON)
  6498. var res ResultEight
  6499. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6500. utils.ErrorLog("解析失败:%v", err)
  6501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6502. return
  6503. }
  6504. }
  6505. //对账明细
  6506. func (c *HisApiController) GetCheckDetailAccount() {
  6507. start_time := c.GetString("start_time")
  6508. end_time := c.GetString("end_time")
  6509. admin_user_id, _ := c.GetInt64("admin_user_id")
  6510. adminUser := c.GetAdminUserInfo()
  6511. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6512. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6513. timeLayout := "2006-01-02"
  6514. loc, _ := time.LoadLocation("Local")
  6515. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  6516. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  6517. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  6518. Mkdir(miConfig.OrgName)
  6519. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  6520. file_name := file + ".txt"
  6521. zip_name := file + ".zip"
  6522. zip_path := miConfig.OrgName + "/" + zip_name
  6523. file_path := miConfig.OrgName + "/" + file_name
  6524. decimal.DivisionPrecision = 2
  6525. var medfee_sumamt float64
  6526. var psn_cash_pay float64
  6527. var fund_pay_sumamt float64
  6528. fixmedins_setl_cnt := int64(len(orders))
  6529. for _, item := range orders {
  6530. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  6531. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  6532. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  6533. }
  6534. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  6535. defer f.Close()
  6536. if err != nil {
  6537. fmt.Println(err.Error())
  6538. } else {
  6539. for _, item := range orders {
  6540. var refd_setl_flag string
  6541. if item.OrderStatus == 2 {
  6542. refd_setl_flag = "0"
  6543. var str string
  6544. str = item.SetlId + " " +
  6545. item.MdtrtId + " " +
  6546. item.PsnNo + " " +
  6547. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  6548. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  6549. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  6550. _, err = f.Write([]byte(str))
  6551. }
  6552. if item.OrderStatus == 3 {
  6553. var str string
  6554. str = item.SetlId + " " +
  6555. item.MdtrtId + " " +
  6556. item.PsnNo + " " +
  6557. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  6558. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  6559. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  6560. _, err = f.Write([]byte(str))
  6561. var str2 string
  6562. str2 = item.SetlId + " " +
  6563. item.MdtrtId + " " +
  6564. item.PsnNo + " " +
  6565. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  6566. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  6567. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  6568. _, err = f.Write([]byte(str2))
  6569. }
  6570. }
  6571. }
  6572. Zip(file_path, zip_path)
  6573. fmt.Println(ReadFile(zip_path))
  6574. fmt.Println(string(ReadFile(zip_path)))
  6575. if config.IsOpen == 1 {
  6576. var user_name string
  6577. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6578. if role.ID == 0 {
  6579. user_name = "管理员"
  6580. } else {
  6581. user_name = role.UserName
  6582. }
  6583. baseParams := models.BaseParams{
  6584. SecretKey: miConfig.SecretKey,
  6585. FixmedinsCode: miConfig.Code,
  6586. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  6587. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  6588. OrgName: miConfig.OrgName,
  6589. Doctor: user_name,
  6590. }
  6591. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  6592. var dat map[string]interface{}
  6593. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6594. fmt.Println(dat)
  6595. } else {
  6596. fmt.Println(err)
  6597. }
  6598. userJSONBytes, _ := json.Marshal(dat)
  6599. var res ResultNine
  6600. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6601. utils.ErrorLog("解析失败:%v", err)
  6602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6603. return
  6604. }
  6605. if res.Infcode == 0 {
  6606. fileNo := res.Output.FileQuryNo
  6607. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  6608. "file_qury_no=" + fileNo +
  6609. "&setl_optins=" + "定点医保中心" +
  6610. "&stmt_begndate=" + start_time +
  6611. "&stm_enddate=" + end_time +
  6612. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  6613. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  6614. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  6615. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  6616. "&fixmedins_code=" + miConfig.Code +
  6617. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  6618. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6619. "&secret_key=" + miConfig.SecretKey +
  6620. "&org_name=" + miConfig.OrgName +
  6621. "&doctor=" + user_name
  6622. resp, requestErr := http.Get(api)
  6623. if requestErr != nil {
  6624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6625. return
  6626. }
  6627. body, ioErr := ioutil.ReadAll(resp.Body)
  6628. if ioErr != nil {
  6629. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6631. return
  6632. }
  6633. var respJSON map[string]interface{}
  6634. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6635. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6637. return
  6638. }
  6639. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6640. userJSONBytes, _ := json.Marshal(respJSON)
  6641. var res ResultTen
  6642. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6643. utils.ErrorLog("解析失败:%v", err)
  6644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6645. return
  6646. }
  6647. if res.Infcode == 0 {
  6648. service.Gdyb9102(baseParams, zip_name, fileNo)
  6649. micc := &models.MedicalInsuranceCostCompare{
  6650. StartTime: startime.Unix(),
  6651. EndTime: endtime.Unix(),
  6652. Insutype: "0",
  6653. CheckType: 2,
  6654. Num: fixmedins_setl_cnt,
  6655. Mtime: time.Now().Unix(),
  6656. Status: 1,
  6657. UserOrgId: adminUser.CurrentOrgId,
  6658. CostTotal: medfee_sumamt,
  6659. FuncTotal: fund_pay_sumamt,
  6660. PsnPay: psn_cash_pay,
  6661. Creator: admin_user_id,
  6662. Ctime: time.Now().Unix(),
  6663. }
  6664. service.CreateMedicalInsuranceCostCompareRecord(micc)
  6665. c.ServeSuccessJSON(map[string]interface{}{
  6666. "msg": "明细对账成功",
  6667. })
  6668. }
  6669. } else {
  6670. }
  6671. }
  6672. }
  6673. type CustomOrderInfo struct {
  6674. Name string
  6675. Spec string
  6676. Unit string
  6677. Count float64
  6678. Price float64
  6679. Total float64
  6680. }
  6681. func (c *HisApiController) GetSettleAccounts() {
  6682. //id, _ := c.GetInt64("id")
  6683. //record_time := c.GetString("record_time")
  6684. order_id, _ := c.GetInt64("order_id")
  6685. admin_user_id, _ := c.GetInt64("admin_user_id")
  6686. //timeLayout := "2006-01-02"
  6687. //loc, _ := time.LoadLocation("Local")
  6688. //
  6689. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6690. //if err != nil {
  6691. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6692. // return
  6693. //}
  6694. //recordDateTime := theTime.Unix()
  6695. adminUser := c.GetAdminUserInfo()
  6696. order, _ := service.GetHisOrderByID(order_id)
  6697. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6698. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  6699. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  6700. orderInfos = append(orderInfos, orderInfos_two...)
  6701. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  6702. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  6703. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  6704. //var config []*models.HisXtDiagnoseConfig
  6705. var name string
  6706. for _, item := range diagnosis_ids {
  6707. id, _ := strconv.ParseInt(item, 10, 64)
  6708. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6709. if len(name) == 0 {
  6710. name = diagnosisConfig.ClassName
  6711. } else {
  6712. name = name + "," + diagnosisConfig.ClassName
  6713. }
  6714. }
  6715. var bedCostTotal float64 = 0 //床位总费
  6716. var bedCostSelfTotal float64 = 0 //床位自费
  6717. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  6718. var operationCostTotal float64 = 0 //手术费
  6719. var operationCostSelfTotal float64 = 0 //手术费
  6720. var operationCostPartSelfTotal float64 = 0 //手术费
  6721. var otherCostTotal float64 = 0 //其他费用
  6722. var otherCostSelfTotal float64 = 0 //其他费用
  6723. var otherCostPartSelfTotal float64 = 0 //其他费用
  6724. var materialCostTotal float64 = 0 //材料费
  6725. var materialCostSelfTotal float64 = 0 //材料费
  6726. var materialCostPartSelfTotal float64 = 0 //材料费
  6727. var westernMedicineCostTotal float64 = 0 //西药费
  6728. var westernMedicineCostSelfTotal float64 = 0 //西药费
  6729. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  6730. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  6731. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  6732. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  6733. var checkCostTotal float64 = 0 //检查费
  6734. var checkCostSelfTotal float64 = 0 //检查费
  6735. var checkCostPartSelfTotal float64 = 0 //检查费
  6736. var laboratoryCostTotal float64 = 0 //化验费
  6737. var laboratoryCostSelfTotal float64 = 0 //化验费
  6738. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  6739. var treatCostTotal float64 = 0 //治疗费用
  6740. var treatCostSelfTotal float64 = 0 //治疗费用
  6741. var treatCostPartSelfTotal float64 = 0 //治疗费用
  6742. decimal.DivisionPrecision = 2
  6743. for _, item := range orderInfos {
  6744. if item.MedChrgitmType == "01" { //床位费
  6745. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6746. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6747. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6748. }
  6749. if item.MedChrgitmType == "03" { //检查费
  6750. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6751. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6752. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6753. }
  6754. if item.MedChrgitmType == "04" { //化验费
  6755. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6756. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6757. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6758. }
  6759. if item.MedChrgitmType == "05" { //治疗费
  6760. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6761. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6762. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6763. }
  6764. if item.MedChrgitmType == "06" { //手术费
  6765. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6766. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6767. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6768. }
  6769. if item.MedChrgitmType == "08" { //材料费
  6770. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6771. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6772. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6773. }
  6774. if item.MedChrgitmType == "09" { //西药费
  6775. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6776. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6777. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6778. }
  6779. if item.MedChrgitmType == "11" { //中成费
  6780. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6781. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6782. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6783. }
  6784. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  6785. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6786. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6787. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6788. }
  6789. }
  6790. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6791. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6792. var user_name string
  6793. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6794. if role.ID == 0 {
  6795. user_name = "管理员"
  6796. } else {
  6797. user_name = role.UserName
  6798. }
  6799. baseParams := models.BaseParams{
  6800. SecretKey: miConfig.SecretKey,
  6801. FixmedinsCode: miConfig.Code,
  6802. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  6803. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  6804. OrgName: miConfig.OrgName,
  6805. Doctor: user_name,
  6806. }
  6807. businessParams := models.BusinessParams{
  6808. PsnNo: order.PsnNo,
  6809. MdtrtId: order.MdtrtId,
  6810. SetlId: order.SetlId,
  6811. }
  6812. var res ResultEleven
  6813. var resEleven10265 ResultEleven10265
  6814. if config.IsOpen == 1 {
  6815. if miConfig.MdtrtareaAdmvs == "421300" {
  6816. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  6817. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  6818. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6819. resp, requestErr := http.Get(api)
  6820. if requestErr != nil {
  6821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6822. return
  6823. }
  6824. body, ioErr := ioutil.ReadAll(resp.Body)
  6825. if ioErr != nil {
  6826. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6828. return
  6829. }
  6830. var respJSON map[string]interface{}
  6831. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6832. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6834. return
  6835. }
  6836. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6837. result, _ := json.Marshal(respJSON)
  6838. fmt.Println("log")
  6839. fmt.Println(string(result))
  6840. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6841. utils.ErrorLog("解析失败:%v", err)
  6842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6843. return
  6844. }
  6845. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6846. api := "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  6847. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  6848. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  6849. resp, requestErr := http.Get(api)
  6850. if requestErr != nil {
  6851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6852. return
  6853. }
  6854. body, ioErr := ioutil.ReadAll(resp.Body)
  6855. if ioErr != nil {
  6856. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6858. return
  6859. }
  6860. var respJSON map[string]interface{}
  6861. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6862. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6864. return
  6865. }
  6866. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6867. result, _ := json.Marshal(respJSON)
  6868. fmt.Println("log")
  6869. fmt.Println(string(result))
  6870. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  6871. utils.ErrorLog("解析失败:%v", err)
  6872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6873. return
  6874. }
  6875. res.InfRefmsgid = resEleven10265.InfRefmsgid
  6876. res.Output = resEleven10265.Output
  6877. res.ErrMsg = resEleven10265.ErrMsg
  6878. res.Cainfo = resEleven10265.Cainfo
  6879. res.WarnMsg = resEleven10265.WarnMsg
  6880. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  6881. res.Infcode = infocode
  6882. } else {
  6883. result2 := service.Gdyb5204(baseParams, businessParams)
  6884. saveLog(result2, "", "5204", "查询")
  6885. result := service.Gdyb5203(baseParams, businessParams)
  6886. var dat map[string]interface{}
  6887. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6888. fmt.Println(dat)
  6889. } else {
  6890. fmt.Println(err)
  6891. }
  6892. userJSONBytes, _ := json.Marshal(dat)
  6893. if miConfig.Code == "H15049901371" {
  6894. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  6895. utils.ErrorLog("解析失败:%v", err)
  6896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6897. return
  6898. }
  6899. res.InfRefmsgid = resEleven10265.InfRefmsgid
  6900. res.Output = resEleven10265.Output
  6901. res.ErrMsg = resEleven10265.ErrMsg
  6902. res.Cainfo = resEleven10265.Cainfo
  6903. res.WarnMsg = resEleven10265.WarnMsg
  6904. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  6905. res.Infcode = infocode
  6906. } else {
  6907. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6908. utils.ErrorLog("解析失败:%v", err)
  6909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6910. return
  6911. }
  6912. }
  6913. }
  6914. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6915. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  6916. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  6917. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6918. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6919. var doctor_name string
  6920. if roles.ID == 0 {
  6921. doctor_name = "管理员"
  6922. } else {
  6923. doctor_name = roles.UserName
  6924. }
  6925. yiliao_leibie := ""
  6926. switch order.MedType {
  6927. case "11":
  6928. yiliao_leibie = "普通门诊"
  6929. break
  6930. case "12":
  6931. yiliao_leibie = "门诊挂号"
  6932. break
  6933. case "13":
  6934. yiliao_leibie = "急诊"
  6935. break
  6936. case "14":
  6937. yiliao_leibie = "门诊特殊病"
  6938. break
  6939. case "15":
  6940. yiliao_leibie = "门诊统筹"
  6941. break
  6942. case "16":
  6943. yiliao_leibie = "门诊慢性病"
  6944. break
  6945. case "21":
  6946. yiliao_leibie = "普通住院"
  6947. break
  6948. }
  6949. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6950. if res.Infcode == 0 {
  6951. c.ServeSuccessJSON(map[string]interface{}{
  6952. "diagnosis": name,
  6953. "order_infos": orderInfos,
  6954. "number": order.MdtrtId,
  6955. "date": order.SettleAccountsDate,
  6956. "charge_admin": charge_admin,
  6957. "printor_admin": printor_admin,
  6958. "info": res.Output.Setlinfo,
  6959. "bedCostTotal": bedCostTotal,
  6960. "bedCostSelfTotal": bedCostSelfTotal,
  6961. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  6962. "operationCostTotal": operationCostTotal,
  6963. "operationCostSelfTotal": operationCostSelfTotal,
  6964. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  6965. "otherCostTotal": otherCostTotal,
  6966. "otherCostSelfTotal": otherCostSelfTotal,
  6967. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  6968. "materialCostTotal": materialCostTotal,
  6969. "materialCostSelfTotal": materialCostSelfTotal,
  6970. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  6971. "westernMedicineCostTotal": westernMedicineCostTotal,
  6972. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  6973. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  6974. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  6975. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  6976. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  6977. "checkCostTotal": checkCostTotal,
  6978. "checkCostSelfTotal": checkCostSelfTotal,
  6979. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  6980. "laboratoryCostTotal": laboratoryCostTotal,
  6981. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  6982. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  6983. "treatCostTotal": treatCostTotal,
  6984. "treatCostSelfTotal": treatCostSelfTotal,
  6985. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  6986. "doctor_code": adminRole_two.DoctorCode,
  6987. "doctor_name": doctor_name,
  6988. "health_card_no": order.PsnNo,
  6989. "department": departments.Name,
  6990. "yiliao_leibie": yiliao_leibie,
  6991. "after_money": order.AccountPrice,
  6992. "patient": patient,
  6993. "org_name": miConfig.OrgName,
  6994. "org_code": miConfig.Code,
  6995. "order_number": order.Number,
  6996. //"check_order_info": cus_slice,
  6997. })
  6998. }
  6999. }
  7000. }
  7001. func (c *HisApiController) CheckTreatment() {
  7002. patient_id, _ := c.GetInt64("patient_id")
  7003. id_card_no := c.GetString("id_card_no")
  7004. insutype := c.GetString("insutype")
  7005. med_type := c.GetString("med_type")
  7006. admin_user_id, _ := c.GetInt64("admin_user_id")
  7007. adminUser := c.GetAdminUserInfo()
  7008. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  7009. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7010. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7011. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7012. if miConfig.MdtrtareaAdmvs == "421300" {
  7013. var res ResultTwo
  7014. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  7015. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7016. "&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)
  7017. resp, requestErr := http.Get(api)
  7018. if requestErr != nil {
  7019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7020. return
  7021. }
  7022. body, ioErr := ioutil.ReadAll(resp.Body)
  7023. if ioErr != nil {
  7024. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7026. return
  7027. }
  7028. var respJSON map[string]interface{}
  7029. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7030. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7032. return
  7033. }
  7034. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7035. result, _ := json.Marshal(respJSON)
  7036. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7037. utils.ErrorLog("解析失败:%v", err)
  7038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7039. return
  7040. }
  7041. if res.Infcode == 0 {
  7042. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  7043. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7044. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  7045. resp, requestErr := http.Get(api)
  7046. if requestErr != nil {
  7047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7048. return
  7049. }
  7050. body, ioErr := ioutil.ReadAll(resp.Body)
  7051. if ioErr != nil {
  7052. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7054. return
  7055. }
  7056. var respJSON map[string]interface{}
  7057. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7058. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7060. return
  7061. }
  7062. var res Result2001
  7063. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7064. result2, _ := json.Marshal(respJSON)
  7065. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  7066. utils.ErrorLog("解析失败:%v", err)
  7067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7068. return
  7069. }
  7070. if res.Infcode == 0 {
  7071. c.ServeSuccessJSON(map[string]interface{}{
  7072. "msg": res.Output.Trtinfo,
  7073. })
  7074. }
  7075. } else {
  7076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7077. return
  7078. }
  7079. } else {
  7080. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  7081. var dat map[string]interface{}
  7082. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7083. fmt.Println(dat)
  7084. } else {
  7085. fmt.Println(err)
  7086. }
  7087. userJSONBytes, _ := json.Marshal(dat)
  7088. var res ResultTwo
  7089. var res10265 ResultTwo10265
  7090. if miConfig.Code == "H15049901371" {
  7091. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7092. utils.ErrorLog("解析失败:%v", err)
  7093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7094. return
  7095. }
  7096. res.ErrMsg = res10265.ErrMsg
  7097. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7098. res.Infcode = infocode
  7099. res.Output = res10265.Output
  7100. res.InfRefmsgid = res10265.InfRefmsgid
  7101. } else {
  7102. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7103. utils.ErrorLog("解析失败:%v", err)
  7104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7105. return
  7106. }
  7107. }
  7108. var user_name string
  7109. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  7110. if role.ID == 0 {
  7111. user_name = "xxx"
  7112. } else {
  7113. user_name = role.UserName
  7114. }
  7115. baseParams := models.BaseParams{
  7116. SecretKey: miConfig.SecretKey,
  7117. FixmedinsCode: miConfig.Code,
  7118. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7119. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7120. OrgName: miConfig.OrgName,
  7121. Doctor: user_name,
  7122. }
  7123. if config.IsOpen == 1 {
  7124. if miConfig.Code == "H15049901371" {
  7125. if med_type == "14" {
  7126. if insutype == "390" {
  7127. med_type = "9933"
  7128. } else if insutype == "310" {
  7129. med_type = "990502"
  7130. }
  7131. } else if med_type == "11" {
  7132. med_type = "11"
  7133. }
  7134. }
  7135. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  7136. var dat map[string]interface{}
  7137. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7138. fmt.Println(dat)
  7139. } else {
  7140. fmt.Println(err)
  7141. }
  7142. var res Result2001
  7143. var res10265 Result2001Org10265
  7144. if miConfig.Code == "H15049901371" {
  7145. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7146. utils.ErrorLog("解析失败:%v", err)
  7147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7148. return
  7149. }
  7150. res.ErrMsg = res10265.ErrMsg
  7151. res.Output = res10265.Output
  7152. res.InfRefmsgid = res10265.InfRefmsgid
  7153. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7154. res.Infcode = infocode
  7155. } else {
  7156. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7157. utils.ErrorLog("解析失败:%v", err)
  7158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7159. return
  7160. }
  7161. }
  7162. if res.Infcode == 0 {
  7163. c.ServeSuccessJSON(map[string]interface{}{
  7164. "msg": res.Output.Trtinfo,
  7165. })
  7166. }
  7167. }
  7168. }
  7169. }
  7170. //func (c *HisApiController) PutRecord() {
  7171. // id, _ := c.GetInt64("id")
  7172. // record_time := c.GetString("record_time")
  7173. // timeLayout := "2006-01-02"
  7174. // loc, _ := time.LoadLocation("Local")
  7175. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7176. // if err != nil {
  7177. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7178. // return
  7179. // }
  7180. // recordDateTime := theTime.Unix()
  7181. //
  7182. // adminInfo := c.GetAdminUserInfo()
  7183. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  7184. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7185. //
  7186. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  7187. //
  7188. // fmt.Println(miConfig.SecretKey)
  7189. //
  7190. // if patient == nil {
  7191. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  7192. // return
  7193. // }
  7194. // if len(patient.IdCardNo) == 0 {
  7195. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  7196. // return
  7197. // }
  7198. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  7199. // if config.IsOpen == 1 {
  7200. // 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
  7201. // resp, requestErr := http.Get(api)
  7202. // if requestErr != nil {
  7203. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7204. // return
  7205. // }
  7206. // defer resp.Body.Close()
  7207. // body, ioErr := ioutil.ReadAll(resp.Body)
  7208. // if ioErr != nil {
  7209. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7210. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7211. // return
  7212. // }
  7213. // var respJSON map[string]interface{}
  7214. //
  7215. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7216. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7217. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7218. // return
  7219. // }
  7220. //
  7221. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7222. // userJSONBytes, _ := json.Marshal(userJSON)
  7223. // var res ResultTwo
  7224. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7225. // utils.ErrorLog("解析失败:%v", err)
  7226. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7227. // return
  7228. // }
  7229. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7230. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7231. // infoStr := string(Iinfos)
  7232. // idetinfoStr := string(Idetinfos)
  7233. //
  7234. // if res.Infcode == 0 {
  7235. // his := models.VMHisPatient{
  7236. // Status: 1,
  7237. // Ctime: time.Now().Unix(),
  7238. // Mtime: time.Now().Unix(),
  7239. // PsnNo: res.Output.Baseinfo.PsnNo,
  7240. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  7241. // Certno: res.Output.Baseinfo.Certno,
  7242. // PsnName: res.Output.Baseinfo.PsnName,
  7243. // Gend: res.Output.Baseinfo.Gend,
  7244. // Naty: res.Output.Baseinfo.Naty,
  7245. // Brdy: res.Output.Baseinfo.Brdy,
  7246. // Age: res.Output.Baseinfo.Age,
  7247. // Iinfo: infoStr,
  7248. // Idetinfo: idetinfoStr,
  7249. // PatientId: patient.ID,
  7250. // RecordDate: theTime.Unix(),
  7251. // UserOrgId: adminInfo.CurrentOrgId,
  7252. // AdminUserId: adminInfo.AdminUser.Id,
  7253. // IsReturn: 1,
  7254. // }
  7255. //
  7256. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  7257. // //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")
  7258. // //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")
  7259. //
  7260. // //var dat map[string]interface{}
  7261. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7262. // // fmt.Println(dat)
  7263. // //} else {
  7264. // // fmt.Println(err)
  7265. // //}
  7266. //
  7267. // var dat2 map[string]interface{}
  7268. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  7269. // fmt.Println(dat2)
  7270. // } else {
  7271. // fmt.Println(err)
  7272. // }
  7273. //
  7274. // } else {
  7275. // adminUser := c.GetAdminUserInfo()
  7276. // errlog := &models.HisOrderError{
  7277. // UserOrgId: adminUser.CurrentOrgId,
  7278. // Ctime: time.Now().Unix(),
  7279. // Mtime: time.Now().Unix(),
  7280. // ErrMsg: res.ErrMsg,
  7281. // Status: 1,
  7282. // PatientId: id,
  7283. // RecordTime: recordDateTime,
  7284. // Stage: 1,
  7285. // }
  7286. // service.CreateErrMsgLog(errlog)
  7287. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  7288. // return
  7289. // }
  7290. // }
  7291. //
  7292. //}
  7293. //func (c *HisApiController) GetUploadDiag() {
  7294. // id, _ := c.GetInt64("id")
  7295. // record_time := c.GetString("record_time")
  7296. //
  7297. // diagnosis_id, _ := c.GetInt64("diagnosis")
  7298. // sick_type, _ := c.GetInt64("sick_type")
  7299. // reg_type, _ := c.GetInt64("reg_type")
  7300. //
  7301. // timeLayout := "2006-01-02"
  7302. // loc, _ := time.LoadLocation("Local")
  7303. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7304. // if err != nil {
  7305. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7306. // return
  7307. // }
  7308. //
  7309. // var patientPrescription models.HisPrescriptionInfo
  7310. // recordDateTime := theTime.Unix()
  7311. // adminInfo := c.GetAdminUserInfo()
  7312. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7313. //
  7314. // if patientPrescription.ID == 0 {
  7315. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7316. // }
  7317. //
  7318. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  7319. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  7320. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7321. // sickConfig, _ := service.FindSickById(sick_type)
  7322. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7323. //
  7324. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  7325. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  7326. // "&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 +
  7327. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  7328. // resp2, requestErr2 := http.Get(api2)
  7329. // if requestErr2 != nil {
  7330. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7331. // return
  7332. // }
  7333. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7334. // if ioErr2 != nil {
  7335. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7336. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7337. // return
  7338. // }
  7339. // var respJSON2 map[string]interface{}
  7340. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  7341. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7342. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7343. // return
  7344. // }
  7345. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7346. // userJSONBytes2, _ := json.Marshal(respJSON2)
  7347. //
  7348. // var res2 ResultSix
  7349. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7350. // utils.ErrorLog("解析失败:%v", err)
  7351. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7352. // return
  7353. // }
  7354. // if res2.Infcode != 0 {
  7355. // adminUser := c.GetAdminUserInfo()
  7356. // errlog := &models.HisOrderError{
  7357. // UserOrgId: adminUser.CurrentOrgId,
  7358. // Ctime: time.Now().Unix(),
  7359. // Mtime: time.Now().Unix(),
  7360. // ErrMsg: res2.ErrMsg,
  7361. // Status: 1,
  7362. // PatientId: id,
  7363. // RecordTime: recordDateTime,
  7364. // Stage: 3,
  7365. // }
  7366. // service.CreateErrMsgLog(errlog)
  7367. //
  7368. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  7369. // return
  7370. // }
  7371. //
  7372. // c.ServeSuccessJSON(map[string]interface{}{
  7373. // "msg": "上传成功",
  7374. // })
  7375. //
  7376. //}
  7377. type QueryResult struct {
  7378. ID int64
  7379. Name string
  7380. Code string
  7381. List_type_code string
  7382. }
  7383. func (c *HisApiController) GetCheckCode() {
  7384. ids_str := c.GetString("ids")
  7385. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  7386. ids_arr := strings.Split(ids_str, ",")
  7387. var queryResult []QueryResult
  7388. ids := make([]int64, 0)
  7389. for _, item := range ids_arr {
  7390. id, _ := strconv.ParseInt(item, 10, 64)
  7391. ids = append(ids, id)
  7392. }
  7393. if record_type == 1 {
  7394. drugs, _ := service.GetBatchDrugList(ids)
  7395. for _, item := range drugs {
  7396. result := QueryResult{
  7397. ID: item.ID,
  7398. Name: item.DrugName,
  7399. Code: item.MedicalInsuranceNumber,
  7400. List_type_code: "101",
  7401. }
  7402. queryResult = append(queryResult, result)
  7403. }
  7404. } else if record_type == 2 {
  7405. goods, _ := service.GetBatchGoodInformationList(ids)
  7406. for _, item := range goods {
  7407. result := QueryResult{
  7408. ID: item.ID,
  7409. Name: item.GoodName,
  7410. Code: item.MedicalInsuranceNumber,
  7411. List_type_code: "301",
  7412. }
  7413. queryResult = append(queryResult, result)
  7414. }
  7415. } else if record_type == 3 {
  7416. projects, _ := service.GetBathchMyPorjecgList(ids)
  7417. for _, item := range projects {
  7418. result := QueryResult{
  7419. ID: item.ID,
  7420. Name: item.ProjectName,
  7421. Code: item.MedicalCode,
  7422. List_type_code: "201",
  7423. }
  7424. queryResult = append(queryResult, result)
  7425. }
  7426. }
  7427. admin_user_id, _ := c.GetInt64("admin_user_id")
  7428. adminUser := c.GetAdminUserInfo()
  7429. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7430. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7431. var user_name string
  7432. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7433. if role.ID == 0 {
  7434. user_name = "xxx"
  7435. } else {
  7436. user_name = role.UserName
  7437. }
  7438. baseParams := &models.BaseParams{
  7439. SecretKey: miConfig.SecretKey,
  7440. FixmedinsCode: miConfig.Code,
  7441. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7442. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7443. OrgName: miConfig.OrgName,
  7444. Doctor: user_name,
  7445. }
  7446. if config.IsOpen == 1 {
  7447. for _, item := range queryResult {
  7448. var result string
  7449. if record_type == 1 {
  7450. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  7451. } else if record_type == 2 {
  7452. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  7453. } else if record_type == 3 {
  7454. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  7455. }
  7456. var dat map[string]interface{}
  7457. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7458. fmt.Println(dat)
  7459. } else {
  7460. fmt.Println(err)
  7461. }
  7462. userJSONBytes, _ := json.Marshal(dat)
  7463. var res ResultSix
  7464. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7465. utils.ErrorLog("解析失败:%v", err)
  7466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7467. return
  7468. }
  7469. if res.Infcode == 0 {
  7470. if record_type == 1 {
  7471. service.UpdateBaseDrugById(item.ID)
  7472. } else if record_type == 2 {
  7473. service.UpdateGoodInformaitonByDetail(item.ID)
  7474. } else if record_type == 3 {
  7475. service.UpdateProjectById(item.ID)
  7476. }
  7477. c.ServeSuccessJSON(map[string]interface{}{
  7478. "failed_code": 0,
  7479. "msg": "目录对照成功",
  7480. })
  7481. } else {
  7482. c.ServeSuccessJSON(map[string]interface{}{
  7483. "failed_code": -10,
  7484. "msg": res.ErrMsg,
  7485. })
  7486. }
  7487. }
  7488. }
  7489. }
  7490. func (c *HisApiController) UnCheckCode() {
  7491. ids_str := c.GetString("ids")
  7492. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  7493. admin_user_id, _ := c.GetInt64("admin_user_id")
  7494. ids_arr := strings.Split(ids_str, ",")
  7495. var queryResult []QueryResult
  7496. ids := make([]int64, 0)
  7497. for _, item := range ids_arr {
  7498. id, _ := strconv.ParseInt(item, 10, 64)
  7499. ids = append(ids, id)
  7500. }
  7501. if record_type == 1 {
  7502. drugs, _ := service.GetBatchDrugList(ids)
  7503. for _, item := range drugs {
  7504. result := QueryResult{
  7505. ID: item.ID,
  7506. Name: item.DrugName,
  7507. Code: item.MedicalInsuranceNumber,
  7508. List_type_code: "101",
  7509. }
  7510. queryResult = append(queryResult, result)
  7511. }
  7512. } else if record_type == 2 {
  7513. goods, _ := service.GetBatchGoodInformationList(ids)
  7514. for _, item := range goods {
  7515. result := QueryResult{
  7516. ID: item.ID,
  7517. Name: item.GoodName,
  7518. Code: item.MedicalInsuranceNumber,
  7519. List_type_code: "301",
  7520. }
  7521. queryResult = append(queryResult, result)
  7522. }
  7523. } else if record_type == 3 {
  7524. projects, _ := service.GetBathchMyPorjecgList(ids)
  7525. for _, item := range projects {
  7526. result := QueryResult{
  7527. ID: item.ID,
  7528. Name: item.ProjectName,
  7529. Code: item.MedicalCode,
  7530. List_type_code: "201",
  7531. }
  7532. queryResult = append(queryResult, result)
  7533. }
  7534. }
  7535. adminUser := c.GetAdminUserInfo()
  7536. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7537. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7538. var user_name string
  7539. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7540. if role.ID == 0 {
  7541. user_name = "xxx"
  7542. } else {
  7543. user_name = role.UserName
  7544. }
  7545. baseParams := &models.BaseParams{
  7546. SecretKey: miConfig.SecretKey,
  7547. FixmedinsCode: miConfig.Code,
  7548. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7549. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7550. OrgName: miConfig.OrgName,
  7551. Doctor: user_name,
  7552. }
  7553. if config.IsOpen == 1 {
  7554. for _, item := range queryResult {
  7555. var result string
  7556. if record_type == 1 {
  7557. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  7558. } else if record_type == 2 {
  7559. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  7560. } else if record_type == 3 {
  7561. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  7562. }
  7563. var dat2 map[string]interface{}
  7564. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  7565. fmt.Println(dat2)
  7566. } else {
  7567. fmt.Println(err)
  7568. }
  7569. userJSONBytes, _ := json.Marshal(dat2)
  7570. var res ResultSix
  7571. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7572. utils.ErrorLog("解析失败:%v", err)
  7573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7574. return
  7575. }
  7576. if res.Infcode == 0 {
  7577. if record_type == 1 {
  7578. service.UpdateDrugByIdDetail(item.ID)
  7579. } else if record_type == 2 {
  7580. service.UpdateGoodInfoById(item.ID)
  7581. } else if record_type == 3 {
  7582. service.UpdateMyProjectById(item.ID)
  7583. }
  7584. c.ServeSuccessJSON(map[string]interface{}{
  7585. "failed_code": 0,
  7586. "msg": "撤销目录对照成功",
  7587. })
  7588. } else {
  7589. c.ServeSuccessJSON(map[string]interface{}{
  7590. "failed_code": -10,
  7591. "msg": res.ErrMsg,
  7592. })
  7593. }
  7594. }
  7595. }
  7596. }
  7597. func (c *HisApiController) GetPatientInfo() {
  7598. id_card_no := c.GetString("id_card_no")
  7599. admin_user_id, _ := c.GetInt64("admin_user_id")
  7600. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  7601. if patient.ID == 0 {
  7602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  7603. return
  7604. }
  7605. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7606. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7607. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  7608. if config.IsOpen == 1 {
  7609. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  7610. var dat map[string]interface{}
  7611. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7612. fmt.Println(dat)
  7613. } else {
  7614. fmt.Println(err)
  7615. }
  7616. userJSONBytes, _ := json.Marshal(dat)
  7617. var res ResultTwo
  7618. var res10265 ResultTwo10265
  7619. if miConfig.Code == "H15049901371" {
  7620. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7621. utils.ErrorLog("解析失败:%v", err)
  7622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7623. return
  7624. }
  7625. res.ErrMsg = res10265.ErrMsg
  7626. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7627. res.Infcode = infocode
  7628. res.Output = res10265.Output
  7629. res.InfRefmsgid = res10265.InfRefmsgid
  7630. } else {
  7631. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7632. utils.ErrorLog("解析失败:%v", err)
  7633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7634. return
  7635. }
  7636. }
  7637. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7638. // utils.ErrorLog("解析失败:%v", err)
  7639. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7640. // return
  7641. //}
  7642. if res.Infcode != 0 {
  7643. c.ServeSuccessJSON(map[string]interface{}{
  7644. "failed_code": -10,
  7645. "msg": res.ErrMsg,
  7646. })
  7647. } else {
  7648. c.ServeSuccessJSON(map[string]interface{}{
  7649. "failed_code": 0,
  7650. "info": res,
  7651. })
  7652. }
  7653. }
  7654. }
  7655. func (c *HisApiController) PsnPutOnRecord() {
  7656. record_type, _ := c.GetInt64("type")
  7657. patient_id, _ := c.GetInt64("patient_id")
  7658. admin_user_id, _ := c.GetInt64("admin_user_id")
  7659. start_time := c.GetString("start_time")
  7660. end_time := c.GetString("end_time")
  7661. adminUser := c.GetAdminUserInfo()
  7662. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7663. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7664. var patients []*models.Patients
  7665. if record_type == 1 { //全部备案
  7666. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  7667. patients = append(patients, patient...)
  7668. } else { //单个备案
  7669. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  7670. patients = append(patients, patient)
  7671. }
  7672. var user_name string
  7673. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7674. if role.ID == 0 {
  7675. user_name = "xxx"
  7676. } else {
  7677. user_name = role.UserName
  7678. }
  7679. if config.IsOpen == 1 {
  7680. for _, item := range patients {
  7681. 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
  7682. resp, requestErr := http.Get(api)
  7683. if requestErr != nil {
  7684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7685. return
  7686. }
  7687. defer resp.Body.Close()
  7688. body, ioErr := ioutil.ReadAll(resp.Body)
  7689. if ioErr != nil {
  7690. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7692. return
  7693. }
  7694. var respJSON map[string]interface{}
  7695. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7696. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7698. return
  7699. }
  7700. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7701. userJSONBytes, _ := json.Marshal(userJSON)
  7702. var res ResultTwo
  7703. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7704. utils.ErrorLog("解析失败:%v", err)
  7705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7706. return
  7707. }
  7708. if res.Infcode == 0 {
  7709. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  7710. var dat map[string]interface{}
  7711. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7712. fmt.Println(dat)
  7713. } else {
  7714. fmt.Println(err)
  7715. }
  7716. userJSONBytes, _ := json.Marshal(dat)
  7717. var res2 ResultThirteen
  7718. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7719. utils.ErrorLog("解析失败:%v", err)
  7720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7721. return
  7722. }
  7723. if res2.Infcode == 0 {
  7724. psnResult := &models.GdybPsnRecord{
  7725. UserOrgId: adminUser.CurrentOrgId,
  7726. PatientId: item.ID,
  7727. PsnNo: res.Output.Baseinfo.PsnNo,
  7728. Ctime: time.Now().Unix(),
  7729. Mtime: time.Now().Unix(),
  7730. Status: 1,
  7731. IsCancel: 1,
  7732. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  7733. }
  7734. service.CreatePsnRecord(psnResult)
  7735. } else {
  7736. c.ServeSuccessJSON(map[string]interface{}{
  7737. "failed_code": -10,
  7738. "msg": res2.ErrMsg,
  7739. })
  7740. return
  7741. }
  7742. }
  7743. }
  7744. }
  7745. }
  7746. func (c *HisApiController) PsnUnPutOnRecord() {
  7747. id, _ := c.GetInt64("id")
  7748. //record_type, _ := c.GetInt64("type")
  7749. admin_user_id, _ := c.GetInt64("admin_user_id")
  7750. adminUser := c.GetAdminUserInfo()
  7751. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7752. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7753. var user_name string
  7754. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7755. if role.ID == 0 {
  7756. user_name = "xxx"
  7757. } else {
  7758. user_name = role.UserName
  7759. }
  7760. psn_record, _ := service.GetPsnRecordById(id)
  7761. if psn_record.ID == 0 {
  7762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  7763. return
  7764. }
  7765. if config.IsOpen == 1 {
  7766. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  7767. var dat map[string]interface{}
  7768. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7769. fmt.Println(dat)
  7770. } else {
  7771. fmt.Println(err)
  7772. }
  7773. userJSONBytes, _ := json.Marshal(dat)
  7774. var res ResultFourteen
  7775. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7776. utils.ErrorLog("解析失败:%v", err)
  7777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7778. return
  7779. }
  7780. if res.Infcode == 0 {
  7781. psn_record.IsCancel = 2
  7782. service.CreatePsnRecord(&psn_record)
  7783. } else {
  7784. c.ServeSuccessJSON(map[string]interface{}{
  7785. "failed_code": -10,
  7786. "msg": res.ErrMsg,
  7787. })
  7788. return
  7789. }
  7790. }
  7791. }
  7792. func (c *HisApiController) PsnPutNCDSOnRecord() {
  7793. patient_id, _ := c.GetInt64("patient_id")
  7794. insutype_two := c.GetString("insutype")
  7795. psn_no := c.GetString("psn_no")
  7796. doctor_id, _ := c.GetInt64("doctor_id")
  7797. sick_id, _ := c.GetInt64("sick_id")
  7798. department_id, _ := c.GetInt64("department_id")
  7799. start_time := c.GetString("start_time")
  7800. end_time := c.GetString("end_time")
  7801. check_time := c.GetString("check_time")
  7802. adminUser := c.GetAdminUserInfo()
  7803. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  7804. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7805. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7806. sick, _ := service.FindSickById(sick_id)
  7807. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  7808. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  7809. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  7810. var res ResultTwo
  7811. var res10265 ResultTwo10265
  7812. if miConfig.Code == "H15049901371" {
  7813. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7814. utils.ErrorLog("解析失败:%v", err)
  7815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7816. return
  7817. }
  7818. res.ErrMsg = res10265.ErrMsg
  7819. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7820. res.Infcode = infocode
  7821. res.Output = res10265.Output
  7822. res.InfRefmsgid = res10265.InfRefmsgid
  7823. } else {
  7824. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7825. utils.ErrorLog("解析失败:%v", err)
  7826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7827. return
  7828. }
  7829. }
  7830. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7831. infoStr := string(Iinfos)
  7832. var rf []*ResultFive
  7833. json.Unmarshal([]byte(infoStr), &rf)
  7834. var insuplc_admdvs string
  7835. var insutype string
  7836. var is390 int = 0
  7837. var is310 int = 0
  7838. var insutypes []*ResultFive
  7839. for _, item := range rf {
  7840. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7841. insutypes = append(insutypes, item)
  7842. }
  7843. }
  7844. if len(insutypes) == 1 {
  7845. insutype = insutypes[0].Insutype
  7846. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7847. } else {
  7848. for _, i := range insutypes {
  7849. if i.Insutype == "390" {
  7850. is390 = 1
  7851. }
  7852. if i.Insutype == "310" {
  7853. is310 = 1
  7854. }
  7855. }
  7856. }
  7857. if is390 == 1 {
  7858. insutype = "390"
  7859. }
  7860. if is310 == 1 {
  7861. insutype = "310"
  7862. }
  7863. if len(insutypes) == 2 {
  7864. insutype = insutype_two
  7865. }
  7866. if len(insutypes) == 0 {
  7867. insutype = "310"
  7868. }
  7869. insutype = insutype_two
  7870. fmt.Println(insutype)
  7871. for _, item := range rf {
  7872. fmt.Println(item.Insutype)
  7873. fmt.Println(insutype)
  7874. if item.Insutype == insutype {
  7875. fmt.Println(item.Insutype)
  7876. fmt.Println(insutype)
  7877. insuplc_admdvs = item.InsuplcAdmdvs
  7878. }
  7879. }
  7880. fmt.Println(insuplc_admdvs)
  7881. if config.IsOpen == 1 {
  7882. 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)
  7883. var dat map[string]interface{}
  7884. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7885. fmt.Println(dat)
  7886. } else {
  7887. fmt.Println(err)
  7888. }
  7889. userJSONBytes, _ := json.Marshal(dat)
  7890. var res2 ResultThirteen
  7891. var res10265 ResultThirteen10265
  7892. if miConfig.Code == "H15049901371" {
  7893. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7894. utils.ErrorLog("解析失败:%v", err)
  7895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7896. return
  7897. }
  7898. res2.ErrMsg = res10265.ErrMsg
  7899. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7900. res2.Infcode = infocode
  7901. res2.Output = res10265.Output
  7902. res2.InfRefmsgid = res10265.InfRefmsgid
  7903. } else {
  7904. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7905. utils.ErrorLog("解析失败:%v", err)
  7906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7907. return
  7908. }
  7909. }
  7910. if res2.Infcode == 0 {
  7911. psnResult := &models.GdybPsnNcdsRecord{
  7912. UserOrgId: adminUser.CurrentOrgId,
  7913. PatientId: patient.ID,
  7914. PsnNo: psn_no,
  7915. DoctorId: doctor.AdminUserId,
  7916. DepartmentId: department_id,
  7917. SickType: sick_id,
  7918. Insutype: insutype,
  7919. Ctime: time.Now().Unix(),
  7920. Mtime: time.Now().Unix(),
  7921. Status: 1,
  7922. IsCancel: 1,
  7923. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  7924. }
  7925. service.CreatePsnNCDSRecord(psnResult)
  7926. c.ServeSuccessJSON(map[string]interface{}{
  7927. "failed_code": 0,
  7928. "msg": "备案成功",
  7929. "result": psnResult,
  7930. })
  7931. } else {
  7932. c.ServeSuccessJSON(map[string]interface{}{
  7933. "failed_code": -10,
  7934. "msg": res2.ErrMsg,
  7935. })
  7936. return
  7937. }
  7938. }
  7939. }
  7940. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  7941. id, _ := c.GetInt64("id")
  7942. admin_user_id, _ := c.GetInt64("admin_user_id")
  7943. adminUser := c.GetAdminUserInfo()
  7944. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7945. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7946. //config, _ := service.Ge(adminUser.CurrentOrgId)
  7947. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  7948. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7949. //var user_name string
  7950. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7951. //if role.ID == 0 {
  7952. // user_name = "xxx"
  7953. //} else {
  7954. // user_name = role.UserName
  7955. //}
  7956. psn_record, _ := service.GetPsnNCDSRecordById(id)
  7957. if psn_record.ID == 0 {
  7958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  7959. return
  7960. }
  7961. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  7962. var res ResultTwo
  7963. var res10265 ResultTwo10265
  7964. if miConfig.Code == "H15049901371" {
  7965. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7966. utils.ErrorLog("解析失败:%v", err)
  7967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7968. return
  7969. }
  7970. res.ErrMsg = res10265.ErrMsg
  7971. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7972. res.Infcode = infocode
  7973. res.Output = res10265.Output
  7974. res.InfRefmsgid = res10265.InfRefmsgid
  7975. } else {
  7976. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7977. utils.ErrorLog("解析失败:%v", err)
  7978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7979. return
  7980. }
  7981. }
  7982. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7983. infoStr := string(Iinfos)
  7984. var rf []*ResultFive
  7985. json.Unmarshal([]byte(infoStr), &rf)
  7986. var insuplc_admdvs string
  7987. var insutype string
  7988. var is390 int = 0
  7989. var is310 int = 0
  7990. var insutypes []*ResultFive
  7991. for _, item := range rf {
  7992. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7993. insutypes = append(insutypes, item)
  7994. }
  7995. }
  7996. if len(insutypes) == 1 {
  7997. insutype = insutypes[0].Insutype
  7998. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7999. } else {
  8000. for _, i := range insutypes {
  8001. if i.Insutype == "390" {
  8002. is390 = 1
  8003. }
  8004. if i.Insutype == "310" {
  8005. is310 = 1
  8006. }
  8007. }
  8008. }
  8009. if is390 == 1 {
  8010. insutype = "390"
  8011. }
  8012. if is310 == 1 {
  8013. insutype = "310"
  8014. }
  8015. if len(insutypes) == 0 {
  8016. insutype = "310"
  8017. }
  8018. insutype = psn_record.Insutype
  8019. for _, item := range rf {
  8020. if item.Insutype == insutype {
  8021. insuplc_admdvs = item.InsuplcAdmdvs
  8022. }
  8023. }
  8024. if config.IsOpen == 1 {
  8025. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  8026. var dat map[string]interface{}
  8027. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8028. fmt.Println(dat)
  8029. } else {
  8030. fmt.Println(err)
  8031. }
  8032. userJSONBytes, _ := json.Marshal(dat)
  8033. var res ResultFourteen
  8034. var res10265 ResultFourteen10265
  8035. if miConfig.Code == "H15049901371" {
  8036. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8037. utils.ErrorLog("解析失败:%v", err)
  8038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8039. return
  8040. }
  8041. res.ErrMsg = res10265.ErrMsg
  8042. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8043. res.Infcode = infocode
  8044. res.Output = res10265.Output
  8045. res.InfRefmsgid = res10265.InfRefmsgid
  8046. } else {
  8047. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8048. utils.ErrorLog("解析失败:%v", err)
  8049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8050. return
  8051. }
  8052. }
  8053. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8054. // utils.ErrorLog("解析失败:%v", err)
  8055. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8056. // return
  8057. //}
  8058. if res.Infcode == 0 {
  8059. psn_record.IsCancel = 2
  8060. service.CreatePsnNCDSRecord(&psn_record)
  8061. c.ServeSuccessJSON(map[string]interface{}{
  8062. "failed_code": 0,
  8063. "msg": "撤销备案成功",
  8064. })
  8065. } else {
  8066. c.ServeSuccessJSON(map[string]interface{}{
  8067. "failed_code": -10,
  8068. "msg": res.ErrMsg,
  8069. })
  8070. return
  8071. }
  8072. }
  8073. }
  8074. func (c *HisApiController) TestTest() {
  8075. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  8076. fmt.Println(patient.Iinfo)
  8077. }
  8078. type CustomData struct {
  8079. MsgId string
  8080. PsnNo string
  8081. Info string
  8082. }
  8083. func (c *HisApiController) ReversalData() {
  8084. var customData []*CustomData
  8085. custom := &CustomData{
  8086. MsgId: "H44022900158202103301714472004",
  8087. PsnNo: "44020000001101329945",
  8088. Info: "2207",
  8089. }
  8090. customData = append(customData, custom)
  8091. custom1 := &CustomData{
  8092. MsgId: "H4402290015820210330172057803",
  8093. PsnNo: "44020000001101161813",
  8094. Info: "2207",
  8095. }
  8096. customData = append(customData, custom1)
  8097. custom2 := &CustomData{
  8098. MsgId: "H44022900158202103301705198813",
  8099. PsnNo: "44190000133097375417",
  8100. Info: "2207",
  8101. }
  8102. customData = append(customData, custom2)
  8103. custom3 := &CustomData{
  8104. MsgId: "H44022900158202103301715524756",
  8105. PsnNo: "44020000001100187221",
  8106. Info: "2207",
  8107. }
  8108. customData = append(customData, custom3)
  8109. custom4 := &CustomData{
  8110. MsgId: "H44022900158202103301730376224",
  8111. PsnNo: "44020000001101959155",
  8112. Info: "2207",
  8113. }
  8114. customData = append(customData, custom4)
  8115. custom5 := &CustomData{
  8116. MsgId: "H44022900158202103301748008725",
  8117. PsnNo: "44020000001104246641",
  8118. Info: "2207",
  8119. }
  8120. customData = append(customData, custom5)
  8121. custom6 := &CustomData{
  8122. MsgId: "H44022900158202103301718096755",
  8123. PsnNo: "44020000001102211860",
  8124. Info: "2207",
  8125. }
  8126. customData = append(customData, custom6)
  8127. custom7 := &CustomData{
  8128. MsgId: "H44022900158202103301736551640",
  8129. PsnNo: "44020000001102687718",
  8130. Info: "2207",
  8131. }
  8132. customData = append(customData, custom7)
  8133. custom8 := &CustomData{
  8134. MsgId: "H44022900158202103301743097676",
  8135. PsnNo: "44020000001102127785",
  8136. Info: "2207",
  8137. }
  8138. customData = append(customData, custom8)
  8139. custom9 := &CustomData{
  8140. MsgId: "H44022900158202103301712304203",
  8141. PsnNo: "44020000001101518097",
  8142. Info: "2207",
  8143. }
  8144. customData = append(customData, custom9)
  8145. custom10 := &CustomData{
  8146. MsgId: "H44022900158202103301738448785",
  8147. PsnNo: "44020000001100500813",
  8148. Info: "2207",
  8149. }
  8150. customData = append(customData, custom10)
  8151. custom11 := &CustomData{
  8152. MsgId: "H44022900158202103301732455843",
  8153. PsnNo: "44020000001102690557",
  8154. Info: "2207",
  8155. }
  8156. customData = append(customData, custom11)
  8157. custom12 := &CustomData{
  8158. MsgId: "H44022900158202103301745421708",
  8159. PsnNo: "44020000001102211928",
  8160. Info: "2207",
  8161. }
  8162. customData = append(customData, custom12)
  8163. custom1212 := &CustomData{
  8164. MsgId: "H440229001582021033017351627",
  8165. PsnNo: "44020000001102481733",
  8166. Info: "2207",
  8167. }
  8168. customData = append(customData, custom1212)
  8169. custom13 := &CustomData{
  8170. MsgId: "H44022900158202103301740327951",
  8171. PsnNo: "44020000001103174866",
  8172. Info: "2207",
  8173. }
  8174. customData = append(customData, custom13)
  8175. custom14 := &CustomData{
  8176. MsgId: "H4402290015820210330174922668",
  8177. PsnNo: "44020000001102927272",
  8178. Info: "2207",
  8179. }
  8180. customData = append(customData, custom14)
  8181. custom15 := &CustomData{
  8182. MsgId: "H44022900158202103301752362273",
  8183. PsnNo: "44020000001102942890",
  8184. Info: "2207",
  8185. }
  8186. customData = append(customData, custom15)
  8187. custom16 := &CustomData{
  8188. MsgId: "H44022900158202103301751082917",
  8189. PsnNo: "44020000001101662162",
  8190. Info: "2207",
  8191. }
  8192. customData = append(customData, custom16)
  8193. custom17 := &CustomData{
  8194. MsgId: "H44022900158202103301754147728",
  8195. PsnNo: "44020000000229014511",
  8196. Info: "2207",
  8197. }
  8198. customData = append(customData, custom17)
  8199. adminUser := c.GetAdminUserInfo()
  8200. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8201. for _, item := range customData {
  8202. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  8203. fmt.Println(result)
  8204. }
  8205. }
  8206. func (c *HisApiController) GetAllopatry() {
  8207. year := c.GetString("year")
  8208. month := c.GetString("month")
  8209. admin_user_id, _ := c.GetInt64("admin_user_id")
  8210. adminUser := c.GetAdminUserInfo()
  8211. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8212. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8213. result, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month)
  8214. var dat map[string]interface{}
  8215. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8216. fmt.Println(dat)
  8217. } else {
  8218. fmt.Println(err)
  8219. }
  8220. userJSONBytes, _ := json.Marshal(dat)
  8221. var res2 models.Result3260
  8222. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8223. utils.ErrorLog("解析失败:%v", err)
  8224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8225. return
  8226. }
  8227. c.ServeSuccessJSON(map[string]interface{}{
  8228. "result": res2,
  8229. })
  8230. }
  8231. func (c *HisApiController) ComfirmAllopatry() {
  8232. year := c.GetString("year")
  8233. month := c.GetString("month")
  8234. admin_user_id, _ := c.GetInt64("admin_user_id")
  8235. adminUser := c.GetAdminUserInfo()
  8236. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8237. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8238. result, _ := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month)
  8239. var dat map[string]interface{}
  8240. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8241. fmt.Println(dat)
  8242. } else {
  8243. fmt.Println(err)
  8244. }
  8245. userJSONBytes, _ := json.Marshal(dat)
  8246. var res2 models.Result3261
  8247. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8248. utils.ErrorLog("解析失败:%v", err)
  8249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8250. return
  8251. }
  8252. c.ServeSuccessJSON(map[string]interface{}{
  8253. "result": res2,
  8254. })
  8255. }
  8256. func (c *HisApiController) RefundAllopatry() {
  8257. //year := c.GetString("year")
  8258. //month := c.GetString("month")
  8259. //admin_user_id, _ := c.GetInt64("admin_user_id")
  8260. //adminUser := c.GetAdminUserInfo()
  8261. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8262. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8263. }
  8264. func (c *HisApiController) ReversalOtherData() {
  8265. var customData []*CustomData
  8266. custom := &CustomData{
  8267. MsgId: "H44022900158202103301714472004",
  8268. PsnNo: "44020000001101329945",
  8269. Info: "2208",
  8270. }
  8271. customData = append(customData, custom)
  8272. custom1 := &CustomData{
  8273. MsgId: "H4402290015820210330172057803",
  8274. PsnNo: "44020000001101161813",
  8275. Info: "2208",
  8276. }
  8277. customData = append(customData, custom1)
  8278. custom2 := &CustomData{
  8279. MsgId: "H44022900158202103301705198813",
  8280. PsnNo: "44190000133097375417",
  8281. Info: "2208",
  8282. }
  8283. customData = append(customData, custom2)
  8284. custom3 := &CustomData{
  8285. MsgId: "H44022900158202103301715524756",
  8286. PsnNo: "44020000001100187221",
  8287. Info: "2208",
  8288. }
  8289. customData = append(customData, custom3)
  8290. custom4 := &CustomData{
  8291. MsgId: "H44022900158202103301730376224",
  8292. PsnNo: "44020000001101959155",
  8293. Info: "2208",
  8294. }
  8295. customData = append(customData, custom4)
  8296. custom5 := &CustomData{
  8297. MsgId: "H44022900158202103301748008725",
  8298. PsnNo: "44020000001104246641",
  8299. Info: "2208",
  8300. }
  8301. customData = append(customData, custom5)
  8302. custom6 := &CustomData{
  8303. MsgId: "H44022900158202103301718096755",
  8304. PsnNo: "44020000001102211860",
  8305. Info: "2208",
  8306. }
  8307. customData = append(customData, custom6)
  8308. custom7 := &CustomData{
  8309. MsgId: "H44022900158202103301736551640",
  8310. PsnNo: "44020000001102687718",
  8311. Info: "2208",
  8312. }
  8313. customData = append(customData, custom7)
  8314. custom8 := &CustomData{
  8315. MsgId: "H44022900158202103301743097676",
  8316. PsnNo: "44020000001102127785",
  8317. Info: "2208",
  8318. }
  8319. customData = append(customData, custom8)
  8320. custom9 := &CustomData{
  8321. MsgId: "H44022900158202103301712304203",
  8322. PsnNo: "44020000001101518097",
  8323. Info: "2208",
  8324. }
  8325. customData = append(customData, custom9)
  8326. custom10 := &CustomData{
  8327. MsgId: "H44022900158202103301738448785",
  8328. PsnNo: "44020000001100500813",
  8329. Info: "2208",
  8330. }
  8331. customData = append(customData, custom10)
  8332. custom11 := &CustomData{
  8333. MsgId: "H44022900158202103301732455843",
  8334. PsnNo: "44020000001102690557",
  8335. Info: "2208",
  8336. }
  8337. customData = append(customData, custom11)
  8338. custom12 := &CustomData{
  8339. MsgId: "H44022900158202103301745421708",
  8340. PsnNo: "44020000001102211928",
  8341. Info: "2208",
  8342. }
  8343. customData = append(customData, custom12)
  8344. custom1212 := &CustomData{
  8345. MsgId: "H440229001582021033017351627",
  8346. PsnNo: "44020000001102481733",
  8347. Info: "2208",
  8348. }
  8349. customData = append(customData, custom1212)
  8350. custom13 := &CustomData{
  8351. MsgId: "H44022900158202103301740327951",
  8352. PsnNo: "44020000001103174866",
  8353. Info: "2208",
  8354. }
  8355. customData = append(customData, custom13)
  8356. custom14 := &CustomData{
  8357. MsgId: "H4402290015820210330174922668",
  8358. PsnNo: "44020000001102927272",
  8359. Info: "2208",
  8360. }
  8361. customData = append(customData, custom14)
  8362. custom15 := &CustomData{
  8363. MsgId: "H44022900158202103301752362273",
  8364. PsnNo: "44020000001102942890",
  8365. Info: "2208",
  8366. }
  8367. customData = append(customData, custom15)
  8368. custom16 := &CustomData{
  8369. MsgId: "H44022900158202103301751082917",
  8370. PsnNo: "44020000001101662162",
  8371. Info: "2208",
  8372. }
  8373. customData = append(customData, custom16)
  8374. custom17 := &CustomData{
  8375. MsgId: "H44022900158202103301754147728",
  8376. PsnNo: "44020000000229014511",
  8377. Info: "2208",
  8378. }
  8379. customData = append(customData, custom17)
  8380. adminUser := c.GetAdminUserInfo()
  8381. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8382. for _, item := range customData {
  8383. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  8384. fmt.Println(result)
  8385. }
  8386. }
  8387. func PathExists(path string) (bool, error) {
  8388. _, err := os.Stat(path)
  8389. if err == nil {
  8390. return true, nil
  8391. }
  8392. if os.IsNotExist(err) {
  8393. return false, nil
  8394. }
  8395. return false, err
  8396. }
  8397. //创建文件夹
  8398. func Mkdir(dir string) {
  8399. // 创建文件夹
  8400. exist, err := PathExists(dir)
  8401. if err != nil {
  8402. fmt.Println(err.Error())
  8403. } else {
  8404. if exist {
  8405. fmt.Println(dir + "文件夹已存在!")
  8406. } else {
  8407. // 文件夹名称,权限
  8408. err := os.Mkdir(dir, os.ModePerm)
  8409. if err != nil {
  8410. fmt.Println(dir+"文件夹创建失败:", err.Error())
  8411. } else {
  8412. fmt.Println(dir + "文件夹创建成功!")
  8413. }
  8414. }
  8415. }
  8416. }
  8417. //压缩文件
  8418. func Zip(srcFile string, destZip string) error {
  8419. zipfile, err := os.Create(destZip)
  8420. if err != nil {
  8421. return err
  8422. }
  8423. defer zipfile.Close()
  8424. archive := zip.NewWriter(zipfile)
  8425. defer archive.Close()
  8426. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  8427. if err != nil {
  8428. return err
  8429. }
  8430. header, err := zip.FileInfoHeader(info)
  8431. if err != nil {
  8432. return err
  8433. }
  8434. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  8435. // header.Name = path
  8436. if info.IsDir() {
  8437. header.Name += "/"
  8438. } else {
  8439. header.Method = zip.Deflate
  8440. }
  8441. writer, err := archive.CreateHeader(header)
  8442. if err != nil {
  8443. return err
  8444. }
  8445. if !info.IsDir() {
  8446. file, err := os.Open(path)
  8447. if err != nil {
  8448. return err
  8449. }
  8450. defer file.Close()
  8451. _, err = io.Copy(writer, file)
  8452. }
  8453. return err
  8454. })
  8455. return err
  8456. }
  8457. func ReadFile(filePath string) []byte {
  8458. f, err := os.Open(filePath)
  8459. if err != nil {
  8460. fmt.Println("read file fail", err)
  8461. return nil
  8462. }
  8463. defer f.Close()
  8464. fd, err := ioutil.ReadAll(f)
  8465. if err != nil {
  8466. fmt.Println("read to fd fail", err)
  8467. return nil
  8468. }
  8469. return fd
  8470. }
  8471. func saveLog(result string, request string, infno string, desc string) {
  8472. org_id, _ := beego.AppConfig.Int64("org_id")
  8473. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  8474. dir := miConfig.OrgName + "日志"
  8475. utils.Mkdir(dir)
  8476. month := time.Unix(1557042972, 0).Format("1")
  8477. year := time.Now().Format("2006")
  8478. month = time.Now().Format("01")
  8479. day := time.Now().Format("02")
  8480. hour := time.Now().Format("15")
  8481. min := time.Now().Format("04")
  8482. sec := time.Now().Format("05")
  8483. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  8484. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  8485. file_name := file + ".txt"
  8486. file_path := miConfig.OrgName + "日志" + "/" + file_name
  8487. exist, _ := utils.PathExists(file_path)
  8488. if exist { //存在
  8489. fmt.Println("存在")
  8490. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  8491. if err != nil {
  8492. fmt.Println("read fail")
  8493. }
  8494. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  8495. n, _ := f.Seek(0, 2)
  8496. _, err = f.WriteAt([]byte(content), n)
  8497. } else { //不存在
  8498. fmt.Println("文件不存在,创建文件")
  8499. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  8500. defer f.Close()
  8501. if err != nil {
  8502. } else {
  8503. _, err = f.Write([]byte("记录日志"))
  8504. }
  8505. }
  8506. }
  8507. type Charset string
  8508. const (
  8509. UTF8 = Charset("UTF-8")
  8510. GB18030 = Charset("GB18030")
  8511. )
  8512. func ConvertToString(src string, srcCode string, tagCode string) string {
  8513. srcCoder := mahonia.NewDecoder(srcCode)
  8514. srcResult := srcCoder.ConvertString(src)
  8515. tagCoder := mahonia.NewDecoder(tagCode)
  8516. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  8517. result := string(cdata)
  8518. return result
  8519. }