his_api_controller.go 422KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/json"
  6. "fmt"
  7. "gdyb/controllers"
  8. "gdyb/enums"
  9. "gdyb/models"
  10. "gdyb/service"
  11. "gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/axgle/mahonia"
  14. "github.com/jinzhu/gorm"
  15. "github.com/shopspring/decimal"
  16. "io"
  17. "io/ioutil"
  18. "math/rand"
  19. "net/http"
  20. "os"
  21. "path/filepath"
  22. "strconv"
  23. "strings"
  24. "syscall"
  25. "time"
  26. "unsafe"
  27. )
  28. type HisApiController struct {
  29. controllers.BaseAuthAPIController
  30. }
  31. func HisManagerApiRegistRouters() {
  32. //挂号
  33. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  34. //上传就诊信息-上传明细-结算
  35. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  36. //查询
  37. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  38. //对总账
  39. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  40. //对明细
  41. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  42. //退费,退明细
  43. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  44. //退号
  45. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  46. //退明细
  47. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  48. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  49. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  50. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  51. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  52. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  53. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  54. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  55. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  56. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  57. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  58. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  59. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  60. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  61. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  62. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  63. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  64. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  65. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  66. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  67. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  68. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  69. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  70. beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  71. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  72. beego.Router("/api/check", &HisApiController{}, "get:Check")
  73. beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  74. beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  75. }
  76. func (c *HisApiController) Check3101() {
  77. patient_id, _ := c.GetInt64("patient_id")
  78. his_patient_id, _ := c.GetInt64("his_patient_id")
  79. admin_user_id, _ := c.GetInt64("admin_user_id")
  80. adminUser := c.GetAdminUserInfo()
  81. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  82. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  83. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  84. record_time := c.GetString("record_time")
  85. trig_scen := c.GetString("trig_scen")
  86. timeLayout := "2006-01-02"
  87. loc, _ := time.LoadLocation("Local")
  88. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  89. if err != nil {
  90. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  91. return
  92. }
  93. recordDateTime := theTime.Unix()
  94. var patientPrescription models.HisPrescriptionInfo
  95. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  96. if patientPrescription.ID == 0 {
  97. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  98. }
  99. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  100. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  101. //
  102. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  103. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  104. var pp models.PublicParams
  105. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  106. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  107. pp.FixmedinsName = miConfig.OrgName
  108. pp.RequestUrl = miConfig.Url
  109. pp.Cainfo = miConfig.Cainfo
  110. pp.SecretKey = miConfig.SecretKey
  111. pp.AccessKey = miConfig.AccessKey
  112. pp.OpterName = roles.UserName
  113. var config []*models.HisXtDiagnoseConfig
  114. for _, item := range diagnosis_ids {
  115. id, _ := strconv.ParseInt(item, 10, 64)
  116. diagnosisConfig, _ := service.FindDiagnoseById(id)
  117. config = append(config, &diagnosisConfig)
  118. }
  119. var pd models.PatientDtos
  120. pd.PatnID = his.PsnNo
  121. pd.PatnName = his.Name
  122. pd.Gend = his.Gend
  123. pd.Brdy = his.Brdy
  124. pd.Poolarea = his.InsuplcAdmdvs
  125. pd.CurrMdtrtID = his.Number
  126. var fed models.FsiEncounterDtos
  127. fed.MdtrtID = his.Number
  128. fed.MedinsID = miConfig.Code
  129. fed.MedinsName = miConfig.OrgName
  130. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  131. fed.MedMdtrtType = "1"
  132. fed.MedinsLv = "11"
  133. tm := time.Unix(his.RecordDate, 0)
  134. s_tm := tm.Format("2006-01-02 15:04:05")
  135. fed.AdmDate = s_tm
  136. fed.DscgDate = s_tm
  137. fed.DscgMainDiseCodg = config[0].CountryCode
  138. fed.DscgMainDiseName = config[0].CountryContentName
  139. //诊断信息
  140. var fdds []*models.FsiDiagnoseDtos
  141. for index, item := range config {
  142. if index == 0 {
  143. var fdd models.FsiDiagnoseDtos
  144. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  145. fdd.InoutDiseType = "1"
  146. fdd.MaindiseFlag = "1"
  147. fdd.DiseDate = s_tm
  148. fdd.DiasSrtNo = "1"
  149. fdd.DiseName = item.CountryContentName
  150. fdd.DiseCodg = item.CountryCode
  151. fdds = append(fdds, &fdd)
  152. } else {
  153. var fdd models.FsiDiagnoseDtos
  154. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  155. fdd.InoutDiseType = "1"
  156. fdd.MaindiseFlag = "1"
  157. fdd.DiseDate = s_tm
  158. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  159. fdd.DiseName = item.CountryContentName
  160. fdd.DiseCodg = item.CountryCode
  161. fdds = append(fdds, &fdd)
  162. }
  163. }
  164. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  165. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  166. fed.AdmDeptName = department.Name
  167. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  168. fed.DscgDeptName = department.Name
  169. fed.MedMdtrtType = ""
  170. if his.Insutype == "390" {
  171. fed.MedType = "1402"
  172. } else {
  173. fed.MedType = "9933"
  174. }
  175. var orders []*models.FsiOrderDtos
  176. if trig_scen == "2" {
  177. //处方医嘱信息
  178. for _, item := range prescriptions {
  179. for _, subItem := range item.HisDoctorAdviceInfo {
  180. var order models.FsiOrderDtos
  181. order.RxID = strconv.FormatInt(item.ID, 10)
  182. order.Rxno = strconv.FormatInt(item.ID, 10)
  183. order.LongDrordFlag = "0"
  184. order.HilistType = "1"
  185. order.ChrgType = "1"
  186. order.DrordBhvr = "-"
  187. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  188. order.HosplistName = subItem.BaseDrugLib.DrugName
  189. order.HilistLv = "1"
  190. order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  191. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  192. order.HosplistName = subItem.BaseDrugLib.DrugName
  193. order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  194. order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  195. order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  196. order.OwnpayAmt = ""
  197. order.SelfpayAmt = ""
  198. order.Spec = ""
  199. order.SpecUnt = ""
  200. order.DrordBegnDate = s_tm
  201. order.DrordStopDate = ""
  202. order.DrordDrCodg = "1"
  203. order.DrordDeptName = department.Name
  204. order.DrordDrCodg = "1"
  205. order.DrordDrName = doctor_info.UserName
  206. order.DrordDrProfttl = ""
  207. order.CurrDrordFlag = "1"
  208. orders = append(orders, &order)
  209. }
  210. for _, subItem := range item.HisPrescriptionProject {
  211. if subItem.Type == 2 {
  212. var order models.FsiOrderDtos
  213. order.RxID = strconv.FormatInt(item.ID, 10)
  214. order.Rxno = strconv.FormatInt(item.ID, 10)
  215. order.LongDrordFlag = "0"
  216. order.HilistType = "1"
  217. order.ChrgType = "1"
  218. order.DrordBhvr = "-"
  219. order.HilistCode = subItem.HisProject.MedicalCode
  220. order.HosplistName = subItem.HisProject.ProjectName
  221. order.HilistLv = "1"
  222. order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  223. order.HosplistCode = subItem.HisProject.MedicalCode
  224. order.HosplistName = subItem.HisProject.ProjectName
  225. order.Cnt = subItem.Count
  226. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  227. order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  228. order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  229. order.OwnpayAmt = ""
  230. order.SelfpayAmt = ""
  231. order.Spec = ""
  232. order.SpecUnt = ""
  233. order.DrordBegnDate = s_tm
  234. order.DrordStopDate = ""
  235. order.DrordDrCodg = "1"
  236. order.DrordDeptName = department.Name
  237. order.DrordDrCodg = "1"
  238. order.DrordDrName = doctor_info.UserName
  239. order.DrordDrProfttl = ""
  240. order.CurrDrordFlag = "1"
  241. orders = append(orders, &order)
  242. }
  243. if subItem.Type == 3 {
  244. var order models.FsiOrderDtos
  245. order.RxID = strconv.FormatInt(item.ID, 10)
  246. order.Rxno = strconv.FormatInt(item.ID, 10)
  247. order.LongDrordFlag = "0"
  248. order.HilistType = "1"
  249. order.ChrgType = "1"
  250. order.DrordBhvr = "-"
  251. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  252. order.HosplistName = subItem.GoodInfo.GoodName
  253. order.HilistLv = "1"
  254. order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  255. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  256. order.HosplistName = subItem.GoodInfo.GoodName
  257. order.Cnt = subItem.Count
  258. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  259. order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  260. order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  261. order.OwnpayAmt = ""
  262. order.SelfpayAmt = ""
  263. order.Spec = ""
  264. order.SpecUnt = ""
  265. order.DrordBegnDate = s_tm
  266. order.DrordStopDate = ""
  267. order.DrordDrCodg = "1"
  268. order.DrordDeptName = department.Name
  269. order.DrordDrCodg = "1"
  270. order.DrordDrName = doctor_info.UserName
  271. order.DrordDrProfttl = ""
  272. order.CurrDrordFlag = "1"
  273. orders = append(orders, &order)
  274. }
  275. }
  276. }
  277. //处方医嘱信息
  278. }
  279. fed.MatnStas = "0"
  280. fed.MedfeeSumamt = "0"
  281. fed.OwnpayAmt = "0"
  282. fed.SelfpayAmt = "0"
  283. fed.AcctPayamt = "0"
  284. fed.MaAmt = "0"
  285. fed.HifpPayamt = "0"
  286. fed.SetlTotlnum = "0"
  287. fed.Insutype = his.Insutype
  288. fed.ReimFlag = "0"
  289. fed.OutSetlFlag = "0"
  290. var fopd []*models.FsiOperationDtosData
  291. data := make(map[string]interface{})
  292. data["fed"] = fed
  293. data["fdd"] = fdds
  294. data["fod"] = orders
  295. data["pd"] = pd
  296. data["pp"] = pp
  297. data["fopd"] = fopd
  298. data["trig_scen"] = trig_scen
  299. fmt.Println(data)
  300. fmt.Println(fed)
  301. fmt.Println(fdds)
  302. fmt.Println(orders)
  303. fmt.Println(pd)
  304. fmt.Println(pp)
  305. fmt.Println(fopd)
  306. client := &http.Client{}
  307. bytesData, _ := json.Marshal(data)
  308. var req *http.Request
  309. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  310. resp, _ := client.Do(req)
  311. defer resp.Body.Close()
  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(body), &respJSON); err != nil {
  320. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  322. return
  323. }
  324. //手术操作集合
  325. //手术操作集合
  326. }
  327. func (c *HisApiController) Check3102() {
  328. patient_id, _ := c.GetInt64("patient_id")
  329. order_id, _ := c.GetInt64("order_id")
  330. his_patient_id, _ := c.GetInt64("his_patient_id")
  331. admin_user_id, _ := c.GetInt64("admin_user_id")
  332. trig_scen := c.GetString("trig_scen")
  333. adminUser := c.GetAdminUserInfo()
  334. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  335. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  336. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  337. record_time := c.GetString("record_time")
  338. order, _ := service.GetHisOrderByID(order_id)
  339. timeLayout := "2006-01-02"
  340. loc, _ := time.LoadLocation("Local")
  341. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  342. if err != nil {
  343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  344. return
  345. }
  346. recordDateTime := theTime.Unix()
  347. var patientPrescription models.HisPrescriptionInfo
  348. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  349. if patientPrescription.ID == 0 {
  350. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  351. }
  352. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  353. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  354. //
  355. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  356. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  357. var pp models.PublicParams
  358. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  359. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  360. pp.FixmedinsName = miConfig.OrgName
  361. pp.RequestUrl = miConfig.Url
  362. pp.Cainfo = miConfig.Cainfo
  363. pp.SecretKey = miConfig.SecretKey
  364. pp.AccessKey = miConfig.AccessKey
  365. pp.OpterName = roles.UserName
  366. var config []*models.HisXtDiagnoseConfig
  367. for _, item := range diagnosis_ids {
  368. id, _ := strconv.ParseInt(item, 10, 64)
  369. diagnosisConfig, _ := service.FindDiagnoseById(id)
  370. config = append(config, &diagnosisConfig)
  371. }
  372. var pd models.PatientDtos
  373. pd.PatnID = his.PsnNo
  374. pd.PatnName = his.Name
  375. pd.Gend = his.Gend
  376. pd.Brdy = his.Brdy
  377. pd.Poolarea = his.InsuplcAdmdvs
  378. pd.CurrMdtrtID = his.Number
  379. var fed models.FsiEncounterDtos
  380. fed.MdtrtID = his.Number
  381. fed.MedinsID = miConfig.Code
  382. fed.MedinsName = miConfig.OrgName
  383. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  384. fed.MedMdtrtType = "1"
  385. fed.MedinsLv = "11"
  386. tm := time.Unix(his.RecordDate, 0)
  387. s_tm := tm.Format("2006-01-02 15:04:05")
  388. fed.AdmDate = s_tm
  389. fed.DscgDate = s_tm
  390. fed.DscgMainDiseCodg = config[0].CountryCode
  391. fed.DscgMainDiseName = config[0].CountryContentName
  392. //诊断信息
  393. var fdds []*models.FsiDiagnoseDtos
  394. for index, item := range config {
  395. if index == 0 {
  396. var fdd *models.FsiDiagnoseDtos
  397. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  398. fdd.InoutDiseType = "1"
  399. fdd.MaindiseFlag = "1"
  400. fdd.DiseDate = s_tm
  401. fdd.DiasSrtNo = "1"
  402. fdd.DiseName = item.CountryContentName
  403. fdd.DiseCodg = item.CountryCode
  404. fdds = append(fdds, fdd)
  405. } else {
  406. var fdd *models.FsiDiagnoseDtos
  407. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  408. fdd.InoutDiseType = "1"
  409. fdd.MaindiseFlag = "1"
  410. fdd.DiseDate = s_tm
  411. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  412. fdd.DiseName = item.CountryContentName
  413. fdd.DiseCodg = item.CountryCode
  414. fdds = append(fdds, fdd)
  415. }
  416. }
  417. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  418. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  419. fed.AdmDeptName = department.Name
  420. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  421. fed.DscgDeptName = department.Name
  422. fed.MedMdtrtType = ""
  423. fed.MedType = order.MedType
  424. //处方医嘱信息
  425. var orders []*models.FsiOrderDtos
  426. for _, item := range prescriptions {
  427. for _, subItem := range item.HisDoctorAdviceInfo {
  428. var order models.FsiOrderDtos
  429. order.RxID = strconv.FormatInt(item.ID, 10)
  430. order.Rxno = strconv.FormatInt(item.ID, 10)
  431. order.LongDrordFlag = "0"
  432. order.HilistType = "1"
  433. order.ChrgType = "1"
  434. order.DrordBhvr = "-"
  435. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  436. order.HosplistName = subItem.BaseDrugLib.DrugName
  437. order.HilistLv = "1"
  438. order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  439. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  440. order.HosplistName = subItem.BaseDrugLib.DrugName
  441. order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  442. order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  443. order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  444. order.OwnpayAmt = ""
  445. order.SelfpayAmt = ""
  446. order.Spec = ""
  447. order.SpecUnt = ""
  448. order.DrordBegnDate = s_tm
  449. order.DrordStopDate = ""
  450. order.DrordDrCodg = "1"
  451. order.DrordDeptName = department.Name
  452. order.DrordDrCodg = "1"
  453. order.DrordDrName = doctor_info.UserName
  454. order.DrordDrProfttl = ""
  455. order.CurrDrordFlag = "1"
  456. orders = append(orders, &order)
  457. }
  458. for _, subItem := range item.HisPrescriptionProject {
  459. if subItem.Type == 2 {
  460. var order models.FsiOrderDtos
  461. order.RxID = strconv.FormatInt(item.ID, 10)
  462. order.Rxno = strconv.FormatInt(item.ID, 10)
  463. order.LongDrordFlag = "0"
  464. order.HilistType = "1"
  465. order.ChrgType = "1"
  466. order.DrordBhvr = "-"
  467. order.HilistCode = subItem.HisProject.MedicalCode
  468. order.HosplistName = subItem.HisProject.ProjectName
  469. order.HilistLv = "1"
  470. order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  471. order.HosplistCode = subItem.HisProject.MedicalCode
  472. order.HosplistName = subItem.HisProject.ProjectName
  473. order.Cnt = subItem.Count
  474. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  475. order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  476. order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  477. order.OwnpayAmt = ""
  478. order.SelfpayAmt = ""
  479. order.Spec = ""
  480. order.SpecUnt = ""
  481. order.DrordBegnDate = s_tm
  482. order.DrordStopDate = ""
  483. order.DrordDrCodg = "1"
  484. order.DrordDeptName = department.Name
  485. order.DrordDrCodg = "1"
  486. order.DrordDrName = doctor_info.UserName
  487. order.DrordDrProfttl = ""
  488. order.CurrDrordFlag = "1"
  489. orders = append(orders, &order)
  490. }
  491. if subItem.Type == 3 {
  492. var order models.FsiOrderDtos
  493. order.RxID = strconv.FormatInt(item.ID, 10)
  494. order.Rxno = strconv.FormatInt(item.ID, 10)
  495. order.LongDrordFlag = "0"
  496. order.HilistType = "1"
  497. order.ChrgType = "1"
  498. order.DrordBhvr = "-"
  499. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  500. order.HosplistName = subItem.GoodInfo.GoodName
  501. order.HilistLv = "1"
  502. order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  503. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  504. order.HosplistName = subItem.GoodInfo.GoodName
  505. order.Cnt = subItem.Count
  506. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  507. order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  508. order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  509. order.OwnpayAmt = ""
  510. order.SelfpayAmt = ""
  511. order.Spec = ""
  512. order.SpecUnt = ""
  513. order.DrordBegnDate = s_tm
  514. order.DrordStopDate = ""
  515. order.DrordDrCodg = "1"
  516. order.DrordDeptName = department.Name
  517. order.DrordDrCodg = "1"
  518. order.DrordDrName = doctor_info.UserName
  519. order.DrordDrProfttl = ""
  520. order.CurrDrordFlag = "1"
  521. orders = append(orders, &order)
  522. }
  523. }
  524. }
  525. //处方医嘱信息
  526. fed.MatnStas = "0"
  527. fed.MedfeeSumamt = strconv.FormatFloat(order.MedfeeSumamt, 'E', -1, 64)
  528. fed.OwnpayAmt = strconv.FormatFloat(order.FulamtOwnpayAmt, 'E', -1, 64)
  529. fed.SelfpayAmt = strconv.FormatFloat(order.PreselfpayAmt, 'E', -1, 64)
  530. fed.AcctPayamt = strconv.FormatFloat(order.AcctPay, 'E', -1, 64)
  531. fed.MaAmt = strconv.FormatFloat(order.MafPay, 'E', -1, 64)
  532. fed.HifpPayamt = strconv.FormatFloat(order.HifpPay, 'E', -1, 64)
  533. fed.SetlTotlnum = "1"
  534. fed.Insutype = his.Insutype
  535. fed.ReimFlag = "0"
  536. fed.OutSetlFlag = "0"
  537. var fopd []*models.FsiOperationDtosData
  538. data := make(map[string]interface{})
  539. data["fed"] = fed
  540. data["fdd"] = fdds
  541. data["fod"] = orders
  542. data["pd"] = pd
  543. data["pp"] = pp
  544. data["fopd"] = fopd
  545. data["trig_scen"] = trig_scen
  546. fmt.Println(data)
  547. fmt.Println(fed)
  548. fmt.Println(fdds)
  549. fmt.Println(orders)
  550. fmt.Println(pd)
  551. fmt.Println(pp)
  552. fmt.Println(fopd)
  553. client := &http.Client{}
  554. bytesData, _ := json.Marshal(data)
  555. var req *http.Request
  556. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  557. resp, _ := client.Do(req)
  558. defer resp.Body.Close()
  559. body, ioErr := ioutil.ReadAll(resp.Body)
  560. if ioErr != nil {
  561. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  563. return
  564. }
  565. var respJSON map[string]interface{}
  566. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  567. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  569. return
  570. }
  571. //手术操作集合
  572. //手术操作集合
  573. }
  574. func (c *HisApiController) Check() {
  575. psn_no := c.GetString("psn_no")
  576. in := c.GetString("in")
  577. mt := c.GetString("mt")
  578. baseParams := models.BaseParams{
  579. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  580. FixmedinsCode: "H15049901371",
  581. InsuplcAdmdvs: "150499",
  582. MdtrtareaAdmvs: "150499",
  583. OrgName: "赤峰费森血液透析中心",
  584. Doctor: "1111",
  585. }
  586. service.Gdyb2001(baseParams, psn_no, in, mt)
  587. }
  588. func (c *HisApiController) GetPsnNcdsInfo() {
  589. admin_user_id, _ := c.GetInt64("admin_user_id")
  590. patient_id, _ := c.GetInt64("patient_id")
  591. id, _ := c.GetInt64("id")
  592. adminUser := c.GetAdminUserInfo()
  593. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  594. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  595. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  596. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  597. psn_record, _ := service.GetPsnNCDSRecordById(id)
  598. //
  599. //if psn_record.ID == 0 {
  600. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  601. // return
  602. //}
  603. var res Result5301
  604. var res10265 Result5301For10265
  605. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  606. psn_info, _ := service.GetPsnByPatientId(patient_id)
  607. var api string
  608. if miConfig.MdtrtareaAdmvs == "320921" {
  609. api = "http://192.168.3.111:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  610. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  611. } else {
  612. api = "http://192.168.5.251:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  613. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  614. }
  615. resp, requestErr := http.Get(api)
  616. if requestErr != nil {
  617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  618. return
  619. }
  620. body, ioErr := ioutil.ReadAll(resp.Body)
  621. if ioErr != nil {
  622. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  624. return
  625. }
  626. var respJSON map[string]interface{}
  627. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  628. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  630. return
  631. }
  632. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  633. result, _ := json.Marshal(respJSON)
  634. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  635. utils.ErrorLog("解析失败:%v", err)
  636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  637. return
  638. }
  639. res.ErrMsg = res10265.ErrMsg
  640. res.Output = res10265.Output
  641. res.InfRefmsgid = res10265.InfRefmsgid
  642. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  643. res.Infcode = infocode
  644. } else {
  645. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  646. var dat map[string]interface{}
  647. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  648. fmt.Println(dat)
  649. } else {
  650. fmt.Println(err)
  651. }
  652. userJSONBytes, _ := json.Marshal(dat)
  653. if miConfig.Code == "H15049901371" {
  654. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  655. utils.ErrorLog("解析失败:%v", err)
  656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  657. return
  658. }
  659. res.InfRefmsgid = res10265.InfRefmsgid
  660. res.Output = res10265.Output
  661. res.ErrMsg = res10265.ErrMsg
  662. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  663. res.Infcode = infocode
  664. } else {
  665. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  666. utils.ErrorLog("解析失败:%v", err)
  667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  668. return
  669. }
  670. }
  671. }
  672. if res.Infcode == 0 {
  673. c.ServeSuccessJSON(map[string]interface{}{
  674. "result": res.Output.Result,
  675. })
  676. }
  677. }
  678. func (c *HisApiController) CheckInsutype() {
  679. his_patient_id, _ := c.GetInt64("his_patient_id")
  680. admin_user_id, _ := c.GetInt64("admin_user_id")
  681. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  682. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  683. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  684. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  685. var dat map[string]interface{}
  686. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  687. fmt.Println(dat)
  688. } else {
  689. fmt.Println(err)
  690. }
  691. userJSONBytes, _ := json.Marshal(dat)
  692. var res Result90100
  693. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  694. utils.ErrorLog("解析失败:%v", err)
  695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  696. return
  697. }
  698. if res.Infcode != 0 {
  699. c.ServeSuccessJSON(map[string]interface{}{
  700. "failed_code": -10,
  701. "msg": res.ErrMsg,
  702. })
  703. return
  704. } else {
  705. fmt.Println(res)
  706. }
  707. }
  708. func (c *HisApiController) CheckCardPWD() {
  709. card_pwd := c.GetString("card_pwd")
  710. his_patient_id, _ := c.GetInt64("his_patient_id")
  711. admin_user_id, _ := c.GetInt64("admin_user_id")
  712. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  713. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  714. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  715. psn, _ := service.GetPsnByPatientId(his.PatientId)
  716. bas := strings.Split(psn.CardInfo, "|")
  717. basNumber := bas[2]
  718. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  719. var dat map[string]interface{}
  720. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  721. fmt.Println(dat)
  722. } else {
  723. fmt.Println(err)
  724. }
  725. userJSONBytes, _ := json.Marshal(dat)
  726. var res Result90991
  727. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  728. utils.ErrorLog("解析失败:%v", err)
  729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  730. return
  731. }
  732. if res.Infcode != 0 {
  733. c.ServeSuccessJSON(map[string]interface{}{
  734. "failed_code": -10,
  735. "msg": res.ErrMsg,
  736. })
  737. return
  738. } else {
  739. if res.Output.Result.CheckStat == "0" {
  740. var msg string
  741. switch res.Output.Result.CardStat {
  742. case "00":
  743. msg = "未激活"
  744. break
  745. case "10":
  746. msg = "激活"
  747. break
  748. case "20":
  749. msg = "窗口挂失"
  750. break
  751. case "21":
  752. msg = "电话挂失"
  753. break
  754. case "22":
  755. msg = "单位网上申报挂失"
  756. break
  757. case "23":
  758. msg = "保健办挂失"
  759. break
  760. case "24":
  761. msg = "个人网上挂失"
  762. break
  763. case "25":
  764. msg = "网上服务大厅挂失"
  765. break
  766. case "30":
  767. msg = "注销"
  768. break
  769. case "40":
  770. msg = "回收"
  771. break
  772. case "99":
  773. msg = "制卡中(无效卡)"
  774. break
  775. }
  776. c.ServeSuccessJSON(map[string]interface{}{
  777. "failed_code": -10,
  778. "msg": msg,
  779. })
  780. return
  781. } else {
  782. c.ServeSuccessJSON(map[string]interface{}{
  783. "msg": "校验成功",
  784. })
  785. return
  786. }
  787. }
  788. }
  789. func (c *HisApiController) ReadCard() {
  790. id_card_type, _ := c.GetInt64("id_card_type")
  791. admin_user_id, _ := c.GetInt64("admin_user_id")
  792. certificates, _ := c.GetInt64("certificates")
  793. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  794. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  795. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  796. switch id_card_type {
  797. case 1:
  798. if miConfig.MdtrtareaAdmvs == "421300" {
  799. var res ResultTwo
  800. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  801. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  802. "&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)
  803. resp, requestErr := http.Get(api)
  804. if requestErr != nil {
  805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  806. return
  807. }
  808. body, ioErr := ioutil.ReadAll(resp.Body)
  809. if ioErr != nil {
  810. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  812. return
  813. }
  814. var respJSON map[string]interface{}
  815. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  816. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  818. return
  819. }
  820. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  821. result, _ := json.Marshal(respJSON)
  822. fmt.Println("log")
  823. fmt.Println(string(result))
  824. if err := json.Unmarshal([]byte(result), &res); err != nil {
  825. utils.ErrorLog("解析失败:%v", err)
  826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  827. return
  828. }
  829. if res.Infcode == 0 {
  830. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  831. if err == gorm.ErrRecordNotFound {
  832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  833. return
  834. } else if err != nil {
  835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  836. return
  837. } else {
  838. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  839. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  840. infoStr := string(Iinfos)
  841. idetinfoStr := string(Idetinfos)
  842. psn := &models.HisPsn{
  843. PsnNo: res.Output.Baseinfo.PsnNo,
  844. Age: res.Output.Baseinfo.Age,
  845. PatientId: patient.ID,
  846. Certno: res.Output.Baseinfo.Certno,
  847. Brdy: res.Output.Baseinfo.Brdy,
  848. Gend: res.Output.Baseinfo.Gend,
  849. Naty: res.Output.Baseinfo.Naty,
  850. PsnCertType: res.Output.Baseinfo.PsnCertType,
  851. PsnName: res.Output.Baseinfo.PsnName,
  852. Idetinfo: idetinfoStr,
  853. Insuinfo: infoStr,
  854. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  855. }
  856. service.CreateHisPsn(psn)
  857. c.ServeSuccessJSON(map[string]interface{}{
  858. "patient": patient,
  859. "number": res.Output.Baseinfo.Certno,
  860. })
  861. }
  862. } else {
  863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  864. return
  865. }
  866. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  867. var api string
  868. if miConfig.MdtrtareaAdmvs == "320921" {
  869. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  870. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  871. fmt.Println(api)
  872. } else {
  873. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  874. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  875. }
  876. resp, requestErr := http.Get(api)
  877. if requestErr != nil {
  878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  879. return
  880. }
  881. body, ioErr := ioutil.ReadAll(resp.Body)
  882. if ioErr != nil {
  883. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  885. return
  886. }
  887. var respJSON map[string]interface{}
  888. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  889. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  891. return
  892. }
  893. var status string
  894. status = respJSON["data"].(map[string]interface{})["status"].(string)
  895. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  896. //console.log()
  897. fmt.Println("type===")
  898. fmt.Println(card_type)
  899. var token string
  900. var res ResultTwo //1101结果
  901. var res10265 ResultTwo10265 //1101结果
  902. var card_info string //卡信息
  903. var busi_card_info string
  904. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  905. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  906. if status == "0" { //读卡成功
  907. if card_type == "1" {
  908. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  909. result, _ := json.Marshal(respJSON)
  910. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  911. utils.ErrorLog("解析失败:%v", err)
  912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  913. return
  914. }
  915. res.ErrMsg = res10265.ErrMsg
  916. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  917. res.Infcode = infocode
  918. res.Output = res10265.Output
  919. res.InfRefmsgid = res10265.InfRefmsgid
  920. } else {
  921. //var card_info string //卡信息
  922. //var busi_card_info string
  923. token = respJSON["data"].(map[string]interface{})["token"].(string)
  924. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  925. //fmt.Println(card_info)
  926. //fmt.Println(busi_card_info)
  927. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  928. result, _ := json.Marshal(respJSON)
  929. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  930. utils.ErrorLog("解析失败:%v", err)
  931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  932. return
  933. }
  934. res.ErrMsg = res10265.ErrMsg
  935. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  936. res.Infcode = infocode
  937. res.Output = res10265.Output
  938. res.InfRefmsgid = res10265.InfRefmsgid
  939. }
  940. if res.Infcode == 0 {
  941. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  942. if err == gorm.ErrRecordNotFound {
  943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  944. return
  945. } else if err != nil {
  946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  947. return
  948. } else {
  949. if card_type == "1" {
  950. bas := strings.Split(card_info, "|")
  951. basNumber := bas[2]
  952. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  953. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  954. infoStr := string(Iinfos)
  955. idetinfoStr := string(Idetinfos)
  956. psn := &models.HisPsn{
  957. PsnNo: res.Output.Baseinfo.PsnNo,
  958. Age: res.Output.Baseinfo.Age,
  959. PatientId: patient.ID,
  960. Certno: res.Output.Baseinfo.Certno,
  961. Brdy: res.Output.Baseinfo.Brdy,
  962. Gend: res.Output.Baseinfo.Gend,
  963. Naty: res.Output.Baseinfo.Naty,
  964. PsnCertType: res.Output.Baseinfo.PsnCertType,
  965. PsnName: res.Output.Baseinfo.PsnName,
  966. Idetinfo: idetinfoStr,
  967. Insuinfo: infoStr,
  968. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  969. CardInfo: card_info,
  970. VerifyNumber: busi_card_info,
  971. }
  972. service.CreateHisPsn(psn)
  973. c.ServeSuccessJSON(map[string]interface{}{
  974. "patient": patient,
  975. "number": basNumber,
  976. })
  977. } else {
  978. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  979. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  980. infoStr := string(Iinfos)
  981. idetinfoStr := string(Idetinfos)
  982. psn := &models.HisPsn{
  983. PsnNo: res.Output.Baseinfo.PsnNo,
  984. Age: res.Output.Baseinfo.Age,
  985. PatientId: patient.ID,
  986. Certno: res.Output.Baseinfo.Certno,
  987. Brdy: res.Output.Baseinfo.Brdy,
  988. Gend: res.Output.Baseinfo.Gend,
  989. Naty: res.Output.Baseinfo.Naty,
  990. PsnCertType: res.Output.Baseinfo.PsnCertType,
  991. PsnName: res.Output.Baseinfo.PsnName,
  992. Idetinfo: idetinfoStr,
  993. Insuinfo: infoStr,
  994. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  995. CardInfo: card_info,
  996. VerifyNumber: token,
  997. }
  998. service.CreateHisPsn(psn)
  999. c.ServeSuccessJSON(map[string]interface{}{
  1000. "patient": patient,
  1001. "number": token,
  1002. })
  1003. }
  1004. }
  1005. } else {
  1006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1007. return
  1008. }
  1009. } else { //读卡失败
  1010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1011. return
  1012. }
  1013. } else {
  1014. if initFlag == 0 {
  1015. c.TestGetBasBaseInit()
  1016. }
  1017. basStr := c.GetBasBaseInfo()
  1018. if len(basStr) == 0 {
  1019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1020. return
  1021. }
  1022. fmt.Println(basStr)
  1023. bas := strings.Split(basStr, "|")
  1024. basNumber := bas[1]
  1025. fmt.Println(basNumber)
  1026. card_sn := bas[3]
  1027. fmt.Println(card_sn)
  1028. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1029. var dat map[string]interface{}
  1030. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1031. fmt.Println(dat)
  1032. } else {
  1033. fmt.Println(err)
  1034. }
  1035. userJSONBytes, _ := json.Marshal(dat)
  1036. var res ResultTwo
  1037. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1038. utils.ErrorLog("解析失败:%v", err)
  1039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1040. return
  1041. }
  1042. if res.Infcode == 0 {
  1043. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1044. if err == gorm.ErrRecordNotFound {
  1045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1046. return
  1047. } else if err != nil {
  1048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1049. return
  1050. } else {
  1051. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1052. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1053. infoStr := string(Iinfos)
  1054. idetinfoStr := string(Idetinfos)
  1055. psn := &models.HisPsn{
  1056. PsnNo: res.Output.Baseinfo.PsnNo,
  1057. Age: res.Output.Baseinfo.Age,
  1058. PatientId: patient.ID,
  1059. Certno: res.Output.Baseinfo.Certno,
  1060. Brdy: res.Output.Baseinfo.Brdy,
  1061. Gend: res.Output.Baseinfo.Gend,
  1062. Naty: res.Output.Baseinfo.Naty,
  1063. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1064. PsnName: res.Output.Baseinfo.PsnName,
  1065. Idetinfo: idetinfoStr,
  1066. Insuinfo: infoStr,
  1067. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1068. CardInfo: basStr,
  1069. VerifyNumber: "",
  1070. }
  1071. service.CreateHisPsn(psn)
  1072. c.ServeSuccessJSON(map[string]interface{}{
  1073. "patient": patient,
  1074. "number": basNumber,
  1075. })
  1076. }
  1077. } else {
  1078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1079. return
  1080. }
  1081. break
  1082. }
  1083. case 2:
  1084. SFZStr := c.GetSFZBaseInfo()
  1085. id_card_str := strings.Split(SFZStr, "^")
  1086. id_card_number := id_card_str[0]
  1087. card_sn := ""
  1088. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1089. var dat map[string]interface{}
  1090. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1091. fmt.Println(dat)
  1092. } else {
  1093. fmt.Println(err)
  1094. }
  1095. userJSONBytes, _ := json.Marshal(dat)
  1096. var res ResultTwo
  1097. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1098. utils.ErrorLog("解析失败:%v", err)
  1099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1100. return
  1101. }
  1102. if res.Infcode == 0 {
  1103. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1104. if err == gorm.ErrRecordNotFound {
  1105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1106. return
  1107. } else if err != nil {
  1108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1109. return
  1110. } else {
  1111. c.ServeSuccessJSON(map[string]interface{}{
  1112. "patient": patient,
  1113. "number": id_card_number,
  1114. })
  1115. }
  1116. } else {
  1117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1118. return
  1119. }
  1120. break
  1121. case 3:
  1122. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1123. var api string
  1124. if miConfig.MdtrtareaAdmvs == "320921" {
  1125. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1126. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  1127. fmt.Println(api)
  1128. } else {
  1129. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1130. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  1131. }
  1132. resp, requestErr := http.Get(api)
  1133. if requestErr != nil {
  1134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1135. return
  1136. }
  1137. body, ioErr := ioutil.ReadAll(resp.Body)
  1138. if ioErr != nil {
  1139. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1141. return
  1142. }
  1143. var respJSON map[string]interface{}
  1144. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1145. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1147. return
  1148. }
  1149. var status string
  1150. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1151. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1152. var token string
  1153. var res ResultTwo //1101结果
  1154. var res10265 ResultTwo10265 //1101结果
  1155. var card_info string //卡信息
  1156. var busi_card_info string
  1157. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1158. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1159. if status == "0" { //读卡成功
  1160. if card_type == "1" {
  1161. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1162. result, _ := json.Marshal(respJSON)
  1163. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1164. utils.ErrorLog("解析失败:%v", err)
  1165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1166. return
  1167. }
  1168. res.ErrMsg = res10265.ErrMsg
  1169. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1170. res.Infcode = infocode
  1171. res.Output = res10265.Output
  1172. res.InfRefmsgid = res10265.InfRefmsgid
  1173. } else {
  1174. //var card_info string //卡信息
  1175. //var busi_card_info string
  1176. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1177. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1178. //fmt.Println(card_info)
  1179. //fmt.Println(busi_card_info)
  1180. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1181. result, _ := json.Marshal(respJSON)
  1182. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1183. utils.ErrorLog("解析失败:%v", err)
  1184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1185. return
  1186. }
  1187. res.ErrMsg = res10265.ErrMsg
  1188. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1189. res.Infcode = infocode
  1190. res.Output = res10265.Output
  1191. res.InfRefmsgid = res10265.InfRefmsgid
  1192. }
  1193. if res.Infcode == 0 {
  1194. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1195. if err == gorm.ErrRecordNotFound {
  1196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1197. return
  1198. } else if err != nil {
  1199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1200. return
  1201. } else {
  1202. if card_type == "1" {
  1203. bas := strings.Split(card_info, "|")
  1204. basNumber := bas[2]
  1205. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1206. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1207. infoStr := string(Iinfos)
  1208. idetinfoStr := string(Idetinfos)
  1209. psn := &models.HisPsn{
  1210. PsnNo: res.Output.Baseinfo.PsnNo,
  1211. Age: res.Output.Baseinfo.Age,
  1212. PatientId: patient.ID,
  1213. Certno: res.Output.Baseinfo.Certno,
  1214. Brdy: res.Output.Baseinfo.Brdy,
  1215. Gend: res.Output.Baseinfo.Gend,
  1216. Naty: res.Output.Baseinfo.Naty,
  1217. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1218. PsnName: res.Output.Baseinfo.PsnName,
  1219. Idetinfo: idetinfoStr,
  1220. Insuinfo: infoStr,
  1221. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1222. CardInfo: card_info,
  1223. VerifyNumber: busi_card_info,
  1224. }
  1225. service.CreateHisPsn(psn)
  1226. c.ServeSuccessJSON(map[string]interface{}{
  1227. "patient": patient,
  1228. "number": basNumber,
  1229. })
  1230. } else {
  1231. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1232. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1233. infoStr := string(Iinfos)
  1234. idetinfoStr := string(Idetinfos)
  1235. psn := &models.HisPsn{
  1236. PsnNo: res.Output.Baseinfo.PsnNo,
  1237. Age: res.Output.Baseinfo.Age,
  1238. PatientId: patient.ID,
  1239. Certno: res.Output.Baseinfo.Certno,
  1240. Brdy: res.Output.Baseinfo.Brdy,
  1241. Gend: res.Output.Baseinfo.Gend,
  1242. Naty: res.Output.Baseinfo.Naty,
  1243. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1244. PsnName: res.Output.Baseinfo.PsnName,
  1245. Idetinfo: idetinfoStr,
  1246. Insuinfo: infoStr,
  1247. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1248. CardInfo: card_info,
  1249. VerifyNumber: token,
  1250. }
  1251. service.CreateHisPsn(psn)
  1252. c.ServeSuccessJSON(map[string]interface{}{
  1253. "patient": patient,
  1254. "number": token,
  1255. })
  1256. }
  1257. }
  1258. } else {
  1259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1260. return
  1261. }
  1262. } else { //读卡失败
  1263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1264. return
  1265. }
  1266. }
  1267. break
  1268. case 4:
  1269. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1270. var api string
  1271. if miConfig.MdtrtareaAdmvs == "320921" {
  1272. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1273. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  1274. fmt.Println(api)
  1275. } else {
  1276. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1277. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  1278. }
  1279. resp, requestErr := http.Get(api)
  1280. if requestErr != nil {
  1281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1282. return
  1283. }
  1284. body, ioErr := ioutil.ReadAll(resp.Body)
  1285. if ioErr != nil {
  1286. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1288. return
  1289. }
  1290. var respJSON map[string]interface{}
  1291. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1292. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1294. return
  1295. }
  1296. var status string
  1297. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1298. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1299. var token string
  1300. var res ResultTwo //1101结果
  1301. var res10265 ResultTwo10265 //1101结果
  1302. if status == "0" { //读卡成功
  1303. var card_info string //卡信息
  1304. var busi_card_info string
  1305. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1306. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1307. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1308. fmt.Println(card_info)
  1309. fmt.Println(busi_card_info)
  1310. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1311. result, _ := json.Marshal(respJSON)
  1312. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1313. utils.ErrorLog("解析失败:%v", err)
  1314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1315. return
  1316. }
  1317. res.ErrMsg = res10265.ErrMsg
  1318. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1319. res.Infcode = infocode
  1320. res.Output = res10265.Output
  1321. res.InfRefmsgid = res10265.InfRefmsgid
  1322. if res.Infcode == 0 {
  1323. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1324. if err == gorm.ErrRecordNotFound {
  1325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1326. return
  1327. } else if err != nil {
  1328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1329. return
  1330. } else {
  1331. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1332. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1333. infoStr := string(Iinfos)
  1334. idetinfoStr := string(Idetinfos)
  1335. psn := &models.HisPsn{
  1336. PsnNo: res.Output.Baseinfo.PsnNo,
  1337. Age: res.Output.Baseinfo.Age,
  1338. PatientId: patient.ID,
  1339. Certno: res.Output.Baseinfo.Certno,
  1340. Brdy: res.Output.Baseinfo.Brdy,
  1341. Gend: res.Output.Baseinfo.Gend,
  1342. Naty: res.Output.Baseinfo.Naty,
  1343. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1344. PsnName: res.Output.Baseinfo.PsnName,
  1345. Idetinfo: idetinfoStr,
  1346. Insuinfo: infoStr,
  1347. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1348. CardInfo: card_info,
  1349. VerifyNumber: token,
  1350. }
  1351. service.CreateHisPsn(psn)
  1352. c.ServeSuccessJSON(map[string]interface{}{
  1353. "patient": patient,
  1354. "number": token,
  1355. })
  1356. }
  1357. } else {
  1358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1359. return
  1360. }
  1361. } else { //读卡失败
  1362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1363. return
  1364. }
  1365. }
  1366. break
  1367. }
  1368. }
  1369. var initFlag int64 = 0
  1370. func (c *HisApiController) TestGetBasBaseInit() {
  1371. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1372. Iinit := DllDef.MustFindProc("Init")
  1373. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1374. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  1375. if ret != 0 {
  1376. fmt.Println("SSCard的报错原因:", err)
  1377. fmt.Println("SSCard的运算结果为:", ret)
  1378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1379. return
  1380. }
  1381. result := int(ret)
  1382. fmt.Println("SSCard的运算结果为1:", result)
  1383. initFlag = 1
  1384. return
  1385. }
  1386. func (c *HisApiController) GetSFZBaseInfo() string {
  1387. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1388. readCard := DllDef.MustFindProc("ReadSFZ")
  1389. if readCard == nil {
  1390. fmt.Println("readcard is nil")
  1391. readCard = DllDef.MustFindProc("ReadSFZ")
  1392. }
  1393. str := make([]byte, 256)
  1394. str1 := make([]byte, 256)
  1395. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1396. fmt.Println(r)
  1397. return string(str)
  1398. }
  1399. func (c *HisApiController) GetBasBaseInfo() string {
  1400. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1401. readCard := DllDef.MustFindProc("ReadCardBas")
  1402. if readCard == nil {
  1403. fmt.Println("readcard is nil")
  1404. readCard = DllDef.MustFindProc("ReadCardBas")
  1405. }
  1406. str := make([]byte, 1024)
  1407. str1 := make([]byte, 1024)
  1408. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  1409. fmt.Println(string(str1))
  1410. fmt.Println(string(str))
  1411. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1412. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1413. if ret2 != 0 {
  1414. return ""
  1415. }
  1416. return string(str)
  1417. }
  1418. type CustomFundPay struct {
  1419. FundPayType string `json:"fund_pay_type"`
  1420. FundPayamt float64 `json:"fund_payamt"`
  1421. }
  1422. func (c *HisApiController) GetSettleList() {
  1423. order_id, _ := c.GetInt64("order_id")
  1424. admin_user_id, _ := c.GetInt64("admin_user_id")
  1425. order, _ := service.GetHisOrderByIDTwo(order_id)
  1426. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1427. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1428. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1429. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1430. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1431. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1432. if order.ID == 0 {
  1433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1434. return
  1435. }
  1436. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1437. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1438. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1439. fmt.Println(count)
  1440. var zero string
  1441. number := count + 1
  1442. if number >= 1000 {
  1443. zero = "0000" + strconv.FormatInt(number, 10)
  1444. } else if number >= 10000 {
  1445. zero = "000" + strconv.FormatInt(number, 10)
  1446. } else if number >= 100000 {
  1447. zero = "00" + strconv.FormatInt(number, 10)
  1448. } else if number >= 1000000 {
  1449. zero = "0" + strconv.FormatInt(number, 10)
  1450. } else {
  1451. zero = strconv.FormatInt(number, 10)
  1452. }
  1453. fmt.Println(zero)
  1454. struct4101 := service.Struct4101{
  1455. PsnNo: order.PsnNo,
  1456. MdtrtId: order.MdtrtId,
  1457. SetlId: order.SetlId,
  1458. PsnName: order.PsnName,
  1459. Gend: order.Gend,
  1460. Brdy: his.Brdy,
  1461. Age: his.Age,
  1462. Naty: order.Naty,
  1463. PatnCertType: "01",
  1464. Certno: order.Certno,
  1465. Prfs: "90",
  1466. ConerName: roles[0].UserName,
  1467. PatnRlts: "99",
  1468. ConerAddr: miConfig.OrgName,
  1469. ConerTel: admin.Mobile,
  1470. HiType: order.Insutype,
  1471. Insuplc: miConfig.InsuplcAdmdvs,
  1472. MaindiagFlag: "1",
  1473. BillCode: last_order.FaPiaoCode,
  1474. BillNo: zero,
  1475. BizSn: order.Number,
  1476. PsnSelfPay: order.PsnPartAmt,
  1477. PsnOwnPay: order.PsnPartAmt,
  1478. AcctPay: order.AcctPay,
  1479. PsnCashpay: order.PsnCashPay,
  1480. HiPaymtd: "1",
  1481. Hsorg: miConfig.InsuplcAdmdvs,
  1482. HsorgOpter: miConfig.InsuplcAdmdvs,
  1483. MedinsFillPsn: curRoles.UserName,
  1484. MedinsFillDept: depart.Name,
  1485. IptMedType: "2",
  1486. }
  1487. struct4101.SetlBegnDate = order.SetlTime
  1488. struct4101.SetlEndDate = order.SetlTime
  1489. time_arr := strings.Split(order.SetlTime, " ")
  1490. struct4101.AdmTime = time_arr[0]
  1491. struct4101.AdmEndTime = time_arr[0]
  1492. var rf []CustomFundPay
  1493. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1494. var tempFunPays []service.CustomStruct
  1495. for _, item := range rf {
  1496. var tempFunPay service.CustomStruct
  1497. tempFunPay.FundPayamt = item.FundPayamt
  1498. tempFunPay.FundPayType = item.FundPayType
  1499. tempFunPays = append(tempFunPays, tempFunPay)
  1500. }
  1501. struct4101.CustomStruct = tempFunPays
  1502. var tempDiaginfos []service.DiaginfoStructTwo
  1503. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1504. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1505. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  1506. var config []*models.HisXtDiagnoseConfig
  1507. for _, item := range diagnosis_ids {
  1508. id, _ := strconv.ParseInt(item, 10, 64)
  1509. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1510. config = append(config, &diagnosisConfig)
  1511. }
  1512. for index, item := range config {
  1513. if index == 0 {
  1514. var tempDiaginfo service.DiaginfoStructTwo
  1515. tempDiaginfo.DiagCode = item.CountryCode
  1516. tempDiaginfo.DiagName = item.CountryContentName
  1517. tempDiaginfo.DiagType = "1"
  1518. tempDiaginfo.MaindiagFlag = "1"
  1519. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1520. } else {
  1521. var tempDiaginfo service.DiaginfoStructTwo
  1522. tempDiaginfo.DiagCode = item.CountryCode
  1523. tempDiaginfo.DiagName = item.CountryContentName
  1524. tempDiaginfo.DiagType = "2"
  1525. tempDiaginfo.MaindiagFlag = "0"
  1526. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1527. }
  1528. }
  1529. struct4101.Diseinfo = tempDiaginfos
  1530. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1531. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1532. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1533. tempOpspdiseinfo2.OprnOprtCode = ""
  1534. tempOpspdiseinfo2.OprnOprtName = ""
  1535. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1536. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1537. var iteminfo service.IteminfoStruct
  1538. var bedCostTotal float64 = 0 //床位总费
  1539. var bedCostSelfTotal float64 = 0 //床位自费
  1540. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1541. var operationCostTotal float64 = 0 //手术费
  1542. var operationCostSelfTotal float64 = 0 //手术费
  1543. var operationCostPartSelfTotal float64 = 0 //手术费
  1544. var otherCostTotal float64 = 0 //其他费用
  1545. var otherCostSelfTotal float64 = 0 //其他费用
  1546. var otherCostPartSelfTotal float64 = 0 //其他费用
  1547. var materialCostTotal float64 = 0 //材料费
  1548. var materialCostSelfTotal float64 = 0 //材料费
  1549. var materialCostPartSelfTotal float64 = 0 //材料费
  1550. var westernMedicineCostTotal float64 = 0 //西药费
  1551. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1552. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1553. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1554. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1555. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1556. var checkCostTotal float64 = 0 //检查费
  1557. var checkCostSelfTotal float64 = 0 //检查费
  1558. var checkCostPartSelfTotal float64 = 0 //检查费
  1559. var laboratoryCostTotal float64 = 0 //化验费
  1560. var laboratoryCostSelfTotal float64 = 0 //化验费
  1561. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1562. var treatCostTotal float64 = 0 //治疗费用
  1563. var treatCostSelfTotal float64 = 0 //治疗费用
  1564. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1565. decimal.DivisionPrecision = 2
  1566. var bed_fulamt_ownpay_amt float64 = 0
  1567. var operation_fulamt_ownpay_amt float64 = 0
  1568. var other_fulamt_ownpay_amt float64 = 0
  1569. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1570. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1571. var check_fulamt_ownpay_amt float64 = 0
  1572. var material_fulamt_ownpay_amt float64 = 0
  1573. var laboratory_fulamt_ownpay_amt float64 = 0
  1574. var treat_fulamt_ownpay_amt float64 = 0
  1575. var bed_claa_sunmfee float64 = 0
  1576. var bed_clab_amt float64 = 0
  1577. var bed_other_amt float64 = 0
  1578. var operation_claa_sunmfee float64 = 0
  1579. var operation_clab_amt float64 = 0
  1580. var operation_other_amt float64 = 0
  1581. var other_claa_sunmfee float64 = 0
  1582. var other_clab_amt float64 = 0
  1583. var other_other_amt float64 = 0
  1584. var westernMedicine_claa_sunmfee float64 = 0
  1585. var westernMedicine_clab_amt float64 = 0
  1586. var westernMedicine_other_amt float64 = 0
  1587. var chineseTraditional_claa_sunmfee float64 = 0
  1588. var chineseTraditional_clab_amt float64 = 0
  1589. var chineseTraditional_other_amt float64 = 0
  1590. var check_claa_sunmfee float64 = 0
  1591. var check_clab_amt float64 = 0
  1592. var check_other_amt float64 = 0
  1593. var material_claa_sunmfee float64 = 0
  1594. var material_clab_amt float64 = 0
  1595. var material_other_amt float64 = 0
  1596. var laboratory_claa_sunmfee float64 = 0
  1597. var laboratory_clab_amt float64 = 0
  1598. var laboratory_other_amt float64 = 0
  1599. var treat_claa_sunmfee float64 = 0
  1600. var treat_clab_amt float64 = 0
  1601. var treat_other_amt float64 = 0
  1602. for _, item := range order.HisOrderInfo {
  1603. if item.MedChrgitmType == "01" { //床位费
  1604. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1605. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1606. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1607. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1608. if item.ChrgitmLv == "1" {
  1609. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1610. }
  1611. if item.ChrgitmLv == "2" {
  1612. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1613. }
  1614. if item.ChrgitmLv == "3" {
  1615. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1616. }
  1617. }
  1618. if item.MedChrgitmType == "03" { //检查费
  1619. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1620. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1621. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1622. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1623. if item.ChrgitmLv == "1" {
  1624. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1625. }
  1626. if item.ChrgitmLv == "2" {
  1627. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1628. }
  1629. if item.ChrgitmLv == "3" {
  1630. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1631. }
  1632. }
  1633. if item.MedChrgitmType == "04" { //化验费
  1634. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1635. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1636. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1637. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1638. if item.ChrgitmLv == "1" {
  1639. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1640. }
  1641. if item.ChrgitmLv == "2" {
  1642. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1643. }
  1644. if item.ChrgitmLv == "3" {
  1645. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1646. }
  1647. }
  1648. if item.MedChrgitmType == "05" { //治疗费
  1649. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1650. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1651. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1652. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1653. if item.ChrgitmLv == "1" {
  1654. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1655. }
  1656. if item.ChrgitmLv == "2" {
  1657. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1658. }
  1659. if item.ChrgitmLv == "3" {
  1660. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1661. }
  1662. }
  1663. if item.MedChrgitmType == "06" { //手术费
  1664. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1665. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1666. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1667. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1668. if item.ChrgitmLv == "1" {
  1669. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1670. }
  1671. if item.ChrgitmLv == "2" {
  1672. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1673. }
  1674. if item.ChrgitmLv == "3" {
  1675. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1676. }
  1677. }
  1678. if item.MedChrgitmType == "08" { //材料费
  1679. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1680. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1681. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1682. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1683. if item.ChrgitmLv == "1" {
  1684. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1685. }
  1686. if item.ChrgitmLv == "2" {
  1687. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1688. }
  1689. if item.ChrgitmLv == "3" {
  1690. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1691. }
  1692. }
  1693. if item.MedChrgitmType == "09" { //西药费
  1694. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1695. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1696. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1697. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1698. if item.ChrgitmLv == "1" {
  1699. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1700. }
  1701. if item.ChrgitmLv == "2" {
  1702. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1703. }
  1704. if item.ChrgitmLv == "3" {
  1705. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1706. }
  1707. }
  1708. if item.MedChrgitmType == "11" { //中成费
  1709. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1710. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1711. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1712. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1713. if item.ChrgitmLv == "1" {
  1714. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1715. }
  1716. if item.ChrgitmLv == "2" {
  1717. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1718. }
  1719. if item.ChrgitmLv == "3" {
  1720. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1721. }
  1722. }
  1723. if item.MedChrgitmType == "14" { //其他费
  1724. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1725. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1726. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1727. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1728. if item.ChrgitmLv == "1" {
  1729. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1730. }
  1731. if item.ChrgitmLv == "2" {
  1732. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1733. }
  1734. if item.ChrgitmLv == "3" {
  1735. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1736. }
  1737. }
  1738. }
  1739. var iteminfoStructs []service.IteminfoStruct
  1740. if bedCostTotal != 0 {
  1741. iteminfo.MedChrgitm = "01"
  1742. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1743. iteminfo.Amt = bedCostTotal
  1744. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1745. iteminfo.ClabAmt = bed_clab_amt
  1746. iteminfo.OthAmt = bed_other_amt
  1747. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1748. }
  1749. if checkCostTotal != 0 {
  1750. iteminfo.MedChrgitm = "03"
  1751. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1752. iteminfo.Amt = checkCostTotal
  1753. iteminfo.ClaaSumfee = check_claa_sunmfee
  1754. iteminfo.ClabAmt = check_clab_amt
  1755. iteminfo.OthAmt = check_other_amt
  1756. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1757. }
  1758. if laboratoryCostTotal != 0 {
  1759. iteminfo.MedChrgitm = "04"
  1760. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1761. iteminfo.Amt = laboratoryCostTotal
  1762. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1763. iteminfo.ClabAmt = laboratory_clab_amt
  1764. iteminfo.OthAmt = laboratory_other_amt
  1765. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1766. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1767. }
  1768. if treatCostTotal != 0 {
  1769. iteminfo.MedChrgitm = "05"
  1770. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1771. iteminfo.Amt = treatCostTotal
  1772. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1773. iteminfo.ClabAmt = treat_clab_amt
  1774. iteminfo.OthAmt = treat_other_amt
  1775. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1776. //(struct4101.IteminfoStruct, iteminfo)
  1777. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1778. }
  1779. if operationCostTotal != 0 {
  1780. iteminfo.MedChrgitm = "06"
  1781. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1782. iteminfo.Amt = operationCostTotal
  1783. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1784. iteminfo.ClabAmt = operation_clab_amt
  1785. iteminfo.OthAmt = operation_other_amt
  1786. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1787. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1788. }
  1789. if materialCostTotal != 0 {
  1790. iteminfo.MedChrgitm = "08"
  1791. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1792. iteminfo.Amt = materialCostTotal
  1793. iteminfo.ClaaSumfee = material_claa_sunmfee
  1794. iteminfo.ClabAmt = material_clab_amt
  1795. iteminfo.OthAmt = material_other_amt
  1796. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1797. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1798. }
  1799. if westernMedicineCostTotal != 0 {
  1800. iteminfo.MedChrgitm = "09"
  1801. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1802. iteminfo.Amt = westernMedicineCostTotal
  1803. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1804. iteminfo.ClabAmt = westernMedicine_clab_amt
  1805. iteminfo.OthAmt = westernMedicine_other_amt
  1806. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1807. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1808. }
  1809. if chineseTraditionalMedicineCostTotal != 0 {
  1810. iteminfo.MedChrgitm = "11"
  1811. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1812. iteminfo.Amt = westernMedicineCostTotal
  1813. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1814. iteminfo.ClabAmt = westernMedicine_clab_amt
  1815. iteminfo.OthAmt = westernMedicine_other_amt
  1816. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1817. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1818. }
  1819. if otherCostTotal != 0 {
  1820. iteminfo.MedChrgitm = "14"
  1821. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1822. iteminfo.Amt = otherCostTotal
  1823. iteminfo.ClaaSumfee = other_claa_sunmfee
  1824. iteminfo.ClabAmt = other_clab_amt
  1825. iteminfo.OthAmt = other_other_amt
  1826. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1827. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1828. }
  1829. struct4101.IteminfoStruct = iteminfoStructs
  1830. struct4101.Ntly = "中国"
  1831. struct4101.AdmCaty = "A03.06"
  1832. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  1833. fmt.Println(result)
  1834. var dat map[string]interface{}
  1835. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1836. fmt.Println(dat)
  1837. } else {
  1838. fmt.Println(err)
  1839. }
  1840. userJSONBytes, _ := json.Marshal(dat)
  1841. var res ResultSeventeen
  1842. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1843. utils.ErrorLog("解析失败:%v", err)
  1844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1845. return
  1846. }
  1847. if res.Infcode != 0 {
  1848. c.ServeSuccessJSON(map[string]interface{}{
  1849. "failed_code": -10,
  1850. "msg": res.ErrMsg,
  1851. })
  1852. return
  1853. } else {
  1854. order.FaPiaoNumber = zero
  1855. order.FaPiaoCode = last_order.FaPiaoCode
  1856. service.UpdateOrder(order)
  1857. hisFundSettleListResult := &models.HisFundSettleListResult{
  1858. Number: res.Output.SetlListId,
  1859. Status: 1,
  1860. Ctime: time.Now().Unix(),
  1861. Mtime: time.Now().Unix(),
  1862. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1863. IsUpload: 1,
  1864. OrderId: order_id,
  1865. }
  1866. service.CreateUploadRecord(hisFundSettleListResult)
  1867. c.ServeSuccessJSON(map[string]interface{}{
  1868. "msg": "上传成功",
  1869. "result": hisFundSettleListResult,
  1870. })
  1871. return
  1872. }
  1873. }
  1874. func (c *HisApiController) GetSettleListHospital() {
  1875. order_id, _ := c.GetInt64("order_id")
  1876. admin_user_id, _ := c.GetInt64("admin_user_id")
  1877. order, _ := service.GetHisOrderByIDTwo(order_id)
  1878. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1879. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1880. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1881. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1882. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1883. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1884. if order.ID == 0 {
  1885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1886. return
  1887. }
  1888. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1889. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1890. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1891. fmt.Println(count)
  1892. var zero string
  1893. number := count + 1
  1894. if number >= 1000 {
  1895. zero = "0000" + strconv.FormatInt(number, 10)
  1896. } else if number >= 10000 {
  1897. zero = "000" + strconv.FormatInt(number, 10)
  1898. } else if number >= 100000 {
  1899. zero = "00" + strconv.FormatInt(number, 10)
  1900. } else if number >= 1000000 {
  1901. zero = "0" + strconv.FormatInt(number, 10)
  1902. } else {
  1903. zero = strconv.FormatInt(number, 10)
  1904. }
  1905. fmt.Println(zero)
  1906. struct4101 := service.Struct4101{
  1907. PsnNo: order.PsnNo,
  1908. MdtrtId: order.MdtrtId,
  1909. SetlId: order.SetlId,
  1910. PsnName: order.PsnName,
  1911. Gend: order.Gend,
  1912. Brdy: his.Brdy,
  1913. Age: int64(order.Age),
  1914. Naty: order.Naty,
  1915. PatnCertType: "01",
  1916. Certno: order.Certno,
  1917. Prfs: "90",
  1918. ConerName: roles[0].UserName,
  1919. PatnRlts: "99",
  1920. ConerAddr: miConfig.OrgName,
  1921. ConerTel: admin.Mobile,
  1922. HiType: order.Insutype,
  1923. Insuplc: miConfig.InsuplcAdmdvs,
  1924. MaindiagFlag: "1",
  1925. BillCode: last_order.FaPiaoCode,
  1926. BillNo: zero,
  1927. BizSn: order.Number,
  1928. PsnSelfPay: order.PsnPartAmt,
  1929. PsnOwnPay: order.PsnPartAmt,
  1930. AcctPay: order.AcctPay,
  1931. PsnCashpay: order.PsnCashPay,
  1932. HiPaymtd: "1",
  1933. Hsorg: miConfig.InsuplcAdmdvs,
  1934. HsorgOpter: miConfig.InsuplcAdmdvs,
  1935. MedinsFillPsn: curRoles.UserName,
  1936. MedinsFillDept: depart.Name,
  1937. IptMedType: "2",
  1938. AdmTime: his.InHosptialTime,
  1939. AdmEndTime: his.OutHosptialTime,
  1940. }
  1941. struct4101.SetlBegnDate = order.SetlTime
  1942. struct4101.SetlEndDate = order.SetlTime
  1943. var rf []CustomFundPay
  1944. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1945. var tempFunPays []service.CustomStruct
  1946. for _, item := range rf {
  1947. var tempFunPay service.CustomStruct
  1948. tempFunPay.FundPayamt = item.FundPayamt
  1949. tempFunPay.FundPayType = item.FundPayType
  1950. tempFunPays = append(tempFunPays, tempFunPay)
  1951. }
  1952. struct4101.CustomStruct = tempFunPays
  1953. var tempDiaginfos []service.DiaginfoStructTwo
  1954. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1955. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1956. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1957. var config []*models.HisXtDiagnoseConfig
  1958. for _, item := range diagnosis_ids {
  1959. id, _ := strconv.ParseInt(item, 10, 64)
  1960. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1961. config = append(config, &diagnosisConfig)
  1962. }
  1963. for index, item := range config {
  1964. if index == 0 {
  1965. var tempDiaginfo service.DiaginfoStructTwo
  1966. tempDiaginfo.DiagCode = item.CountryCode
  1967. tempDiaginfo.DiagName = item.CountryContentName
  1968. tempDiaginfo.DiagType = "1"
  1969. tempDiaginfo.MaindiagFlag = "1"
  1970. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1971. } else {
  1972. var tempDiaginfo service.DiaginfoStructTwo
  1973. tempDiaginfo.DiagCode = item.CountryCode
  1974. tempDiaginfo.DiagName = item.CountryContentName
  1975. tempDiaginfo.DiagType = "2"
  1976. tempDiaginfo.MaindiagFlag = "0"
  1977. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1978. }
  1979. }
  1980. struct4101.Diseinfo = tempDiaginfos
  1981. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1982. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1983. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1984. tempOpspdiseinfo2.OprnOprtCode = ""
  1985. tempOpspdiseinfo2.OprnOprtName = ""
  1986. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1987. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1988. var iteminfo service.IteminfoStruct
  1989. var bedCostTotal float64 = 0 //床位总费
  1990. var bedCostSelfTotal float64 = 0 //床位自费
  1991. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1992. var operationCostTotal float64 = 0 //手术费
  1993. var operationCostSelfTotal float64 = 0 //手术费
  1994. var operationCostPartSelfTotal float64 = 0 //手术费
  1995. var otherCostTotal float64 = 0 //其他费用
  1996. var otherCostSelfTotal float64 = 0 //其他费用
  1997. var otherCostPartSelfTotal float64 = 0 //其他费用
  1998. var materialCostTotal float64 = 0 //材料费
  1999. var materialCostSelfTotal float64 = 0 //材料费
  2000. var materialCostPartSelfTotal float64 = 0 //材料费
  2001. var westernMedicineCostTotal float64 = 0 //西药费
  2002. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2003. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2004. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2005. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2006. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2007. var checkCostTotal float64 = 0 //检查费
  2008. var checkCostSelfTotal float64 = 0 //检查费
  2009. var checkCostPartSelfTotal float64 = 0 //检查费
  2010. var laboratoryCostTotal float64 = 0 //化验费
  2011. var laboratoryCostSelfTotal float64 = 0 //化验费
  2012. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2013. var treatCostTotal float64 = 0 //治疗费用
  2014. var treatCostSelfTotal float64 = 0 //治疗费用
  2015. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2016. decimal.DivisionPrecision = 2
  2017. var bed_fulamt_ownpay_amt float64 = 0
  2018. var operation_fulamt_ownpay_amt float64 = 0
  2019. var other_fulamt_ownpay_amt float64 = 0
  2020. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2021. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2022. var check_fulamt_ownpay_amt float64 = 0
  2023. var material_fulamt_ownpay_amt float64 = 0
  2024. var laboratory_fulamt_ownpay_amt float64 = 0
  2025. var treat_fulamt_ownpay_amt float64 = 0
  2026. var bed_claa_sunmfee float64 = 0
  2027. var bed_clab_amt float64 = 0
  2028. var bed_other_amt float64 = 0
  2029. var operation_claa_sunmfee float64 = 0
  2030. var operation_clab_amt float64 = 0
  2031. var operation_other_amt float64 = 0
  2032. var other_claa_sunmfee float64 = 0
  2033. var other_clab_amt float64 = 0
  2034. var other_other_amt float64 = 0
  2035. var westernMedicine_claa_sunmfee float64 = 0
  2036. var westernMedicine_clab_amt float64 = 0
  2037. var westernMedicine_other_amt float64 = 0
  2038. var chineseTraditional_claa_sunmfee float64 = 0
  2039. var chineseTraditional_clab_amt float64 = 0
  2040. var chineseTraditional_other_amt float64 = 0
  2041. var check_claa_sunmfee float64 = 0
  2042. var check_clab_amt float64 = 0
  2043. var check_other_amt float64 = 0
  2044. var material_claa_sunmfee float64 = 0
  2045. var material_clab_amt float64 = 0
  2046. var material_other_amt float64 = 0
  2047. var laboratory_claa_sunmfee float64 = 0
  2048. var laboratory_clab_amt float64 = 0
  2049. var laboratory_other_amt float64 = 0
  2050. var treat_claa_sunmfee float64 = 0
  2051. var treat_clab_amt float64 = 0
  2052. var treat_other_amt float64 = 0
  2053. for _, item := range order.HisOrderInfo {
  2054. if item.MedChrgitmType == "01" { //床位费
  2055. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2056. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2057. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2058. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2059. if item.ChrgitmLv == "1" {
  2060. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2061. }
  2062. if item.ChrgitmLv == "2" {
  2063. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2064. }
  2065. if item.ChrgitmLv == "3" {
  2066. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2067. }
  2068. }
  2069. if item.MedChrgitmType == "03" { //检查费
  2070. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2071. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2072. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2073. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2074. if item.ChrgitmLv == "1" {
  2075. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2076. }
  2077. if item.ChrgitmLv == "2" {
  2078. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2079. }
  2080. if item.ChrgitmLv == "3" {
  2081. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2082. }
  2083. }
  2084. if item.MedChrgitmType == "04" { //化验费
  2085. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2086. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2087. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2088. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2089. if item.ChrgitmLv == "1" {
  2090. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2091. }
  2092. if item.ChrgitmLv == "2" {
  2093. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2094. }
  2095. if item.ChrgitmLv == "3" {
  2096. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2097. }
  2098. }
  2099. if item.MedChrgitmType == "05" { //治疗费
  2100. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2101. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2102. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2103. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2104. if item.ChrgitmLv == "1" {
  2105. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2106. }
  2107. if item.ChrgitmLv == "2" {
  2108. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2109. }
  2110. if item.ChrgitmLv == "3" {
  2111. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2112. }
  2113. }
  2114. if item.MedChrgitmType == "06" { //手术费
  2115. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2116. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2117. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2118. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2119. if item.ChrgitmLv == "1" {
  2120. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2121. }
  2122. if item.ChrgitmLv == "2" {
  2123. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2124. }
  2125. if item.ChrgitmLv == "3" {
  2126. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2127. }
  2128. }
  2129. if item.MedChrgitmType == "08" { //材料费
  2130. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2131. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2132. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2133. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2134. if item.ChrgitmLv == "1" {
  2135. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2136. }
  2137. if item.ChrgitmLv == "2" {
  2138. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2139. }
  2140. if item.ChrgitmLv == "3" {
  2141. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2142. }
  2143. }
  2144. if item.MedChrgitmType == "09" { //西药费
  2145. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2146. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2147. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2148. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2149. if item.ChrgitmLv == "1" {
  2150. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2151. }
  2152. if item.ChrgitmLv == "2" {
  2153. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2154. }
  2155. if item.ChrgitmLv == "3" {
  2156. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2157. }
  2158. }
  2159. if item.MedChrgitmType == "11" { //中成费
  2160. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2161. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2162. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2163. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2164. if item.ChrgitmLv == "1" {
  2165. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2166. }
  2167. if item.ChrgitmLv == "2" {
  2168. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2169. }
  2170. if item.ChrgitmLv == "3" {
  2171. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2172. }
  2173. }
  2174. if item.MedChrgitmType == "14" { //其他费
  2175. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2176. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2177. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2178. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2179. if item.ChrgitmLv == "1" {
  2180. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2181. }
  2182. if item.ChrgitmLv == "2" {
  2183. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2184. }
  2185. if item.ChrgitmLv == "3" {
  2186. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2187. }
  2188. }
  2189. }
  2190. var iteminfoStructs []service.IteminfoStruct
  2191. if bedCostTotal != 0 {
  2192. iteminfo.MedChrgitm = "01"
  2193. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2194. iteminfo.Amt = bedCostTotal
  2195. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2196. iteminfo.ClabAmt = bed_clab_amt
  2197. iteminfo.OthAmt = bed_other_amt
  2198. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2199. }
  2200. if checkCostTotal != 0 {
  2201. iteminfo.MedChrgitm = "03"
  2202. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2203. iteminfo.Amt = checkCostTotal
  2204. iteminfo.ClaaSumfee = check_claa_sunmfee
  2205. iteminfo.ClabAmt = check_clab_amt
  2206. iteminfo.OthAmt = check_other_amt
  2207. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2208. }
  2209. if laboratoryCostTotal != 0 {
  2210. iteminfo.MedChrgitm = "04"
  2211. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2212. iteminfo.Amt = laboratoryCostTotal
  2213. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2214. iteminfo.ClabAmt = laboratory_clab_amt
  2215. iteminfo.OthAmt = laboratory_other_amt
  2216. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2217. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2218. }
  2219. if treatCostTotal != 0 {
  2220. iteminfo.MedChrgitm = "05"
  2221. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2222. iteminfo.Amt = treatCostTotal
  2223. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2224. iteminfo.ClabAmt = treat_clab_amt
  2225. iteminfo.OthAmt = treat_other_amt
  2226. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2227. //(struct4101.IteminfoStruct, iteminfo)
  2228. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2229. }
  2230. if operationCostTotal != 0 {
  2231. iteminfo.MedChrgitm = "06"
  2232. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2233. iteminfo.Amt = operationCostTotal
  2234. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2235. iteminfo.ClabAmt = operation_clab_amt
  2236. iteminfo.OthAmt = operation_other_amt
  2237. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2238. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2239. }
  2240. if materialCostTotal != 0 {
  2241. iteminfo.MedChrgitm = "08"
  2242. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2243. iteminfo.Amt = materialCostTotal
  2244. iteminfo.ClaaSumfee = material_claa_sunmfee
  2245. iteminfo.ClabAmt = material_clab_amt
  2246. iteminfo.OthAmt = material_other_amt
  2247. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2248. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2249. }
  2250. if westernMedicineCostTotal != 0 {
  2251. iteminfo.MedChrgitm = "09"
  2252. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2253. iteminfo.Amt = westernMedicineCostTotal
  2254. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2255. iteminfo.ClabAmt = westernMedicine_clab_amt
  2256. iteminfo.OthAmt = westernMedicine_other_amt
  2257. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2258. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2259. }
  2260. if chineseTraditionalMedicineCostTotal != 0 {
  2261. iteminfo.MedChrgitm = "11"
  2262. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2263. iteminfo.Amt = westernMedicineCostTotal
  2264. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2265. iteminfo.ClabAmt = westernMedicine_clab_amt
  2266. iteminfo.OthAmt = westernMedicine_other_amt
  2267. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2268. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2269. }
  2270. if otherCostTotal != 0 {
  2271. iteminfo.MedChrgitm = "14"
  2272. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2273. iteminfo.Amt = otherCostTotal
  2274. iteminfo.ClaaSumfee = other_claa_sunmfee
  2275. iteminfo.ClabAmt = other_clab_amt
  2276. iteminfo.OthAmt = other_other_amt
  2277. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2278. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2279. }
  2280. struct4101.IteminfoStruct = iteminfoStructs
  2281. struct4101.Ntly = "中国"
  2282. struct4101.AdmCaty = "A03.06"
  2283. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2284. fmt.Println(result)
  2285. var dat map[string]interface{}
  2286. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2287. fmt.Println(dat)
  2288. } else {
  2289. fmt.Println(err)
  2290. }
  2291. userJSONBytes, _ := json.Marshal(dat)
  2292. var res ResultSeventeen
  2293. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2294. utils.ErrorLog("解析失败:%v", err)
  2295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2296. return
  2297. }
  2298. if res.Infcode != 0 {
  2299. c.ServeSuccessJSON(map[string]interface{}{
  2300. "failed_code": -10,
  2301. "msg": res.ErrMsg,
  2302. })
  2303. return
  2304. } else {
  2305. order.FaPiaoNumber = zero
  2306. order.FaPiaoCode = last_order.FaPiaoCode
  2307. service.UpdateOrder(order)
  2308. hisFundSettleListResult := &models.HisFundSettleListResult{
  2309. Number: res.Output.SetlListId,
  2310. Status: 1,
  2311. Ctime: time.Now().Unix(),
  2312. Mtime: time.Now().Unix(),
  2313. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2314. IsUpload: 1,
  2315. OrderId: order_id,
  2316. }
  2317. service.CreateUploadRecord(hisFundSettleListResult)
  2318. c.ServeSuccessJSON(map[string]interface{}{
  2319. "msg": "上传成功",
  2320. "result": hisFundSettleListResult,
  2321. })
  2322. return
  2323. }
  2324. }
  2325. func (c *HisApiController) GetBatchSettleList() {
  2326. orders, _ := service.GetAllHisOrder(10106)
  2327. for _, item := range orders {
  2328. order_id := item.ID
  2329. order, _ := service.GetHisOrderByIDTwo(order_id)
  2330. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2331. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2332. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2333. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  2334. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2335. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2336. if order.ID == 0 {
  2337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2338. return
  2339. }
  2340. if his.BalanceAccountsType == 2 {
  2341. continue
  2342. }
  2343. struct4101 := service.Struct4101{
  2344. PsnNo: order.PsnNo,
  2345. MdtrtId: order.MdtrtId,
  2346. SetlId: order.SetlId,
  2347. PsnName: order.PsnName,
  2348. Gend: order.Gend,
  2349. Brdy: his.Brdy,
  2350. Age: his.Age,
  2351. Naty: order.Naty,
  2352. PatnCertType: "01",
  2353. Certno: order.Certno,
  2354. Prfs: "90",
  2355. ConerName: roles[0].UserName,
  2356. PatnRlts: "99",
  2357. ConerAddr: miConfig.OrgName,
  2358. ConerTel: admin.Mobile,
  2359. HiType: order.Insutype,
  2360. Insuplc: his.InsuplcAdmdvs,
  2361. MaindiagFlag: "1",
  2362. BillCode: order.FaPiaoCode,
  2363. BillNo: order.FaPiaoNumber,
  2364. BizSn: order.Number,
  2365. PsnSelfPay: order.PsnPartAmt,
  2366. PsnOwnPay: order.PsnPartAmt,
  2367. AcctPay: order.AcctPay,
  2368. PsnCashpay: order.PsnCashPay,
  2369. HiPaymtd: "1",
  2370. Hsorg: his.InsuplcAdmdvs,
  2371. HsorgOpter: his.InsuplcAdmdvs,
  2372. MedinsFillPsn: curRoles.UserName,
  2373. MedinsFillDept: depart.Name,
  2374. IptMedType: "2",
  2375. }
  2376. struct4101.SetlBegnDate = order.SetlTime
  2377. struct4101.SetlEndDate = order.SetlTime
  2378. //if order.SettleType == 1 {
  2379. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  2380. // dateStr := t.Format("2006-01-02")
  2381. // struct4101.SetlBegnDate = dateStr
  2382. // struct4101.SetlEndDate = dateStr
  2383. //} else {
  2384. // t := time.Unix(int64(order.SettleStartTime), 0)
  2385. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  2386. // dateStartStr := t.Format("2006-01-02")
  2387. // dateEndStr := t2.Format("2006-01-02")
  2388. // struct4101.SetlBegnDate = dateStartStr
  2389. // struct4101.SetlEndDate = dateEndStr
  2390. //}
  2391. var rf []CustomFundPay
  2392. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2393. var tempFunPays []service.CustomStruct
  2394. var tempFunPay610100 service.CustomStruct
  2395. for _, item := range rf {
  2396. if item.FundPayType == "610100" {
  2397. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  2398. tempFunPay610100.FundPayType = item.FundPayType
  2399. } else {
  2400. var tempFunPay service.CustomStruct
  2401. tempFunPay.FundPayamt = item.FundPayamt
  2402. tempFunPay.FundPayType = item.FundPayType
  2403. tempFunPays = append(tempFunPays, tempFunPay)
  2404. }
  2405. }
  2406. tempFunPays = append(tempFunPays, tempFunPay610100)
  2407. struct4101.CustomStruct = tempFunPays
  2408. var tempDiaginfos []service.DiaginfoStructTwo
  2409. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2410. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2411. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2412. var config []*models.HisXtDiagnoseConfig
  2413. for _, item := range diagnosis_ids {
  2414. id, _ := strconv.ParseInt(item, 10, 64)
  2415. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2416. config = append(config, &diagnosisConfig)
  2417. }
  2418. for index, item := range config {
  2419. if index == 0 {
  2420. var tempDiaginfo service.DiaginfoStructTwo
  2421. tempDiaginfo.DiagCode = item.CountryCode
  2422. tempDiaginfo.DiagName = item.CountryContentName
  2423. tempDiaginfo.DiagType = "1"
  2424. tempDiaginfo.MaindiagFlag = "1"
  2425. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2426. } else {
  2427. var tempDiaginfo service.DiaginfoStructTwo
  2428. tempDiaginfo.DiagCode = item.CountryCode
  2429. tempDiaginfo.DiagName = item.CountryContentName
  2430. tempDiaginfo.DiagType = "2"
  2431. tempDiaginfo.MaindiagFlag = "0"
  2432. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2433. }
  2434. }
  2435. struct4101.Diseinfo = tempDiaginfos
  2436. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2437. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2438. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2439. tempOpspdiseinfo2.OprnOprtCode = ""
  2440. tempOpspdiseinfo2.OprnOprtName = ""
  2441. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2442. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2443. var iteminfo service.IteminfoStruct
  2444. var bedCostTotal float64 = 0 //床位总费
  2445. var bedCostSelfTotal float64 = 0 //床位自费
  2446. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2447. var examineCostTotal float64 = 0 //诊查总费
  2448. var examineCostSelfTotal float64 = 0 //诊查自费
  2449. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  2450. var nursingCostTotal float64 = 0 //护理总费
  2451. var nursingCostSelfTotal float64 = 0 //护理自费
  2452. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  2453. var chineseMedicineCostTotal float64 = 0 //中成药
  2454. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  2455. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  2456. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  2457. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  2458. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  2459. var registerCostTotal float64 = 0 //一般诊疗费
  2460. var registerCostSelfTotal float64 = 0 //一般诊疗费
  2461. var registerPartSelfTotal float64 = 0 //一般诊疗费
  2462. var operationCostTotal float64 = 0 //手术费
  2463. var operationCostSelfTotal float64 = 0 //手术费
  2464. var operationCostPartSelfTotal float64 = 0 //手术费
  2465. var otherCostTotal float64 = 0 //其他费用
  2466. var otherCostSelfTotal float64 = 0 //其他费用
  2467. var otherCostPartSelfTotal float64 = 0 //其他费用
  2468. var materialCostTotal float64 = 0 //材料费
  2469. var materialCostSelfTotal float64 = 0 //材料费
  2470. var materialCostPartSelfTotal float64 = 0 //材料费
  2471. var westernMedicineCostTotal float64 = 0 //西药费
  2472. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2473. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2474. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2475. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2476. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2477. var checkCostTotal float64 = 0 //检查费
  2478. var checkCostSelfTotal float64 = 0 //检查费
  2479. var checkCostPartSelfTotal float64 = 0 //检查费
  2480. var laboratoryCostTotal float64 = 0 //化验费
  2481. var laboratoryCostSelfTotal float64 = 0 //化验费
  2482. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2483. var treatCostTotal float64 = 0 //治疗费用
  2484. var treatCostSelfTotal float64 = 0 //治疗费用
  2485. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2486. decimal.DivisionPrecision = 2
  2487. var bed_fulamt_ownpay_amt float64 = 0
  2488. var examine_fulamt_ownpay_amt float64 = 0
  2489. var nursing_fulamt_ownpay_amt float64 = 0
  2490. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  2491. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  2492. var register_fulamt_ownpay_amt float64 = 0
  2493. var operation_fulamt_ownpay_amt float64 = 0
  2494. var other_fulamt_ownpay_amt float64 = 0
  2495. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2496. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2497. var check_fulamt_ownpay_amt float64 = 0
  2498. var material_fulamt_ownpay_amt float64 = 0
  2499. var laboratory_fulamt_ownpay_amt float64 = 0
  2500. var treat_fulamt_ownpay_amt float64 = 0
  2501. var bed_claa_sunmfee float64 = 0
  2502. var bed_clab_amt float64 = 0
  2503. var bed_other_amt float64 = 0
  2504. var examine_claa_sunmfee float64 = 0
  2505. var examine_clab_amt float64 = 0
  2506. var examine_other_amt float64 = 0
  2507. var nursing_claa_sunmfee float64 = 0
  2508. var nursing_clab_amt float64 = 0
  2509. var nursing_other_amt float64 = 0
  2510. var chinese_medicine_claa_sunmfee float64 = 0
  2511. var chinese_medicine_clab_amt float64 = 0
  2512. var chinese_medicine_other_amt float64 = 0
  2513. var commonly_treatment_claa_sunmfee float64 = 0
  2514. var commonly_treatment_clab_amt float64 = 0
  2515. var commonly_treatment_other_amt float64 = 0
  2516. var operation_claa_sunmfee float64 = 0
  2517. var operation_clab_amt float64 = 0
  2518. var operation_other_amt float64 = 0
  2519. var other_claa_sunmfee float64 = 0
  2520. var other_clab_amt float64 = 0
  2521. var other_other_amt float64 = 0
  2522. var westernMedicine_claa_sunmfee float64 = 0
  2523. var westernMedicine_clab_amt float64 = 0
  2524. var westernMedicine_other_amt float64 = 0
  2525. var chineseTraditional_claa_sunmfee float64 = 0
  2526. var chineseTraditional_clab_amt float64 = 0
  2527. var chineseTraditional_other_amt float64 = 0
  2528. var check_claa_sunmfee float64 = 0
  2529. var check_clab_amt float64 = 0
  2530. var check_other_amt float64 = 0
  2531. var material_claa_sunmfee float64 = 0
  2532. var material_clab_amt float64 = 0
  2533. var material_other_amt float64 = 0
  2534. var laboratory_claa_sunmfee float64 = 0
  2535. var laboratory_clab_amt float64 = 0
  2536. var laboratory_other_amt float64 = 0
  2537. var treat_claa_sunmfee float64 = 0
  2538. var treat_clab_amt float64 = 0
  2539. var treat_other_amt float64 = 0
  2540. var register_claa_sunmfee float64 = 0
  2541. var register_clab_amt float64 = 0
  2542. var register_other_amt float64 = 0
  2543. for _, item := range order.HisOrderInfo {
  2544. if item.MedChrgitmType == "01" { //床位费
  2545. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2546. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2547. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2548. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2549. if item.ChrgitmLv == "1" {
  2550. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2551. }
  2552. if item.ChrgitmLv == "2" {
  2553. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2554. }
  2555. if item.ChrgitmLv == "3" {
  2556. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2557. }
  2558. }
  2559. if item.MedChrgitmType == "02" { //诊查
  2560. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2561. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2562. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2563. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2564. if item.ChrgitmLv == "1" {
  2565. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2566. }
  2567. if item.ChrgitmLv == "2" {
  2568. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2569. }
  2570. if item.ChrgitmLv == "3" {
  2571. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2572. }
  2573. }
  2574. if item.MedChrgitmType == "03" { //检查费
  2575. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2576. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2577. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2578. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2579. if item.ChrgitmLv == "1" {
  2580. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2581. }
  2582. if item.ChrgitmLv == "2" {
  2583. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2584. }
  2585. if item.ChrgitmLv == "3" {
  2586. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2587. }
  2588. }
  2589. if item.MedChrgitmType == "04" { //化验费
  2590. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2591. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2592. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2593. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2594. if item.ChrgitmLv == "1" {
  2595. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2596. }
  2597. if item.ChrgitmLv == "2" {
  2598. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2599. }
  2600. if item.ChrgitmLv == "3" {
  2601. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2602. }
  2603. }
  2604. if item.MedChrgitmType == "05" { //治疗费
  2605. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2606. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2607. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2608. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2609. if item.ChrgitmLv == "1" {
  2610. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2611. }
  2612. if item.ChrgitmLv == "2" {
  2613. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2614. }
  2615. if item.ChrgitmLv == "3" {
  2616. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2617. }
  2618. }
  2619. if item.MedChrgitmType == "06" { //手术费
  2620. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2621. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2622. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2623. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2624. if item.ChrgitmLv == "1" {
  2625. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2626. }
  2627. if item.ChrgitmLv == "2" {
  2628. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2629. }
  2630. if item.ChrgitmLv == "3" {
  2631. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2632. }
  2633. }
  2634. if item.MedChrgitmType == "07" { //手术费
  2635. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2636. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2637. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2638. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2639. if item.ChrgitmLv == "1" {
  2640. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2641. }
  2642. if item.ChrgitmLv == "2" {
  2643. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2644. }
  2645. if item.ChrgitmLv == "3" {
  2646. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2647. }
  2648. }
  2649. if item.MedChrgitmType == "08" { //材料费
  2650. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2651. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2652. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2653. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2654. if item.ChrgitmLv == "1" {
  2655. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2656. }
  2657. if item.ChrgitmLv == "2" {
  2658. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2659. }
  2660. if item.ChrgitmLv == "3" {
  2661. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2662. }
  2663. }
  2664. if item.MedChrgitmType == "09" { //西药费
  2665. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2666. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2667. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2668. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2669. if item.ChrgitmLv == "1" {
  2670. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2671. }
  2672. if item.ChrgitmLv == "2" {
  2673. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2674. }
  2675. if item.ChrgitmLv == "3" {
  2676. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2677. }
  2678. }
  2679. if item.MedChrgitmType == "10" { //中药饮片
  2680. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2681. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2682. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2683. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2684. if item.ChrgitmLv == "1" {
  2685. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2686. }
  2687. if item.ChrgitmLv == "2" {
  2688. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2689. }
  2690. if item.ChrgitmLv == "3" {
  2691. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2692. }
  2693. }
  2694. if item.MedChrgitmType == "11" { //中成费
  2695. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2696. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2697. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2698. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2699. if item.ChrgitmLv == "1" {
  2700. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2701. }
  2702. if item.ChrgitmLv == "2" {
  2703. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2704. }
  2705. if item.ChrgitmLv == "3" {
  2706. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2707. }
  2708. }
  2709. if item.MedChrgitmType == "12" { //中成费
  2710. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2711. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2712. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2713. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2714. if item.ChrgitmLv == "1" {
  2715. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2716. }
  2717. if item.ChrgitmLv == "2" {
  2718. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2719. }
  2720. if item.ChrgitmLv == "3" {
  2721. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2722. }
  2723. }
  2724. if item.MedChrgitmType == "13" { //中成费
  2725. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2726. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2727. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2728. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2729. if item.ChrgitmLv == "1" {
  2730. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2731. }
  2732. if item.ChrgitmLv == "2" {
  2733. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2734. }
  2735. if item.ChrgitmLv == "3" {
  2736. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2737. }
  2738. }
  2739. if item.MedChrgitmType == "14" { //其他费
  2740. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2741. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2742. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2743. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2744. if item.ChrgitmLv == "1" {
  2745. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2746. }
  2747. if item.ChrgitmLv == "2" {
  2748. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2749. }
  2750. if item.ChrgitmLv == "3" {
  2751. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2752. }
  2753. }
  2754. }
  2755. var iteminfoStructs []service.IteminfoStruct
  2756. if bedCostTotal != 0 {
  2757. iteminfo.MedChrgitm = "01"
  2758. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2759. iteminfo.Amt = bedCostTotal
  2760. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2761. iteminfo.ClabAmt = bed_clab_amt
  2762. iteminfo.OthAmt = bed_other_amt
  2763. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2764. }
  2765. if examineCostTotal != 0 {
  2766. iteminfo.MedChrgitm = "02"
  2767. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  2768. iteminfo.Amt = examineCostTotal
  2769. iteminfo.ClaaSumfee = examine_claa_sunmfee
  2770. iteminfo.ClabAmt = examine_clab_amt
  2771. iteminfo.OthAmt = examine_other_amt
  2772. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2773. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2774. }
  2775. if checkCostTotal != 0 {
  2776. iteminfo.MedChrgitm = "03"
  2777. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2778. iteminfo.Amt = checkCostTotal
  2779. iteminfo.ClaaSumfee = check_claa_sunmfee
  2780. iteminfo.ClabAmt = check_clab_amt
  2781. iteminfo.OthAmt = check_other_amt
  2782. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2783. }
  2784. if laboratoryCostTotal != 0 {
  2785. iteminfo.MedChrgitm = "04"
  2786. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2787. iteminfo.Amt = laboratoryCostTotal
  2788. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2789. iteminfo.ClabAmt = laboratory_clab_amt
  2790. iteminfo.OthAmt = laboratory_other_amt
  2791. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2792. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2793. }
  2794. if treatCostTotal != 0 {
  2795. iteminfo.MedChrgitm = "05"
  2796. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2797. iteminfo.Amt = treatCostTotal
  2798. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2799. iteminfo.ClabAmt = treat_clab_amt
  2800. iteminfo.OthAmt = treat_other_amt
  2801. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2802. //(struct4101.IteminfoStruct, iteminfo)
  2803. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2804. }
  2805. if operationCostTotal != 0 {
  2806. iteminfo.MedChrgitm = "06"
  2807. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2808. iteminfo.Amt = operationCostTotal
  2809. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2810. iteminfo.ClabAmt = operation_clab_amt
  2811. iteminfo.OthAmt = operation_other_amt
  2812. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2813. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2814. }
  2815. if nursingCostTotal != 0 {
  2816. iteminfo.MedChrgitm = "07"
  2817. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  2818. iteminfo.Amt = nursingCostTotal
  2819. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  2820. iteminfo.ClabAmt = nursing_clab_amt
  2821. iteminfo.OthAmt = nursing_other_amt
  2822. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2823. }
  2824. if materialCostTotal != 0 {
  2825. iteminfo.MedChrgitm = "08"
  2826. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2827. iteminfo.Amt = materialCostTotal
  2828. iteminfo.ClaaSumfee = material_claa_sunmfee
  2829. iteminfo.ClabAmt = material_clab_amt
  2830. iteminfo.OthAmt = material_other_amt
  2831. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2832. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2833. }
  2834. if westernMedicineCostTotal != 0 {
  2835. iteminfo.MedChrgitm = "09"
  2836. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2837. iteminfo.Amt = westernMedicineCostTotal
  2838. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2839. iteminfo.ClabAmt = westernMedicine_clab_amt
  2840. iteminfo.OthAmt = westernMedicine_other_amt
  2841. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2842. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2843. }
  2844. if chineseMedicineCostTotal != 0 {
  2845. iteminfo.MedChrgitm = "10"
  2846. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  2847. iteminfo.Amt = chineseMedicineCostTotal
  2848. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  2849. iteminfo.ClabAmt = chinese_medicine_clab_amt
  2850. iteminfo.OthAmt = chinese_medicine_other_amt
  2851. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2852. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2853. }
  2854. if chineseTraditionalMedicineCostTotal != 0 {
  2855. iteminfo.MedChrgitm = "11"
  2856. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2857. iteminfo.Amt = westernMedicineCostTotal
  2858. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2859. iteminfo.ClabAmt = westernMedicine_clab_amt
  2860. iteminfo.OthAmt = westernMedicine_other_amt
  2861. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2862. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2863. }
  2864. if commonlyTreatmentCostTotal != 0 {
  2865. iteminfo.MedChrgitm = "12"
  2866. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  2867. iteminfo.Amt = commonlyTreatmentCostTotal
  2868. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  2869. iteminfo.ClabAmt = commonly_treatment_clab_amt
  2870. iteminfo.OthAmt = commonly_treatment_other_amt
  2871. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2872. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2873. }
  2874. if registerCostTotal != 0 {
  2875. iteminfo.MedChrgitm = "13"
  2876. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  2877. iteminfo.Amt = registerCostTotal
  2878. iteminfo.ClaaSumfee = register_claa_sunmfee
  2879. iteminfo.ClabAmt = register_clab_amt
  2880. iteminfo.OthAmt = register_other_amt
  2881. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2882. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2883. }
  2884. if otherCostTotal != 0 {
  2885. iteminfo.MedChrgitm = "14"
  2886. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2887. iteminfo.Amt = otherCostTotal
  2888. iteminfo.ClaaSumfee = other_claa_sunmfee
  2889. iteminfo.ClabAmt = other_clab_amt
  2890. iteminfo.OthAmt = other_other_amt
  2891. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2892. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2893. }
  2894. struct4101.IteminfoStruct = iteminfoStructs
  2895. struct4101.Ntly = "中国"
  2896. struct4101.AdmCaty = "A03.06"
  2897. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  2898. fmt.Println(result)
  2899. var dat map[string]interface{}
  2900. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2901. fmt.Println(dat)
  2902. } else {
  2903. fmt.Println(err)
  2904. }
  2905. userJSONBytes, _ := json.Marshal(dat)
  2906. var res ResultSeventeen
  2907. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2908. utils.ErrorLog("解析失败:%v", err)
  2909. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2910. adminUser := c.GetAdminUserInfo()
  2911. errlog := &models.HisOrderError{
  2912. UserOrgId: adminUser.CurrentOrgId,
  2913. Ctime: time.Now().Unix(),
  2914. Mtime: time.Now().Unix(),
  2915. ErrMsg: res.ErrMsg + "解析失败",
  2916. Status: 1,
  2917. PatientId: order_id,
  2918. Stage: 10106,
  2919. }
  2920. service.CreateErrMsgLog(errlog)
  2921. continue
  2922. }
  2923. if res.Infcode != 0 {
  2924. adminUser := c.GetAdminUserInfo()
  2925. errlog := &models.HisOrderError{
  2926. UserOrgId: adminUser.CurrentOrgId,
  2927. Ctime: time.Now().Unix(),
  2928. Mtime: time.Now().Unix(),
  2929. ErrMsg: res.ErrMsg,
  2930. Status: 1,
  2931. PatientId: order_id,
  2932. Stage: 10106,
  2933. }
  2934. service.CreateErrMsgLog(errlog)
  2935. continue
  2936. } else {
  2937. hisFundSettleListResult := &models.HisFundSettleListResult{
  2938. Number: res.Output.SetlListId,
  2939. Status: 1,
  2940. Ctime: time.Now().Unix(),
  2941. Mtime: time.Now().Unix(),
  2942. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2943. IsUpload: 1,
  2944. OrderId: order_id,
  2945. }
  2946. service.CreateUploadRecord(hisFundSettleListResult)
  2947. continue
  2948. }
  2949. }
  2950. }
  2951. func (c *HisApiController) GetOrgInfo() {
  2952. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  2953. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  2954. }
  2955. func (c *HisApiController) GetHisPatientInfo() {
  2956. medical_insurance_card := c.GetString("medical_insurance_card")
  2957. id_card_type, _ := c.GetInt64("id_card_type")
  2958. id_card := c.GetString("id_card")
  2959. adminInfo := c.GetAdminUserInfo()
  2960. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  2961. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  2962. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  2963. IdCardNo := ""
  2964. if id_card_type == 1 {
  2965. IdCardNo = medical_insurance_card
  2966. } else if id_card_type == 2 {
  2967. IdCardNo = id_card
  2968. }
  2969. if config.IsOpen == 1 {
  2970. 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
  2971. resp, requestErr := http.Get(api)
  2972. if requestErr != nil {
  2973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2974. return
  2975. }
  2976. defer resp.Body.Close()
  2977. body, ioErr := ioutil.ReadAll(resp.Body)
  2978. if ioErr != nil {
  2979. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2981. return
  2982. }
  2983. var respJSON map[string]interface{}
  2984. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2985. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2987. return
  2988. }
  2989. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2990. userJSONBytes, _ := json.Marshal(userJSON)
  2991. var res ResultTwo
  2992. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2993. utils.ErrorLog("解析失败:%v", err)
  2994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2995. return
  2996. }
  2997. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2998. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2999. infoStr := string(Iinfos)
  3000. idetinfoStr := string(Idetinfos)
  3001. if res.Infcode == 0 {
  3002. his := models.VMHisPatient{
  3003. Status: 1,
  3004. Ctime: time.Now().Unix(),
  3005. Mtime: time.Now().Unix(),
  3006. PsnNo: res.Output.Baseinfo.PsnNo,
  3007. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3008. Certno: res.Output.Baseinfo.Certno,
  3009. PsnName: res.Output.Baseinfo.PsnName,
  3010. Gend: res.Output.Baseinfo.Gend,
  3011. Naty: res.Output.Baseinfo.Naty,
  3012. Brdy: res.Output.Baseinfo.Brdy,
  3013. Age: res.Output.Baseinfo.Age,
  3014. Iinfo: infoStr,
  3015. Idetinfo: idetinfoStr,
  3016. UserOrgId: adminInfo.CurrentOrgId,
  3017. IsReturn: 1,
  3018. IdCardType: id_card_type,
  3019. }
  3020. c.ServeSuccessJSON(map[string]interface{}{
  3021. "info": his,
  3022. })
  3023. } else {
  3024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3025. return
  3026. }
  3027. }
  3028. }
  3029. //func GetBasBaseInfo() (jsonStr string, err error) {
  3030. //
  3031. // handle := syscall.NewLazyDLL("SSCard.dll")
  3032. // add := handle.NewProc("ReadCardBas")
  3033. // str := make([]byte, 1024)
  3034. // str1 := make([]byte, 1024)
  3035. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3036. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3037. //
  3038. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3039. //
  3040. // fmt.Println("> Add(4,5)的结果为:", ret)
  3041. // handle.Release()
  3042. //
  3043. // return "", nil
  3044. //
  3045. //}
  3046. //func GetQRBaseInfo() (jsonStr string, err error) {
  3047. // handle := syscall.LoadDLL("SSCard.dll")
  3048. // ReadCardBas := handle.FindProc("GetQRBase")
  3049. //
  3050. // str := make([]byte, 256)
  3051. // str1 := make([]byte, 256)
  3052. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3053. //
  3054. // fmt.Println(string(str))
  3055. // fmt.Println(r)
  3056. // return string(str), nil
  3057. //}
  3058. //func CardInit() int {
  3059. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  3060. // add := DllTestDef.MustFindProc("Init")
  3061. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3062. // if err != nil {
  3063. // fmt.Println("SSCard的运算结果为:", ret)
  3064. // }
  3065. // result := int(ret)
  3066. // return result
  3067. //}
  3068. //func CardInit() int {
  3069. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3070. // if err != nil {
  3071. // fmt.Println("SSCard的运算结果为:", ret)
  3072. // }
  3073. // fmt.Println(err)
  3074. // result := int(ret)
  3075. // return result
  3076. //}
  3077. func IntPtr(n int) uintptr {
  3078. return uintptr(n)
  3079. }
  3080. func StrPtr(s string) uintptr {
  3081. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3082. }
  3083. type Result2001 struct {
  3084. Cainfo interface{} `json:"cainfo"`
  3085. ErrMsg string `json:"err_msg"`
  3086. InfRefmsgid string `json:"inf_refmsgid"`
  3087. Infcode int64 `json:"infcode"`
  3088. Output struct {
  3089. Trtinfo struct {
  3090. PsnNo string `json:"psn_no"`
  3091. TrtChkType string `json:"trt_chk_type"`
  3092. FundPayType string `json:"fund_pay_type"`
  3093. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3094. Begndate string `json:"begndate"`
  3095. Enddate string `json:"enddate"`
  3096. TrtChkRslt string `json:"trt_chk_rslt"`
  3097. } `json:"trtinfo"`
  3098. } `json:"output"`
  3099. RefmsgTime string `json:"refmsg_time"`
  3100. RespondTime string `json:"respond_time"`
  3101. Signtype interface{} `json:"signtype"`
  3102. WarnMsg interface{} `json:"warn_msg"`
  3103. }
  3104. type Result2001Org10265 struct {
  3105. Cainfo interface{} `json:"cainfo"`
  3106. ErrMsg string `json:"err_msg"`
  3107. InfRefmsgid string `json:"inf_refmsgid"`
  3108. Infcode string `json:"infcode"`
  3109. Output struct {
  3110. Trtinfo struct {
  3111. PsnNo string `json:"psn_no"`
  3112. TrtChkType string `json:"trt_chk_type"`
  3113. FundPayType string `json:"fund_pay_type"`
  3114. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3115. Begndate string `json:"begndate"`
  3116. Enddate string `json:"enddate"`
  3117. TrtChkRslt string `json:"trt_chk_rslt"`
  3118. } `json:"trtinfo"`
  3119. } `json:"output"`
  3120. RefmsgTime string `json:"refmsg_time"`
  3121. RespondTime string `json:"respond_time"`
  3122. Signtype interface{} `json:"signtype"`
  3123. WarnMsg interface{} `json:"warn_msg"`
  3124. }
  3125. type ResultTwo struct {
  3126. ErrMsg string `json:"err_msg"`
  3127. InfRefmsgid string `json:"inf_refmsgid"`
  3128. Infcode int64 `json:"infcode"`
  3129. Output struct {
  3130. Baseinfo struct {
  3131. Age float64 `json:"age"`
  3132. Brdy string `json:"brdy"`
  3133. Certno string `json:"certno"`
  3134. Gend string `json:"gend"`
  3135. Naty string `json:"naty"`
  3136. PsnCertType string `json:"psn_cert_type"`
  3137. PsnName string `json:"psn_name"`
  3138. PsnNo string `json:"psn_no"`
  3139. } `json:"baseinfo"`
  3140. Idetinfo []interface{} `json:"idetinfo"`
  3141. Iinfo []struct {
  3142. Balc float64 `json:"balc"`
  3143. CvlservFlag string `json:"cvlserv_flag"`
  3144. EmpName string `json:"emp_name"`
  3145. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3146. Insutype string `json:"insutype"`
  3147. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3148. PausInsuDate string `json:"paus_insu_date"`
  3149. PsnInsuDate string `json:"psn_insu_date"`
  3150. PsnInsuStas string `json:"psn_insu_stas"`
  3151. PsnType string `json:"psn_type"`
  3152. } `json:"insuinfo"`
  3153. } `json:"output"`
  3154. RefmsgTime string `json:"refmsg_time"`
  3155. RespondTime string `json:"respond_time"`
  3156. Signtype interface{} `json:"signtype"`
  3157. WarnInfo interface{} `json:"warn_info"`
  3158. }
  3159. type ResultTwo10265 struct {
  3160. ErrMsg string `json:"err_msg"`
  3161. InfRefmsgid string `json:"inf_refmsgid"`
  3162. Infcode string `json:"infcode"`
  3163. Output struct {
  3164. Baseinfo struct {
  3165. Age float64 `json:"age"`
  3166. Brdy string `json:"brdy"`
  3167. Certno string `json:"certno"`
  3168. Gend string `json:"gend"`
  3169. Naty string `json:"naty"`
  3170. PsnCertType string `json:"psn_cert_type"`
  3171. PsnName string `json:"psn_name"`
  3172. PsnNo string `json:"psn_no"`
  3173. } `json:"baseinfo"`
  3174. Idetinfo []interface{} `json:"idetinfo"`
  3175. Iinfo []struct {
  3176. Balc float64 `json:"balc"`
  3177. CvlservFlag string `json:"cvlserv_flag"`
  3178. EmpName string `json:"emp_name"`
  3179. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3180. Insutype string `json:"insutype"`
  3181. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3182. PausInsuDate string `json:"paus_insu_date"`
  3183. PsnInsuDate string `json:"psn_insu_date"`
  3184. PsnInsuStas string `json:"psn_insu_stas"`
  3185. PsnType string `json:"psn_type"`
  3186. } `json:"insuinfo"`
  3187. } `json:"output"`
  3188. RefmsgTime string `json:"refmsg_time"`
  3189. RespondTime string `json:"respond_time"`
  3190. Signtype interface{} `json:"signtype"`
  3191. WarnInfo interface{} `json:"warn_info"`
  3192. }
  3193. type ResultThree struct {
  3194. Cainfo interface{} `json:"cainfo"`
  3195. ErrMsg string `json:"err_msg"`
  3196. InfRefmsgid string `json:"inf_refmsgid"`
  3197. Infcode int64 `json:"infcode"`
  3198. Output struct {
  3199. Data struct {
  3200. IptOtpNo string `json:"ipt_otp_no"`
  3201. MdtrtID string `json:"mdtrt_id"`
  3202. PsnNo string `json:"psn_no"`
  3203. } `json:"data"`
  3204. } `json:"output"`
  3205. RefmsgTime string `json:"refmsg_time"`
  3206. RespondTime string `json:"respond_time"`
  3207. Signtype interface{} `json:"signtype"`
  3208. WarnMsg interface{} `json:"warn_msg"`
  3209. }
  3210. type ResultThree10265 struct {
  3211. Cainfo interface{} `json:"cainfo"`
  3212. ErrMsg string `json:"err_msg"`
  3213. InfRefmsgid string `json:"inf_refmsgid"`
  3214. Infcode string `json:"infcode"`
  3215. Output struct {
  3216. Data struct {
  3217. IptOtpNo string `json:"ipt_otp_no"`
  3218. MdtrtID string `json:"mdtrt_id"`
  3219. PsnNo string `json:"psn_no"`
  3220. } `json:"data"`
  3221. } `json:"output"`
  3222. RefmsgTime string `json:"refmsg_time"`
  3223. RespondTime string `json:"respond_time"`
  3224. Signtype interface{} `json:"signtype"`
  3225. WarnMsg interface{} `json:"warn_msg"`
  3226. }
  3227. type ResultFour struct {
  3228. Cainfo string `json:"cainfo"`
  3229. ErrMsg string `json:"err_msg"`
  3230. InfRefmsgid string `json:"inf_refmsgid"`
  3231. Infcode int64 `json:"infcode"`
  3232. Output struct {
  3233. Result []struct {
  3234. BasMednFlag string `json:"bas_medn_flag"`
  3235. ChldMedcFlag string `json:"chld_medc_flag"`
  3236. ChrgitmLv string `json:"chrgitm_lv"`
  3237. Cnt float64 `json:"cnt"`
  3238. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3239. DrtReimFlag string `json:"drt_reim_flag"`
  3240. FeedetlSn string `json:"feedetl_sn"`
  3241. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3242. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3243. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3244. ListSpItemFlag string `json:"list_sp_item_flag"`
  3245. LmtUsedFlag string `json:"lmt_used_flag"`
  3246. MedChrgitmType string `json:"med_chrgitm_type"`
  3247. Memo string `json:"memo"`
  3248. OverlmtAmt float64 `json:"overlmt_amt"`
  3249. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3250. Pric float64 `json:"pric"`
  3251. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3252. SelfpayProp float64 `json:"selfpay_prop"`
  3253. } `json:"result"`
  3254. } `json:"output"`
  3255. RefmsgTime string `json:"refmsg_time"`
  3256. RespondTime string `json:"respond_time"`
  3257. Signtype string `json:"signtype"`
  3258. WarnMsg string `json:"warn_msg"`
  3259. }
  3260. type ResultFour10265 struct {
  3261. Cainfo string `json:"cainfo"`
  3262. ErrMsg string `json:"err_msg"`
  3263. InfRefmsgid string `json:"inf_refmsgid"`
  3264. Infcode string `json:"infcode"`
  3265. Output struct {
  3266. Result []struct {
  3267. BasMednFlag string `json:"bas_medn_flag"`
  3268. ChldMedcFlag string `json:"chld_medc_flag"`
  3269. ChrgitmLv string `json:"chrgitm_lv"`
  3270. Cnt float64 `json:"cnt"`
  3271. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3272. DrtReimFlag string `json:"drt_reim_flag"`
  3273. FeedetlSn string `json:"feedetl_sn"`
  3274. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3275. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3276. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3277. ListSpItemFlag string `json:"list_sp_item_flag"`
  3278. LmtUsedFlag string `json:"lmt_used_flag"`
  3279. MedChrgitmType string `json:"med_chrgitm_type"`
  3280. Memo string `json:"memo"`
  3281. OverlmtAmt float64 `json:"overlmt_amt"`
  3282. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3283. Pric float64 `json:"pric"`
  3284. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3285. SelfpayProp float64 `json:"selfpay_prop"`
  3286. } `json:"result"`
  3287. } `json:"output"`
  3288. RefmsgTime string `json:"refmsg_time"`
  3289. RespondTime string `json:"respond_time"`
  3290. Signtype string `json:"signtype"`
  3291. WarnMsg string `json:"warn_msg"`
  3292. }
  3293. type ResultFive struct {
  3294. Balc float64 `json:"balc"`
  3295. CvlservFlag string `json:"cvlserv_flag"`
  3296. EmpName string `json:"emp_name"`
  3297. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3298. Insutype string `json:"insutype"`
  3299. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3300. PausInsuDate string `json:"paus_insu_date"`
  3301. PsnInsuDate string `json:"psn_insu_date"`
  3302. PsnInsuStas string `json:"psn_insu_stas"`
  3303. PsnType string `json:"psn_type"`
  3304. }
  3305. type ResultSix struct {
  3306. Cainfo interface{} `json:"cainfo"`
  3307. ErrMsg string `json:"err_msg"`
  3308. InfRefmsgid string `json:"inf_refmsgid"`
  3309. Infcode int64 `json:"infcode"`
  3310. Output struct {
  3311. } `json:"output"`
  3312. RefmsgTime string `json:"refmsg_time"`
  3313. RespondTime string `json:"respond_time"`
  3314. Signtype interface{} `json:"signtype"`
  3315. WarnMsg interface{} `json:"warn_msg"`
  3316. }
  3317. type ResultSix10265 struct {
  3318. Cainfo interface{} `json:"cainfo"`
  3319. ErrMsg string `json:"err_msg"`
  3320. InfRefmsgid string `json:"inf_refmsgid"`
  3321. Infcode string `json:"infcode"`
  3322. Output struct {
  3323. } `json:"output"`
  3324. RefmsgTime string `json:"refmsg_time"`
  3325. RespondTime string `json:"respond_time"`
  3326. Signtype interface{} `json:"signtype"`
  3327. WarnMsg interface{} `json:"warn_msg"`
  3328. }
  3329. type ResultSeven struct {
  3330. Cainfo string `json:"cainfo"`
  3331. ErrMsg string `json:"err_msg"`
  3332. InfRefmsgid string `json:"inf_refmsgid"`
  3333. Infcode int64 `json:"infcode"`
  3334. Output struct {
  3335. Setldetail []interface{} `json:"setldetail"`
  3336. Setlinfo struct {
  3337. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3338. AcctPay float64 `json:"acct_pay"`
  3339. ActPayDedc float64 `json:"act_pay_dedc"`
  3340. Age float64 `json:"age"`
  3341. Balc float64 `json:"balc"`
  3342. Brdy string `json:"brdy"`
  3343. Certno string `json:"certno"`
  3344. ClrOptins string `json:"clr_optins"`
  3345. ClrType string `json:"clr_type"`
  3346. ClrWay string `json:"clr_way"`
  3347. CvlservFlag string `json:"cvlserv_flag"`
  3348. CvlservPay float64 `json:"cvlserv_pay"`
  3349. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3350. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3351. Gend string `json:"gend"`
  3352. HifesPay float64 `json:"hifes_pay"`
  3353. HifmiPay float64 `json:"hifmi_pay"`
  3354. HifpPay float64 `json:"hifp_pay"`
  3355. HospPartAmt float64 `json:"hosp_part_amt"`
  3356. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3357. Insutype string `json:"insutype"`
  3358. MafPay float64 `json:"maf_pay"`
  3359. MdtrtCertType string `json:"mdtrt_cert_type"`
  3360. HifobPay float64 `json:"hifob_pay"`
  3361. MdtrtID string `json:"mdtrt_id"`
  3362. MedType string `json:"med_type"`
  3363. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3364. MedinsSetlID string `json:"medins_setl_id"`
  3365. Naty string `json:"naty"`
  3366. OthPay float64 `json:"oth_pay"`
  3367. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3368. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3369. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3370. PsnCashPay float64 `json:"psn_cash_pay"`
  3371. PsnCertType string `json:"psn_cert_type"`
  3372. PsnName string `json:"psn_name"`
  3373. PsnNo string `json:"psn_no"`
  3374. PsnPartAmt float64 `json:"psn_part_amt"`
  3375. PsnType string `json:"psn_type"`
  3376. SetlID string `json:"setl_id"`
  3377. SetlTime string `json:"setl_time"`
  3378. } `json:"setlinfo"`
  3379. } `json:"output"`
  3380. RefmsgTime string `json:"refmsg_time"`
  3381. RespondTime string `json:"respond_time"`
  3382. Signtype interface{} `json:"signtype"`
  3383. WarnMsg interface{} `json:"warn_msg"`
  3384. }
  3385. type ResultSeven10265 struct {
  3386. Cainfo string `json:"cainfo"`
  3387. ErrMsg string `json:"err_msg"`
  3388. InfRefmsgid string `json:"inf_refmsgid"`
  3389. Infcode string `json:"infcode"`
  3390. Output struct {
  3391. Setldetail []interface{} `json:"setldetail"`
  3392. Setlinfo struct {
  3393. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3394. AcctPay float64 `json:"acct_pay"`
  3395. ActPayDedc float64 `json:"act_pay_dedc"`
  3396. Age float64 `json:"age"`
  3397. Balc float64 `json:"balc"`
  3398. Brdy string `json:"brdy"`
  3399. Certno string `json:"certno"`
  3400. ClrOptins string `json:"clr_optins"`
  3401. ClrType string `json:"clr_type"`
  3402. ClrWay string `json:"clr_way"`
  3403. CvlservFlag string `json:"cvlserv_flag"`
  3404. CvlservPay float64 `json:"cvlserv_pay"`
  3405. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3406. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3407. Gend string `json:"gend"`
  3408. HifesPay float64 `json:"hifes_pay"`
  3409. HifmiPay float64 `json:"hifmi_pay"`
  3410. HifpPay float64 `json:"hifp_pay"`
  3411. HospPartAmt float64 `json:"hosp_part_amt"`
  3412. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3413. Insutype string `json:"insutype"`
  3414. MafPay float64 `json:"maf_pay"`
  3415. MdtrtCertType string `json:"mdtrt_cert_type"`
  3416. HifobPay float64 `json:"hifob_pay"`
  3417. MdtrtID string `json:"mdtrt_id"`
  3418. MedType string `json:"med_type"`
  3419. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3420. MedinsSetlID string `json:"medins_setl_id"`
  3421. Naty string `json:"naty"`
  3422. OthPay float64 `json:"oth_pay"`
  3423. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3424. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3425. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3426. PsnCashPay float64 `json:"psn_cash_pay"`
  3427. PsnCertType string `json:"psn_cert_type"`
  3428. PsnName string `json:"psn_name"`
  3429. PsnNo string `json:"psn_no"`
  3430. PsnPartAmt float64 `json:"psn_part_amt"`
  3431. PsnType string `json:"psn_type"`
  3432. SetlID string `json:"setl_id"`
  3433. SetlTime string `json:"setl_time"`
  3434. } `json:"setlinfo"`
  3435. } `json:"output"`
  3436. RefmsgTime string `json:"refmsg_time"`
  3437. RespondTime string `json:"respond_time"`
  3438. Signtype interface{} `json:"signtype"`
  3439. WarnMsg interface{} `json:"warn_msg"`
  3440. }
  3441. type ResultEight struct {
  3442. Cainfo string `json:"cainfo"`
  3443. ErrMsg string `json:"err_msg"`
  3444. InfRefmsgid string `json:"inf_refmsgid"`
  3445. Infcode int64 `json:"infcode"`
  3446. Output struct {
  3447. Stmtinfo struct {
  3448. SetlOptins string `json:"setl_optins"`
  3449. StmtRslt string `json:"stmt_rslt"`
  3450. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3451. } `json:"stmtinfo"`
  3452. } `json:"output"`
  3453. RefmsgTime string `json:"refmsg_time"`
  3454. RespondTime string `json:"respond_time"`
  3455. Signtype interface{} `json:"signtype"`
  3456. WarnMsg interface{} `json:"warn_msg"`
  3457. }
  3458. type ResultEightFor10188 struct {
  3459. Cainfo string `json:"cainfo"`
  3460. ErrMsg string `json:"err_msg"`
  3461. InfRefmsgid string `json:"inf_refmsgid"`
  3462. Infcode string `json:"infcode"`
  3463. Output struct {
  3464. Stmtinfo struct {
  3465. SetlOptins string `json:"setl_optins"`
  3466. StmtRslt string `json:"stmt_rslt"`
  3467. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3468. } `json:"stmtinfo"`
  3469. } `json:"output"`
  3470. RefmsgTime string `json:"refmsg_time"`
  3471. RespondTime string `json:"respond_time"`
  3472. Signtype interface{} `json:"signtype"`
  3473. WarnMsg interface{} `json:"warn_msg"`
  3474. }
  3475. type ResultNine struct {
  3476. Cainfo string `json:"cainfo"`
  3477. ErrMsg string `json:"err_msg"`
  3478. InfRefmsgid string `json:"inf_refmsgid"`
  3479. Infcode int64 `json:"infcode"`
  3480. Output struct {
  3481. FileQuryNo string `json:"file_qury_no"`
  3482. } `json:"output"`
  3483. RefmsgTime string `json:"refmsg_time"`
  3484. RespondTime string `json:"respond_time"`
  3485. Signtype interface{} `json:"signtype"`
  3486. WarnMsg interface{} `json:"warn_msg"`
  3487. }
  3488. type ResultTen struct {
  3489. Cainfo string `json:"cainfo"`
  3490. ErrMsg string `json:"err_msg"`
  3491. InfRefmsgid string `json:"inf_refmsgid"`
  3492. Infcode int64 `json:"infcode"`
  3493. Output struct {
  3494. DldEndtime string `json:"dld_endtime"`
  3495. FileQuryNo string `json:"file_qury_no"`
  3496. Filename string `json:"filename"`
  3497. } `json:"output"`
  3498. RefmsgTime string `json:"refmsg_time"`
  3499. RespondTime string `json:"respond_time"`
  3500. Signtype interface{} `json:"signtype"`
  3501. WarnMsg interface{} `json:"warn_msg"`
  3502. }
  3503. //type Autogenerated struct {
  3504. // Output struct {
  3505. // Setlinfo struct {
  3506. // SetlTime string `json:"setl_time"`
  3507. // CvlservPay float64 `json:"cvlserv_pay"`
  3508. // Year string `json:"year"`
  3509. // MedType string `json:"med_type"`
  3510. // PsnPay float64 `json:"psn_pay"`
  3511. // OpterID string `json:"opter_id"`
  3512. // Begndate string `json:"begndate"`
  3513. // FlxempeFlag string `json:"flxempe_flag"`
  3514. // HifmiPay float64 `json:"hifmi_pay"`
  3515. // PsnNo string `json:"psn_no"`
  3516. // ActPayDedc float64 `json:"act_pay_dedc"`
  3517. // MedinsSetlID interface{} `json:"medins_setl_id"`
  3518. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3519. // ClrWay string `json:"clr_way"`
  3520. // OthPay float64 `json:"oth_pay"`
  3521. // Gend string `json:"gend"`
  3522. // MdtrtID string `json:"mdtrt_id"`
  3523. // AcctPay float64 `json:"acct_pay"`
  3524. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  3525. // Insutype string `json:"insutype"`
  3526. // Invono interface{} `json:"invono"`
  3527. // Enddate string `json:"enddate"`
  3528. // CashPayamt float64 `json:"cash_payamt"`
  3529. // PsnType string `json:"psn_type"`
  3530. // FixmedinsName string `json:"fixmedins_name"`
  3531. // HifpPay float64 `json:"hifp_pay"`
  3532. // NewFlag interface{} `json:"new_flag"`
  3533. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3534. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  3535. // PayLoc string `json:"pay_loc"`
  3536. // ClrType string `json:"clr_type"`
  3537. // RefdSetlFlag string `json:"refd_setl_flag"`
  3538. // CvlservFlag string `json:"cvlserv_flag"`
  3539. // EmpName string `json:"emp_name"`
  3540. // Brdy string `json:"brdy"`
  3541. // Naty string `json:"naty"`
  3542. // Certno string `json:"certno"`
  3543. // DiseCode string `json:"dise_code"`
  3544. // FixmedinsCode string `json:"fixmedins_code"`
  3545. // DedcHospLv string `json:"dedc_hosp_lv"`
  3546. // OpterName string `json:"opter_name"`
  3547. // Balc float64 `json:"balc"`
  3548. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3549. // PsnCertType string `json:"psn_cert_type"`
  3550. // HifobPay float64 `json:"hifob_pay"`
  3551. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  3552. // HifesPay float64 `json:"hifes_pay"`
  3553. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3554. // OptTime string `json:"opt_time"`
  3555. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3556. // SetlID string `json:"setl_id"`
  3557. // MafPay float64 `json:"maf_pay"`
  3558. // PsnName string `json:"psn_name"`
  3559. // InsuOptins interface{} `json:"insu_optins"`
  3560. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3561. // ClrOptins string `json:"clr_optins"`
  3562. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3563. // DiseName string `json:"dise_name"`
  3564. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3565. // Age float64 `json:"age"`
  3566. // DtrtCertType string `json:"dtrt_cert_type"`
  3567. // HospLv string `json:"hosp_lv"`
  3568. // } `json:"setlinfo"`
  3569. // Setldetail []struct {
  3570. // FundPayType string `json:"fund_pay_type"`
  3571. // FundPayamt float64 `json:"fund_payamt"`
  3572. // SetlProcInfo interface{} `json:"setl_proc_info"`
  3573. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  3574. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  3575. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  3576. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3577. // } `json:"setldetail"`
  3578. // } `json:"output"`
  3579. // Infcode int `json:"infcode"`
  3580. // WarnMsg interface{} `json:"warn_msg"`
  3581. // Cainfo interface{} `json:"cainfo"`
  3582. // ErrMsg interface{} `json:"err_msg"`
  3583. // RefmsgTime string `json:"refmsg_time"`
  3584. // Signtype interface{} `json:"signtype"`
  3585. // RespondTime string `json:"respond_time"`
  3586. // InfRefmsgid string `json:"inf_refmsgid"`
  3587. //}
  3588. type ResultEleven struct {
  3589. Cainfo string `json:"cainfo"`
  3590. ErrMsg string `json:"err_msg"`
  3591. InfRefmsgid string `json:"inf_refmsgid"`
  3592. Infcode int64 `json:"infcode"`
  3593. Output struct {
  3594. Setlinfo struct {
  3595. SetlTime string `json:"setl_time"`
  3596. CvlservPay float64 `json:"cvlserv_pay"`
  3597. Year string `json:"year"`
  3598. MedType string `json:"med_type"`
  3599. PsnPay float64 `json:"psn_pay"`
  3600. OpterID string `json:"opter_id"`
  3601. Begndate string `json:"begndate"`
  3602. FlxempeFlag string `json:"flxempe_flag"`
  3603. HifmiPay float64 `json:"hifmi_pay"`
  3604. PsnNo string `json:"psn_no"`
  3605. ActPayDedc float64 `json:"act_pay_dedc"`
  3606. MedinsSetlID interface{} `json:"medins_setl_id"`
  3607. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3608. ClrWay string `json:"clr_way"`
  3609. OthPay float64 `json:"oth_pay"`
  3610. Gend string `json:"gend"`
  3611. MdtrtID string `json:"mdtrt_id"`
  3612. AcctPay float64 `json:"acct_pay"`
  3613. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3614. Insutype string `json:"insutype"`
  3615. Invono interface{} `json:"invono"`
  3616. Enddate string `json:"enddate"`
  3617. CashPayamt float64 `json:"cash_payamt"`
  3618. PsnType string `json:"psn_type"`
  3619. FixmedinsName string `json:"fixmedins_name"`
  3620. HifpPay float64 `json:"hifp_pay"`
  3621. NewFlag interface{} `json:"new_flag"`
  3622. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3623. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3624. PayLoc string `json:"pay_loc"`
  3625. ClrType string `json:"clr_type"`
  3626. RefdSetlFlag string `json:"refd_setl_flag"`
  3627. CvlservFlag string `json:"cvlserv_flag"`
  3628. EmpName string `json:"emp_name"`
  3629. Brdy string `json:"brdy"`
  3630. Naty string `json:"naty"`
  3631. Certno string `json:"certno"`
  3632. DiseCode string `json:"dise_code"`
  3633. FixmedinsCode string `json:"fixmedins_code"`
  3634. DedcHospLv string `json:"dedc_hosp_lv"`
  3635. OpterName string `json:"opter_name"`
  3636. Balc float64 `json:"balc"`
  3637. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3638. PsnCertType string `json:"psn_cert_type"`
  3639. HifobPay float64 `json:"hifob_pay"`
  3640. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3641. HifesPay float64 `json:"hifes_pay"`
  3642. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3643. OptTime string `json:"opt_time"`
  3644. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3645. SetlID string `json:"setl_id"`
  3646. MafPay float64 `json:"maf_pay"`
  3647. PsnName string `json:"psn_name"`
  3648. InsuOptins interface{} `json:"insu_optins"`
  3649. PrefFundPay interface{} `json:"pref_fund_pay"`
  3650. ClrOptins string `json:"clr_optins"`
  3651. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3652. DiseName string `json:"dise_name"`
  3653. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3654. Age float64 `json:"age"`
  3655. DtrtCertType string `json:"dtrt_cert_type"`
  3656. HospLv string `json:"hosp_lv"`
  3657. } `json:"setlinfo"`
  3658. } `json:"output"`
  3659. RefmsgTime string `json:"refmsg_time"`
  3660. RespondTime string `json:"respond_time"`
  3661. Signtype interface{} `json:"signtype"`
  3662. WarnMsg interface{} `json:"warn_msg"`
  3663. }
  3664. type ResultEleven10265 struct {
  3665. Cainfo string `json:"cainfo"`
  3666. ErrMsg string `json:"err_msg"`
  3667. InfRefmsgid string `json:"inf_refmsgid"`
  3668. Infcode string `json:"infcode"`
  3669. Output struct {
  3670. Setlinfo struct {
  3671. SetlTime string `json:"setl_time"`
  3672. CvlservPay float64 `json:"cvlserv_pay"`
  3673. Year string `json:"year"`
  3674. MedType string `json:"med_type"`
  3675. PsnPay float64 `json:"psn_pay"`
  3676. OpterID string `json:"opter_id"`
  3677. Begndate string `json:"begndate"`
  3678. FlxempeFlag string `json:"flxempe_flag"`
  3679. HifmiPay float64 `json:"hifmi_pay"`
  3680. PsnNo string `json:"psn_no"`
  3681. ActPayDedc float64 `json:"act_pay_dedc"`
  3682. MedinsSetlID interface{} `json:"medins_setl_id"`
  3683. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3684. ClrWay string `json:"clr_way"`
  3685. OthPay float64 `json:"oth_pay"`
  3686. Gend string `json:"gend"`
  3687. MdtrtID string `json:"mdtrt_id"`
  3688. AcctPay float64 `json:"acct_pay"`
  3689. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3690. Insutype string `json:"insutype"`
  3691. Invono interface{} `json:"invono"`
  3692. Enddate string `json:"enddate"`
  3693. CashPayamt float64 `json:"cash_payamt"`
  3694. PsnType string `json:"psn_type"`
  3695. FixmedinsName string `json:"fixmedins_name"`
  3696. HifpPay float64 `json:"hifp_pay"`
  3697. NewFlag interface{} `json:"new_flag"`
  3698. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3699. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3700. PayLoc string `json:"pay_loc"`
  3701. ClrType string `json:"clr_type"`
  3702. RefdSetlFlag string `json:"refd_setl_flag"`
  3703. CvlservFlag string `json:"cvlserv_flag"`
  3704. EmpName string `json:"emp_name"`
  3705. Brdy string `json:"brdy"`
  3706. Naty string `json:"naty"`
  3707. Certno string `json:"certno"`
  3708. DiseCode string `json:"dise_code"`
  3709. FixmedinsCode string `json:"fixmedins_code"`
  3710. DedcHospLv string `json:"dedc_hosp_lv"`
  3711. OpterName string `json:"opter_name"`
  3712. Balc float64 `json:"balc"`
  3713. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3714. PsnCertType string `json:"psn_cert_type"`
  3715. HifobPay float64 `json:"hifob_pay"`
  3716. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3717. HifesPay float64 `json:"hifes_pay"`
  3718. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3719. OptTime string `json:"opt_time"`
  3720. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3721. SetlID string `json:"setl_id"`
  3722. MafPay float64 `json:"maf_pay"`
  3723. PsnName string `json:"psn_name"`
  3724. InsuOptins interface{} `json:"insu_optins"`
  3725. PrefFundPay interface{} `json:"pref_fund_pay"`
  3726. ClrOptins string `json:"clr_optins"`
  3727. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3728. DiseName string `json:"dise_name"`
  3729. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3730. Age float64 `json:"age"`
  3731. DtrtCertType string `json:"dtrt_cert_type"`
  3732. HospLv string `json:"hosp_lv"`
  3733. } `json:"setlinfo"`
  3734. } `json:"output"`
  3735. RefmsgTime string `json:"refmsg_time"`
  3736. RespondTime string `json:"respond_time"`
  3737. Signtype interface{} `json:"signtype"`
  3738. WarnMsg interface{} `json:"warn_msg"`
  3739. }
  3740. type ResultTwelve struct {
  3741. Cainfo string `json:"cainfo"`
  3742. ErrMsg string `json:"err_msg"`
  3743. InfRefmsgid string `json:"inf_refmsgid"`
  3744. Infcode int64 `json:"infcode"`
  3745. Output struct {
  3746. MdtrtId string `json:"mdtrt_id"`
  3747. ChrgBchno string `json:"chrg_bchno"`
  3748. PsnNo string `json:"psn_no"`
  3749. } `json:"output"`
  3750. RefmsgTime string `json:"refmsg_time"`
  3751. RespondTime string `json:"respond_time"`
  3752. Signtype interface{} `json:"signtype"`
  3753. WarnMsg interface{} `json:"warn_msg"`
  3754. }
  3755. type ResultThirteen struct {
  3756. ErrMsg string `json:"err_msg"`
  3757. InfRefmsgid string `json:"inf_refmsgid"`
  3758. Infcode int64 `json:"infcode"`
  3759. Output struct {
  3760. Result struct {
  3761. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3762. } `json:"result"`
  3763. } `json:"output"`
  3764. RefmsgTime string `json:"refmsg_time"`
  3765. RespondTime string `json:"respond_time"`
  3766. Signtype interface{} `json:"signtype"`
  3767. WarnInfo interface{} `json:"warn_info"`
  3768. }
  3769. type ResultThirteen10265 struct {
  3770. ErrMsg string `json:"err_msg"`
  3771. InfRefmsgid string `json:"inf_refmsgid"`
  3772. Infcode string `json:"infcode"`
  3773. Output struct {
  3774. Result struct {
  3775. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3776. } `json:"result"`
  3777. } `json:"output"`
  3778. RefmsgTime string `json:"refmsg_time"`
  3779. RespondTime string `json:"respond_time"`
  3780. Signtype interface{} `json:"signtype"`
  3781. WarnInfo interface{} `json:"warn_info"`
  3782. }
  3783. type ResultFourteen struct {
  3784. ErrMsg string `json:"err_msg"`
  3785. InfRefmsgid string `json:"inf_refmsgid"`
  3786. Infcode int64 `json:"infcode"`
  3787. Output struct {
  3788. } `json:"output"`
  3789. RefmsgTime string `json:"refmsg_time"`
  3790. RespondTime string `json:"respond_time"`
  3791. Signtype interface{} `json:"signtype"`
  3792. WarnInfo interface{} `json:"warn_info"`
  3793. }
  3794. type ResultFourteen10265 struct {
  3795. ErrMsg string `json:"err_msg"`
  3796. InfRefmsgid string `json:"inf_refmsgid"`
  3797. Infcode string `json:"infcode"`
  3798. Output struct {
  3799. } `json:"output"`
  3800. RefmsgTime string `json:"refmsg_time"`
  3801. RespondTime string `json:"respond_time"`
  3802. Signtype interface{} `json:"signtype"`
  3803. WarnInfo interface{} `json:"warn_info"`
  3804. }
  3805. type ResultSixteen struct {
  3806. Cainfo string `json:"cainfo"`
  3807. ErrMsg string `json:"err_msg"`
  3808. InfRefmsgid string `json:"inf_refmsgid"`
  3809. Infcode int64 `json:"infcode"`
  3810. Output struct {
  3811. Setldetail []interface{} `json:"setldetail"`
  3812. Setlinfo struct {
  3813. MdtrtID string `json:"mdtrt_id"`
  3814. SetlID string `json:"setl_id"`
  3815. ClrOptins string `json:"clr_optins"`
  3816. SetlTime string `json:"setl_time"`
  3817. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3818. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3819. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3820. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3821. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3822. ActPayDedc float64 `json:"act_pay_dedc"`
  3823. HifpPay float64 `json:"hifp_pay"`
  3824. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3825. Lfpay float64 `json:"selfpay"`
  3826. CvlservPay float64 `json:"cvlserv_pay"`
  3827. HifesPay float64 `json:"hifes_pay"`
  3828. HifmiPay float64 `json:"hifmi_pay"`
  3829. HifobPay float64 `json:"hifob_pay"`
  3830. MafPay float64 `json:"maf_pay"`
  3831. OthPay float64 `json:"oth_pay"`
  3832. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3833. PsnPartAmt float64 `json:"psn_part_amt"`
  3834. AcctPay float64 `json:"acct_pay"`
  3835. Balc float64 `json:"balc"`
  3836. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3837. HospPartAmt float64 `json:"hosp_part_amt"`
  3838. MedinsSetlID string `json:"medins_setl_id"`
  3839. PdnCashPay string `json:"pdn_cash_pay"`
  3840. } `json:"setlinfo"`
  3841. } `json:"output"`
  3842. RefmsgTime string `json:"refmsg_time"`
  3843. RespondTime string `json:"respond_time"`
  3844. Signtype interface{} `json:"signtype"`
  3845. WarnMsg interface{} `json:"warn_msg"`
  3846. }
  3847. type ResultSixteen10265 struct {
  3848. Cainfo string `json:"cainfo"`
  3849. ErrMsg string `json:"err_msg"`
  3850. InfRefmsgid string `json:"inf_refmsgid"`
  3851. Infcode string `json:"infcode"`
  3852. Output struct {
  3853. Setldetail []interface{} `json:"setldetail"`
  3854. Setlinfo struct {
  3855. MdtrtID string `json:"mdtrt_id"`
  3856. SetlID string `json:"setl_id"`
  3857. ClrOptins string `json:"clr_optins"`
  3858. SetlTime string `json:"setl_time"`
  3859. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3860. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3861. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3862. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3863. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3864. ActPayDedc float64 `json:"act_pay_dedc"`
  3865. HifpPay float64 `json:"hifp_pay"`
  3866. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3867. Lfpay float64 `json:"selfpay"`
  3868. CvlservPay float64 `json:"cvlserv_pay"`
  3869. HifesPay float64 `json:"hifes_pay"`
  3870. HifmiPay float64 `json:"hifmi_pay"`
  3871. HifobPay float64 `json:"hifob_pay"`
  3872. MafPay float64 `json:"maf_pay"`
  3873. OthPay float64 `json:"oth_pay"`
  3874. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3875. PsnPartAmt float64 `json:"psn_part_amt"`
  3876. AcctPay float64 `json:"acct_pay"`
  3877. Balc float64 `json:"balc"`
  3878. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3879. HospPartAmt float64 `json:"hosp_part_amt"`
  3880. MedinsSetlID string `json:"medins_setl_id"`
  3881. PdnCashPay string `json:"pdn_cash_pay"`
  3882. } `json:"setlinfo"`
  3883. } `json:"output"`
  3884. RefmsgTime string `json:"refmsg_time"`
  3885. RespondTime string `json:"respond_time"`
  3886. Signtype interface{} `json:"signtype"`
  3887. WarnMsg interface{} `json:"warn_msg"`
  3888. }
  3889. type ResultSeventeen struct {
  3890. ErrMsg string `json:"err_msg"`
  3891. InfRefmsgid string `json:"inf_refmsgid"`
  3892. Infcode int64 `json:"infcode"`
  3893. Output struct {
  3894. SetlListId string `json:"setl_list_id"`
  3895. } `json:"output"`
  3896. RefmsgTime string `json:"refmsg_time"`
  3897. RespondTime string `json:"respond_time"`
  3898. Signtype string `json:"signtype"`
  3899. WarnInfo string `json:"warn_info"`
  3900. }
  3901. type Result90991 struct {
  3902. ErrMsg string `json:"err_msg"`
  3903. InfRefmsgid string `json:"inf_refmsgid"`
  3904. Infcode int64 `json:"infcode"`
  3905. Output struct {
  3906. Result struct {
  3907. PsnNo string `json:"psn_no"`
  3908. CardStat string `json:"card_stat"`
  3909. Certno string `json:"certno"`
  3910. PsnName string `json:"psn_name"`
  3911. CheckStat string `json:"check_stat"`
  3912. } `json:"result"`
  3913. } `json:"output"`
  3914. RefmsgTime string `json:"refmsg_time"`
  3915. RespondTime string `json:"respond_time"`
  3916. Signtype interface{} `json:"signtype"`
  3917. WarnInfo interface{} `json:"warn_info"`
  3918. }
  3919. type Result90100 struct {
  3920. ErrMsg string `json:"err_msg"`
  3921. InfRefmsgid string `json:"inf_refmsgid"`
  3922. Infcode int64 `json:"infcode"`
  3923. Output struct {
  3924. PoolareaNo string `json:"poolarea_no"`
  3925. PoolareaNoName string `json:"poolarea_no_name"`
  3926. Insutype string `json:"insutype"`
  3927. InsutypeName string `json:"insutype_name"`
  3928. ClctType string `json:"clct_type"`
  3929. ClctTypeName string `json:"clct_type_name"`
  3930. ClctFlag string `json:"clct_flag"`
  3931. ClctFlagName string `json:"clct_flag_name"`
  3932. AccrymBegn string `json:"accrym_begn"`
  3933. AccrymEnd string `json:"accrym_end"`
  3934. ClctTime string `json:"clct_time"`
  3935. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  3936. } `json:"output"`
  3937. RefmsgTime string `json:"refmsg_time"`
  3938. RespondTime string `json:"respond_time"`
  3939. Signtype interface{} `json:"signtype"`
  3940. WarnInfo interface{} `json:"warn_info"`
  3941. }
  3942. type Custom struct {
  3943. DetItemFeeSumamt string
  3944. Cut string
  3945. FeedetlSn string
  3946. Price string
  3947. MedListCodg string
  3948. Type int64
  3949. AdviceId int64
  3950. ProjectId int64
  3951. ItemId int64
  3952. }
  3953. type Result5301 struct {
  3954. ErrMsg string `json:"err_msg"`
  3955. InfRefmsgid string `json:"inf_refmsgid"`
  3956. Infcode int64 `json:"infcode"`
  3957. Output struct {
  3958. Result []struct {
  3959. OpspDiseCode string `json:"opsp_dise_code"`
  3960. OpspDiseName string `json:"opsp_dise_name"`
  3961. Begndate string `json:"begndate"`
  3962. Enddate string `json:"enddate"`
  3963. } `json:"feedetail"`
  3964. } `json:"output"`
  3965. RefmsgTime string `json:"refmsg_time"`
  3966. RespondTime string `json:"respond_time"`
  3967. Signtype interface{} `json:"signtype"`
  3968. WarnInfo interface{} `json:"warn_info"`
  3969. }
  3970. type Result5301For10265 struct {
  3971. ErrMsg string `json:"err_msg"`
  3972. InfRefmsgid string `json:"inf_refmsgid"`
  3973. Infcode string `json:"infcode"`
  3974. Output struct {
  3975. Result []struct {
  3976. OpspDiseCode string `json:"opsp_dise_code"`
  3977. OpspDiseName string `json:"opsp_dise_name"`
  3978. Begndate string `json:"begndate"`
  3979. Enddate string `json:"enddate"`
  3980. } `json:"feedetail"`
  3981. } `json:"output"`
  3982. RefmsgTime string `json:"refmsg_time"`
  3983. RespondTime string `json:"respond_time"`
  3984. Signtype interface{} `json:"signtype"`
  3985. WarnInfo interface{} `json:"warn_info"`
  3986. }
  3987. //获取个人信息----挂号-----上传就诊信息
  3988. func (c *HisApiController) GetRegisterInfo() {
  3989. id, _ := c.GetInt64("id")
  3990. record_time := c.GetString("record_time")
  3991. settlementValue, _ := c.GetInt64("settlement_value")
  3992. medical_insurance_card := c.GetString("medical_insurance_card")
  3993. name := c.GetString("name")
  3994. id_card_type, _ := c.GetInt64("id_card_type")
  3995. certificates, _ := c.GetInt64("certificates")
  3996. medical_care, _ := c.GetInt64("medical_care")
  3997. birthday := c.GetString("birthday")
  3998. id_card := c.GetString("id_card")
  3999. register_type, _ := c.GetInt64("register")
  4000. doctor, _ := c.GetInt64("doctor")
  4001. department, _ := c.GetInt64("department")
  4002. gender, _ := c.GetInt64("sex")
  4003. registration_fee, _ := c.GetFloat("registration_fee")
  4004. medical_expenses, _ := c.GetFloat("medical_expenses")
  4005. social_type, _ := c.GetInt64("social_type")
  4006. med_type := c.GetString("social_type")
  4007. admin_user_id, _ := c.GetInt64("admin_user_id")
  4008. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4009. timeLayout := "2006-01-02"
  4010. loc, _ := time.LoadLocation("Local")
  4011. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4012. birthUnix := birthdays.Unix()
  4013. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4014. if err != nil {
  4015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4016. return
  4017. }
  4018. recordDateTime := theTime.Unix()
  4019. adminInfo := c.GetAdminUserInfo()
  4020. var patient service.Patients
  4021. if id == 0 {
  4022. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4023. } else {
  4024. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4025. }
  4026. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4027. if patientPrescription.ID == 0 {
  4028. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4029. }
  4030. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4031. if patient.ID == 0 {
  4032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4033. return
  4034. }
  4035. if len(patient.IdCardNo) == 0 {
  4036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4037. return
  4038. }
  4039. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4040. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4041. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4042. //就诊结算未完成,不能进行二次挂号
  4043. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4044. if len(his) >= 1 {
  4045. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  4046. if len(his) >= 1 && order.ID == 0 {
  4047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  4048. return
  4049. }
  4050. }
  4051. //var register_log string
  4052. if config.IsOpen == 1 {
  4053. var res ResultTwo
  4054. var res10265 ResultTwo10265
  4055. var PsnNo string
  4056. var PsnCertType string
  4057. var Certno string
  4058. var PsnName string
  4059. var Gend string
  4060. var Naty string
  4061. var Brdy string
  4062. var Age float64
  4063. var infoStr string
  4064. var idetinfoStr string
  4065. var infocode int64
  4066. var verify_number string
  4067. fmt.Println(verify_number)
  4068. if miConfig.MdtrtareaAdmvs == "421300" {
  4069. psn_info, _ := service.GetPsnByPatientId(id)
  4070. PsnNo = psn_info.PsnNo
  4071. PsnCertType = psn_info.PsnCertType
  4072. Certno = psn_info.Certno
  4073. PsnName = psn_info.PsnName
  4074. Gend = psn_info.Gend
  4075. Naty = psn_info.Naty
  4076. Brdy = psn_info.Brdy
  4077. Age = psn_info.Age
  4078. infoStr = psn_info.Insuinfo
  4079. idetinfoStr = psn_info.Idetinfo
  4080. infocode = 0
  4081. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4082. psn_info, _ := service.GetPsnByPatientId(id)
  4083. PsnNo = psn_info.PsnNo
  4084. PsnCertType = psn_info.PsnCertType
  4085. Certno = psn_info.Certno
  4086. PsnName = psn_info.PsnName
  4087. Gend = psn_info.Gend
  4088. Naty = psn_info.Naty
  4089. Brdy = psn_info.Brdy
  4090. Age = psn_info.Age
  4091. infoStr = psn_info.Insuinfo
  4092. idetinfoStr = psn_info.Idetinfo
  4093. infocode = 0
  4094. verify_number = psn_info.VerifyNumber
  4095. } else {
  4096. var result string
  4097. var requestLog string
  4098. if miConfig.UserOrgId == 10138 {
  4099. result, requestLog = service.Gdyb1101D(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name, record_time)
  4100. } else {
  4101. 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)
  4102. }
  4103. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4104. if miConfig.Code == "H15049901371" {
  4105. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4106. utils.ErrorLog("解析失败:%v", err)
  4107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4108. return
  4109. }
  4110. res.ErrMsg = res10265.ErrMsg
  4111. res.Output = res10265.Output
  4112. res.InfRefmsgid = res10265.InfRefmsgid
  4113. } else {
  4114. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4115. utils.ErrorLog("解析失败:%v", err)
  4116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4117. return
  4118. }
  4119. }
  4120. PsnNo = res.Output.Baseinfo.PsnNo
  4121. PsnCertType = res.Output.Baseinfo.PsnCertType
  4122. Certno = res.Output.Baseinfo.Certno
  4123. PsnName = res.Output.Baseinfo.PsnName
  4124. Gend = res.Output.Baseinfo.Gend
  4125. Naty = res.Output.Baseinfo.Naty
  4126. Brdy = res.Output.Baseinfo.Brdy
  4127. Age = res.Output.Baseinfo.Age
  4128. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4129. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4130. infoStr = string(Iinfos)
  4131. idetinfoStr = string(Idetinfos)
  4132. if miConfig.Code == "H15049901371" {
  4133. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  4134. } else {
  4135. infocode = res.Infcode
  4136. }
  4137. }
  4138. if infocode == 0 {
  4139. his := models.VMHisPatient{
  4140. Name: name,
  4141. Gender: gender,
  4142. Birthday: birthUnix,
  4143. MedicalTreatmentType: medical_care,
  4144. IdType: certificates,
  4145. IdCardNo: id_card,
  4146. BalanceAccountsType: settlementValue,
  4147. SocialType: social_type,
  4148. MedicalInsuranceNumber: medical_insurance_card,
  4149. RegisterType: register_type,
  4150. RegisterCost: registration_fee,
  4151. TreatmentCost: medical_expenses,
  4152. Status: 1,
  4153. Ctime: time.Now().Unix(),
  4154. Mtime: time.Now().Unix(),
  4155. PsnNo: PsnNo,
  4156. PsnCertType: PsnCertType,
  4157. Certno: Certno,
  4158. PsnName: PsnName,
  4159. Gend: Gend,
  4160. Naty: Naty,
  4161. Brdy: Brdy,
  4162. Age: Age,
  4163. Iinfo: infoStr,
  4164. Idetinfo: idetinfoStr,
  4165. PatientId: patient.ID,
  4166. RecordDate: theTime.Unix(),
  4167. UserOrgId: adminInfo.CurrentOrgId,
  4168. AdminUserId: admin_user_id,
  4169. IsReturn: 1,
  4170. IdCardType: id_card_type,
  4171. Doctor: doctor,
  4172. Departments: department,
  4173. }
  4174. timestamp := time.Now().Unix()
  4175. tempTime := time.Unix(timestamp, 0)
  4176. timeFormat := tempTime.Format("20060102150405")
  4177. chrgBchno := rand.Intn(100000) + 10000
  4178. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4179. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  4180. department, _ := service.GetDepartMentDetail(department)
  4181. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  4182. IdCardNo := ""
  4183. if id_card_type == 1 {
  4184. // IdCardNo = medical_insurance_card
  4185. IdCardNo = patient.IdCardNo
  4186. } else {
  4187. IdCardNo = patient.IdCardNo
  4188. }
  4189. var rf []*ResultFive
  4190. json.Unmarshal([]byte(his.Iinfo), &rf)
  4191. var insutypes []*ResultFive
  4192. var insutype string
  4193. var insuplc_admdvs_temp string
  4194. var is390 int = 0
  4195. var is310 int = 0
  4196. for _, item := range rf {
  4197. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4198. insutypes = append(insutypes, item)
  4199. }
  4200. }
  4201. if len(insutypes) == 1 {
  4202. insutype = insutypes[0].Insutype
  4203. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4204. } else {
  4205. for _, i := range insutypes {
  4206. if i.Insutype == "390" {
  4207. is390 = 1
  4208. }
  4209. if i.Insutype == "310" {
  4210. is310 = 1
  4211. }
  4212. }
  4213. }
  4214. if is390 == 1 {
  4215. insutype = "390"
  4216. }
  4217. if is310 == 1 {
  4218. insutype = "310"
  4219. }
  4220. if len(insutypes) == 0 {
  4221. insutype = "310"
  4222. }
  4223. if len(insutypes) == 2 {
  4224. insutype = med_type
  4225. }
  4226. if len(med_type) > 0 {
  4227. insutype = med_type
  4228. }
  4229. //for _, item := range rf {
  4230. // if item.Insutype == insutype {
  4231. // insuplc_admdvs = item.InsuplcAdmdvs
  4232. // }
  4233. //}
  4234. var infocode int64
  4235. var resThree ResultThree
  4236. var resThree10265 ResultThree10265
  4237. if len(insuplc_admdvs) == 0 {
  4238. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  4239. } else {
  4240. insuplc_admdvs_temp = insuplc_admdvs
  4241. }
  4242. if miConfig.MdtrtareaAdmvs == "421300" {
  4243. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  4244. "&org_name=" + miConfig.OrgName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4245. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&doctor_name=" + doctor_info.UserName
  4246. resp, requestErr := http.Get(api)
  4247. if requestErr != nil {
  4248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4249. return
  4250. }
  4251. body, ioErr := ioutil.ReadAll(resp.Body)
  4252. if ioErr != nil {
  4253. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4255. return
  4256. }
  4257. var respJSON map[string]interface{}
  4258. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4259. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4261. return
  4262. }
  4263. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4264. result, _ := json.Marshal(respJSON)
  4265. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4266. utils.ErrorLog("解析失败:%v", err)
  4267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4268. return
  4269. }
  4270. infocode = resThree.Infcode
  4271. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4272. psn_info, _ := service.GetPsnByPatientId(id)
  4273. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4274. var cert_no string
  4275. if id_card_type == 3 {
  4276. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  4277. cert_no = IdCardNo
  4278. } else {
  4279. bas := strings.Split(psn_info.CardInfo, "|")
  4280. cert_no = bas[2]
  4281. }
  4282. var api string
  4283. if miConfig.MdtrtareaAdmvs == "320921" {
  4284. api = "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4285. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4286. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4287. } else {
  4288. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4289. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4290. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4291. }
  4292. resp, requestErr := http.Get(api)
  4293. if requestErr != nil {
  4294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4295. return
  4296. }
  4297. body, ioErr := ioutil.ReadAll(resp.Body)
  4298. if ioErr != nil {
  4299. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4301. return
  4302. }
  4303. var respJSON map[string]interface{}
  4304. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4305. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4307. return
  4308. }
  4309. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4310. result, _ := json.Marshal(respJSON)
  4311. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4312. utils.ErrorLog("解析失败:%v", err)
  4313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4314. return
  4315. }
  4316. resThree.ErrMsg = resThree10265.ErrMsg
  4317. resThree.Output = resThree10265.Output
  4318. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4319. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4320. } else {
  4321. result, requestLog := service.Gdyb2201A(res.Output.Baseinfo.PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_id, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, record_time)
  4322. saveLog(result, requestLog, "2201A", "挂号")
  4323. if miConfig.Code == "H15049901371" {
  4324. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4325. utils.ErrorLog("解析失败:%v", err)
  4326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4327. return
  4328. }
  4329. resThree.ErrMsg = resThree10265.ErrMsg
  4330. resThree.Output = resThree10265.Output
  4331. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4332. } else {
  4333. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4334. utils.ErrorLog("解析失败:%v", err)
  4335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4336. return
  4337. }
  4338. }
  4339. if miConfig.Code == "H15049901371" {
  4340. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4341. } else {
  4342. infocode = resThree.Infcode
  4343. }
  4344. }
  4345. if infocode != 0 {
  4346. adminUser := c.GetAdminUserInfo()
  4347. errlog := &models.HisOrderError{
  4348. UserOrgId: adminUser.CurrentOrgId,
  4349. Ctime: time.Now().Unix(),
  4350. Mtime: time.Now().Unix(),
  4351. ErrMsg: resThree.ErrMsg,
  4352. Status: 1,
  4353. PatientId: id,
  4354. RecordTime: recordDateTime,
  4355. Stage: 2,
  4356. }
  4357. service.CreateErrMsgLog(errlog)
  4358. c.ServeSuccessJSON(map[string]interface{}{
  4359. "failed_code": -10,
  4360. "msg": resThree.ErrMsg,
  4361. })
  4362. return
  4363. }
  4364. his.Number = resThree.Output.Data.MdtrtID
  4365. his.PsnNo = resThree.Output.Data.PsnNo
  4366. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  4367. his.IdCardNo = patient.IdCardNo
  4368. his.PhoneNumber = patient.Phone
  4369. his.UserOrgId = adminInfo.CurrentOrgId
  4370. his.Insutype = insutype
  4371. his.Ctime = time.Now().Unix()
  4372. his.Mtime = time.Now().Unix()
  4373. his.InsuplcAdmdvs = insuplc_admdvs_temp
  4374. his.Status = 1
  4375. service.UpdateHisPatientStatus(&his)
  4376. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  4377. c.ServeSuccessJSON(map[string]interface{}{
  4378. "his_info": his,
  4379. })
  4380. } else {
  4381. adminUser := c.GetAdminUserInfo()
  4382. errlog := &models.HisOrderError{
  4383. UserOrgId: adminUser.CurrentOrgId,
  4384. Ctime: time.Now().Unix(),
  4385. Mtime: time.Now().Unix(),
  4386. ErrMsg: res.ErrMsg,
  4387. Status: 1,
  4388. PatientId: id,
  4389. RecordTime: recordDateTime,
  4390. Stage: 1,
  4391. }
  4392. service.CreateErrMsgLog(errlog)
  4393. c.ServeSuccessJSON(map[string]interface{}{
  4394. "failed_code": -10,
  4395. "msg": res.ErrMsg,
  4396. })
  4397. return
  4398. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  4399. }
  4400. }
  4401. }
  4402. //上传明细----预结算----确认订单
  4403. func (c *HisApiController) GetUploadInfo() {
  4404. id, _ := c.GetInt64("id")
  4405. record_time := c.GetString("record_time")
  4406. his_patient_id, _ := c.GetInt64("his_patient_id")
  4407. order_id, _ := c.GetInt64("order_id")
  4408. pay_way, _ := c.GetInt64("pay_way")
  4409. pay_price, _ := c.GetFloat("pay_price")
  4410. pay_card_no := c.GetString("pay_card_no")
  4411. discount_price, _ := c.GetFloat("discount_price")
  4412. preferential_price, _ := c.GetFloat("preferential_price")
  4413. reality_price, _ := c.GetFloat("reality_price")
  4414. found_price, _ := c.GetFloat("found_price")
  4415. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  4416. private_price, _ := c.GetFloat("private_price")
  4417. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4418. admin_user_id, _ := c.GetInt64("admin_user_id")
  4419. fapiao_code := c.GetString("fapiao_code")
  4420. fapiao_number := c.GetString("fapiao_number")
  4421. diagnosis_id := c.GetString("diagnosis")
  4422. sick_type, _ := c.GetInt64("sick_type")
  4423. reg_type, _ := c.GetInt64("p_type")
  4424. begin_time := c.GetString("begin_time")
  4425. id_str := c.GetString("ids")
  4426. ids_arr := strings.Split(id_str, ",")
  4427. timeLayout := "2006-01-02"
  4428. loc, _ := time.LoadLocation("Local")
  4429. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4430. if err != nil {
  4431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4432. return
  4433. }
  4434. recordDateTime := theTime.Unix()
  4435. adminUser := c.GetAdminUserInfo()
  4436. var tempOrder models.HisOrder
  4437. tempOrder, _ = service.GetHisOrderByID(order_id)
  4438. var prescriptions []*models.HisPrescription
  4439. var start_time int64
  4440. var end_time int64
  4441. //if adminUser.CurrentOrgId == 10106{
  4442. // if len(fapiao_code) == 0{
  4443. // fapiao_code = "144072080589"
  4444. // }
  4445. // if len(fapiao_number) == 0{
  4446. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  4447. // if order.ID == 0{
  4448. // fapiao_number = "00001520"
  4449. // }else{
  4450. // //fapiao_code = "00001520"
  4451. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  4452. // var zero string
  4453. // if fpNumber >= 1000{
  4454. // zero = "0000" + strconv.Itoa(fpNumber)
  4455. // }else if fpNumber >= 10000{
  4456. // zero = "000" + strconv.Itoa(fpNumber)
  4457. // } else if fpNumber >= 100000{
  4458. // zero = "00" + strconv.Itoa(fpNumber)
  4459. // } else if fpNumber >= 1000000{
  4460. // zero = "0" + strconv.Itoa(fpNumber)
  4461. // }else {
  4462. // zero = strconv.Itoa(fpNumber)
  4463. // }
  4464. // fapiao_number = zero
  4465. // }
  4466. // }
  4467. //}
  4468. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4469. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4470. var patientPrescription models.HisPrescriptionInfo
  4471. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4472. if patientPrescription.ID == 0 {
  4473. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4474. }
  4475. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4476. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4477. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4478. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4479. var config []*models.HisXtDiagnoseConfig
  4480. for _, item := range diagnosis_ids {
  4481. id, _ := strconv.ParseInt(item, 10, 64)
  4482. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4483. config = append(config, &diagnosisConfig)
  4484. }
  4485. sickConfig, _ := service.FindSickById(sick_type)
  4486. //if tempOrder.ID == 0 {
  4487. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  4488. //}
  4489. if tempOrder.ID == 0 {
  4490. var result string
  4491. var requestLog string
  4492. var res2 ResultSix
  4493. var ressix10265 ResultSix10265
  4494. if miConfig.MdtrtareaAdmvs == "421300" {
  4495. data := make(map[string]interface{})
  4496. client := &http.Client{}
  4497. data["psn_no"] = his.PsnNo
  4498. data["mdtrt_id"] = his.Number
  4499. data["doctor"] = roles.UserName
  4500. data["department"] = department.Name
  4501. data["org_name"] = miConfig.OrgName
  4502. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4503. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4504. data["fixmedins_code"] = miConfig.Code
  4505. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4506. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4507. data["secret_key"] = miConfig.SecretKey
  4508. data["sick_code"] = sickConfig.CountryCode
  4509. data["sick_name"] = sickConfig.ClassName
  4510. data["dept"] = strconv.FormatInt(department.ID, 10)
  4511. data["config"] = config
  4512. data["begin_time"] = begin_time
  4513. bytesData, _ := json.Marshal(data)
  4514. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  4515. resp, _ := client.Do(req)
  4516. defer resp.Body.Close()
  4517. body, ioErr := ioutil.ReadAll(resp.Body)
  4518. if ioErr != nil {
  4519. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4521. return
  4522. }
  4523. var respJSON map[string]interface{}
  4524. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4525. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4527. return
  4528. }
  4529. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4530. userJSONBytes, _ := json.Marshal(respJSON)
  4531. fmt.Println("log")
  4532. fmt.Println(string(userJSONBytes))
  4533. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4534. utils.ErrorLog("解析失败:%v", err)
  4535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4536. return
  4537. }
  4538. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4539. //江苏地区国家医保医疗类别
  4540. //职工透析:医疗类别选特殊情况门诊9933
  4541. //居民血透门慢: 医疗类别选门诊慢病1402
  4542. //var med_type string
  4543. //if his.Insutype == "310" {
  4544. // if reg_type == 14 {
  4545. // med_type = "9933"
  4546. // } else if reg_type == 11 {
  4547. // med_type = "11"
  4548. //
  4549. // }
  4550. //} else if his.Insutype == "390" {
  4551. // if reg_type == 14 {
  4552. // med_type = "1402"
  4553. // } else if reg_type == 11 {
  4554. // med_type = "11"
  4555. // }
  4556. //}
  4557. data := make(map[string]interface{})
  4558. client := &http.Client{}
  4559. data["psn_no"] = his.PsnNo
  4560. data["mdtrt_id"] = his.Number
  4561. data["doctor"] = roles.UserName
  4562. data["department"] = department.Name
  4563. data["org_name"] = miConfig.OrgName
  4564. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4565. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4566. data["fixmedins_code"] = miConfig.Code
  4567. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4568. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4569. data["secret_key"] = miConfig.SecretKey
  4570. data["sick_code"] = sickConfig.CountryCode
  4571. data["sick_name"] = sickConfig.ClassName
  4572. data["url"] = miConfig.Url
  4573. data["ak"] = miConfig.AccessKey
  4574. data["begin_time"] = begin_time
  4575. data["cainfo"] = miConfig.Cainfo
  4576. data["dept"] = strconv.FormatInt(department.ID, 10)
  4577. data["config"] = config
  4578. bytesData, _ := json.Marshal(data)
  4579. var req *http.Request
  4580. if miConfig.MdtrtareaAdmvs == "320921" {
  4581. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4582. //api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  4583. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  4584. } else {
  4585. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4586. }
  4587. resp, _ := client.Do(req)
  4588. defer resp.Body.Close()
  4589. body, ioErr := ioutil.ReadAll(resp.Body)
  4590. if ioErr != nil {
  4591. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4593. return
  4594. }
  4595. var respJSON map[string]interface{}
  4596. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4597. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4599. return
  4600. }
  4601. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4602. userJSONBytes, _ := json.Marshal(respJSON)
  4603. fmt.Println("log")
  4604. fmt.Println(string(userJSONBytes))
  4605. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  4606. utils.ErrorLog("解析失败:%v", err)
  4607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4608. return
  4609. }
  4610. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4611. res2.Output = ressix10265.Output
  4612. res2.ErrMsg = ressix10265.ErrMsg
  4613. res2.Cainfo = ressix10265.Cainfo
  4614. res2.WarnMsg = ressix10265.WarnMsg
  4615. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4616. res2.Infcode = infocode
  4617. } else {
  4618. if miConfig.MdtrtareaAdmvs == "440781" { //
  4619. result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  4620. } else {
  4621. if miConfig.Code == "H15049901371" {
  4622. //赤峰地区国家医保医疗类别
  4623. //职工透析:医疗类别选特殊情况门诊990502
  4624. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4625. var med_type string
  4626. if his.Insutype == "390" {
  4627. if reg_type == 14 {
  4628. med_type = "9933"
  4629. } else if reg_type == 11 {
  4630. med_type = "11"
  4631. }
  4632. } else if his.Insutype == "310" {
  4633. if reg_type == 14 {
  4634. med_type = "990502"
  4635. } else if reg_type == 11 {
  4636. med_type = "11"
  4637. }
  4638. }
  4639. 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)
  4640. } else {
  4641. 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)
  4642. }
  4643. }
  4644. saveLog(result, requestLog, "2203", "上传就诊信息")
  4645. var respJSON2 map[string]interface{}
  4646. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4647. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4649. return
  4650. }
  4651. userJSONBytes2, _ := json.Marshal(respJSON2)
  4652. if miConfig.Code == "H15049901371" {
  4653. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  4654. utils.ErrorLog("解析失败:%v", err)
  4655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4656. return
  4657. }
  4658. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4659. res2.Output = ressix10265.Output
  4660. res2.ErrMsg = ressix10265.ErrMsg
  4661. res2.Cainfo = ressix10265.Cainfo
  4662. res2.WarnMsg = ressix10265.WarnMsg
  4663. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4664. res2.Infcode = infocode
  4665. } else {
  4666. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4667. utils.ErrorLog("解析失败:%v", err)
  4668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4669. return
  4670. }
  4671. }
  4672. }
  4673. if res2.Infcode != 0 {
  4674. adminUser := c.GetAdminUserInfo()
  4675. errlog := &models.HisOrderError{
  4676. UserOrgId: adminUser.CurrentOrgId,
  4677. Ctime: time.Now().Unix(),
  4678. Mtime: time.Now().Unix(),
  4679. ErrMsg: res2.ErrMsg,
  4680. Status: 1,
  4681. PatientId: id,
  4682. RecordTime: recordDateTime,
  4683. Stage: 3,
  4684. }
  4685. service.CreateErrMsgLog(errlog)
  4686. c.ServeSuccessJSON(map[string]interface{}{
  4687. "failed_code": -10,
  4688. "msg": res2.ErrMsg,
  4689. })
  4690. return
  4691. } else {
  4692. his.Diagnosis = diagnosis_id
  4693. his.SickType = sickConfig.ID
  4694. //var p_type int64
  4695. //if reg_type == 1111 || reg_type == 1112 {
  4696. // p_type = 11
  4697. //
  4698. //}
  4699. his.PType = fmt.Sprintf("%d", reg_type)
  4700. service.UpdateHisPatientThree(&his)
  4701. data := make(map[string]interface{})
  4702. if settle_accounts_type == 1 { //日结
  4703. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  4704. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  4705. } else {
  4706. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  4707. }
  4708. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  4709. data["pre"] = prescriptions
  4710. } else { //月结
  4711. start_time_str := c.GetString("start_time")
  4712. end_time_str := c.GetString("end_time")
  4713. timeLayout := "2006-01-02"
  4714. loc, _ := time.LoadLocation("Local")
  4715. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4716. if err != nil {
  4717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4718. return
  4719. }
  4720. recordStartTime := theStartTime.Unix()
  4721. start_time = recordStartTime
  4722. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4723. if err != nil {
  4724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4725. return
  4726. }
  4727. recordEndTime := theEndTime.Unix()
  4728. end_time = recordEndTime
  4729. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  4730. data["pre"] = prescriptions
  4731. }
  4732. timestamp := time.Now().Unix()
  4733. tempTime := time.Unix(timestamp, 0)
  4734. timeFormat := tempTime.Format("20060102150405")
  4735. chrgBchno := rand.Intn(100000) + 10000
  4736. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4737. strconv.FormatInt(his.PatientId, 10)
  4738. client := &http.Client{}
  4739. data["psn_no"] = his.PsnNo
  4740. data["mdtrt_id"] = his.Number
  4741. data["chrg_bchno"] = chrg_bchno
  4742. data["org_name"] = miConfig.OrgName
  4743. data["doctor"] = roles.UserName
  4744. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4745. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4746. data["fixmedins_code"] = miConfig.Code
  4747. //if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  4748. // data["dept_code"] = "15"
  4749. //} else {
  4750. data["dept_code"] = department.Number
  4751. //}
  4752. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4753. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4754. data["secret_key"] = miConfig.SecretKey
  4755. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  4756. data["url"] = miConfig.Url
  4757. data["ak"] = miConfig.AccessKey
  4758. data["new_doctor_name"] = patientPrescription.Doctor
  4759. data["diag_code"] = sickConfig.CountryCode
  4760. data["cainfo"] = miConfig.Cainfo
  4761. var ids []int64
  4762. for _, item := range prescriptions {
  4763. ids = append(ids, item.ID)
  4764. }
  4765. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4766. if config.IsOpen == 1 { //对接了医保,走医保流程
  4767. var res ResultFour
  4768. var resFour10265 ResultFour10265
  4769. if miConfig.MdtrtareaAdmvs == "421300" {
  4770. bytesData, _ := json.Marshal(data)
  4771. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  4772. resp, _ := client.Do(req)
  4773. defer resp.Body.Close()
  4774. body, ioErr := ioutil.ReadAll(resp.Body)
  4775. if ioErr != nil {
  4776. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4778. return
  4779. }
  4780. var respJSON map[string]interface{}
  4781. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4782. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4784. return
  4785. }
  4786. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4787. userJSONBytes, _ := json.Marshal(respJSON)
  4788. fmt.Println("log")
  4789. fmt.Println(string(userJSONBytes))
  4790. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4791. utils.ErrorLog("解析失败:%v", err)
  4792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4793. return
  4794. }
  4795. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4796. bytesData, _ := json.Marshal(data)
  4797. var req *http.Request
  4798. if miConfig.MdtrtareaAdmvs == "320921" {
  4799. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4800. } else {
  4801. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4802. }
  4803. resp, _ := client.Do(req)
  4804. defer resp.Body.Close()
  4805. body, ioErr := ioutil.ReadAll(resp.Body)
  4806. if ioErr != nil {
  4807. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4809. return
  4810. }
  4811. var respJSON map[string]interface{}
  4812. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4813. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4815. return
  4816. }
  4817. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4818. userJSONBytes, _ := json.Marshal(respJSON)
  4819. fmt.Println("log")
  4820. fmt.Println(string(userJSONBytes))
  4821. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4822. utils.ErrorLog("解析失败:%v", err)
  4823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4824. return
  4825. }
  4826. res.InfRefmsgid = resFour10265.InfRefmsgid
  4827. res.Output = resFour10265.Output
  4828. res.ErrMsg = resFour10265.ErrMsg
  4829. res.Cainfo = resFour10265.Cainfo
  4830. res.WarnMsg = resFour10265.WarnMsg
  4831. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4832. res.Infcode = infocode
  4833. } else {
  4834. if miConfig.Code == "H15049901371" {
  4835. 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)
  4836. var dat map[string]interface{}
  4837. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4838. fmt.Println(dat)
  4839. } else {
  4840. fmt.Println(err)
  4841. }
  4842. saveLog(result, request_log, "2204", "上传费用明细")
  4843. userJSONBytes, _ := json.Marshal(dat)
  4844. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4845. utils.ErrorLog("解析失败:%v", err)
  4846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4847. return
  4848. }
  4849. res.InfRefmsgid = resFour10265.InfRefmsgid
  4850. res.Output = resFour10265.Output
  4851. res.ErrMsg = resFour10265.ErrMsg
  4852. res.Cainfo = resFour10265.Cainfo
  4853. res.WarnMsg = resFour10265.WarnMsg
  4854. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4855. res.Infcode = infocode
  4856. } else {
  4857. 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)
  4858. var dat map[string]interface{}
  4859. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4860. fmt.Println(dat)
  4861. } else {
  4862. fmt.Println(err)
  4863. }
  4864. saveLog(result, request_log, "2204", "上传费用明细")
  4865. userJSONBytes, _ := json.Marshal(dat)
  4866. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4867. utils.ErrorLog("解析失败:%v", err)
  4868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4869. return
  4870. }
  4871. }
  4872. }
  4873. if res.Infcode == 0 {
  4874. order := &models.HisOrder{
  4875. UserOrgId: adminUser.CurrentOrgId,
  4876. HisPatientId: his.ID,
  4877. PatientId: his.PatientId,
  4878. SettleAccountsDate: recordDateTime,
  4879. MdtrtId: his.Number,
  4880. PsnNo: his.PsnNo,
  4881. MedType: strconv.FormatInt(reg_type, 10),
  4882. Ctime: time.Now().Unix(),
  4883. Mtime: time.Now().Unix(),
  4884. Status: 1,
  4885. Number: chrg_bchno,
  4886. Infcode: res.Infcode,
  4887. WarnMsg: res.WarnMsg,
  4888. Cainfo: res.Cainfo,
  4889. ErrMsg: res.ErrMsg,
  4890. RespondTime: res.RefmsgTime,
  4891. InfRefmsgid: res.InfRefmsgid,
  4892. OrderStatus: 1,
  4893. PayWay: pay_way,
  4894. PayPrice: pay_price,
  4895. PayCardNo: pay_card_no,
  4896. DiscountPrice: discount_price,
  4897. PreferentialPrice: preferential_price,
  4898. RealityPrice: reality_price,
  4899. FoundPrice: found_price,
  4900. MedicalInsurancePrice: medical_insurance_price,
  4901. PrivatePrice: private_price,
  4902. IsMedicineInsurance: 1,
  4903. SettleType: settle_accounts_type,
  4904. SettleStartTime: start_time,
  4905. SettleEndTime: end_time,
  4906. Creator: roles.AdminUserId,
  4907. Modify: roles.AdminUserId,
  4908. FaPiaoNumber: fapiao_number,
  4909. FaPiaoCode: fapiao_code,
  4910. PType: 2,
  4911. Diagnosis: diagnosis_id,
  4912. }
  4913. err = service.CreateOrder(order)
  4914. if err != nil {
  4915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4916. return
  4917. }
  4918. for _, item := range res.Output.Result {
  4919. temp := strings.Split(item.FeedetlSn, "-")
  4920. var advice_id int64 = 0
  4921. var project_id int64 = 0
  4922. var types int64 = 0
  4923. id, _ := strconv.ParseInt(temp[2], 10, 64)
  4924. types, _ = strconv.ParseInt(temp[1], 10, 64)
  4925. if temp[1] == "1" {
  4926. advice_id = id
  4927. project_id = 0
  4928. } else if temp[1] == "2" {
  4929. advice_id = 0
  4930. project_id = id
  4931. }
  4932. info := &models.HisOrderInfo{
  4933. OrderNumber: order.Number,
  4934. FeedetlSn: item.FeedetlSn,
  4935. UploadDate: time.Now().Unix(),
  4936. AdviceId: advice_id,
  4937. DetItemFeeSumamt: item.DetItemFeeSumamt,
  4938. Cnt: item.Cnt,
  4939. Pric: float64(item.Pric),
  4940. PatientId: his.PatientId,
  4941. PricUplmtAmt: item.PricUplmtAmt,
  4942. SelfpayProp: item.SelfpayProp,
  4943. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4944. OverlmtAmt: item.OverlmtAmt,
  4945. PreselfpayAmt: item.PreselfpayAmt,
  4946. BasMednFlag: item.BasMednFlag,
  4947. MedChrgitmType: item.MedChrgitmType,
  4948. HiNegoDrugFlag: item.HiNegoDrugFlag,
  4949. Status: 1,
  4950. Memo: item.Memo,
  4951. Mtime: time.Now().Unix(),
  4952. InscpScpAmt: item.InscpScpAmt,
  4953. DrtReimFlag: item.DrtReimFlag,
  4954. Ctime: time.Now().Unix(),
  4955. ListSpItemFlag: item.ListSpItemFlag,
  4956. ChldMedcFlag: item.ChldMedcFlag,
  4957. LmtUsedFlag: item.LmtUsedFlag,
  4958. ChrgitmLv: item.ChrgitmLv,
  4959. UserOrgId: adminUser.CurrentOrgId,
  4960. HisPatientId: his.ID,
  4961. OrderId: order.ID,
  4962. ProjectId: project_id,
  4963. Type: types,
  4964. }
  4965. service.CreateOrderInfo(info)
  4966. }
  4967. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4968. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  4969. var total float64
  4970. for _, item := range prescriptions {
  4971. if item.Type == 1 { //药品
  4972. for _, subItem := range item.HisDoctorAdviceInfo {
  4973. total = total + (subItem.Price * subItem.PrescribingNumber)
  4974. }
  4975. }
  4976. if item.Type == 2 { //项目
  4977. for _, subItem := range item.HisPrescriptionProject {
  4978. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4979. total = total + (subItem.Price * cnt)
  4980. }
  4981. }
  4982. }
  4983. for _, item := range prescriptions {
  4984. for _, subItem := range item.HisAdditionalCharge {
  4985. total = total + (subItem.Price * float64(subItem.Count))
  4986. }
  4987. }
  4988. var allTotal string
  4989. if adminUser.CurrentOrgId == 9919 {
  4990. allTotal = fmt.Sprintf("%.4f", total)
  4991. } else {
  4992. allTotal = fmt.Sprintf("%.4f", total)
  4993. }
  4994. if res.Infcode == 0 {
  4995. var rf []*ResultFive
  4996. json.Unmarshal([]byte(his.Iinfo), &rf)
  4997. chrg_bchno := chrg_bchno
  4998. cert_no := his.Certno
  4999. var insutypes []string
  5000. var insutype string
  5001. var is390 int = 0
  5002. var is310 int = 0
  5003. for _, item := range rf {
  5004. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5005. insutypes = append(insutypes, item.Insutype)
  5006. }
  5007. }
  5008. if len(insutypes) == 1 {
  5009. insutype = insutypes[0]
  5010. } else {
  5011. for _, i := range insutypes {
  5012. if i == "390" {
  5013. is390 = 1
  5014. }
  5015. if i == "310" {
  5016. is310 = 1
  5017. }
  5018. }
  5019. }
  5020. if is390 == 1 {
  5021. insutype = "390"
  5022. }
  5023. if is310 == 1 {
  5024. insutype = "310"
  5025. }
  5026. if len(insutypes) == 0 {
  5027. insutype = "310"
  5028. }
  5029. if len(insutypes) == 2 {
  5030. insutype = strconv.FormatInt(his.SocialType, 10)
  5031. }
  5032. insutype = strconv.FormatInt(his.SocialType, 10)
  5033. //insutype = "390"
  5034. if his.IdCardType == 1 {
  5035. // cert_no = his.MedicalInsuranceNumber
  5036. cert_no = his.Certno
  5037. } else {
  5038. cert_no = his.Certno
  5039. }
  5040. var res ResultSeven
  5041. var resSeven10265 ResultSeven10265
  5042. var src_resquest string
  5043. var result2 string
  5044. var acct_used_flag string
  5045. fmt.Println("pay_way")
  5046. fmt.Println(pay_way)
  5047. fmt.Println("pay_way")
  5048. if pay_way == 4 {
  5049. acct_used_flag = "1"
  5050. } else {
  5051. acct_used_flag = "0"
  5052. }
  5053. if miConfig.MdtrtareaAdmvs == "421300" {
  5054. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5055. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5056. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5057. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5058. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5059. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5060. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5061. resp, requestErr := http.Get(api)
  5062. if requestErr != nil {
  5063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5064. return
  5065. }
  5066. body, ioErr := ioutil.ReadAll(resp.Body)
  5067. if ioErr != nil {
  5068. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5070. return
  5071. }
  5072. var respJSON map[string]interface{}
  5073. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5074. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5076. return
  5077. }
  5078. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5079. result, _ := json.Marshal(respJSON)
  5080. if miConfig.Code == "H15049901371" {
  5081. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5082. utils.ErrorLog("解析失败:%v", err)
  5083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5084. return
  5085. }
  5086. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5087. res.Output = resSeven10265.Output
  5088. res.ErrMsg = resSeven10265.ErrMsg
  5089. res.Cainfo = resSeven10265.Cainfo
  5090. res.WarnMsg = resSeven10265.WarnMsg
  5091. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5092. res.Infcode = infocode
  5093. } else {
  5094. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5095. utils.ErrorLog("解析失败:%v", err)
  5096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5097. return
  5098. }
  5099. }
  5100. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5101. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5102. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5103. //psn_info, _ := service.GetPsnByPatientId(id)
  5104. bas := strings.Split(psn_info.CardInfo, "|")
  5105. if his.IdCardType == 1 {
  5106. cert_no = bas[2]
  5107. } else if his.IdCardType == 3 {
  5108. cert_no = his.Certno
  5109. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  5110. } else {
  5111. cert_no = bas[1]
  5112. }
  5113. //江苏地区国家医保医疗类别
  5114. //职工透析:医疗类别选特殊情况门诊9933
  5115. //居民血透门慢: 医疗类别选门诊慢病1402
  5116. //var med_type string
  5117. //if his.Insutype == "310" {
  5118. // if reg_type == 14 {
  5119. // med_type = "9933"
  5120. // } else if reg_type == 11 {
  5121. // med_type = "11"
  5122. //
  5123. // }
  5124. //} else if his.Insutype == "390" {
  5125. // if reg_type == 14 {
  5126. // med_type = "1402"
  5127. // } else if reg_type == 11 {
  5128. // med_type = "11"
  5129. // }
  5130. //}
  5131. //psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5132. var api string
  5133. if miConfig.MdtrtareaAdmvs == "320921" {
  5134. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5135. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5136. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5137. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5138. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5139. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5140. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  5141. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5142. } else {
  5143. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5144. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5145. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5146. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5147. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5148. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5149. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5150. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  5151. }
  5152. resp, requestErr := http.Get(api)
  5153. if requestErr != nil {
  5154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5155. return
  5156. }
  5157. body, ioErr := ioutil.ReadAll(resp.Body)
  5158. if ioErr != nil {
  5159. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5161. return
  5162. }
  5163. var respJSON map[string]interface{}
  5164. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5165. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5167. return
  5168. }
  5169. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5170. result, _ := json.Marshal(respJSON)
  5171. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5172. utils.ErrorLog("解析失败:%v", err)
  5173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5174. return
  5175. }
  5176. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5177. res.Output = resSeven10265.Output
  5178. res.ErrMsg = resSeven10265.ErrMsg
  5179. res.Cainfo = resSeven10265.Cainfo
  5180. res.WarnMsg = resSeven10265.WarnMsg
  5181. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5182. res.Infcode = infocode
  5183. } else {
  5184. if miConfig.Code == "H15049901371" {
  5185. //赤峰地区国家医保医疗类别
  5186. //职工透析:医疗类别选特殊情况门诊990502
  5187. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5188. var med_type string
  5189. if his.Insutype == "390" {
  5190. if reg_type == 14 {
  5191. med_type = "9933"
  5192. } else if reg_type == 11 {
  5193. med_type = "11"
  5194. }
  5195. } else if his.Insutype == "310" {
  5196. if reg_type == 14 {
  5197. med_type = "990502"
  5198. } else if reg_type == 11 {
  5199. med_type = "11"
  5200. }
  5201. }
  5202. 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)
  5203. } else {
  5204. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  5205. }
  5206. //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)
  5207. var dat map[string]interface{}
  5208. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5209. fmt.Println(dat)
  5210. } else {
  5211. fmt.Println(err)
  5212. }
  5213. saveLog(result2, src_resquest, "2207", "结算")
  5214. userJSONBytes, _ := json.Marshal(dat)
  5215. if miConfig.Code == "H15049901371" {
  5216. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5217. utils.ErrorLog("解析失败:%v", err)
  5218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5219. return
  5220. }
  5221. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5222. res.Output = resSeven10265.Output
  5223. res.ErrMsg = resSeven10265.ErrMsg
  5224. res.Cainfo = resSeven10265.Cainfo
  5225. res.WarnMsg = resSeven10265.WarnMsg
  5226. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5227. res.Infcode = infocode
  5228. } else {
  5229. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5230. utils.ErrorLog("解析失败:%v", err)
  5231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5232. return
  5233. }
  5234. }
  5235. }
  5236. if res.Infcode != 0 {
  5237. errlog := &models.HisOrderError{
  5238. UserOrgId: adminUser.CurrentOrgId,
  5239. Ctime: time.Now().Unix(),
  5240. Mtime: time.Now().Unix(),
  5241. Number: chrg_bchno,
  5242. ErrMsg: res.ErrMsg,
  5243. Status: 1,
  5244. PatientId: id,
  5245. RecordTime: recordDateTime,
  5246. Stage: 6,
  5247. }
  5248. service.CreateErrMsgLog(errlog)
  5249. c.ServeSuccessJSON(map[string]interface{}{
  5250. "failed_code": -10,
  5251. "msg": res.ErrMsg,
  5252. })
  5253. return
  5254. } else {
  5255. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5256. order.OrderStatus = 2
  5257. order.Status = 1
  5258. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5259. order.SetlId = res.Output.Setlinfo.SetlID
  5260. order.PsnNo = res.Output.Setlinfo.PsnNo
  5261. order.PsnName = res.Output.Setlinfo.PsnName
  5262. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5263. order.Certno = res.Output.Setlinfo.Certno
  5264. order.Gend = res.Output.Setlinfo.Gend
  5265. order.Naty = res.Output.Setlinfo.Naty
  5266. order.Age = res.Output.Setlinfo.Age
  5267. order.Insutype = res.Output.Setlinfo.Insutype
  5268. order.PsnType = res.Output.Setlinfo.PsnType
  5269. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5270. order.SetlTime = res.Output.Setlinfo.SetlTime
  5271. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5272. if res.Output.Setlinfo.MedType == "140101" {
  5273. order.MedType = "14"
  5274. } else {
  5275. order.MedType = res.Output.Setlinfo.MedType
  5276. }
  5277. if reg_type == 1112 {
  5278. order.MedType = "1112"
  5279. }
  5280. if reg_type == 1111 {
  5281. order.MedType = "1111"
  5282. }
  5283. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5284. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5285. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5286. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5287. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5288. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5289. order.HifpPay = res.Output.Setlinfo.HifpPay
  5290. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5291. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5292. order.HifesPay = res.Output.Setlinfo.HifesPay
  5293. order.HifobPay = res.Output.Setlinfo.HifobPay
  5294. order.MafPay = res.Output.Setlinfo.MafPay
  5295. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5296. order.OthPay = res.Output.Setlinfo.OthPay
  5297. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5298. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5299. order.AcctPay = res.Output.Setlinfo.AcctPay
  5300. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5301. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5302. order.Balc = res.Output.Setlinfo.Balc
  5303. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5304. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5305. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5306. order.ClrType = res.Output.Setlinfo.ClrType
  5307. order.ClrWay = res.Output.Setlinfo.ClrWay
  5308. order.Creator = order.Creator
  5309. order.Modify = roles.AdminUserId
  5310. order.RequestLog = src_resquest
  5311. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5312. detailStr := string(setlDetail)
  5313. order.SetlDetail = detailStr
  5314. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5315. err = service.UpDateOrder(order)
  5316. if err == nil {
  5317. c.ServeSuccessJSON(map[string]interface{}{
  5318. "msg": "结算成功",
  5319. })
  5320. } else {
  5321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5322. return
  5323. }
  5324. }
  5325. } else {
  5326. adminUser := c.GetAdminUserInfo()
  5327. errlog := &models.HisOrderError{
  5328. UserOrgId: adminUser.CurrentOrgId,
  5329. Ctime: time.Now().Unix(),
  5330. Mtime: time.Now().Unix(),
  5331. ErrMsg: res.ErrMsg,
  5332. Status: 1,
  5333. PatientId: id,
  5334. RecordTime: recordDateTime,
  5335. Stage: 4,
  5336. }
  5337. service.CreateErrMsgLog(errlog)
  5338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5339. return
  5340. }
  5341. } else {
  5342. adminUser := c.GetAdminUserInfo()
  5343. errlog := &models.HisOrderError{
  5344. UserOrgId: adminUser.CurrentOrgId,
  5345. Ctime: time.Now().Unix(),
  5346. Mtime: time.Now().Unix(),
  5347. ErrMsg: res.ErrMsg,
  5348. Status: 1,
  5349. PatientId: id,
  5350. RecordTime: recordDateTime,
  5351. Stage: 4,
  5352. }
  5353. service.CreateErrMsgLog(errlog)
  5354. c.ServeSuccessJSON(map[string]interface{}{
  5355. "failed_code": -10,
  5356. "msg": res.ErrMsg,
  5357. })
  5358. return
  5359. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5360. //return
  5361. }
  5362. }
  5363. }
  5364. } else if tempOrder.ID > 0 {
  5365. if tempOrder.IsPre == 1 {
  5366. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  5367. var rf []*ResultFive
  5368. json.Unmarshal([]byte(his.Iinfo), &rf)
  5369. chrg_bchno := tempOrder.Number
  5370. cert_no := his.Certno
  5371. var insutypes []string
  5372. var insutype string
  5373. var is390 int = 0
  5374. var is310 int = 0
  5375. for _, item := range rf {
  5376. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5377. insutypes = append(insutypes, item.Insutype)
  5378. }
  5379. }
  5380. if len(insutypes) == 1 {
  5381. insutype = insutypes[0]
  5382. } else {
  5383. for _, i := range insutypes {
  5384. if i == "390" {
  5385. is390 = 1
  5386. }
  5387. if i == "310" {
  5388. is310 = 1
  5389. }
  5390. }
  5391. }
  5392. if is390 == 1 {
  5393. insutype = "390"
  5394. }
  5395. if is310 == 1 {
  5396. insutype = "310"
  5397. }
  5398. if len(insutypes) == 0 {
  5399. insutype = "310"
  5400. }
  5401. if len(insutypes) == 2 {
  5402. insutype = strconv.FormatInt(his.SocialType, 64)
  5403. }
  5404. //insutype = "390"
  5405. if his.IdCardType == 1 {
  5406. // cert_no = his.MedicalInsuranceNumber
  5407. cert_no = his.Certno
  5408. } else {
  5409. cert_no = his.Certno
  5410. }
  5411. var res ResultSeven
  5412. var resSeven10265 ResultSeven10265
  5413. var src_resquest string
  5414. var result2 string
  5415. var acct_used_flag string
  5416. fmt.Println("pay_way")
  5417. fmt.Println(pay_way)
  5418. fmt.Println("pay_way")
  5419. if pay_way == 4 {
  5420. acct_used_flag = "1"
  5421. } else {
  5422. acct_used_flag = "0"
  5423. }
  5424. if miConfig.MdtrtareaAdmvs == "421300" {
  5425. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5426. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5427. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5428. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5429. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5430. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5431. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5432. resp, requestErr := http.Get(api)
  5433. if requestErr != nil {
  5434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5435. return
  5436. }
  5437. body, ioErr := ioutil.ReadAll(resp.Body)
  5438. if ioErr != nil {
  5439. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5441. return
  5442. }
  5443. var respJSON map[string]interface{}
  5444. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5445. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5447. return
  5448. }
  5449. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5450. result, _ := json.Marshal(respJSON)
  5451. fmt.Println("log")
  5452. fmt.Println(string(result))
  5453. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5454. utils.ErrorLog("解析失败:%v", err)
  5455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5456. return
  5457. }
  5458. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5459. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5460. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5461. //psn_info, _ := service.GetPsnByPatientId(id)
  5462. bas := strings.Split(psn_info.CardInfo, "|")
  5463. if his.IdCardType == 1 {
  5464. cert_no = bas[2]
  5465. } else {
  5466. cert_no = bas[1]
  5467. }
  5468. //江苏地区国家医保医疗类别
  5469. //职工透析:医疗类别选特殊情况门诊9933
  5470. //居民血透门慢: 医疗类别选门诊慢病1402
  5471. //var med_type string
  5472. //if his.Insutype == "310" {
  5473. // if reg_type == 14 {
  5474. // med_type = "9933"
  5475. // } else if reg_type == 11 {
  5476. // med_type = "11"
  5477. //
  5478. // }
  5479. //} else if his.Insutype == "390" {
  5480. // if reg_type == 14 {
  5481. // med_type = "1402"
  5482. // } else if reg_type == 11 {
  5483. // med_type = "11"
  5484. // }
  5485. //}
  5486. var api string
  5487. if miConfig.MdtrtareaAdmvs == "320921" {
  5488. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5489. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5490. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5491. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5492. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5493. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5494. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  5495. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5496. } else {
  5497. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5498. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5499. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5500. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5501. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5502. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5503. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5504. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  5505. }
  5506. resp, requestErr := http.Get(api)
  5507. if requestErr != nil {
  5508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5509. return
  5510. }
  5511. body, ioErr := ioutil.ReadAll(resp.Body)
  5512. if ioErr != nil {
  5513. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5515. return
  5516. }
  5517. var respJSON map[string]interface{}
  5518. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5519. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5521. return
  5522. }
  5523. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5524. result, _ := json.Marshal(respJSON)
  5525. fmt.Println("log")
  5526. fmt.Println(string(result))
  5527. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5528. utils.ErrorLog("解析失败:%v", err)
  5529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5530. return
  5531. }
  5532. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5533. res.Output = resSeven10265.Output
  5534. res.ErrMsg = resSeven10265.ErrMsg
  5535. res.Cainfo = resSeven10265.Cainfo
  5536. res.WarnMsg = resSeven10265.WarnMsg
  5537. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5538. res.Infcode = infocode
  5539. } else {
  5540. var src_resquest string
  5541. if miConfig.Code == "H15049901371" {
  5542. //赤峰地区国家医保医疗类别
  5543. //职工透析:医疗类别选特殊情况门诊990502
  5544. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5545. var med_type string
  5546. if his.Insutype == "390" {
  5547. if reg_type == 14 {
  5548. med_type = "9933"
  5549. } else if reg_type == 11 {
  5550. med_type = "11"
  5551. }
  5552. } else if his.Insutype == "310" {
  5553. if reg_type == 14 {
  5554. med_type = "990502"
  5555. } else if reg_type == 11 {
  5556. med_type = "11"
  5557. }
  5558. }
  5559. 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)
  5560. } else {
  5561. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  5562. }
  5563. var dat map[string]interface{}
  5564. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5565. fmt.Println(dat)
  5566. } else {
  5567. fmt.Println(err)
  5568. }
  5569. saveLog(result2, src_resquest, "2207", "结算")
  5570. userJSONBytes, _ := json.Marshal(dat)
  5571. if miConfig.Code == "H15049901371" {
  5572. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5573. utils.ErrorLog("解析失败:%v", err)
  5574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5575. return
  5576. }
  5577. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5578. res.Output = resSeven10265.Output
  5579. res.ErrMsg = resSeven10265.ErrMsg
  5580. res.Cainfo = resSeven10265.Cainfo
  5581. res.WarnMsg = resSeven10265.WarnMsg
  5582. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5583. res.Infcode = infocode
  5584. } else {
  5585. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5586. utils.ErrorLog("解析失败:%v", err)
  5587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5588. return
  5589. }
  5590. }
  5591. }
  5592. if res.Infcode != 0 {
  5593. errlog := &models.HisOrderError{
  5594. UserOrgId: adminUser.CurrentOrgId,
  5595. Ctime: time.Now().Unix(),
  5596. Mtime: time.Now().Unix(),
  5597. Number: chrg_bchno,
  5598. ErrMsg: res.ErrMsg,
  5599. Status: 1,
  5600. PatientId: id,
  5601. RecordTime: recordDateTime,
  5602. Stage: 6,
  5603. }
  5604. service.CreateErrMsgLog(errlog)
  5605. c.ServeSuccessJSON(map[string]interface{}{
  5606. "failed_code": -10,
  5607. "msg": res.ErrMsg,
  5608. })
  5609. return
  5610. } else {
  5611. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5612. order.OrderStatus = 2
  5613. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5614. order.SetlId = res.Output.Setlinfo.SetlID
  5615. order.PsnNo = res.Output.Setlinfo.PsnNo
  5616. order.PsnName = res.Output.Setlinfo.PsnName
  5617. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5618. order.Certno = res.Output.Setlinfo.Certno
  5619. order.Gend = res.Output.Setlinfo.Gend
  5620. order.Naty = res.Output.Setlinfo.Naty
  5621. order.Age = res.Output.Setlinfo.Age
  5622. order.Insutype = res.Output.Setlinfo.Insutype
  5623. order.PsnType = res.Output.Setlinfo.PsnType
  5624. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5625. order.SetlTime = res.Output.Setlinfo.SetlTime
  5626. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5627. //order.MedType = res.Output.Setlinfo.MedType
  5628. if reg_type == 1112 {
  5629. order.MedType = "1112"
  5630. }
  5631. if reg_type == 1111 {
  5632. order.MedType = "1111"
  5633. }
  5634. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5635. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5636. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5637. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5638. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5639. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5640. order.HifpPay = res.Output.Setlinfo.HifpPay
  5641. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5642. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5643. order.HifesPay = res.Output.Setlinfo.HifesPay
  5644. order.HifobPay = res.Output.Setlinfo.HifobPay
  5645. order.MafPay = res.Output.Setlinfo.MafPay
  5646. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5647. order.OthPay = res.Output.Setlinfo.OthPay
  5648. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5649. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5650. order.AcctPay = res.Output.Setlinfo.AcctPay
  5651. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5652. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5653. order.Balc = res.Output.Setlinfo.Balc
  5654. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5655. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5656. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5657. order.ClrWay = res.Output.Setlinfo.ClrWay
  5658. order.Creator = order.Creator
  5659. order.Modify = roles.AdminUserId
  5660. order.RequestLog = src_resquest
  5661. order.Diagnosis = diagnosis_id
  5662. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5663. detailStr := string(setlDetail)
  5664. order.SetlDetail = detailStr
  5665. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5666. err = service.UpDateOrder(order)
  5667. if err == nil {
  5668. c.ServeSuccessJSON(map[string]interface{}{
  5669. "msg": "结算成功",
  5670. })
  5671. } else {
  5672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5673. return
  5674. }
  5675. }
  5676. }
  5677. }
  5678. }
  5679. //func (c *HisApiController) GetPreUploadInfo() {
  5680. // id, _ := c.GetInt64("id")
  5681. // record_time := c.GetString("record_time")
  5682. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5683. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5684. //
  5685. // timeLayout := "2006-01-02"
  5686. // loc, _ := time.LoadLocation("Local")
  5687. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5688. // if err != nil {
  5689. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5690. // return
  5691. // }
  5692. // recordDateTime := theTime.Unix()
  5693. // adminUser := c.GetAdminUserInfo()
  5694. //
  5695. // var prescriptions []*models.HisPrescription
  5696. //
  5697. // var start_time int64
  5698. // var end_time int64
  5699. //
  5700. // data := make(map[string]interface{})
  5701. // if settle_accounts_type == 1 { //日结
  5702. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  5703. // data["pre"] = prescriptions
  5704. //
  5705. // } else { //月结
  5706. // start_time_str := c.GetString("start_time")
  5707. // end_time_str := c.GetString("end_time")
  5708. // timeLayout := "2006-01-02"
  5709. // loc, _ := time.LoadLocation("Local")
  5710. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5711. // if err != nil {
  5712. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5713. // return
  5714. // }
  5715. // recordStartTime := theStartTime.Unix()
  5716. // start_time = recordStartTime
  5717. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5718. // if err != nil {
  5719. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5720. // return
  5721. // }
  5722. // recordEndTime := theEndTime.Unix()
  5723. // end_time = recordEndTime
  5724. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  5725. // data["pre"] = prescriptions
  5726. //
  5727. // }
  5728. //
  5729. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5730. //
  5731. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5732. // timestamp := time.Now().Unix()
  5733. // tempTime := time.Unix(timestamp, 0)
  5734. // timeFormat := tempTime.Format("20060102150405")
  5735. // chrgBchno := rand.Intn(100000) + 10000
  5736. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5737. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5738. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5739. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5740. // strconv.FormatInt(his.PatientId, 10)
  5741. // client := &http.Client{}
  5742. // data["psn_no"] = his.PsnNo
  5743. // data["mdtrt_id"] = his.Number
  5744. // data["chrg_bchno"] = chrg_bchno
  5745. // data["org_name"] = miConfig.OrgName
  5746. // data["doctor"] = roles.UserName
  5747. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5748. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5749. // data["fixmedins_code"] = miConfig.Code
  5750. // data["dept_code"] = department.Number
  5751. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5752. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5753. // data["secret_key"] = miConfig.SecretKey
  5754. // var ids []int64
  5755. //
  5756. // for _, item := range prescriptions {
  5757. // ids = append(ids, item.ID)
  5758. // }
  5759. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5760. // if config.IsOpen == 1 { //对接了医保,走医保流程
  5761. // bytesData, _ := json.Marshal(data)
  5762. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  5763. // resp, _ := client.Do(req)
  5764. // defer resp.Body.Close()
  5765. // body, ioErr := ioutil.ReadAll(resp.Body)
  5766. // if ioErr != nil {
  5767. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5768. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5769. // return
  5770. // }
  5771. // var respJSON map[string]interface{}
  5772. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5773. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5774. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5775. // return
  5776. // }
  5777. //
  5778. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5779. // userJSONBytes, _ := json.Marshal(respJSON)
  5780. // var res ResultFour
  5781. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5782. // utils.ErrorLog("解析失败:%v", err)
  5783. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5784. // return
  5785. // }
  5786. //
  5787. // if res.Infcode == 0 {
  5788. // order := &models.HisOrder{
  5789. // UserOrgId: adminUser.CurrentOrgId,
  5790. // HisPatientId: his.ID,
  5791. // PatientId: his.PatientId,
  5792. // SettleAccountsDate: recordDateTime,
  5793. // Ctime: time.Now().Unix(),
  5794. // Mtime: time.Now().Unix(),
  5795. // Status: 1,
  5796. // Number: chrg_bchno,
  5797. // Infcode: res.Infcode,
  5798. // WarnMsg: res.WarnMsg,
  5799. // Cainfo: res.Cainfo,
  5800. // ErrMsg: res.ErrMsg,
  5801. // RespondTime: res.RefmsgTime,
  5802. // InfRefmsgid: res.InfRefmsgid,
  5803. // OrderStatus: 1,
  5804. // IsMedicineInsurance: 1,
  5805. // SettleType: settle_accounts_type,
  5806. // SettleStartTime: start_time,
  5807. // SettleEndTime: end_time,
  5808. // Creator: roles.ID,
  5809. // Modify: roles.ID,
  5810. // PType: 2,
  5811. // }
  5812. // err = service.CreateOrder(order)
  5813. // if err != nil {
  5814. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5815. // return
  5816. // }
  5817. //
  5818. // for _, item := range res.Output.Result {
  5819. // temp := strings.Split(item.FeedetlSn, "-")
  5820. // var advice_id int64 = 0
  5821. // var project_id int64 = 0
  5822. // var types int64 = 0
  5823. //
  5824. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  5825. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  5826. //
  5827. // if temp[1] == "1" {
  5828. // advice_id = id
  5829. // project_id = 0
  5830. // } else if temp[1] == "2" {
  5831. // advice_id = 0
  5832. // project_id = id
  5833. // }
  5834. //
  5835. // info := &models.HisOrderInfo{
  5836. // OrderNumber: order.Number,
  5837. // FeedetlSn: item.FeedetlSn,
  5838. // UploadDate: time.Now().Unix(),
  5839. // AdviceId: advice_id,
  5840. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  5841. // Cnt: item.Cnt,
  5842. // Pric: float64(item.Pric),
  5843. // PatientId: his.PatientId,
  5844. // PricUplmtAmt: item.PricUplmtAmt,
  5845. // SelfpayProp: item.SelfpayProp,
  5846. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5847. // OverlmtAmt: item.OverlmtAmt,
  5848. // PreselfpayAmt: item.PreselfpayAmt,
  5849. // BasMednFlag: item.BasMednFlag,
  5850. // MedChrgitmType: item.MedChrgitmType,
  5851. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  5852. // Status: 1,
  5853. // Memo: item.Memo,
  5854. // Mtime: time.Now().Unix(),
  5855. // InscpScpAmt: item.InscpScpAmt,
  5856. // DrtReimFlag: item.DrtReimFlag,
  5857. // Ctime: time.Now().Unix(),
  5858. // ListSpItemFlag: item.ListSpItemFlag,
  5859. // ChldMedcFlag: item.ChldMedcFlag,
  5860. // LmtUsedFlag: item.LmtUsedFlag,
  5861. // ChrgitmLv: item.ChrgitmLv,
  5862. // UserOrgId: adminUser.CurrentOrgId,
  5863. // HisPatientId: his.ID,
  5864. // OrderId: order.ID,
  5865. // ProjectId: project_id,
  5866. // Type: types,
  5867. // }
  5868. // service.CreateOrderInfo(info)
  5869. //
  5870. // }
  5871. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5872. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  5873. //
  5874. // var total float64
  5875. // for _, item := range prescriptions {
  5876. // if item.Type == 1 { //药品
  5877. // for _, subItem := range item.HisDoctorAdviceInfo {
  5878. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5879. // }
  5880. // }
  5881. // if item.Type == 2 { //项目
  5882. // for _, subItem := range item.HisPrescriptionProject {
  5883. // total = total + (subItem.Price * float64(subItem.Count))
  5884. // }
  5885. // }
  5886. // }
  5887. //
  5888. // for _, item := range prescriptions {
  5889. // for _, subItem := range item.HisAdditionalCharge {
  5890. // total = total + (subItem.Price * float64(subItem.Count))
  5891. // }
  5892. // }
  5893. //
  5894. // allTotal := fmt.Sprintf("%.2f", total)
  5895. // if res.Infcode == 0 {
  5896. // var rf []*ResultFive
  5897. // json.Unmarshal([]byte(his.Iinfo), &rf)
  5898. // psn_no := his.PsnNo
  5899. // mdtrt_id := his.Number
  5900. // chrg_bchno := chrg_bchno
  5901. // cert_no := his.Certno
  5902. // insutype := rf[0].Insutype
  5903. //
  5904. // if his.IdCardType == 1 {
  5905. // cert_no = his.MedicalInsuranceNumber
  5906. //
  5907. // } else {
  5908. //
  5909. // cert_no = his.Certno
  5910. //
  5911. // }
  5912. //
  5913. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  5914. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  5915. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  5916. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  5917. // resp, requestErr := http.Get(api)
  5918. // if requestErr != nil {
  5919. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5920. // return
  5921. // }
  5922. // defer resp.Body.Close()
  5923. // body, ioErr := ioutil.ReadAll(resp.Body)
  5924. // if ioErr != nil {
  5925. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5926. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5927. // return
  5928. // }
  5929. // var respJSON map[string]interface{}
  5930. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5931. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5932. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5933. // return
  5934. // }
  5935. // fmt.Println(respJSON)
  5936. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5937. // userJSONBytes, _ := json.Marshal(respJSON)
  5938. // var res ResultSeven
  5939. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5940. // utils.ErrorLog("解析失败:%v", err)
  5941. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5942. // return
  5943. // }
  5944. // if res.Infcode != 0 {
  5945. // errlog := &models.HisOrderError{
  5946. // UserOrgId: adminUser.CurrentOrgId,
  5947. // Ctime: time.Now().Unix(),
  5948. // Mtime: time.Now().Unix(),
  5949. // Number: chrg_bchno,
  5950. // ErrMsg: res.ErrMsg,
  5951. // Status: 1,
  5952. // PatientId: id,
  5953. // RecordTime: recordDateTime,
  5954. // Stage: 7,
  5955. // }
  5956. // service.CreateErrMsgLog(errlog)
  5957. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5958. // return
  5959. // } else {
  5960. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5961. // order.OrderStatus = 1
  5962. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5963. // order.SetlId = res.Output.Setlinfo.SetlID
  5964. // order.PsnNo = res.Output.Setlinfo.PsnNo
  5965. // order.PsnName = res.Output.Setlinfo.PsnName
  5966. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5967. // order.Certno = res.Output.Setlinfo.Certno
  5968. // order.Gend = res.Output.Setlinfo.Gend
  5969. // order.Naty = res.Output.Setlinfo.Naty
  5970. // order.Age = res.Output.Setlinfo.Age
  5971. // order.Insutype = res.Output.Setlinfo.Insutype
  5972. // order.PsnType = res.Output.Setlinfo.PsnType
  5973. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5974. // order.SetlTime = res.Output.Setlinfo.SetlTime
  5975. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5976. // order.MedType = res.Output.Setlinfo.MedType
  5977. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5978. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5979. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5980. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5981. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5982. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5983. // order.HifpPay = res.Output.Setlinfo.HifpPay
  5984. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5985. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5986. // order.HifesPay = res.Output.Setlinfo.HifesPay
  5987. // order.HifobPay = res.Output.Setlinfo.HifobPay
  5988. // order.MafPay = res.Output.Setlinfo.MafPay
  5989. // order.OthPay = res.Output.Setlinfo.OthPay
  5990. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5991. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5992. // order.AcctPay = res.Output.Setlinfo.AcctPay
  5993. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5994. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5995. // order.Balc = res.Output.Setlinfo.Balc
  5996. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5997. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5998. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5999. // order.ClrWay = res.Output.Setlinfo.ClrWay
  6000. // order.Creator = order.Creator
  6001. // order.Modify = roles.ID
  6002. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6003. // detailStr := string(setlDetail)
  6004. // order.SetlDetail = detailStr
  6005. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6006. // err = service.UpDateOrder(order)
  6007. // if err == nil {
  6008. // c.ServeSuccessJSON(map[string]interface{}{
  6009. // "msg": "预结算成功",
  6010. // })
  6011. // } else {
  6012. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6013. // return
  6014. // }
  6015. // }
  6016. // } else {
  6017. // adminUser := c.GetAdminUserInfo()
  6018. // errlog := &models.HisOrderError{
  6019. // UserOrgId: adminUser.CurrentOrgId,
  6020. // Ctime: time.Now().Unix(),
  6021. // Mtime: time.Now().Unix(),
  6022. // ErrMsg: res.ErrMsg,
  6023. // Status: 1,
  6024. // PatientId: id,
  6025. // RecordTime: recordDateTime,
  6026. // Stage: 4,
  6027. // }
  6028. // service.CreateErrMsgLog(errlog)
  6029. //
  6030. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6031. // return
  6032. // }
  6033. // } else {
  6034. // adminUser := c.GetAdminUserInfo()
  6035. // errlog := &models.HisOrderError{
  6036. // UserOrgId: adminUser.CurrentOrgId,
  6037. // Ctime: time.Now().Unix(),
  6038. // Mtime: time.Now().Unix(),
  6039. // ErrMsg: res.ErrMsg,
  6040. // Status: 1,
  6041. // PatientId: id,
  6042. // RecordTime: recordDateTime,
  6043. // Stage: 4,
  6044. // }
  6045. // service.CreateErrMsgLog(errlog)
  6046. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6047. // return
  6048. // }
  6049. //
  6050. // } else {
  6051. // var total float64
  6052. // for _, item := range prescriptions {
  6053. // if item.Type == 1 { //药品
  6054. // for _, subItem := range item.HisDoctorAdviceInfo {
  6055. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6056. // }
  6057. // }
  6058. // if item.Type == 2 { //项目
  6059. // for _, subItem := range item.HisPrescriptionProject {
  6060. // total = total + (subItem.Price * float64(subItem.Count))
  6061. // }
  6062. // }
  6063. //
  6064. // for _, subItem := range item.HisAdditionalCharge {
  6065. // total = total + (subItem.Price * float64(subItem.Count))
  6066. // }
  6067. // }
  6068. //
  6069. // allTotal := fmt.Sprintf("%.2f", total)
  6070. // totals, _ := strconv.ParseFloat(allTotal, 64)
  6071. // order := &models.HisOrder{
  6072. // UserOrgId: adminUser.CurrentOrgId,
  6073. // HisPatientId: his.ID,
  6074. // PatientId: id,
  6075. // SettleAccountsDate: recordDateTime,
  6076. // Ctime: time.Now().Unix(),
  6077. // Mtime: time.Now().Unix(),
  6078. // Status: 1,
  6079. // OrderStatus: 2,
  6080. // Number: chrg_bchno,
  6081. // MedfeeSumamt: totals,
  6082. // }
  6083. // err = service.CreateOrder(order)
  6084. // if err != nil {
  6085. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6086. // return
  6087. // }
  6088. //
  6089. // var customs []*Custom
  6090. // for _, item := range prescriptions {
  6091. //
  6092. // if item.Type == 1 { //药品
  6093. // for _, subItem := range item.HisDoctorAdviceInfo {
  6094. // cus := &Custom{
  6095. // AdviceId: subItem.ID,
  6096. // ProjectId: 0,
  6097. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  6098. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  6099. // FeedetlSn: subItem.FeedetlSn,
  6100. // Price: fmt.Sprintf("%.2f", subItem.Price),
  6101. // MedListCodg: subItem.MedListCodg,
  6102. // Type: 1,
  6103. // }
  6104. // customs = append(customs, cus)
  6105. // }
  6106. // }
  6107. //
  6108. // if item.Type == 2 { //项目
  6109. // for _, subItem := range item.HisPrescriptionProject {
  6110. //
  6111. // cus := &Custom{
  6112. // AdviceId: 0,
  6113. // ProjectId: subItem.ID,
  6114. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  6115. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  6116. // FeedetlSn: subItem.FeedetlSn,
  6117. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  6118. // MedListCodg: subItem.MedListCodg,
  6119. // Type: 2,
  6120. // }
  6121. //
  6122. // customs = append(customs, cus)
  6123. // }
  6124. // }
  6125. //
  6126. // for _, item := range item.HisAdditionalCharge {
  6127. // cus := &Custom{
  6128. // ItemId: item.ID,
  6129. // AdviceId: 0,
  6130. // ProjectId: 0,
  6131. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  6132. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  6133. // FeedetlSn: item.FeedetlSn,
  6134. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  6135. // MedListCodg: item.XtHisAddtionConfig.Code,
  6136. // Type: 3,
  6137. // }
  6138. //
  6139. // customs = append(customs, cus)
  6140. // }
  6141. //
  6142. // }
  6143. //
  6144. // for _, item := range customs {
  6145. // var advice_id int64 = 0
  6146. // var project_id int64 = 0
  6147. // var item_id int64 = 0
  6148. //
  6149. // var types int64 = 0
  6150. //
  6151. // if item.Type == 1 {
  6152. // advice_id = item.AdviceId
  6153. // project_id = 0
  6154. // item_id = 0
  6155. // } else if item.Type == 2 {
  6156. // advice_id = 0
  6157. // item_id = 0
  6158. //
  6159. // project_id = item.ProjectId
  6160. // } else if item.Type == 3 {
  6161. // advice_id = 0
  6162. // item_id = item.ItemId
  6163. // project_id = 0
  6164. // }
  6165. //
  6166. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  6167. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  6168. // pric, _ := strconv.ParseFloat(item.Price, 32)
  6169. //
  6170. // info := &models.HisOrderInfo{
  6171. // OrderNumber: order.Number,
  6172. // UploadDate: time.Now().Unix(),
  6173. // AdviceId: advice_id,
  6174. // DetItemFeeSumamt: detItemFeeSumamt,
  6175. // Cnt: cut,
  6176. // Pric: pric,
  6177. // PatientId: id,
  6178. // Status: 1,
  6179. // Mtime: time.Now().Unix(),
  6180. // Ctime: time.Now().Unix(),
  6181. // UserOrgId: adminUser.CurrentOrgId,
  6182. // HisPatientId: his.ID,
  6183. // OrderId: order.ID,
  6184. // ProjectId: project_id,
  6185. // Type: types,
  6186. // ItemId: item_id,
  6187. // }
  6188. // service.CreateOrderInfo(info)
  6189. // }
  6190. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6191. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6192. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  6193. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6194. // if err == nil {
  6195. // c.ServeSuccessJSON(map[string]interface{}{
  6196. // "msg": "结算成功",
  6197. // })
  6198. // } else {
  6199. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6200. // return
  6201. // }
  6202. // }
  6203. //}
  6204. //上传明细-预结算-
  6205. func (c *HisApiController) GetPreUploadInfo() {
  6206. id, _ := c.GetInt64("id")
  6207. record_time := c.GetString("record_time")
  6208. his_patient_id, _ := c.GetInt64("his_patient_id")
  6209. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6210. admin_user_id, _ := c.GetInt64("admin_user_id")
  6211. diagnosis_id := c.GetString("diagnosis")
  6212. sick_type, _ := c.GetInt64("sick_type")
  6213. reg_type, _ := c.GetInt64("p_type")
  6214. begin_time := c.GetString("begin_time")
  6215. id_str := c.GetString("ids")
  6216. ids_arr := strings.Split(id_str, ",")
  6217. timeLayout := "2006-01-02"
  6218. loc, _ := time.LoadLocation("Local")
  6219. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6220. if err != nil {
  6221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6222. return
  6223. }
  6224. recordDateTime := theTime.Unix()
  6225. adminUser := c.GetAdminUserInfo()
  6226. diagnosis_ids := strings.Split(diagnosis_id, ",")
  6227. var config []*models.HisXtDiagnoseConfig
  6228. for _, item := range diagnosis_ids {
  6229. id, _ := strconv.ParseInt(item, 10, 64)
  6230. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6231. config = append(config, &diagnosisConfig)
  6232. }
  6233. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  6234. sickConfig, _ := service.FindSickById(sick_type)
  6235. var prescriptions []*models.HisPrescription
  6236. var start_time int64
  6237. var end_time int64
  6238. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6239. fmt.Println(his_patient_id)
  6240. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6241. timestamp := time.Now().Unix()
  6242. tempTime := time.Unix(timestamp, 0)
  6243. timeFormat := tempTime.Format("20060102150405")
  6244. chrgBchno := rand.Intn(100000) + 10000
  6245. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6246. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6247. var patientPrescription models.HisPrescriptionInfo
  6248. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6249. if patientPrescription.ID == 0 {
  6250. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6251. }
  6252. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6253. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6254. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6255. strconv.FormatInt(his.PatientId, 10)
  6256. var res2 ResultSix
  6257. var resSix10265 ResultSix10265
  6258. var time_stamp string
  6259. if miConfig.MdtrtareaAdmvs == "421300" {
  6260. data := make(map[string]interface{})
  6261. client := &http.Client{}
  6262. data["psn_no"] = his.PsnNo
  6263. data["mdtrt_id"] = his.Number
  6264. data["doctor"] = roles.UserName
  6265. data["department"] = department.Name
  6266. data["org_name"] = miConfig.OrgName
  6267. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6268. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6269. data["fixmedins_code"] = miConfig.Code
  6270. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6271. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6272. data["secret_key"] = miConfig.SecretKey
  6273. data["sick_code"] = sickConfig.CountryCode
  6274. data["sick_name"] = sickConfig.ClassName
  6275. data["begin_time"] = begin_time
  6276. data["dept"] = strconv.FormatInt(department.ID, 10)
  6277. data["config"] = config
  6278. fmt.Println(data)
  6279. bytesData, _ := json.Marshal(data)
  6280. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  6281. resp, _ := client.Do(req)
  6282. defer resp.Body.Close()
  6283. body, ioErr := ioutil.ReadAll(resp.Body)
  6284. if ioErr != nil {
  6285. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6287. return
  6288. }
  6289. var respJSON map[string]interface{}
  6290. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6291. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6293. return
  6294. }
  6295. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6296. userJSONBytes, _ := json.Marshal(respJSON)
  6297. fmt.Println("log")
  6298. fmt.Println(string(userJSONBytes))
  6299. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6300. utils.ErrorLog("解析失败:%v", err)
  6301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6302. return
  6303. }
  6304. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6305. //江苏地区国家医保医疗类别
  6306. //职工透析:医疗类别选特殊情况门诊9933
  6307. //居民血透门慢: 医疗类别选门诊慢病1402
  6308. //var med_type string
  6309. //if his.Insutype == "310" {
  6310. // if reg_type == 14 {
  6311. // med_type = "9933"
  6312. // } else if reg_type == 11 {
  6313. // med_type = "11"
  6314. //
  6315. // }
  6316. //} else if his.Insutype == "390" {
  6317. // if reg_type == 14 {
  6318. // med_type = "1402"
  6319. // } else if reg_type == 11 {
  6320. // med_type = "11"
  6321. // }
  6322. //}
  6323. data := make(map[string]interface{})
  6324. client := &http.Client{}
  6325. data["psn_no"] = his.PsnNo
  6326. data["mdtrt_id"] = his.Number
  6327. data["doctor"] = roles.UserName
  6328. data["department"] = department.Name
  6329. data["org_name"] = miConfig.OrgName
  6330. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6331. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6332. data["fixmedins_code"] = miConfig.Code
  6333. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6334. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6335. data["secret_key"] = miConfig.SecretKey
  6336. data["sick_code"] = sickConfig.CountryCode
  6337. data["sick_name"] = sickConfig.ClassName
  6338. data["begin_time"] = begin_time
  6339. data["dept"] = strconv.FormatInt(department.ID, 10)
  6340. data["config"] = config
  6341. data["url"] = miConfig.Url
  6342. data["ak"] = miConfig.AccessKey
  6343. data["cainfo"] = miConfig.Cainfo
  6344. bytesData, _ := json.Marshal(data)
  6345. var req *http.Request
  6346. if miConfig.MdtrtareaAdmvs == "320921" {
  6347. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6348. //api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  6349. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  6350. } else {
  6351. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6352. }
  6353. resp, _ := client.Do(req)
  6354. defer resp.Body.Close()
  6355. body, ioErr := ioutil.ReadAll(resp.Body)
  6356. if ioErr != nil {
  6357. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6359. return
  6360. }
  6361. var respJSON map[string]interface{}
  6362. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6363. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6365. return
  6366. }
  6367. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  6368. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  6369. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  6370. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6371. userJSONBytes, _ := json.Marshal(respJSON)
  6372. fmt.Println("log")
  6373. fmt.Println(string(userJSONBytes))
  6374. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6375. utils.ErrorLog("解析失败:%v", err)
  6376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6377. return
  6378. }
  6379. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6380. res2.Output = resSix10265.Output
  6381. res2.ErrMsg = resSix10265.ErrMsg
  6382. res2.Cainfo = resSix10265.Cainfo
  6383. res2.WarnMsg = resSix10265.WarnMsg
  6384. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6385. res2.Infcode = infocode
  6386. } else {
  6387. var result string
  6388. var requestLog string
  6389. if miConfig.MdtrtareaAdmvs == "440781" { //
  6390. 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)
  6391. } else {
  6392. if miConfig.Code == "H15049901371" {
  6393. //赤峰地区国家医保医疗类别
  6394. //职工透析:医疗类别选特殊情况门诊990502
  6395. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6396. var med_type string
  6397. if his.Insutype == "390" {
  6398. if reg_type == 14 {
  6399. med_type = "9933"
  6400. } else if reg_type == 11 {
  6401. med_type = "11"
  6402. }
  6403. } else if his.Insutype == "310" {
  6404. if reg_type == 14 {
  6405. med_type = "990502"
  6406. } else if reg_type == 11 {
  6407. med_type = "11"
  6408. }
  6409. }
  6410. 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)
  6411. } else {
  6412. 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)
  6413. }
  6414. saveLog(result, requestLog, "2203", "上传就诊信息")
  6415. var respJSON2 map[string]interface{}
  6416. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6417. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6419. return
  6420. }
  6421. userJSONBytes2, _ := json.Marshal(respJSON2)
  6422. if miConfig.Code == "H15049901371" {
  6423. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  6424. utils.ErrorLog("解析失败:%v", err)
  6425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6426. return
  6427. }
  6428. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6429. res2.Output = resSix10265.Output
  6430. res2.ErrMsg = resSix10265.ErrMsg
  6431. res2.Cainfo = resSix10265.Cainfo
  6432. res2.WarnMsg = resSix10265.WarnMsg
  6433. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6434. res2.Infcode = infocode
  6435. } else {
  6436. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  6437. utils.ErrorLog("解析失败:%v", err)
  6438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6439. return
  6440. }
  6441. }
  6442. }
  6443. }
  6444. if res2.Infcode != 0 {
  6445. adminUser := c.GetAdminUserInfo()
  6446. errlog := &models.HisOrderError{
  6447. UserOrgId: adminUser.CurrentOrgId,
  6448. Ctime: time.Now().Unix(),
  6449. Mtime: time.Now().Unix(),
  6450. ErrMsg: res2.ErrMsg,
  6451. Status: 1,
  6452. PatientId: id,
  6453. RecordTime: recordDateTime,
  6454. Stage: 3,
  6455. }
  6456. service.CreateErrMsgLog(errlog)
  6457. c.ServeSuccessJSON(map[string]interface{}{
  6458. "failed_code": -10,
  6459. "msg": res2.ErrMsg,
  6460. })
  6461. return
  6462. } else {
  6463. his.Diagnosis = diagnosis_id
  6464. his.SickType = sickConfig.ID
  6465. his.PType = fmt.Sprintf("%d", reg_type)
  6466. service.UpdateHisPatientThree(&his)
  6467. data := make(map[string]interface{})
  6468. if settle_accounts_type == 1 { //日结
  6469. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  6470. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  6471. } else {
  6472. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  6473. }
  6474. data["pre"] = prescriptions
  6475. } else { //月结
  6476. start_time_str := c.GetString("start_time")
  6477. end_time_str := c.GetString("end_time")
  6478. timeLayout := "2006-01-02"
  6479. loc, _ := time.LoadLocation("Local")
  6480. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6481. if err != nil {
  6482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6483. return
  6484. }
  6485. recordStartTime := theStartTime.Unix()
  6486. start_time = recordStartTime
  6487. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6488. if err != nil {
  6489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6490. return
  6491. }
  6492. recordEndTime := theEndTime.Unix()
  6493. end_time = recordEndTime
  6494. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  6495. data["pre"] = prescriptions
  6496. }
  6497. client := &http.Client{}
  6498. data["psn_no"] = his.PsnNo
  6499. data["mdtrt_id"] = his.Number
  6500. data["chrg_bchno"] = chrg_bchno
  6501. data["org_name"] = miConfig.OrgName
  6502. data["doctor"] = roles.UserName
  6503. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6504. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6505. data["fixmedins_code"] = miConfig.Code
  6506. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  6507. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  6508. data["dept_code"] = "15"
  6509. } else {
  6510. data["dept_code"] = department.Number
  6511. }
  6512. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6513. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6514. data["secret_key"] = miConfig.SecretKey
  6515. data["url"] = miConfig.Url
  6516. data["ak"] = miConfig.AccessKey
  6517. data["new_doctor_name"] = patientPrescription.Doctor
  6518. data["diag_code"] = sickConfig.CountryCode
  6519. data["time_stamp"] = time_stamp
  6520. data["cainfo"] = miConfig.Cainfo
  6521. var ids []int64
  6522. for _, item := range prescriptions {
  6523. ids = append(ids, item.ID)
  6524. }
  6525. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6526. if config.IsOpen == 1 { //对接了医保,走医保流程
  6527. var res ResultFour
  6528. var resFour10265 ResultFour10265
  6529. if miConfig.MdtrtareaAdmvs == "421300" {
  6530. bytesData, _ := json.Marshal(data)
  6531. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  6532. resp, _ := client.Do(req)
  6533. defer resp.Body.Close()
  6534. body, ioErr := ioutil.ReadAll(resp.Body)
  6535. if ioErr != nil {
  6536. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6538. return
  6539. }
  6540. var respJSON map[string]interface{}
  6541. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6542. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6544. return
  6545. }
  6546. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6547. userJSONBytes, _ := json.Marshal(respJSON)
  6548. fmt.Println("log")
  6549. fmt.Println(string(userJSONBytes))
  6550. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6551. utils.ErrorLog("解析失败:%v", err)
  6552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6553. return
  6554. }
  6555. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6556. bytesData, _ := json.Marshal(data)
  6557. var req *http.Request
  6558. if miConfig.MdtrtareaAdmvs == "320921" {
  6559. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6560. } else {
  6561. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6562. }
  6563. resp, _ := client.Do(req)
  6564. defer resp.Body.Close()
  6565. body, ioErr := ioutil.ReadAll(resp.Body)
  6566. if ioErr != nil {
  6567. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6569. return
  6570. }
  6571. var respJSON map[string]interface{}
  6572. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6573. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6575. return
  6576. }
  6577. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6578. userJSONBytes, _ := json.Marshal(respJSON)
  6579. fmt.Println("log")
  6580. fmt.Println(string(userJSONBytes))
  6581. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6582. utils.ErrorLog("解析失败:%v", err)
  6583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6584. return
  6585. }
  6586. res.InfRefmsgid = resFour10265.InfRefmsgid
  6587. res.Output = resFour10265.Output
  6588. res.ErrMsg = resFour10265.ErrMsg
  6589. res.Cainfo = resFour10265.Cainfo
  6590. res.WarnMsg = resFour10265.WarnMsg
  6591. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6592. res.Infcode = infocode
  6593. } else {
  6594. if miConfig.Code == "H15049901371" {
  6595. 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)
  6596. var dat map[string]interface{}
  6597. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6598. fmt.Println(dat)
  6599. } else {
  6600. fmt.Println(err)
  6601. }
  6602. saveLog(result, request_log, "2204", "上传费用明细")
  6603. userJSONBytes, _ := json.Marshal(dat)
  6604. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6605. utils.ErrorLog("解析失败:%v", err)
  6606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6607. return
  6608. }
  6609. res.InfRefmsgid = resFour10265.InfRefmsgid
  6610. res.Output = resFour10265.Output
  6611. res.ErrMsg = resFour10265.ErrMsg
  6612. res.Cainfo = resFour10265.Cainfo
  6613. res.WarnMsg = resFour10265.WarnMsg
  6614. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6615. res.Infcode = infocode
  6616. } else {
  6617. 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)
  6618. var dat map[string]interface{}
  6619. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6620. fmt.Println(dat)
  6621. } else {
  6622. fmt.Println(err)
  6623. }
  6624. saveLog(result, request_log, "2204", "上传费用明细")
  6625. userJSONBytes, _ := json.Marshal(dat)
  6626. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6627. utils.ErrorLog("解析失败:%v", err)
  6628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6629. return
  6630. }
  6631. }
  6632. }
  6633. if res.Infcode == 0 {
  6634. order := &models.HisOrder{
  6635. UserOrgId: adminUser.CurrentOrgId,
  6636. HisPatientId: his.ID,
  6637. PatientId: his.PatientId,
  6638. SettleAccountsDate: recordDateTime,
  6639. Ctime: time.Now().Unix(),
  6640. Mtime: time.Now().Unix(),
  6641. MdtrtId: his.Number,
  6642. PsnNo: his.PsnNo,
  6643. MedType: strconv.FormatInt(reg_type, 10),
  6644. Status: 1,
  6645. Number: chrg_bchno,
  6646. Infcode: res.Infcode,
  6647. WarnMsg: res.WarnMsg,
  6648. Cainfo: res.Cainfo,
  6649. ErrMsg: res.ErrMsg,
  6650. RespondTime: res.RefmsgTime,
  6651. InfRefmsgid: res.InfRefmsgid,
  6652. OrderStatus: 1,
  6653. IsMedicineInsurance: 1,
  6654. SettleType: settle_accounts_type,
  6655. SettleStartTime: start_time,
  6656. SettleEndTime: end_time,
  6657. Creator: roles.AdminUserId,
  6658. Modify: roles.AdminUserId,
  6659. PType: 2,
  6660. Diagnosis: diagnosis_id,
  6661. }
  6662. err = service.CreateOrder(order)
  6663. if err != nil {
  6664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6665. return
  6666. }
  6667. for _, item := range res.Output.Result {
  6668. temp := strings.Split(item.FeedetlSn, "-")
  6669. var advice_id int64 = 0
  6670. var project_id int64 = 0
  6671. var types int64 = 0
  6672. id, _ := strconv.ParseInt(temp[2], 10, 64)
  6673. types, _ = strconv.ParseInt(temp[1], 10, 64)
  6674. if temp[1] == "1" {
  6675. advice_id = id
  6676. project_id = 0
  6677. } else if temp[1] == "2" {
  6678. advice_id = 0
  6679. project_id = id
  6680. }
  6681. info := &models.HisOrderInfo{
  6682. OrderNumber: order.Number,
  6683. FeedetlSn: item.FeedetlSn,
  6684. UploadDate: time.Now().Unix(),
  6685. AdviceId: advice_id,
  6686. DetItemFeeSumamt: item.DetItemFeeSumamt,
  6687. Cnt: item.Cnt,
  6688. Pric: float64(item.Pric),
  6689. PatientId: his.PatientId,
  6690. PricUplmtAmt: item.PricUplmtAmt,
  6691. SelfpayProp: item.SelfpayProp,
  6692. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6693. OverlmtAmt: item.OverlmtAmt,
  6694. PreselfpayAmt: item.PreselfpayAmt,
  6695. BasMednFlag: item.BasMednFlag,
  6696. MedChrgitmType: item.MedChrgitmType,
  6697. HiNegoDrugFlag: item.HiNegoDrugFlag,
  6698. Status: 1,
  6699. Memo: item.Memo,
  6700. Mtime: time.Now().Unix(),
  6701. InscpScpAmt: item.InscpScpAmt,
  6702. DrtReimFlag: item.DrtReimFlag,
  6703. Ctime: time.Now().Unix(),
  6704. ListSpItemFlag: item.ListSpItemFlag,
  6705. ChldMedcFlag: item.ChldMedcFlag,
  6706. LmtUsedFlag: item.LmtUsedFlag,
  6707. ChrgitmLv: item.ChrgitmLv,
  6708. UserOrgId: adminUser.CurrentOrgId,
  6709. HisPatientId: his.ID,
  6710. OrderId: order.ID,
  6711. ProjectId: project_id,
  6712. Type: types,
  6713. }
  6714. service.CreateOrderInfo(info)
  6715. }
  6716. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6717. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  6718. var total float64
  6719. for _, item := range prescriptions {
  6720. if item.Type == 1 { //药品
  6721. for _, subItem := range item.HisDoctorAdviceInfo {
  6722. total = total + (subItem.Price * subItem.PrescribingNumber)
  6723. }
  6724. }
  6725. if item.Type == 2 { //项目
  6726. for _, subItem := range item.HisPrescriptionProject {
  6727. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6728. total = total + (subItem.Price * cnt)
  6729. }
  6730. }
  6731. }
  6732. for _, item := range prescriptions {
  6733. for _, subItem := range item.HisAdditionalCharge {
  6734. total = total + (subItem.Price * float64(subItem.Count))
  6735. }
  6736. }
  6737. allTotal := fmt.Sprintf("%.4f", total)
  6738. if res.Infcode == 0 {
  6739. var rf []*ResultFive
  6740. json.Unmarshal([]byte(his.Iinfo), &rf)
  6741. chrg_bchno := chrg_bchno
  6742. cert_no := his.Certno
  6743. var insutypes []string
  6744. var insutype string
  6745. var is390 int = 0
  6746. var is310 int = 0
  6747. for _, item := range rf {
  6748. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6749. insutypes = append(insutypes, item.Insutype)
  6750. }
  6751. }
  6752. if len(insutypes) == 1 {
  6753. insutype = insutypes[0]
  6754. } else {
  6755. for _, i := range insutypes {
  6756. if i == "390" {
  6757. is390 = 1
  6758. }
  6759. if i == "310" {
  6760. is310 = 1
  6761. }
  6762. }
  6763. }
  6764. if is390 == 1 {
  6765. insutype = "390"
  6766. }
  6767. if is310 == 1 {
  6768. insutype = "310"
  6769. }
  6770. if len(insutypes) == 0 {
  6771. insutype = "310"
  6772. }
  6773. if len(insutypes) == 2 {
  6774. insutype = strconv.FormatInt(his.SocialType, 64)
  6775. }
  6776. //insutype = "390"
  6777. if his.IdCardType == 1 {
  6778. cert_no = his.MedicalInsuranceNumber
  6779. } else {
  6780. cert_no = his.Certno
  6781. }
  6782. var res ResultSeven
  6783. var resSeven10265 ResultSeven10265
  6784. if miConfig.MdtrtareaAdmvs == "421300" {
  6785. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6786. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6787. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6788. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6789. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6790. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6791. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  6792. resp, requestErr := http.Get(api)
  6793. if requestErr != nil {
  6794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6795. return
  6796. }
  6797. body, ioErr := ioutil.ReadAll(resp.Body)
  6798. if ioErr != nil {
  6799. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6801. return
  6802. }
  6803. var respJSON map[string]interface{}
  6804. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6805. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6807. return
  6808. }
  6809. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6810. result, _ := json.Marshal(respJSON)
  6811. fmt.Println("log")
  6812. fmt.Println(string(result))
  6813. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6814. utils.ErrorLog("解析失败:%v", err)
  6815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6816. return
  6817. }
  6818. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6819. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6820. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6821. bas := strings.Split(psn_info.CardInfo, "|")
  6822. if his.IdCardType == 1 {
  6823. cert_no = bas[2]
  6824. } else {
  6825. cert_no = bas[1]
  6826. }
  6827. //江苏地区国家医保医疗类别
  6828. //职工透析:医疗类别选特殊情况门诊9933
  6829. //居民血透门慢: 医疗类别选门诊慢病1402
  6830. //var med_type string
  6831. //if his.Insutype == "310" {
  6832. // if reg_type == 14 {
  6833. // med_type = "9933"
  6834. // } else if reg_type == 11 {
  6835. // med_type = "11"
  6836. //
  6837. // }
  6838. //} else if his.Insutype == "390" {
  6839. // if reg_type == 14 {
  6840. // med_type = "1402"
  6841. // } else if reg_type == 11 {
  6842. // med_type = "11"
  6843. // }
  6844. //}
  6845. var api string
  6846. if miConfig.MdtrtareaAdmvs == "320921" {
  6847. api = "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6848. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6849. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6850. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6851. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6852. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6853. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + psn_info.VerifyNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6854. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6855. } else {
  6856. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6857. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6858. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6859. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6860. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6861. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6862. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6863. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + psn_info.VerifyNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6864. }
  6865. resp, requestErr := http.Get(api)
  6866. if requestErr != nil {
  6867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6868. return
  6869. }
  6870. body, ioErr := ioutil.ReadAll(resp.Body)
  6871. if ioErr != nil {
  6872. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6874. return
  6875. }
  6876. var respJSON map[string]interface{}
  6877. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6878. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6880. return
  6881. }
  6882. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6883. result, _ := json.Marshal(respJSON)
  6884. fmt.Println("log")
  6885. fmt.Println(string(result))
  6886. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6887. utils.ErrorLog("解析失败:%v", err)
  6888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6889. return
  6890. }
  6891. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6892. res.Output = resSeven10265.Output
  6893. res.ErrMsg = resSeven10265.ErrMsg
  6894. res.Cainfo = resSeven10265.Cainfo
  6895. res.WarnMsg = resSeven10265.WarnMsg
  6896. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6897. res.Infcode = infocode
  6898. } else {
  6899. var result string
  6900. var request_log string
  6901. if miConfig.Code == "H15049901371" {
  6902. //赤峰地区国家医保医疗类别
  6903. //职工透析:医疗类别选特殊情况门诊990502
  6904. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6905. var med_type string
  6906. if his.Insutype == "390" {
  6907. if reg_type == 14 {
  6908. med_type = "9933"
  6909. } else if reg_type == 11 {
  6910. med_type = "11"
  6911. }
  6912. } else if his.Insutype == "310" {
  6913. if reg_type == 14 {
  6914. med_type = "990502"
  6915. } else if reg_type == 11 {
  6916. med_type = "11"
  6917. }
  6918. }
  6919. 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)
  6920. } else {
  6921. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType)
  6922. }
  6923. var dat map[string]interface{}
  6924. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6925. fmt.Println(dat)
  6926. } else {
  6927. fmt.Println(err)
  6928. }
  6929. saveLog(result, request_log, "2206", "预结算")
  6930. //userJSONBytes, _ := json.Marshal(dat)
  6931. //
  6932. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6933. // utils.ErrorLog("解析失败:%v", err)
  6934. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6935. // return
  6936. //}
  6937. userJSONBytes, _ := json.Marshal(dat)
  6938. if miConfig.Code == "H15049901371" {
  6939. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6940. utils.ErrorLog("解析失败:%v", err)
  6941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6942. return
  6943. }
  6944. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6945. res.Output = resSeven10265.Output
  6946. res.ErrMsg = resSeven10265.ErrMsg
  6947. res.Cainfo = resSeven10265.Cainfo
  6948. res.WarnMsg = resSeven10265.WarnMsg
  6949. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6950. res.Infcode = infocode
  6951. } else {
  6952. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6953. utils.ErrorLog("解析失败:%v", err)
  6954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6955. return
  6956. }
  6957. }
  6958. }
  6959. if res.Infcode != 0 {
  6960. errlog := &models.HisOrderError{
  6961. UserOrgId: adminUser.CurrentOrgId,
  6962. Ctime: time.Now().Unix(),
  6963. Mtime: time.Now().Unix(),
  6964. Number: chrg_bchno,
  6965. ErrMsg: res.ErrMsg,
  6966. Status: 1,
  6967. PatientId: id,
  6968. RecordTime: recordDateTime,
  6969. Stage: 20,
  6970. }
  6971. service.CreateErrMsgLog(errlog)
  6972. c.ServeSuccessJSON(map[string]interface{}{
  6973. "failed_code": -10,
  6974. "msg": res.ErrMsg,
  6975. })
  6976. return
  6977. } else {
  6978. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6979. order.OrderStatus = 1
  6980. order.IsPre = 1
  6981. order.Status = 1
  6982. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6983. order.SetlId = res.Output.Setlinfo.SetlID
  6984. order.PsnNo = res.Output.Setlinfo.PsnNo
  6985. order.PsnName = res.Output.Setlinfo.PsnName
  6986. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6987. order.Certno = res.Output.Setlinfo.Certno
  6988. order.Gend = res.Output.Setlinfo.Gend
  6989. order.Naty = res.Output.Setlinfo.Naty
  6990. order.Age = res.Output.Setlinfo.Age
  6991. order.Insutype = res.Output.Setlinfo.Insutype
  6992. order.PsnType = res.Output.Setlinfo.PsnType
  6993. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6994. order.SetlTime = res.Output.Setlinfo.SetlTime
  6995. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6996. if res.Output.Setlinfo.MedType == "140101" {
  6997. order.MedType = "14"
  6998. } else {
  6999. order.MedType = res.Output.Setlinfo.MedType
  7000. }
  7001. if reg_type == 1112 {
  7002. order.MedType = "1112"
  7003. }
  7004. if reg_type == 1111 {
  7005. order.MedType = "1111"
  7006. }
  7007. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7008. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7009. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7010. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7011. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7012. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7013. order.HifpPay = res.Output.Setlinfo.HifpPay
  7014. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7015. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7016. order.HifesPay = res.Output.Setlinfo.HifesPay
  7017. order.HifobPay = res.Output.Setlinfo.HifobPay
  7018. order.MafPay = res.Output.Setlinfo.MafPay
  7019. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  7020. order.OthPay = res.Output.Setlinfo.OthPay
  7021. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7022. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7023. order.AcctPay = res.Output.Setlinfo.AcctPay
  7024. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7025. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7026. order.Balc = res.Output.Setlinfo.Balc
  7027. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7028. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7029. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7030. order.ClrWay = res.Output.Setlinfo.ClrWay
  7031. order.Creator = order.Creator
  7032. order.Modify = roles.AdminUserId
  7033. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7034. detailStr := string(setlDetail)
  7035. order.SetlDetail = detailStr
  7036. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7037. err = service.UpDateOrder(order)
  7038. if err == nil {
  7039. c.ServeSuccessJSON(map[string]interface{}{
  7040. "msg": "预结算成功",
  7041. })
  7042. } else {
  7043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7044. return
  7045. }
  7046. }
  7047. } else {
  7048. adminUser := c.GetAdminUserInfo()
  7049. errlog := &models.HisOrderError{
  7050. UserOrgId: adminUser.CurrentOrgId,
  7051. Ctime: time.Now().Unix(),
  7052. Mtime: time.Now().Unix(),
  7053. ErrMsg: res.ErrMsg,
  7054. Status: 1,
  7055. PatientId: id,
  7056. RecordTime: recordDateTime,
  7057. Stage: 4,
  7058. }
  7059. service.CreateErrMsgLog(errlog)
  7060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7061. return
  7062. }
  7063. } else {
  7064. adminUser := c.GetAdminUserInfo()
  7065. errlog := &models.HisOrderError{
  7066. UserOrgId: adminUser.CurrentOrgId,
  7067. Ctime: time.Now().Unix(),
  7068. Mtime: time.Now().Unix(),
  7069. ErrMsg: res.ErrMsg,
  7070. Status: 1,
  7071. PatientId: id,
  7072. RecordTime: recordDateTime,
  7073. Stage: 4,
  7074. }
  7075. service.CreateErrMsgLog(errlog)
  7076. c.ServeSuccessJSON(map[string]interface{}{
  7077. "failed_code": -10,
  7078. "msg": res.ErrMsg,
  7079. })
  7080. return
  7081. }
  7082. }
  7083. }
  7084. }
  7085. //func (c *HisApiController) GetSettleInfo() {
  7086. // id, _ := c.GetInt64("id")
  7087. // order_id, _ := c.GetInt64("order_id")
  7088. //
  7089. // record_time := c.GetString("record_time")
  7090. // pay_way, _ := c.GetInt64("pay_way")
  7091. // pay_price, _ := c.GetFloat("pay_price")
  7092. // pay_card_no := c.GetString("pay_card_no")
  7093. // discount_price, _ := c.GetFloat("discount_price")
  7094. // preferential_price, _ := c.GetFloat("preferential_price")
  7095. // reality_price, _ := c.GetFloat("reality_price")
  7096. // found_price, _ := c.GetFloat("found_price")
  7097. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  7098. // private_price, _ := c.GetFloat("private_price")
  7099. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7100. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7101. //
  7102. // timeLayout := "2006-01-02"
  7103. // loc, _ := time.LoadLocation("Local")
  7104. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7105. // if err != nil {
  7106. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7107. // return
  7108. // }
  7109. // recordDateTime := theTime.Unix()
  7110. // adminUser := c.GetAdminUserInfo()
  7111. //
  7112. // var prescriptions []*models.HisPrescription
  7113. //
  7114. // data := make(map[string]interface{})
  7115. // if settle_accounts_type == 1 { //日结
  7116. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  7117. // data["pre"] = prescriptions
  7118. //
  7119. // } else { //月结
  7120. // start_time_str := c.GetString("start_time")
  7121. // end_time_str := c.GetString("end_time")
  7122. // timeLayout := "2006-01-02"
  7123. // loc, _ := time.LoadLocation("Local")
  7124. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7125. // if err != nil {
  7126. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7127. // return
  7128. // }
  7129. // recordStartTime := theStartTime.Unix()
  7130. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7131. // if err != nil {
  7132. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7133. // return
  7134. // }
  7135. // recordEndTime := theEndTime.Unix()
  7136. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  7137. // data["pre"] = prescriptions
  7138. //
  7139. // }
  7140. //
  7141. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7142. //
  7143. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7144. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7145. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7146. // strconv.FormatInt(his.PatientId, 10)
  7147. //
  7148. // order_src, _ := service.GetHisOrderByID(order_id)
  7149. //
  7150. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7151. // if config.IsOpen == 1 { //对接了医保,走医保流程
  7152. //
  7153. // var total float64
  7154. // for _, item := range prescriptions {
  7155. // if item.Type == 1 { //药品
  7156. // for _, subItem := range item.HisDoctorAdviceInfo {
  7157. // total = total + (subItem.Price * subItem.PrescribingNumber)
  7158. // }
  7159. // }
  7160. // if item.Type == 2 { //项目
  7161. // for _, subItem := range item.HisPrescriptionProject {
  7162. // total = total + (subItem.Price * float64(subItem.Count))
  7163. // }
  7164. // }
  7165. // }
  7166. //
  7167. // for _, item := range prescriptions {
  7168. // for _, subItem := range item.HisAdditionalCharge {
  7169. // total = total + (subItem.Price * float64(subItem.Count))
  7170. // }
  7171. // }
  7172. //
  7173. // allTotal := fmt.Sprintf("%.2f", total)
  7174. // var rf []*ResultFive
  7175. // json.Unmarshal([]byte(his.Iinfo), &rf)
  7176. // psn_no := order_src.PsnNo
  7177. // mdtrt_id := order_src.MdtrtId
  7178. // chrg_bchno := order_src.Number
  7179. // cert_no := order_src.Certno
  7180. // insutype := rf[0].Insutype
  7181. //
  7182. // if his.IdCardType == 1 {
  7183. // cert_no = his.MedicalInsuranceNumber
  7184. // } else {
  7185. // cert_no = his.Certno
  7186. // }
  7187. //
  7188. // 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)
  7189. // var dat map[string]interface{}
  7190. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7191. // fmt.Println(dat)
  7192. // } else {
  7193. // fmt.Println(err)
  7194. // }
  7195. //
  7196. // userJSONBytes, _ := json.Marshal(dat)
  7197. //
  7198. //
  7199. //
  7200. // var res ResultSeven
  7201. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7202. // utils.ErrorLog("解析失败:%v", err)
  7203. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7204. // return
  7205. // }
  7206. // if res.Infcode == -1 {
  7207. // errlog := &models.HisOrderError{
  7208. // UserOrgId: adminUser.CurrentOrgId,
  7209. // Ctime: time.Now().Unix(),
  7210. // Mtime: time.Now().Unix(),
  7211. // Number: chrg_bchno,
  7212. // ErrMsg: res.ErrMsg,
  7213. // Status: 1,
  7214. // PatientId: id,
  7215. // RecordTime: recordDateTime,
  7216. // Stage: 6,
  7217. // }
  7218. // service.CreateErrMsgLog(errlog)
  7219. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7220. // return
  7221. // } else {
  7222. // order_src.OrderStatus = 2
  7223. // order_src.PayWay = pay_way
  7224. // order_src.PayPrice = pay_price
  7225. // order_src.PayCardNo = pay_card_no
  7226. // order_src.DiscountPrice = discount_price
  7227. // order_src.PreferentialPrice = preferential_price
  7228. // order_src.RealityPrice = reality_price
  7229. // order_src.FoundPrice = found_price
  7230. // order_src.MedicalInsurancePrice = medical_insurance_price
  7231. // order_src.PrivatePrice = private_price
  7232. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  7233. // order_src.SetlId = res.Output.Setlinfo.SetlID
  7234. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  7235. // order_src.PsnName = res.Output.Setlinfo.PsnName
  7236. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  7237. // order_src.Certno = res.Output.Setlinfo.Certno
  7238. // order_src.Gend = res.Output.Setlinfo.Gend
  7239. // order_src.Naty = res.Output.Setlinfo.Naty
  7240. // order_src.Age = res.Output.Setlinfo.Age
  7241. // order_src.Insutype = res.Output.Setlinfo.Insutype
  7242. // order_src.PsnType = res.Output.Setlinfo.PsnType
  7243. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7244. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  7245. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7246. // order_src.MedType = res.Output.Setlinfo.MedType
  7247. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7248. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7249. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7250. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7251. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7252. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7253. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  7254. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  7255. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7256. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  7257. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  7258. // order_src.MafPay = res.Output.Setlinfo.MafPay
  7259. // order_src.OthPay = res.Output.Setlinfo.OthPay
  7260. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7261. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7262. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  7263. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7264. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7265. // order_src.Balc = res.Output.Setlinfo.Balc
  7266. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7267. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7268. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  7269. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  7270. // order_src.Creator = order_src.Creator
  7271. // order_src.Modify = roles.ID
  7272. // order_src.RequestLog = src_resquest
  7273. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7274. // detailStr := string(setlDetail)
  7275. // order_src.SetlDetail = detailStr
  7276. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7277. // err = service.UpDateOrder(order_src)
  7278. //
  7279. // if err == nil {
  7280. // c.ServeSuccessJSON(map[string]interface{}{
  7281. // "msg": "结算成功",
  7282. // })
  7283. // } else {
  7284. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7285. // return
  7286. // }
  7287. // }
  7288. // }
  7289. //}
  7290. //退款
  7291. func (c *HisApiController) Refund() {
  7292. order_id, _ := c.GetInt64("order_id")
  7293. admin_user_id, _ := c.GetInt64("admin_user_id")
  7294. adminUser := c.GetAdminUserInfo()
  7295. var order models.HisOrder
  7296. order, _ = service.GetHisOrderByID(order_id)
  7297. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7298. if order.ID == 0 {
  7299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7300. return
  7301. }
  7302. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7303. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7304. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7305. if config.IsOpen == 1 { //对接了医保,走医保流程
  7306. var res ResultSixteen
  7307. var resSixteen10265 ResultSixteen10265
  7308. var src_resquest string
  7309. var result string
  7310. if miConfig.MdtrtareaAdmvs == "421300" {
  7311. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  7312. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7313. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7314. resp3, requestErr3 := http.Get(api3)
  7315. if requestErr3 != nil {
  7316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7317. return
  7318. }
  7319. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7320. if ioErr3 != nil {
  7321. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7323. return
  7324. }
  7325. var respJSON3 map[string]interface{}
  7326. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7327. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7329. return
  7330. }
  7331. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7332. userJSONBytes3, _ := json.Marshal(respJSON3)
  7333. fmt.Println("log")
  7334. fmt.Println(string(userJSONBytes3))
  7335. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  7336. utils.ErrorLog("解析失败:%v", err)
  7337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7338. return
  7339. }
  7340. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7341. var api3 string
  7342. if miConfig.MdtrtareaAdmvs == "320921" {
  7343. api3 = "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7344. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7345. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7346. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7347. } else {
  7348. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7349. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7350. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7351. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7352. }
  7353. resp3, requestErr3 := http.Get(api3)
  7354. if requestErr3 != nil {
  7355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7356. return
  7357. }
  7358. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7359. if ioErr3 != nil {
  7360. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7362. return
  7363. }
  7364. var respJSON3 map[string]interface{}
  7365. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7366. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7368. return
  7369. }
  7370. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7371. userJSONBytes3, _ := json.Marshal(respJSON3)
  7372. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  7373. utils.ErrorLog("解析失败:%v", err)
  7374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7375. return
  7376. }
  7377. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7378. res.Output = resSixteen10265.Output
  7379. res.ErrMsg = resSixteen10265.ErrMsg
  7380. res.Cainfo = resSixteen10265.Cainfo
  7381. res.WarnMsg = resSixteen10265.WarnMsg
  7382. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7383. res.Infcode = infocode
  7384. } else {
  7385. if miConfig.Code == "H15049901371" {
  7386. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7387. var dat map[string]interface{}
  7388. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7389. fmt.Println(dat)
  7390. } else {
  7391. fmt.Println(err)
  7392. }
  7393. saveLog(result, src_resquest, "2208", "退费")
  7394. userJSONBytes, _ := json.Marshal(dat)
  7395. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  7396. utils.ErrorLog("解析失败:%v", err)
  7397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7398. return
  7399. }
  7400. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7401. res.Output = resSixteen10265.Output
  7402. res.ErrMsg = resSixteen10265.ErrMsg
  7403. res.Cainfo = resSixteen10265.Cainfo
  7404. res.WarnMsg = resSixteen10265.WarnMsg
  7405. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7406. res.Infcode = infocode
  7407. } else {
  7408. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7409. var dat map[string]interface{}
  7410. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7411. fmt.Println(dat)
  7412. } else {
  7413. fmt.Println(err)
  7414. }
  7415. saveLog(result, src_resquest, "2208", "退费")
  7416. userJSONBytes, _ := json.Marshal(dat)
  7417. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7418. utils.ErrorLog("解析失败:%v", err)
  7419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7420. return
  7421. }
  7422. }
  7423. }
  7424. if res.Infcode == 0 {
  7425. var res2 ResultSix
  7426. var resSix10265 ResultSix10265
  7427. if miConfig.MdtrtareaAdmvs == "421300" {
  7428. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7429. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7430. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7431. resp3, requestErr3 := http.Get(api3)
  7432. if requestErr3 != nil {
  7433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7434. return
  7435. }
  7436. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7437. if ioErr3 != nil {
  7438. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7440. return
  7441. }
  7442. var respJSON3 map[string]interface{}
  7443. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7444. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7446. return
  7447. }
  7448. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7449. userJSONBytes3, _ := json.Marshal(respJSON3)
  7450. fmt.Println("log")
  7451. fmt.Println(string(userJSONBytes3))
  7452. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7453. utils.ErrorLog("解析失败:%v", err)
  7454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7455. return
  7456. }
  7457. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7458. var api3 string
  7459. if miConfig.MdtrtareaAdmvs == "320921" {
  7460. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7461. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7462. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7463. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7464. } else {
  7465. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7466. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7467. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7468. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7469. }
  7470. resp3, requestErr3 := http.Get(api3)
  7471. if requestErr3 != nil {
  7472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7473. return
  7474. }
  7475. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7476. if ioErr3 != nil {
  7477. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7479. return
  7480. }
  7481. var respJSON3 map[string]interface{}
  7482. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7483. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7485. return
  7486. }
  7487. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7488. userJSONBytes3, _ := json.Marshal(respJSON3)
  7489. fmt.Println("log")
  7490. fmt.Println(string(userJSONBytes3))
  7491. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7492. utils.ErrorLog("解析失败:%v", err)
  7493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7494. return
  7495. }
  7496. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7497. res2.Output = resSix10265.Output
  7498. res2.ErrMsg = resSix10265.ErrMsg
  7499. res2.Cainfo = resSix10265.Cainfo
  7500. res2.WarnMsg = resSix10265.WarnMsg
  7501. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7502. res2.Infcode = infocode
  7503. } else {
  7504. if miConfig.Code == "H15049901371" {
  7505. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7506. var dat map[string]interface{}
  7507. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7508. fmt.Println(dat)
  7509. } else {
  7510. fmt.Println(err)
  7511. }
  7512. saveLog(result2, src_request, "2205", "撤销明细")
  7513. userJSONBytes, _ := json.Marshal(dat)
  7514. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7515. utils.ErrorLog("解析失败:%v", err)
  7516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7517. return
  7518. }
  7519. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7520. res2.Output = resSix10265.Output
  7521. res2.ErrMsg = resSix10265.ErrMsg
  7522. res2.Cainfo = resSix10265.Cainfo
  7523. res2.WarnMsg = resSix10265.WarnMsg
  7524. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7525. res2.Infcode = infocode
  7526. } else {
  7527. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7528. var dat map[string]interface{}
  7529. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7530. fmt.Println(dat)
  7531. } else {
  7532. fmt.Println(err)
  7533. }
  7534. saveLog(result2, src_request, "2205", "撤销明细")
  7535. userJSONBytes, _ := json.Marshal(dat)
  7536. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7537. utils.ErrorLog("解析失败:%v", err)
  7538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7539. return
  7540. }
  7541. }
  7542. }
  7543. if res2.Infcode == 0 {
  7544. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  7545. if err == nil {
  7546. c.ServeSuccessJSON(map[string]interface{}{
  7547. "msg": "退费成功",
  7548. })
  7549. } else {
  7550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7551. return
  7552. }
  7553. } else {
  7554. c.ServeSuccessJSON(map[string]interface{}{
  7555. "code": -10,
  7556. "msg": res2.ErrMsg,
  7557. })
  7558. }
  7559. } else {
  7560. c.ServeSuccessJSON(map[string]interface{}{
  7561. "code": -10,
  7562. "msg": res.ErrMsg,
  7563. })
  7564. }
  7565. }
  7566. }
  7567. func (c *HisApiController) RefundNumber() {
  7568. record_time := c.GetString("record_time")
  7569. //patient_id, _ := c.GetInt64("patient_id")
  7570. admin_user_id, _ := c.GetInt64("admin_user_id")
  7571. his_patient_id, _ := c.GetInt64("id")
  7572. timeLayout := "2006-01-02"
  7573. loc, _ := time.LoadLocation("Local")
  7574. adminUser := c.GetAdminUserInfo()
  7575. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7576. fmt.Println(err)
  7577. if err != nil {
  7578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7579. return
  7580. }
  7581. recordDateTime := theTime.Unix()
  7582. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7583. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  7584. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7585. //order, _ := service.GetHisOrderByID(order_id)
  7586. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7587. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7588. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7589. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  7590. if count > 0 {
  7591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  7592. return
  7593. }
  7594. if config.IsOpen == 1 { //对接了医保,走医保流程
  7595. var res2 ResultSix
  7596. var resSix10265 ResultSix10265
  7597. if miConfig.MdtrtareaAdmvs == "421300" {
  7598. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  7599. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7600. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7601. resp3, requestErr3 := http.Get(api3)
  7602. if requestErr3 != nil {
  7603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7604. return
  7605. }
  7606. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7607. if ioErr3 != nil {
  7608. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7610. return
  7611. }
  7612. var respJSON3 map[string]interface{}
  7613. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7614. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7616. return
  7617. }
  7618. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7619. userJSONBytes3, _ := json.Marshal(respJSON3)
  7620. fmt.Println("log")
  7621. fmt.Println(string(userJSONBytes3))
  7622. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7623. utils.ErrorLog("解析失败:%v", err)
  7624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7625. return
  7626. }
  7627. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7628. var api3 string
  7629. if miConfig.MdtrtareaAdmvs == "320921" {
  7630. api3 = "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  7631. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7632. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7633. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7634. } else {
  7635. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7636. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  7637. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7638. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7639. }
  7640. resp3, requestErr3 := http.Get(api3)
  7641. if requestErr3 != nil {
  7642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7643. return
  7644. }
  7645. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7646. if ioErr3 != nil {
  7647. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7649. return
  7650. }
  7651. var respJSON3 map[string]interface{}
  7652. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7653. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7655. return
  7656. }
  7657. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7658. userJSONBytes3, _ := json.Marshal(respJSON3)
  7659. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7660. utils.ErrorLog("解析失败:%v", err)
  7661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7662. return
  7663. }
  7664. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7665. res2.Output = resSix10265.Output
  7666. res2.ErrMsg = resSix10265.ErrMsg
  7667. res2.Cainfo = resSix10265.Cainfo
  7668. res2.WarnMsg = resSix10265.WarnMsg
  7669. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7670. res2.Infcode = infocode
  7671. } else {
  7672. var api3 string
  7673. if miConfig.Code == "H15049901371" {
  7674. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7675. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7676. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7677. } else {
  7678. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7679. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7680. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7681. }
  7682. resp3, requestErr3 := http.Get(api3)
  7683. if requestErr3 != nil {
  7684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7685. return
  7686. }
  7687. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7688. if ioErr3 != nil {
  7689. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7691. return
  7692. }
  7693. var respJSON3 map[string]interface{}
  7694. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7695. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7697. return
  7698. }
  7699. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7700. userJSONBytes3, _ := json.Marshal(respJSON3)
  7701. if miConfig.Code == "H15049901371" {
  7702. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7703. utils.ErrorLog("解析失败:%v", err)
  7704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7705. return
  7706. }
  7707. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7708. res2.Output = resSix10265.Output
  7709. res2.ErrMsg = resSix10265.ErrMsg
  7710. res2.Cainfo = resSix10265.Cainfo
  7711. res2.WarnMsg = resSix10265.WarnMsg
  7712. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7713. res2.Infcode = infocode
  7714. } else {
  7715. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7716. utils.ErrorLog("解析失败:%v", err)
  7717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7718. return
  7719. }
  7720. }
  7721. }
  7722. if res2.Infcode == 0 {
  7723. if err == nil {
  7724. c.ServeSuccessJSON(map[string]interface{}{
  7725. "msg": "退号成功",
  7726. })
  7727. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  7728. } else {
  7729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7730. return
  7731. }
  7732. } else {
  7733. c.ServeSuccessJSON(map[string]interface{}{
  7734. "code": -10,
  7735. "msg": res2.ErrMsg,
  7736. })
  7737. }
  7738. } else {
  7739. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  7740. //if err == nil {
  7741. // c.ServeSuccessJSON(map[string]interface{}{
  7742. // "msg": "退费成功",
  7743. // })
  7744. //} else {
  7745. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7746. // return
  7747. //}
  7748. }
  7749. }
  7750. func (c *HisApiController) RefundDetail() {
  7751. order_id, _ := c.GetInt64("order_id")
  7752. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7753. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7754. number := c.GetString("number")
  7755. record_time := c.GetString("record_time")
  7756. patient_id, _ := c.GetInt64("patient_id")
  7757. //med_type, _ := c.GetInt64("med_type")
  7758. timeLayout := "2006-01-02"
  7759. loc, _ := time.LoadLocation("Local")
  7760. adminUser := c.GetAdminUserInfo()
  7761. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7762. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7763. fmt.Println(err)
  7764. if err != nil {
  7765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7766. return
  7767. }
  7768. recordDateTime := theTime.Unix()
  7769. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7770. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7771. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7772. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7773. var order models.HisOrder
  7774. order, _ = service.GetHisOrderByID(order_id)
  7775. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7776. if config.IsOpen == 1 { //对接了医保,走医保流程
  7777. var res2 ResultSix
  7778. if miConfig.MdtrtareaAdmvs == "421300" {
  7779. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7780. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7781. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7782. resp3, requestErr3 := http.Get(api3)
  7783. if requestErr3 != nil {
  7784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7785. return
  7786. }
  7787. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7788. if ioErr3 != nil {
  7789. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7791. return
  7792. }
  7793. var respJSON3 map[string]interface{}
  7794. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7795. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7797. return
  7798. }
  7799. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7800. userJSONBytes3, _ := json.Marshal(respJSON3)
  7801. fmt.Println("log")
  7802. fmt.Println(string(userJSONBytes3))
  7803. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7804. utils.ErrorLog("解析失败:%v", err)
  7805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7806. return
  7807. }
  7808. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7809. if err == nil {
  7810. c.ServeSuccessJSON(map[string]interface{}{
  7811. "msg": "撤销明细成功",
  7812. })
  7813. return
  7814. } else {
  7815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7816. return
  7817. }
  7818. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7819. var resSix10265 ResultSix10265
  7820. var api3 string
  7821. if miConfig.MdtrtareaAdmvs == "320921" {
  7822. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7823. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7824. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7825. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7826. } else {
  7827. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7828. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7829. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7830. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7831. }
  7832. resp3, requestErr3 := http.Get(api3)
  7833. if requestErr3 != nil {
  7834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7835. return
  7836. }
  7837. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7838. if ioErr3 != nil {
  7839. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7841. return
  7842. }
  7843. var respJSON3 map[string]interface{}
  7844. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7845. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7847. return
  7848. }
  7849. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7850. userJSONBytes3, _ := json.Marshal(respJSON3)
  7851. fmt.Println("log")
  7852. fmt.Println(string(userJSONBytes3))
  7853. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7854. utils.ErrorLog("解析失败:%v", err)
  7855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7856. return
  7857. }
  7858. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7859. res2.Output = resSix10265.Output
  7860. res2.ErrMsg = resSix10265.ErrMsg
  7861. res2.Cainfo = resSix10265.Cainfo
  7862. res2.WarnMsg = resSix10265.WarnMsg
  7863. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7864. res2.Infcode = infocode
  7865. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7866. if err == nil {
  7867. c.ServeSuccessJSON(map[string]interface{}{
  7868. "msg": "撤销明细成功",
  7869. })
  7870. return
  7871. } else {
  7872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7873. return
  7874. }
  7875. } else {
  7876. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  7877. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7878. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7879. resp2, requestErr2 := http.Get(api2)
  7880. if requestErr2 != nil {
  7881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7882. return
  7883. }
  7884. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7885. if ioErr2 != nil {
  7886. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7888. return
  7889. }
  7890. var respJSON2 map[string]interface{}
  7891. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  7892. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7894. return
  7895. }
  7896. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7897. if err == nil {
  7898. c.ServeSuccessJSON(map[string]interface{}{
  7899. "msg": "撤销明细成功",
  7900. })
  7901. return
  7902. } else {
  7903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7904. return
  7905. }
  7906. }
  7907. } else {
  7908. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7909. if err == nil {
  7910. c.ServeSuccessJSON(map[string]interface{}{
  7911. "msg": "退费成功",
  7912. })
  7913. } else {
  7914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7915. return
  7916. }
  7917. }
  7918. }
  7919. //对账
  7920. func (c *HisApiController) GetCheckAccount() {
  7921. start_time := c.GetString("start_time")
  7922. end_time := c.GetString("end_time")
  7923. insutype := c.GetString("insutype")
  7924. clr_type := c.GetString("clr_type")
  7925. clr_org := c.GetString("clr_optins")
  7926. admin_user_id, _ := c.GetInt64("admin_user_id")
  7927. adminUser := c.GetAdminUserInfo()
  7928. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7929. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7930. if len(clr_org) == 0 {
  7931. clr_org = miConfig.MdtrtareaAdmvs
  7932. }
  7933. timeLayout := "2006-01-02"
  7934. loc, _ := time.LoadLocation("Local")
  7935. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  7936. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  7937. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_org, clr_type)
  7938. fixmedins_setl_cnt := int64(len(orders))
  7939. var medfee_sumamt float64
  7940. var acct_pay float64
  7941. var fund_pay_sumamt float64
  7942. for _, item := range orders {
  7943. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  7944. acct_pay = acct_pay + item.AcctPay
  7945. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  7946. }
  7947. var user_name string
  7948. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7949. if role.ID == 0 {
  7950. user_name = "xxx"
  7951. } else {
  7952. user_name = role.UserName
  7953. }
  7954. var res ResultEight
  7955. var res10188 ResultEightFor10188
  7956. if config.IsOpen == 1 {
  7957. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7958. api := "http://192.168.3.111:9532/" + "jsyb/3201?" +
  7959. "insutype=" + insutype +
  7960. "&clr_type=" + "11" +
  7961. "&setl_optins=" + clr_org +
  7962. "&stmt_begndate=" + start_time +
  7963. "&stm_enddate=" + end_time +
  7964. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7965. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7966. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7967. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7968. "&fixmedins_code=" + miConfig.Code +
  7969. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7970. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7971. "&secret_key=" + miConfig.SecretKey +
  7972. "&org_name=" + miConfig.OrgName +
  7973. "&doctor=" + user_name +
  7974. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7975. fmt.Println(api)
  7976. resp, requestErr := http.Get(api)
  7977. if requestErr != nil {
  7978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7979. return
  7980. }
  7981. body, ioErr := ioutil.ReadAll(resp.Body)
  7982. fmt.Println(body)
  7983. if ioErr != nil {
  7984. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7986. return
  7987. }
  7988. var respJSON map[string]interface{}
  7989. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7990. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7992. return
  7993. }
  7994. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7995. userJSONBytes, _ := json.Marshal(respJSON)
  7996. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7997. utils.ErrorLog("解析失败:%v", err)
  7998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7999. return
  8000. }
  8001. res.InfRefmsgid = res10188.InfRefmsgid
  8002. res.Output = res10188.Output
  8003. res.ErrMsg = res10188.ErrMsg
  8004. res.Cainfo = res10188.Cainfo
  8005. res.WarnMsg = res10188.WarnMsg
  8006. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8007. res.Infcode = infocode
  8008. } else {
  8009. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8010. "insutype=" + insutype +
  8011. "&clr_type=" + clr_type +
  8012. "&setl_optins=" + clr_org +
  8013. "&stmt_begndate=" + start_time +
  8014. "&stm_enddate=" + end_time +
  8015. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8016. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8017. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8018. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8019. "&fixmedins_code=" + miConfig.Code +
  8020. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8021. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8022. "&secret_key=" + miConfig.SecretKey +
  8023. "&org_name=" + miConfig.OrgName +
  8024. "&doctor=" + user_name
  8025. fmt.Println(api)
  8026. resp, requestErr := http.Get(api)
  8027. if requestErr != nil {
  8028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8029. return
  8030. }
  8031. body, ioErr := ioutil.ReadAll(resp.Body)
  8032. fmt.Println(body)
  8033. if ioErr != nil {
  8034. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8036. return
  8037. }
  8038. var respJSON map[string]interface{}
  8039. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8040. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8042. return
  8043. }
  8044. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8045. userJSONBytes, _ := json.Marshal(respJSON)
  8046. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8047. utils.ErrorLog("解析失败:%v", err)
  8048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8049. return
  8050. }
  8051. }
  8052. if res.Infcode == 0 {
  8053. if res.Output.Stmtinfo.StmtRslt == "0" {
  8054. micc := &models.MedicalInsuranceCostCompare{
  8055. StartTime: startime.Unix(),
  8056. EndTime: endtime.Unix(),
  8057. Insutype: insutype,
  8058. CheckType: 1,
  8059. Num: fixmedins_setl_cnt,
  8060. Mtime: time.Now().Unix(),
  8061. Status: 1,
  8062. UserOrgId: adminUser.CurrentOrgId,
  8063. CostTotal: medfee_sumamt,
  8064. FuncTotal: fund_pay_sumamt,
  8065. PsnPay: acct_pay,
  8066. Creator: admin_user_id,
  8067. Ctime: time.Now().Unix(),
  8068. ClrType: clr_type,
  8069. }
  8070. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  8071. if err == nil {
  8072. c.ServeSuccessJSON(map[string]interface{}{
  8073. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8074. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8075. })
  8076. } else {
  8077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8078. }
  8079. } else {
  8080. c.ServeSuccessJSON(map[string]interface{}{
  8081. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8082. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8083. })
  8084. }
  8085. } else {
  8086. c.ServeSuccessJSON(map[string]interface{}{
  8087. "code": -10,
  8088. "msg": res.ErrMsg,
  8089. })
  8090. }
  8091. }
  8092. }
  8093. func (c *HisApiController) Check310() {
  8094. adminUser := c.GetAdminUserInfo()
  8095. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8096. var user_name string
  8097. user_name = "高慧裕"
  8098. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8099. "insutype=" + "310" +
  8100. "&clr_type=" + "" +
  8101. "&setl_optins=" + "441202" +
  8102. "&stmt_begndate=" + "2022-03-01" +
  8103. "&stm_enddate=" + "2022-03-31" +
  8104. "&medfee_sumamt=" + "194930.12" +
  8105. "&fund_pay_sumamt=" + "188741.46" +
  8106. "&acct_pay=" + "0" +
  8107. "&fixmedins_setl_cnt=" + "452" +
  8108. "&fixmedins_code=" + miConfig.Code +
  8109. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8110. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8111. "&secret_key=" + miConfig.SecretKey +
  8112. "&org_name=" + miConfig.OrgName +
  8113. "&doctor=" + user_name
  8114. fmt.Println(api)
  8115. resp, requestErr := http.Get(api)
  8116. if requestErr != nil {
  8117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8118. return
  8119. }
  8120. body, ioErr := ioutil.ReadAll(resp.Body)
  8121. fmt.Println(body)
  8122. if ioErr != nil {
  8123. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8125. return
  8126. }
  8127. var respJSON map[string]interface{}
  8128. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8129. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8131. return
  8132. }
  8133. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8134. userJSONBytes, _ := json.Marshal(respJSON)
  8135. var res ResultEight
  8136. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8137. utils.ErrorLog("解析失败:%v", err)
  8138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8139. return
  8140. }
  8141. }
  8142. func (c *HisApiController) Check390() {
  8143. adminUser := c.GetAdminUserInfo()
  8144. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8145. var user_name string
  8146. user_name = "高慧裕"
  8147. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8148. "insutype=" + "390" +
  8149. "&clr_type=" + "" +
  8150. "&setl_optins=" + "441202" +
  8151. "&stmt_begndate=" + "2022-03-01" +
  8152. "&stm_enddate=" + "2022-03-31" +
  8153. "&medfee_sumamt=" + "1068448.89" +
  8154. "&fund_pay_sumamt=" + "1014677.62" +
  8155. "&acct_pay=" + "0" +
  8156. "&fixmedins_setl_cnt=" + "1950" +
  8157. "&fixmedins_code=" + miConfig.Code +
  8158. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8159. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8160. "&secret_key=" + miConfig.SecretKey +
  8161. "&org_name=" + miConfig.OrgName +
  8162. "&doctor=" + user_name
  8163. fmt.Println(api)
  8164. resp, requestErr := http.Get(api)
  8165. if requestErr != nil {
  8166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8167. return
  8168. }
  8169. body, ioErr := ioutil.ReadAll(resp.Body)
  8170. fmt.Println(body)
  8171. if ioErr != nil {
  8172. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8174. return
  8175. }
  8176. var respJSON map[string]interface{}
  8177. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8178. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8180. return
  8181. }
  8182. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8183. userJSONBytes, _ := json.Marshal(respJSON)
  8184. var res ResultEight
  8185. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8186. utils.ErrorLog("解析失败:%v", err)
  8187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8188. return
  8189. }
  8190. }
  8191. //对账明细
  8192. func (c *HisApiController) GetCheckDetailAccount() {
  8193. start_time := c.GetString("start_time")
  8194. end_time := c.GetString("end_time")
  8195. admin_user_id, _ := c.GetInt64("admin_user_id")
  8196. adminUser := c.GetAdminUserInfo()
  8197. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8198. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8199. timeLayout := "2006-01-02"
  8200. loc, _ := time.LoadLocation("Local")
  8201. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8202. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8203. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  8204. Mkdir(miConfig.OrgName)
  8205. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  8206. file_name := file + ".txt"
  8207. zip_name := file + ".zip"
  8208. zip_path := miConfig.OrgName + "/" + zip_name
  8209. file_path := miConfig.OrgName + "/" + file_name
  8210. decimal.DivisionPrecision = 2
  8211. var medfee_sumamt float64
  8212. var psn_cash_pay float64
  8213. var fund_pay_sumamt float64
  8214. fixmedins_setl_cnt := int64(len(orders))
  8215. for _, item := range orders {
  8216. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8217. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  8218. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8219. }
  8220. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  8221. defer f.Close()
  8222. if err != nil {
  8223. fmt.Println(err.Error())
  8224. } else {
  8225. for _, item := range orders {
  8226. var refd_setl_flag string
  8227. if item.OrderStatus == 2 {
  8228. refd_setl_flag = "0"
  8229. var str string
  8230. str = item.SetlId + " " +
  8231. item.MdtrtId + " " +
  8232. item.PsnNo + " " +
  8233. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8234. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8235. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  8236. _, err = f.Write([]byte(str))
  8237. }
  8238. if item.OrderStatus == 3 {
  8239. var str string
  8240. str = item.SetlId + " " +
  8241. item.MdtrtId + " " +
  8242. item.PsnNo + " " +
  8243. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8244. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8245. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  8246. _, err = f.Write([]byte(str))
  8247. var str2 string
  8248. str2 = item.SetlId + " " +
  8249. item.MdtrtId + " " +
  8250. item.PsnNo + " " +
  8251. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  8252. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  8253. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  8254. _, err = f.Write([]byte(str2))
  8255. }
  8256. }
  8257. }
  8258. Zip(file_path, zip_path)
  8259. fmt.Println(ReadFile(zip_path))
  8260. fmt.Println(string(ReadFile(zip_path)))
  8261. if config.IsOpen == 1 {
  8262. var user_name string
  8263. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8264. if role.ID == 0 {
  8265. user_name = "管理员"
  8266. } else {
  8267. user_name = role.UserName
  8268. }
  8269. baseParams := models.BaseParams{
  8270. SecretKey: miConfig.SecretKey,
  8271. FixmedinsCode: miConfig.Code,
  8272. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8273. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8274. OrgName: miConfig.OrgName,
  8275. Doctor: user_name,
  8276. }
  8277. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  8278. var dat map[string]interface{}
  8279. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8280. fmt.Println(dat)
  8281. } else {
  8282. fmt.Println(err)
  8283. }
  8284. userJSONBytes, _ := json.Marshal(dat)
  8285. var res ResultNine
  8286. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8287. utils.ErrorLog("解析失败:%v", err)
  8288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8289. return
  8290. }
  8291. if res.Infcode == 0 {
  8292. fileNo := res.Output.FileQuryNo
  8293. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  8294. "file_qury_no=" + fileNo +
  8295. "&setl_optins=" + "定点医保中心" +
  8296. "&stmt_begndate=" + start_time +
  8297. "&stm_enddate=" + end_time +
  8298. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8299. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8300. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  8301. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8302. "&fixmedins_code=" + miConfig.Code +
  8303. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8304. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8305. "&secret_key=" + miConfig.SecretKey +
  8306. "&org_name=" + miConfig.OrgName +
  8307. "&doctor=" + user_name
  8308. resp, requestErr := http.Get(api)
  8309. if requestErr != nil {
  8310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8311. return
  8312. }
  8313. body, ioErr := ioutil.ReadAll(resp.Body)
  8314. if ioErr != nil {
  8315. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8317. return
  8318. }
  8319. var respJSON map[string]interface{}
  8320. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8321. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8323. return
  8324. }
  8325. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8326. userJSONBytes, _ := json.Marshal(respJSON)
  8327. var res ResultTen
  8328. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8329. utils.ErrorLog("解析失败:%v", err)
  8330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8331. return
  8332. }
  8333. if res.Infcode == 0 {
  8334. service.Gdyb9102(baseParams, zip_name, fileNo)
  8335. micc := &models.MedicalInsuranceCostCompare{
  8336. StartTime: startime.Unix(),
  8337. EndTime: endtime.Unix(),
  8338. Insutype: "0",
  8339. CheckType: 2,
  8340. Num: fixmedins_setl_cnt,
  8341. Mtime: time.Now().Unix(),
  8342. Status: 1,
  8343. UserOrgId: adminUser.CurrentOrgId,
  8344. CostTotal: medfee_sumamt,
  8345. FuncTotal: fund_pay_sumamt,
  8346. PsnPay: psn_cash_pay,
  8347. Creator: admin_user_id,
  8348. Ctime: time.Now().Unix(),
  8349. }
  8350. service.CreateMedicalInsuranceCostCompareRecord(micc)
  8351. c.ServeSuccessJSON(map[string]interface{}{
  8352. "msg": "明细对账成功",
  8353. })
  8354. }
  8355. } else {
  8356. }
  8357. }
  8358. }
  8359. type CustomOrderInfo struct {
  8360. Name string
  8361. Spec string
  8362. Unit string
  8363. Count float64
  8364. Price float64
  8365. Total float64
  8366. }
  8367. func (c *HisApiController) GetSettleAccounts() {
  8368. //id, _ := c.GetInt64("id")
  8369. //record_time := c.GetString("record_time")
  8370. order_id, _ := c.GetInt64("order_id")
  8371. admin_user_id, _ := c.GetInt64("admin_user_id")
  8372. //timeLayout := "2006-01-02"
  8373. //loc, _ := time.LoadLocation("Local")
  8374. //
  8375. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8376. //if err != nil {
  8377. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8378. // return
  8379. //}
  8380. //recordDateTime := theTime.Unix()
  8381. adminUser := c.GetAdminUserInfo()
  8382. order, _ := service.GetHisOrderByID(order_id)
  8383. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8384. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  8385. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8386. orderInfos = append(orderInfos, orderInfos_two...)
  8387. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8388. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  8389. var diagnosis_ids []string
  8390. if his.ID > 0 {
  8391. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  8392. } else {
  8393. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  8394. }
  8395. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  8396. var dia_config []*models.HisXtDiagnoseConfig
  8397. var name string
  8398. for _, item := range diagnosis_ids {
  8399. id, _ := strconv.ParseInt(item, 10, 64)
  8400. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8401. dia_config = append(dia_config, &diagnosisConfig)
  8402. if len(name) == 0 {
  8403. name = diagnosisConfig.ClassName
  8404. } else {
  8405. name = name + "," + diagnosisConfig.ClassName
  8406. }
  8407. }
  8408. var bedCostTotal float64 = 0 //床位总费
  8409. var bedCostSelfTotal float64 = 0 //床位自费
  8410. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  8411. var operationCostTotal float64 = 0 //手术费
  8412. var operationCostSelfTotal float64 = 0 //手术费
  8413. var operationCostPartSelfTotal float64 = 0 //手术费
  8414. var otherCostTotal float64 = 0 //其他费用
  8415. var otherCostSelfTotal float64 = 0 //其他费用
  8416. var otherCostPartSelfTotal float64 = 0 //其他费用
  8417. var materialCostTotal float64 = 0 //材料费
  8418. var materialCostSelfTotal float64 = 0 //材料费
  8419. var materialCostPartSelfTotal float64 = 0 //材料费
  8420. var westernMedicineCostTotal float64 = 0 //西药费
  8421. var westernMedicineCostSelfTotal float64 = 0 //西药费
  8422. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  8423. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  8424. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  8425. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  8426. var checkCostTotal float64 = 0 //检查费
  8427. var checkCostSelfTotal float64 = 0 //检查费
  8428. var checkCostPartSelfTotal float64 = 0 //检查费
  8429. var laboratoryCostTotal float64 = 0 //化验费
  8430. var laboratoryCostSelfTotal float64 = 0 //化验费
  8431. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  8432. var treatCostTotal float64 = 0 //治疗费用
  8433. var treatCostSelfTotal float64 = 0 //治疗费用
  8434. var treatCostPartSelfTotal float64 = 0 //治疗费用
  8435. decimal.DivisionPrecision = 2
  8436. for _, item := range orderInfos {
  8437. if item.MedChrgitmType == "01" { //床位费
  8438. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8439. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8440. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8441. }
  8442. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  8443. if item.MedChrgitmType == "03" { //检查费
  8444. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8445. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8446. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8447. }
  8448. } else {
  8449. if item.MedChrgitmType == "03" { //检查费
  8450. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8451. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8452. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8453. }
  8454. }
  8455. if item.MedChrgitmType == "04" { //化验费
  8456. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8457. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8458. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8459. }
  8460. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  8461. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8462. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8463. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8464. }
  8465. if item.MedChrgitmType == "06" { //手术费
  8466. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8467. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8468. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8469. }
  8470. if item.MedChrgitmType == "08" { //材料费
  8471. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8472. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8473. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8474. }
  8475. if item.MedChrgitmType == "09" { //西药费
  8476. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8477. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8478. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8479. }
  8480. if item.MedChrgitmType == "11" { //中成费
  8481. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8482. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8483. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8484. }
  8485. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  8486. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8487. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8488. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8489. }
  8490. }
  8491. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8492. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8493. var user_name string
  8494. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8495. if role.ID == 0 {
  8496. user_name = "管理员"
  8497. } else {
  8498. user_name = role.UserName
  8499. }
  8500. baseParams := models.BaseParams{
  8501. SecretKey: miConfig.SecretKey,
  8502. FixmedinsCode: miConfig.Code,
  8503. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8504. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8505. OrgName: miConfig.OrgName,
  8506. Doctor: user_name,
  8507. }
  8508. businessParams := models.BusinessParams{
  8509. PsnNo: order.PsnNo,
  8510. MdtrtId: order.MdtrtId,
  8511. SetlId: order.SetlId,
  8512. }
  8513. var res ResultEleven
  8514. var resEleven10265 ResultEleven10265
  8515. if config.IsOpen == 1 {
  8516. if miConfig.MdtrtareaAdmvs == "421300" {
  8517. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8518. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8519. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8520. resp, requestErr := http.Get(api)
  8521. if requestErr != nil {
  8522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8523. return
  8524. }
  8525. body, ioErr := ioutil.ReadAll(resp.Body)
  8526. if ioErr != nil {
  8527. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8529. return
  8530. }
  8531. var respJSON map[string]interface{}
  8532. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8533. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8535. return
  8536. }
  8537. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8538. result, _ := json.Marshal(respJSON)
  8539. fmt.Println("log")
  8540. fmt.Println(string(result))
  8541. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8542. utils.ErrorLog("解析失败:%v", err)
  8543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8544. return
  8545. }
  8546. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8547. var api string
  8548. if miConfig.MdtrtareaAdmvs == "320921" {
  8549. api = "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8550. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8551. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8552. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8553. } else {
  8554. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8555. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8556. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8557. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8558. }
  8559. resp, requestErr := http.Get(api)
  8560. if requestErr != nil {
  8561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8562. return
  8563. }
  8564. body, ioErr := ioutil.ReadAll(resp.Body)
  8565. if ioErr != nil {
  8566. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8568. return
  8569. }
  8570. var respJSON map[string]interface{}
  8571. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8572. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8574. return
  8575. }
  8576. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8577. result, _ := json.Marshal(respJSON)
  8578. fmt.Println("log")
  8579. fmt.Println(string(result))
  8580. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  8581. utils.ErrorLog("解析失败:%v", err)
  8582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8583. return
  8584. }
  8585. res.InfRefmsgid = resEleven10265.InfRefmsgid
  8586. res.Output = resEleven10265.Output
  8587. res.ErrMsg = resEleven10265.ErrMsg
  8588. res.Cainfo = resEleven10265.Cainfo
  8589. res.WarnMsg = resEleven10265.WarnMsg
  8590. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  8591. res.Infcode = infocode
  8592. } else {
  8593. //result2 := service.Gdyb1101()
  8594. //result2 := service.Gdyb5204(baseParams, businessParams)
  8595. //saveLog(result2, "", "5204", "查询")
  8596. result := service.Gdyb5203(baseParams, businessParams)
  8597. var dat map[string]interface{}
  8598. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8599. fmt.Println(dat)
  8600. } else {
  8601. fmt.Println(err)
  8602. }
  8603. userJSONBytes, _ := json.Marshal(dat)
  8604. if miConfig.Code == "H15049901371" {
  8605. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  8606. utils.ErrorLog("解析失败:%v", err)
  8607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8608. return
  8609. }
  8610. res.InfRefmsgid = resEleven10265.InfRefmsgid
  8611. res.Output = resEleven10265.Output
  8612. res.ErrMsg = resEleven10265.ErrMsg
  8613. res.Cainfo = resEleven10265.Cainfo
  8614. res.WarnMsg = resEleven10265.WarnMsg
  8615. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  8616. res.Infcode = infocode
  8617. } else {
  8618. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8619. utils.ErrorLog("解析失败:%v", err)
  8620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8621. return
  8622. }
  8623. }
  8624. }
  8625. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8626. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  8627. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  8628. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  8629. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  8630. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8631. var doctor_name string
  8632. if roles.ID == 0 {
  8633. doctor_name = "管理员"
  8634. } else {
  8635. doctor_name = roles.UserName
  8636. }
  8637. yiliao_leibie := ""
  8638. switch order.MedType {
  8639. case "11":
  8640. yiliao_leibie = "普通门诊"
  8641. break
  8642. case "12":
  8643. yiliao_leibie = "门诊挂号"
  8644. break
  8645. case "13":
  8646. yiliao_leibie = "急诊"
  8647. break
  8648. case "14":
  8649. yiliao_leibie = "门诊特殊病"
  8650. break
  8651. case "15":
  8652. yiliao_leibie = "门诊统筹"
  8653. break
  8654. case "16":
  8655. yiliao_leibie = "门诊慢性病"
  8656. break
  8657. case "21":
  8658. yiliao_leibie = "普通住院"
  8659. break
  8660. }
  8661. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8662. if res.Infcode == 0 {
  8663. c.ServeSuccessJSON(map[string]interface{}{
  8664. "diagnosis": name,
  8665. "order_infos": orderInfos,
  8666. "number": order.MdtrtId,
  8667. "date": order.SettleAccountsDate,
  8668. "charge_admin": charge_admin,
  8669. "printor_admin": printor_admin,
  8670. "info": res.Output.Setlinfo,
  8671. "order": order,
  8672. "bedCostTotal": bedCostTotal,
  8673. "bedCostSelfTotal": bedCostSelfTotal,
  8674. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  8675. "operationCostTotal": operationCostTotal,
  8676. "operationCostSelfTotal": operationCostSelfTotal,
  8677. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  8678. "otherCostTotal": otherCostTotal,
  8679. "otherCostSelfTotal": otherCostSelfTotal,
  8680. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  8681. "materialCostTotal": materialCostTotal,
  8682. "materialCostSelfTotal": materialCostSelfTotal,
  8683. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  8684. "westernMedicineCostTotal": westernMedicineCostTotal,
  8685. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  8686. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  8687. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  8688. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  8689. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  8690. "checkCostTotal": checkCostTotal,
  8691. "checkCostSelfTotal": checkCostSelfTotal,
  8692. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  8693. "laboratoryCostTotal": laboratoryCostTotal,
  8694. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  8695. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  8696. "treatCostTotal": treatCostTotal,
  8697. "treatCostSelfTotal": treatCostSelfTotal,
  8698. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  8699. "doctor_info": doctor_info,
  8700. "doctor_code": adminRole_two.DoctorCode,
  8701. "doctor_name": doctor_name,
  8702. "health_card_no": order.PsnNo,
  8703. "department": departments.Name,
  8704. "yiliao_leibie": yiliao_leibie,
  8705. "after_money": order.AccountPrice,
  8706. "patient": patient,
  8707. "org_name": miConfig.OrgName,
  8708. "org_code": miConfig.Code,
  8709. "order_number": order.Number,
  8710. "his_hospital": his_hospital,
  8711. "his": his,
  8712. "dia_config": dia_config,
  8713. //"check_order_info": cus_slice,
  8714. })
  8715. }
  8716. }
  8717. }
  8718. func (c *HisApiController) CheckTreatment() {
  8719. patient_id, _ := c.GetInt64("patient_id")
  8720. id_card_no := c.GetString("id_card_no")
  8721. insutype := c.GetString("insutype")
  8722. med_type := c.GetString("med_type")
  8723. admin_user_id, _ := c.GetInt64("admin_user_id")
  8724. adminUser := c.GetAdminUserInfo()
  8725. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8726. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8727. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8728. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8729. if miConfig.MdtrtareaAdmvs == "421300" {
  8730. var res ResultTwo
  8731. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  8732. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8733. "&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)
  8734. resp, requestErr := http.Get(api)
  8735. if requestErr != nil {
  8736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8737. return
  8738. }
  8739. body, ioErr := ioutil.ReadAll(resp.Body)
  8740. if ioErr != nil {
  8741. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8743. return
  8744. }
  8745. var respJSON map[string]interface{}
  8746. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8747. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8749. return
  8750. }
  8751. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8752. result, _ := json.Marshal(respJSON)
  8753. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8754. utils.ErrorLog("解析失败:%v", err)
  8755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8756. return
  8757. }
  8758. if res.Infcode == 0 {
  8759. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  8760. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8761. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  8762. resp, requestErr := http.Get(api)
  8763. if requestErr != nil {
  8764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8765. return
  8766. }
  8767. body, ioErr := ioutil.ReadAll(resp.Body)
  8768. if ioErr != nil {
  8769. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8771. return
  8772. }
  8773. var respJSON map[string]interface{}
  8774. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8775. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8777. return
  8778. }
  8779. var res Result2001
  8780. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8781. result2, _ := json.Marshal(respJSON)
  8782. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  8783. utils.ErrorLog("解析失败:%v", err)
  8784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8785. return
  8786. }
  8787. if res.Infcode == 0 {
  8788. c.ServeSuccessJSON(map[string]interface{}{
  8789. "msg": res.Output.Trtinfo,
  8790. })
  8791. }
  8792. } else {
  8793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8794. return
  8795. }
  8796. } else {
  8797. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  8798. var dat map[string]interface{}
  8799. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8800. fmt.Println(dat)
  8801. } else {
  8802. fmt.Println(err)
  8803. }
  8804. userJSONBytes, _ := json.Marshal(dat)
  8805. var res ResultTwo
  8806. var res10265 ResultTwo10265
  8807. if miConfig.Code == "H15049901371" {
  8808. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8809. utils.ErrorLog("解析失败:%v", err)
  8810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8811. return
  8812. }
  8813. res.ErrMsg = res10265.ErrMsg
  8814. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8815. res.Infcode = infocode
  8816. res.Output = res10265.Output
  8817. res.InfRefmsgid = res10265.InfRefmsgid
  8818. } else {
  8819. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8820. utils.ErrorLog("解析失败:%v", err)
  8821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8822. return
  8823. }
  8824. }
  8825. var user_name string
  8826. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  8827. if role.ID == 0 {
  8828. user_name = "xxx"
  8829. } else {
  8830. user_name = role.UserName
  8831. }
  8832. baseParams := models.BaseParams{
  8833. SecretKey: miConfig.SecretKey,
  8834. FixmedinsCode: miConfig.Code,
  8835. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8836. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8837. OrgName: miConfig.OrgName,
  8838. Doctor: user_name,
  8839. }
  8840. if config.IsOpen == 1 {
  8841. if miConfig.Code == "H15049901371" {
  8842. if med_type == "14" {
  8843. if insutype == "390" {
  8844. med_type = "9933"
  8845. } else if insutype == "310" {
  8846. med_type = "990502"
  8847. }
  8848. } else if med_type == "11" {
  8849. med_type = "11"
  8850. }
  8851. }
  8852. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  8853. var dat map[string]interface{}
  8854. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8855. fmt.Println(dat)
  8856. } else {
  8857. fmt.Println(err)
  8858. }
  8859. var res Result2001
  8860. var res10265 Result2001Org10265
  8861. if miConfig.Code == "H15049901371" {
  8862. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8863. utils.ErrorLog("解析失败:%v", err)
  8864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8865. return
  8866. }
  8867. res.ErrMsg = res10265.ErrMsg
  8868. res.Output = res10265.Output
  8869. res.InfRefmsgid = res10265.InfRefmsgid
  8870. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8871. res.Infcode = infocode
  8872. } else {
  8873. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8874. utils.ErrorLog("解析失败:%v", err)
  8875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8876. return
  8877. }
  8878. }
  8879. if res.Infcode == 0 {
  8880. c.ServeSuccessJSON(map[string]interface{}{
  8881. "msg": res.Output.Trtinfo,
  8882. })
  8883. }
  8884. }
  8885. }
  8886. }
  8887. //func (c *HisApiController) PutRecord() {
  8888. // id, _ := c.GetInt64("id")
  8889. // record_time := c.GetString("record_time")
  8890. // timeLayout := "2006-01-02"
  8891. // loc, _ := time.LoadLocation("Local")
  8892. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8893. // if err != nil {
  8894. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8895. // return
  8896. // }
  8897. // recordDateTime := theTime.Unix()
  8898. //
  8899. // adminInfo := c.GetAdminUserInfo()
  8900. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  8901. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8902. //
  8903. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8904. //
  8905. // fmt.Println(miConfig.SecretKey)
  8906. //
  8907. // if patient == nil {
  8908. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  8909. // return
  8910. // }
  8911. // if len(patient.IdCardNo) == 0 {
  8912. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  8913. // return
  8914. // }
  8915. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  8916. // if config.IsOpen == 1 {
  8917. // 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
  8918. // resp, requestErr := http.Get(api)
  8919. // if requestErr != nil {
  8920. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8921. // return
  8922. // }
  8923. // defer resp.Body.Close()
  8924. // body, ioErr := ioutil.ReadAll(resp.Body)
  8925. // if ioErr != nil {
  8926. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8927. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8928. // return
  8929. // }
  8930. // var respJSON map[string]interface{}
  8931. //
  8932. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8933. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8934. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8935. // return
  8936. // }
  8937. //
  8938. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8939. // userJSONBytes, _ := json.Marshal(userJSON)
  8940. // var res ResultTwo
  8941. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8942. // utils.ErrorLog("解析失败:%v", err)
  8943. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8944. // return
  8945. // }
  8946. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8947. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8948. // infoStr := string(Iinfos)
  8949. // idetinfoStr := string(Idetinfos)
  8950. //
  8951. // if res.Infcode == 0 {
  8952. // his := models.VMHisPatient{
  8953. // Status: 1,
  8954. // Ctime: time.Now().Unix(),
  8955. // Mtime: time.Now().Unix(),
  8956. // PsnNo: res.Output.Baseinfo.PsnNo,
  8957. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  8958. // Certno: res.Output.Baseinfo.Certno,
  8959. // PsnName: res.Output.Baseinfo.PsnName,
  8960. // Gend: res.Output.Baseinfo.Gend,
  8961. // Naty: res.Output.Baseinfo.Naty,
  8962. // Brdy: res.Output.Baseinfo.Brdy,
  8963. // Age: res.Output.Baseinfo.Age,
  8964. // Iinfo: infoStr,
  8965. // Idetinfo: idetinfoStr,
  8966. // PatientId: patient.ID,
  8967. // RecordDate: theTime.Unix(),
  8968. // UserOrgId: adminInfo.CurrentOrgId,
  8969. // AdminUserId: adminInfo.AdminUser.Id,
  8970. // IsReturn: 1,
  8971. // }
  8972. //
  8973. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  8974. // //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")
  8975. // //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")
  8976. //
  8977. // //var dat map[string]interface{}
  8978. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8979. // // fmt.Println(dat)
  8980. // //} else {
  8981. // // fmt.Println(err)
  8982. // //}
  8983. //
  8984. // var dat2 map[string]interface{}
  8985. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  8986. // fmt.Println(dat2)
  8987. // } else {
  8988. // fmt.Println(err)
  8989. // }
  8990. //
  8991. // } else {
  8992. // adminUser := c.GetAdminUserInfo()
  8993. // errlog := &models.HisOrderError{
  8994. // UserOrgId: adminUser.CurrentOrgId,
  8995. // Ctime: time.Now().Unix(),
  8996. // Mtime: time.Now().Unix(),
  8997. // ErrMsg: res.ErrMsg,
  8998. // Status: 1,
  8999. // PatientId: id,
  9000. // RecordTime: recordDateTime,
  9001. // Stage: 1,
  9002. // }
  9003. // service.CreateErrMsgLog(errlog)
  9004. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  9005. // return
  9006. // }
  9007. // }
  9008. //
  9009. //}
  9010. //func (c *HisApiController) GetUploadDiag() {
  9011. // id, _ := c.GetInt64("id")
  9012. // record_time := c.GetString("record_time")
  9013. //
  9014. // diagnosis_id, _ := c.GetInt64("diagnosis")
  9015. // sick_type, _ := c.GetInt64("sick_type")
  9016. // reg_type, _ := c.GetInt64("reg_type")
  9017. //
  9018. // timeLayout := "2006-01-02"
  9019. // loc, _ := time.LoadLocation("Local")
  9020. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9021. // if err != nil {
  9022. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9023. // return
  9024. // }
  9025. //
  9026. // var patientPrescription models.HisPrescriptionInfo
  9027. // recordDateTime := theTime.Unix()
  9028. // adminInfo := c.GetAdminUserInfo()
  9029. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9030. //
  9031. // if patientPrescription.ID == 0 {
  9032. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9033. // }
  9034. //
  9035. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9036. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9037. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9038. // sickConfig, _ := service.FindSickById(sick_type)
  9039. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9040. //
  9041. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  9042. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  9043. // "&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 +
  9044. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  9045. // resp2, requestErr2 := http.Get(api2)
  9046. // if requestErr2 != nil {
  9047. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9048. // return
  9049. // }
  9050. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  9051. // if ioErr2 != nil {
  9052. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  9053. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9054. // return
  9055. // }
  9056. // var respJSON2 map[string]interface{}
  9057. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  9058. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9059. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9060. // return
  9061. // }
  9062. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9063. // userJSONBytes2, _ := json.Marshal(respJSON2)
  9064. //
  9065. // var res2 ResultSix
  9066. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9067. // utils.ErrorLog("解析失败:%v", err)
  9068. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9069. // return
  9070. // }
  9071. // if res2.Infcode != 0 {
  9072. // adminUser := c.GetAdminUserInfo()
  9073. // errlog := &models.HisOrderError{
  9074. // UserOrgId: adminUser.CurrentOrgId,
  9075. // Ctime: time.Now().Unix(),
  9076. // Mtime: time.Now().Unix(),
  9077. // ErrMsg: res2.ErrMsg,
  9078. // Status: 1,
  9079. // PatientId: id,
  9080. // RecordTime: recordDateTime,
  9081. // Stage: 3,
  9082. // }
  9083. // service.CreateErrMsgLog(errlog)
  9084. //
  9085. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  9086. // return
  9087. // }
  9088. //
  9089. // c.ServeSuccessJSON(map[string]interface{}{
  9090. // "msg": "上传成功",
  9091. // })
  9092. //
  9093. //}
  9094. type QueryResult struct {
  9095. ID int64
  9096. Name string
  9097. Code string
  9098. List_type_code string
  9099. }
  9100. func (c *HisApiController) GetCheckCode() {
  9101. ids_str := c.GetString("ids")
  9102. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9103. ids_arr := strings.Split(ids_str, ",")
  9104. var queryResult []QueryResult
  9105. ids := make([]int64, 0)
  9106. for _, item := range ids_arr {
  9107. id, _ := strconv.ParseInt(item, 10, 64)
  9108. ids = append(ids, id)
  9109. }
  9110. if record_type == 1 {
  9111. drugs, _ := service.GetBatchDrugList(ids)
  9112. for _, item := range drugs {
  9113. result := QueryResult{
  9114. ID: item.ID,
  9115. Name: item.DrugName,
  9116. Code: item.MedicalInsuranceNumber,
  9117. List_type_code: "101",
  9118. }
  9119. queryResult = append(queryResult, result)
  9120. }
  9121. } else if record_type == 2 {
  9122. goods, _ := service.GetBatchGoodInformationList(ids)
  9123. for _, item := range goods {
  9124. result := QueryResult{
  9125. ID: item.ID,
  9126. Name: item.GoodName,
  9127. Code: item.MedicalInsuranceNumber,
  9128. List_type_code: "301",
  9129. }
  9130. queryResult = append(queryResult, result)
  9131. }
  9132. } else if record_type == 3 {
  9133. projects, _ := service.GetBathchMyPorjecgList(ids)
  9134. for _, item := range projects {
  9135. result := QueryResult{
  9136. ID: item.ID,
  9137. Name: item.ProjectName,
  9138. Code: item.MedicalCode,
  9139. List_type_code: "201",
  9140. }
  9141. queryResult = append(queryResult, result)
  9142. }
  9143. }
  9144. admin_user_id, _ := c.GetInt64("admin_user_id")
  9145. adminUser := c.GetAdminUserInfo()
  9146. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9147. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9148. var user_name string
  9149. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9150. if role.ID == 0 {
  9151. user_name = "xxx"
  9152. } else {
  9153. user_name = role.UserName
  9154. }
  9155. baseParams := &models.BaseParams{
  9156. SecretKey: miConfig.SecretKey,
  9157. FixmedinsCode: miConfig.Code,
  9158. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9159. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9160. OrgName: miConfig.OrgName,
  9161. Doctor: user_name,
  9162. }
  9163. if config.IsOpen == 1 {
  9164. for _, item := range queryResult {
  9165. var result string
  9166. if record_type == 1 {
  9167. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9168. } else if record_type == 2 {
  9169. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9170. } else if record_type == 3 {
  9171. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9172. }
  9173. var dat map[string]interface{}
  9174. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9175. fmt.Println(dat)
  9176. } else {
  9177. fmt.Println(err)
  9178. }
  9179. userJSONBytes, _ := json.Marshal(dat)
  9180. var res ResultSix
  9181. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9182. utils.ErrorLog("解析失败:%v", err)
  9183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9184. return
  9185. }
  9186. if res.Infcode == 0 {
  9187. if record_type == 1 {
  9188. service.UpdateBaseDrugById(item.ID)
  9189. } else if record_type == 2 {
  9190. service.UpdateGoodInformaitonByDetail(item.ID)
  9191. } else if record_type == 3 {
  9192. service.UpdateProjectById(item.ID)
  9193. }
  9194. c.ServeSuccessJSON(map[string]interface{}{
  9195. "failed_code": 0,
  9196. "msg": "目录对照成功",
  9197. })
  9198. } else {
  9199. c.ServeSuccessJSON(map[string]interface{}{
  9200. "failed_code": -10,
  9201. "msg": res.ErrMsg,
  9202. })
  9203. }
  9204. }
  9205. }
  9206. }
  9207. func (c *HisApiController) UnCheckCode() {
  9208. ids_str := c.GetString("ids")
  9209. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9210. admin_user_id, _ := c.GetInt64("admin_user_id")
  9211. ids_arr := strings.Split(ids_str, ",")
  9212. var queryResult []QueryResult
  9213. ids := make([]int64, 0)
  9214. for _, item := range ids_arr {
  9215. id, _ := strconv.ParseInt(item, 10, 64)
  9216. ids = append(ids, id)
  9217. }
  9218. if record_type == 1 {
  9219. drugs, _ := service.GetBatchDrugList(ids)
  9220. for _, item := range drugs {
  9221. result := QueryResult{
  9222. ID: item.ID,
  9223. Name: item.DrugName,
  9224. Code: item.MedicalInsuranceNumber,
  9225. List_type_code: "101",
  9226. }
  9227. queryResult = append(queryResult, result)
  9228. }
  9229. } else if record_type == 2 {
  9230. goods, _ := service.GetBatchGoodInformationList(ids)
  9231. for _, item := range goods {
  9232. result := QueryResult{
  9233. ID: item.ID,
  9234. Name: item.GoodName,
  9235. Code: item.MedicalInsuranceNumber,
  9236. List_type_code: "301",
  9237. }
  9238. queryResult = append(queryResult, result)
  9239. }
  9240. } else if record_type == 3 {
  9241. projects, _ := service.GetBathchMyPorjecgList(ids)
  9242. for _, item := range projects {
  9243. result := QueryResult{
  9244. ID: item.ID,
  9245. Name: item.ProjectName,
  9246. Code: item.MedicalCode,
  9247. List_type_code: "201",
  9248. }
  9249. queryResult = append(queryResult, result)
  9250. }
  9251. }
  9252. adminUser := c.GetAdminUserInfo()
  9253. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9254. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9255. var user_name string
  9256. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9257. if role.ID == 0 {
  9258. user_name = "xxx"
  9259. } else {
  9260. user_name = role.UserName
  9261. }
  9262. baseParams := &models.BaseParams{
  9263. SecretKey: miConfig.SecretKey,
  9264. FixmedinsCode: miConfig.Code,
  9265. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9266. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9267. OrgName: miConfig.OrgName,
  9268. Doctor: user_name,
  9269. }
  9270. if config.IsOpen == 1 {
  9271. for _, item := range queryResult {
  9272. var result string
  9273. if record_type == 1 {
  9274. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9275. } else if record_type == 2 {
  9276. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9277. } else if record_type == 3 {
  9278. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9279. }
  9280. var dat2 map[string]interface{}
  9281. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  9282. fmt.Println(dat2)
  9283. } else {
  9284. fmt.Println(err)
  9285. }
  9286. userJSONBytes, _ := json.Marshal(dat2)
  9287. var res ResultSix
  9288. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9289. utils.ErrorLog("解析失败:%v", err)
  9290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9291. return
  9292. }
  9293. if res.Infcode == 0 {
  9294. if record_type == 1 {
  9295. service.UpdateDrugByIdDetail(item.ID)
  9296. } else if record_type == 2 {
  9297. service.UpdateGoodInfoById(item.ID)
  9298. } else if record_type == 3 {
  9299. service.UpdateMyProjectById(item.ID)
  9300. }
  9301. c.ServeSuccessJSON(map[string]interface{}{
  9302. "failed_code": 0,
  9303. "msg": "撤销目录对照成功",
  9304. })
  9305. } else {
  9306. c.ServeSuccessJSON(map[string]interface{}{
  9307. "failed_code": -10,
  9308. "msg": res.ErrMsg,
  9309. })
  9310. }
  9311. }
  9312. }
  9313. }
  9314. func (c *HisApiController) GetPatientInfo() {
  9315. id_card_no := c.GetString("id_card_no")
  9316. admin_user_id, _ := c.GetInt64("admin_user_id")
  9317. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  9318. if patient.ID == 0 {
  9319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9320. return
  9321. }
  9322. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9323. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9324. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  9325. if config.IsOpen == 1 {
  9326. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9327. var dat map[string]interface{}
  9328. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9329. fmt.Println(dat)
  9330. } else {
  9331. fmt.Println(err)
  9332. }
  9333. userJSONBytes, _ := json.Marshal(dat)
  9334. var res ResultTwo
  9335. var res10265 ResultTwo10265
  9336. if miConfig.Code == "H15049901371" {
  9337. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9338. utils.ErrorLog("解析失败:%v", err)
  9339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9340. return
  9341. }
  9342. res.ErrMsg = res10265.ErrMsg
  9343. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9344. res.Infcode = infocode
  9345. res.Output = res10265.Output
  9346. res.InfRefmsgid = res10265.InfRefmsgid
  9347. } else {
  9348. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9349. utils.ErrorLog("解析失败:%v", err)
  9350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9351. return
  9352. }
  9353. }
  9354. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9355. // utils.ErrorLog("解析失败:%v", err)
  9356. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9357. // return
  9358. //}
  9359. if res.Infcode != 0 {
  9360. c.ServeSuccessJSON(map[string]interface{}{
  9361. "failed_code": -10,
  9362. "msg": res.ErrMsg,
  9363. })
  9364. } else {
  9365. c.ServeSuccessJSON(map[string]interface{}{
  9366. "failed_code": 0,
  9367. "info": res,
  9368. })
  9369. }
  9370. }
  9371. }
  9372. func (c *HisApiController) PsnPutOnRecord() {
  9373. record_type, _ := c.GetInt64("type")
  9374. patient_id, _ := c.GetInt64("patient_id")
  9375. admin_user_id, _ := c.GetInt64("admin_user_id")
  9376. start_time := c.GetString("start_time")
  9377. end_time := c.GetString("end_time")
  9378. adminUser := c.GetAdminUserInfo()
  9379. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9380. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9381. var patients []*models.Patients
  9382. if record_type == 1 { //全部备案
  9383. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  9384. patients = append(patients, patient...)
  9385. } else { //单个备案
  9386. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9387. patients = append(patients, patient)
  9388. }
  9389. var user_name string
  9390. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9391. if role.ID == 0 {
  9392. user_name = "xxx"
  9393. } else {
  9394. user_name = role.UserName
  9395. }
  9396. if config.IsOpen == 1 {
  9397. for _, item := range patients {
  9398. 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
  9399. resp, requestErr := http.Get(api)
  9400. if requestErr != nil {
  9401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9402. return
  9403. }
  9404. defer resp.Body.Close()
  9405. body, ioErr := ioutil.ReadAll(resp.Body)
  9406. if ioErr != nil {
  9407. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9409. return
  9410. }
  9411. var respJSON map[string]interface{}
  9412. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9413. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9415. return
  9416. }
  9417. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9418. userJSONBytes, _ := json.Marshal(userJSON)
  9419. var res ResultTwo
  9420. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9421. utils.ErrorLog("解析失败:%v", err)
  9422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9423. return
  9424. }
  9425. if res.Infcode == 0 {
  9426. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  9427. var dat map[string]interface{}
  9428. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9429. fmt.Println(dat)
  9430. } else {
  9431. fmt.Println(err)
  9432. }
  9433. userJSONBytes, _ := json.Marshal(dat)
  9434. var res2 ResultThirteen
  9435. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9436. utils.ErrorLog("解析失败:%v", err)
  9437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9438. return
  9439. }
  9440. if res2.Infcode == 0 {
  9441. psnResult := &models.GdybPsnRecord{
  9442. UserOrgId: adminUser.CurrentOrgId,
  9443. PatientId: item.ID,
  9444. PsnNo: res.Output.Baseinfo.PsnNo,
  9445. Ctime: time.Now().Unix(),
  9446. Mtime: time.Now().Unix(),
  9447. Status: 1,
  9448. IsCancel: 1,
  9449. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  9450. }
  9451. service.CreatePsnRecord(psnResult)
  9452. } else {
  9453. c.ServeSuccessJSON(map[string]interface{}{
  9454. "failed_code": -10,
  9455. "msg": res2.ErrMsg,
  9456. })
  9457. return
  9458. }
  9459. }
  9460. }
  9461. }
  9462. }
  9463. func (c *HisApiController) PsnUnPutOnRecord() {
  9464. id, _ := c.GetInt64("id")
  9465. //record_type, _ := c.GetInt64("type")
  9466. admin_user_id, _ := c.GetInt64("admin_user_id")
  9467. adminUser := c.GetAdminUserInfo()
  9468. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9469. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9470. var user_name string
  9471. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9472. if role.ID == 0 {
  9473. user_name = "xxx"
  9474. } else {
  9475. user_name = role.UserName
  9476. }
  9477. psn_record, _ := service.GetPsnRecordById(id)
  9478. if psn_record.ID == 0 {
  9479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  9480. return
  9481. }
  9482. if config.IsOpen == 1 {
  9483. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  9484. var dat map[string]interface{}
  9485. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9486. fmt.Println(dat)
  9487. } else {
  9488. fmt.Println(err)
  9489. }
  9490. userJSONBytes, _ := json.Marshal(dat)
  9491. var res ResultFourteen
  9492. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9493. utils.ErrorLog("解析失败:%v", err)
  9494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9495. return
  9496. }
  9497. if res.Infcode == 0 {
  9498. psn_record.IsCancel = 2
  9499. service.CreatePsnRecord(&psn_record)
  9500. } else {
  9501. c.ServeSuccessJSON(map[string]interface{}{
  9502. "failed_code": -10,
  9503. "msg": res.ErrMsg,
  9504. })
  9505. return
  9506. }
  9507. }
  9508. }
  9509. func (c *HisApiController) PsnPutNCDSOnRecord() {
  9510. patient_id, _ := c.GetInt64("patient_id")
  9511. insutype_two := c.GetString("insutype")
  9512. psn_no := c.GetString("psn_no")
  9513. doctor_id, _ := c.GetInt64("doctor_id")
  9514. sick_id, _ := c.GetInt64("sick_id")
  9515. department_id, _ := c.GetInt64("department_id")
  9516. start_time := c.GetString("start_time")
  9517. end_time := c.GetString("end_time")
  9518. check_time := c.GetString("check_time")
  9519. adminUser := c.GetAdminUserInfo()
  9520. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9521. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9522. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9523. sick, _ := service.FindSickById(sick_id)
  9524. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  9525. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  9526. var res ResultTwo
  9527. var res10265 ResultTwo10265
  9528. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9529. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  9530. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  9531. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  9532. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(3, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(1, 10) + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  9533. resp, requestErr := http.Get(api)
  9534. if requestErr != nil {
  9535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9536. return
  9537. }
  9538. body, ioErr := ioutil.ReadAll(resp.Body)
  9539. if ioErr != nil {
  9540. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9542. return
  9543. }
  9544. var respJSON map[string]interface{}
  9545. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9546. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9548. return
  9549. }
  9550. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9551. result, _ := json.Marshal(respJSON)
  9552. fmt.Println("log")
  9553. fmt.Println(string(result))
  9554. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9555. utils.ErrorLog("解析失败:%v", err)
  9556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9557. return
  9558. }
  9559. res.ErrMsg = res10265.ErrMsg
  9560. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9561. res.Infcode = infocode
  9562. res.Output = res10265.Output
  9563. res.InfRefmsgid = res10265.InfRefmsgid
  9564. } else {
  9565. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  9566. if miConfig.Code == "H15049901371" {
  9567. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9568. utils.ErrorLog("解析失败:%v", err)
  9569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9570. return
  9571. }
  9572. res.ErrMsg = res10265.ErrMsg
  9573. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9574. res.Infcode = infocode
  9575. res.Output = res10265.Output
  9576. res.InfRefmsgid = res10265.InfRefmsgid
  9577. } else {
  9578. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9579. utils.ErrorLog("解析失败:%v", err)
  9580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9581. return
  9582. }
  9583. }
  9584. }
  9585. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9586. infoStr := string(Iinfos)
  9587. var rf []*ResultFive
  9588. json.Unmarshal([]byte(infoStr), &rf)
  9589. var insuplc_admdvs string
  9590. var insutype string
  9591. var is390 int = 0
  9592. var is310 int = 0
  9593. var insutypes []*ResultFive
  9594. for _, item := range rf {
  9595. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9596. insutypes = append(insutypes, item)
  9597. }
  9598. }
  9599. if len(insutypes) == 1 {
  9600. insutype = insutypes[0].Insutype
  9601. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9602. } else {
  9603. for _, i := range insutypes {
  9604. if i.Insutype == "390" {
  9605. is390 = 1
  9606. }
  9607. if i.Insutype == "310" {
  9608. is310 = 1
  9609. }
  9610. }
  9611. }
  9612. if is390 == 1 {
  9613. insutype = "390"
  9614. }
  9615. if is310 == 1 {
  9616. insutype = "310"
  9617. }
  9618. if len(insutypes) == 2 {
  9619. insutype = insutype_two
  9620. }
  9621. if len(insutypes) == 0 {
  9622. insutype = "310"
  9623. }
  9624. insutype = insutype_two
  9625. fmt.Println(insutype)
  9626. for _, item := range rf {
  9627. fmt.Println(item.Insutype)
  9628. fmt.Println(insutype)
  9629. if item.Insutype == insutype {
  9630. fmt.Println(item.Insutype)
  9631. fmt.Println(insutype)
  9632. insuplc_admdvs = item.InsuplcAdmdvs
  9633. }
  9634. }
  9635. fmt.Println(insuplc_admdvs)
  9636. var res2 ResultThirteen
  9637. var res10265_2 ResultThirteen10265
  9638. if config.IsOpen == 1 {
  9639. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9640. } else {
  9641. 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)
  9642. var dat map[string]interface{}
  9643. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9644. fmt.Println(dat)
  9645. } else {
  9646. fmt.Println(err)
  9647. }
  9648. userJSONBytes, _ := json.Marshal(dat)
  9649. if miConfig.Code == "H15049901371" {
  9650. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  9651. utils.ErrorLog("解析失败:%v", err)
  9652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9653. return
  9654. }
  9655. res2.ErrMsg = res10265_2.ErrMsg
  9656. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  9657. res2.Infcode = infocode
  9658. res2.Output = res10265_2.Output
  9659. res2.InfRefmsgid = res10265_2.InfRefmsgid
  9660. } else {
  9661. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9662. utils.ErrorLog("解析失败:%v", err)
  9663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9664. return
  9665. }
  9666. }
  9667. }
  9668. if res2.Infcode == 0 {
  9669. psnResult := &models.GdybPsnNcdsRecord{
  9670. UserOrgId: adminUser.CurrentOrgId,
  9671. PatientId: patient.ID,
  9672. PsnNo: psn_no,
  9673. DoctorId: doctor.AdminUserId,
  9674. DepartmentId: department_id,
  9675. SickType: sick_id,
  9676. Insutype: insutype,
  9677. Ctime: time.Now().Unix(),
  9678. Mtime: time.Now().Unix(),
  9679. Status: 1,
  9680. IsCancel: 1,
  9681. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  9682. }
  9683. service.CreatePsnNCDSRecord(psnResult)
  9684. c.ServeSuccessJSON(map[string]interface{}{
  9685. "failed_code": 0,
  9686. "msg": "备案成功",
  9687. "result": psnResult,
  9688. })
  9689. } else {
  9690. c.ServeSuccessJSON(map[string]interface{}{
  9691. "failed_code": -10,
  9692. "msg": res2.ErrMsg,
  9693. })
  9694. return
  9695. }
  9696. }
  9697. }
  9698. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  9699. id, _ := c.GetInt64("id")
  9700. admin_user_id, _ := c.GetInt64("admin_user_id")
  9701. adminUser := c.GetAdminUserInfo()
  9702. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9703. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9704. //config, _ := service.Ge(adminUser.CurrentOrgId)
  9705. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  9706. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9707. //var user_name string
  9708. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9709. //if role.ID == 0 {
  9710. // user_name = "xxx"
  9711. //} else {
  9712. // user_name = role.UserName
  9713. //}
  9714. psn_record, _ := service.GetPsnNCDSRecordById(id)
  9715. if psn_record.ID == 0 {
  9716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  9717. return
  9718. }
  9719. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  9720. var res ResultTwo
  9721. var res10265 ResultTwo10265
  9722. if miConfig.Code == "H15049901371" {
  9723. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9724. utils.ErrorLog("解析失败:%v", err)
  9725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9726. return
  9727. }
  9728. res.ErrMsg = res10265.ErrMsg
  9729. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9730. res.Infcode = infocode
  9731. res.Output = res10265.Output
  9732. res.InfRefmsgid = res10265.InfRefmsgid
  9733. } else {
  9734. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9735. utils.ErrorLog("解析失败:%v", err)
  9736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9737. return
  9738. }
  9739. }
  9740. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9741. infoStr := string(Iinfos)
  9742. var rf []*ResultFive
  9743. json.Unmarshal([]byte(infoStr), &rf)
  9744. var insuplc_admdvs string
  9745. var insutype string
  9746. var is390 int = 0
  9747. var is310 int = 0
  9748. var insutypes []*ResultFive
  9749. for _, item := range rf {
  9750. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9751. insutypes = append(insutypes, item)
  9752. }
  9753. }
  9754. if len(insutypes) == 1 {
  9755. insutype = insutypes[0].Insutype
  9756. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9757. } else {
  9758. for _, i := range insutypes {
  9759. if i.Insutype == "390" {
  9760. is390 = 1
  9761. }
  9762. if i.Insutype == "310" {
  9763. is310 = 1
  9764. }
  9765. }
  9766. }
  9767. if is390 == 1 {
  9768. insutype = "390"
  9769. }
  9770. if is310 == 1 {
  9771. insutype = "310"
  9772. }
  9773. if len(insutypes) == 0 {
  9774. insutype = "310"
  9775. }
  9776. insutype = psn_record.Insutype
  9777. for _, item := range rf {
  9778. if item.Insutype == insutype {
  9779. insuplc_admdvs = item.InsuplcAdmdvs
  9780. }
  9781. }
  9782. if config.IsOpen == 1 {
  9783. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  9784. var dat map[string]interface{}
  9785. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9786. fmt.Println(dat)
  9787. } else {
  9788. fmt.Println(err)
  9789. }
  9790. userJSONBytes, _ := json.Marshal(dat)
  9791. var res ResultFourteen
  9792. var res10265 ResultFourteen10265
  9793. if miConfig.Code == "H15049901371" {
  9794. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9795. utils.ErrorLog("解析失败:%v", err)
  9796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9797. return
  9798. }
  9799. res.ErrMsg = res10265.ErrMsg
  9800. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9801. res.Infcode = infocode
  9802. res.Output = res10265.Output
  9803. res.InfRefmsgid = res10265.InfRefmsgid
  9804. } else {
  9805. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9806. utils.ErrorLog("解析失败:%v", err)
  9807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9808. return
  9809. }
  9810. }
  9811. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9812. // utils.ErrorLog("解析失败:%v", err)
  9813. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9814. // return
  9815. //}
  9816. if res.Infcode == 0 {
  9817. psn_record.IsCancel = 2
  9818. service.CreatePsnNCDSRecord(&psn_record)
  9819. c.ServeSuccessJSON(map[string]interface{}{
  9820. "failed_code": 0,
  9821. "msg": "撤销备案成功",
  9822. })
  9823. } else {
  9824. c.ServeSuccessJSON(map[string]interface{}{
  9825. "failed_code": -10,
  9826. "msg": res.ErrMsg,
  9827. })
  9828. return
  9829. }
  9830. }
  9831. }
  9832. func (c *HisApiController) TestTest() {
  9833. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  9834. fmt.Println(patient.Iinfo)
  9835. }
  9836. type CustomData struct {
  9837. MsgId string
  9838. PsnNo string
  9839. Info string
  9840. }
  9841. func (c *HisApiController) ReversalData() {
  9842. var customData []*CustomData
  9843. custom := &CustomData{
  9844. MsgId: "H44022900158202103301714472004",
  9845. PsnNo: "44020000001101329945",
  9846. Info: "2207",
  9847. }
  9848. customData = append(customData, custom)
  9849. custom1 := &CustomData{
  9850. MsgId: "H4402290015820210330172057803",
  9851. PsnNo: "44020000001101161813",
  9852. Info: "2207",
  9853. }
  9854. customData = append(customData, custom1)
  9855. custom2 := &CustomData{
  9856. MsgId: "H44022900158202103301705198813",
  9857. PsnNo: "44190000133097375417",
  9858. Info: "2207",
  9859. }
  9860. customData = append(customData, custom2)
  9861. custom3 := &CustomData{
  9862. MsgId: "H44022900158202103301715524756",
  9863. PsnNo: "44020000001100187221",
  9864. Info: "2207",
  9865. }
  9866. customData = append(customData, custom3)
  9867. custom4 := &CustomData{
  9868. MsgId: "H44022900158202103301730376224",
  9869. PsnNo: "44020000001101959155",
  9870. Info: "2207",
  9871. }
  9872. customData = append(customData, custom4)
  9873. custom5 := &CustomData{
  9874. MsgId: "H44022900158202103301748008725",
  9875. PsnNo: "44020000001104246641",
  9876. Info: "2207",
  9877. }
  9878. customData = append(customData, custom5)
  9879. custom6 := &CustomData{
  9880. MsgId: "H44022900158202103301718096755",
  9881. PsnNo: "44020000001102211860",
  9882. Info: "2207",
  9883. }
  9884. customData = append(customData, custom6)
  9885. custom7 := &CustomData{
  9886. MsgId: "H44022900158202103301736551640",
  9887. PsnNo: "44020000001102687718",
  9888. Info: "2207",
  9889. }
  9890. customData = append(customData, custom7)
  9891. custom8 := &CustomData{
  9892. MsgId: "H44022900158202103301743097676",
  9893. PsnNo: "44020000001102127785",
  9894. Info: "2207",
  9895. }
  9896. customData = append(customData, custom8)
  9897. custom9 := &CustomData{
  9898. MsgId: "H44022900158202103301712304203",
  9899. PsnNo: "44020000001101518097",
  9900. Info: "2207",
  9901. }
  9902. customData = append(customData, custom9)
  9903. custom10 := &CustomData{
  9904. MsgId: "H44022900158202103301738448785",
  9905. PsnNo: "44020000001100500813",
  9906. Info: "2207",
  9907. }
  9908. customData = append(customData, custom10)
  9909. custom11 := &CustomData{
  9910. MsgId: "H44022900158202103301732455843",
  9911. PsnNo: "44020000001102690557",
  9912. Info: "2207",
  9913. }
  9914. customData = append(customData, custom11)
  9915. custom12 := &CustomData{
  9916. MsgId: "H44022900158202103301745421708",
  9917. PsnNo: "44020000001102211928",
  9918. Info: "2207",
  9919. }
  9920. customData = append(customData, custom12)
  9921. custom1212 := &CustomData{
  9922. MsgId: "H440229001582021033017351627",
  9923. PsnNo: "44020000001102481733",
  9924. Info: "2207",
  9925. }
  9926. customData = append(customData, custom1212)
  9927. custom13 := &CustomData{
  9928. MsgId: "H44022900158202103301740327951",
  9929. PsnNo: "44020000001103174866",
  9930. Info: "2207",
  9931. }
  9932. customData = append(customData, custom13)
  9933. custom14 := &CustomData{
  9934. MsgId: "H4402290015820210330174922668",
  9935. PsnNo: "44020000001102927272",
  9936. Info: "2207",
  9937. }
  9938. customData = append(customData, custom14)
  9939. custom15 := &CustomData{
  9940. MsgId: "H44022900158202103301752362273",
  9941. PsnNo: "44020000001102942890",
  9942. Info: "2207",
  9943. }
  9944. customData = append(customData, custom15)
  9945. custom16 := &CustomData{
  9946. MsgId: "H44022900158202103301751082917",
  9947. PsnNo: "44020000001101662162",
  9948. Info: "2207",
  9949. }
  9950. customData = append(customData, custom16)
  9951. custom17 := &CustomData{
  9952. MsgId: "H44022900158202103301754147728",
  9953. PsnNo: "44020000000229014511",
  9954. Info: "2207",
  9955. }
  9956. customData = append(customData, custom17)
  9957. adminUser := c.GetAdminUserInfo()
  9958. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9959. for _, item := range customData {
  9960. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  9961. fmt.Println(result)
  9962. }
  9963. }
  9964. func (c *HisApiController) GetAllopatry() {
  9965. year := c.GetString("year")
  9966. month := c.GetString("month")
  9967. admin_user_id, _ := c.GetInt64("admin_user_id")
  9968. adminUser := c.GetAdminUserInfo()
  9969. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9970. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9971. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9972. var dat map[string]interface{}
  9973. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9974. fmt.Println(dat)
  9975. } else {
  9976. fmt.Println(err)
  9977. }
  9978. userJSONBytes, _ := json.Marshal(dat)
  9979. var res models.Result9001
  9980. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9981. utils.ErrorLog("解析失败:%v", err)
  9982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9983. return
  9984. }
  9985. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9986. var dat2 map[string]interface{}
  9987. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9988. fmt.Println(dat)
  9989. } else {
  9990. fmt.Println(err)
  9991. }
  9992. userJSONBytes2, _ := json.Marshal(dat2)
  9993. var res2 models.Result3260
  9994. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9995. utils.ErrorLog("解析失败:%v", err)
  9996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9997. return
  9998. }
  9999. if res2.Infcode == 0 {
  10000. c.ServeSuccessJSON(map[string]interface{}{
  10001. "list": res2.Output.Data,
  10002. })
  10003. return
  10004. } else {
  10005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10006. return
  10007. }
  10008. }
  10009. func (c *HisApiController) ComfirmAllopatry() {
  10010. year := c.GetString("year")
  10011. month := c.GetString("month")
  10012. admin_user_id, _ := c.GetInt64("admin_user_id")
  10013. adminUser := c.GetAdminUserInfo()
  10014. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10015. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10016. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10017. var dat map[string]interface{}
  10018. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10019. fmt.Println(dat)
  10020. } else {
  10021. fmt.Println(err)
  10022. }
  10023. userJSONBytes, _ := json.Marshal(dat)
  10024. var res models.Result9001
  10025. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10026. utils.ErrorLog("解析失败:%v", err)
  10027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10028. return
  10029. }
  10030. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10031. var dat2 map[string]interface{}
  10032. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10033. fmt.Println(dat)
  10034. } else {
  10035. fmt.Println(err)
  10036. }
  10037. userJSONBytes2, _ := json.Marshal(dat2)
  10038. var res2 models.Result3260
  10039. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10040. utils.ErrorLog("解析失败:%v", err)
  10041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10042. return
  10043. }
  10044. if res2.Infcode == 0 {
  10045. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  10046. var dat map[string]interface{}
  10047. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10048. fmt.Println(dat)
  10049. } else {
  10050. fmt.Println(err)
  10051. }
  10052. userJSONBytes, _ := json.Marshal(dat)
  10053. var res3 models.Result3261
  10054. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  10055. utils.ErrorLog("解析失败:%v", err)
  10056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10057. return
  10058. }
  10059. if res3.Infcode == 0 {
  10060. record := &models.HisYidiClearRecord{
  10061. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10062. Ctime: time.Now().Unix(),
  10063. Mtime: time.Now().Unix(),
  10064. Status: 1,
  10065. MsgId: msgId,
  10066. }
  10067. service.SaveClearRecord(record)
  10068. c.ServeSuccessJSON(map[string]interface{}{
  10069. "msg": "提取成功",
  10070. })
  10071. }
  10072. }
  10073. }
  10074. func (c *HisApiController) RefundAllopatry() {
  10075. year := c.GetString("year")
  10076. month := c.GetString("month")
  10077. id, _ := c.GetInt64("id")
  10078. admin_user_id, _ := c.GetInt64("admin_user_id")
  10079. adminUser := c.GetAdminUserInfo()
  10080. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10081. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10082. record, _ := service.GetClearRecordById(id)
  10083. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  10084. var dat map[string]interface{}
  10085. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10086. fmt.Println(dat)
  10087. } else {
  10088. fmt.Println(err)
  10089. }
  10090. userJSONBytes, _ := json.Marshal(dat)
  10091. var empty ResultFourteen
  10092. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  10093. utils.ErrorLog("解析失败:%v", err)
  10094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10095. return
  10096. }
  10097. if empty.Infcode == 0 {
  10098. c.ServeSuccessJSON(map[string]interface{}{
  10099. "msg": "撤销成功",
  10100. })
  10101. return
  10102. }
  10103. }
  10104. func (c *HisApiController) ReversalOtherData() {
  10105. var customData []*CustomData
  10106. custom := &CustomData{
  10107. MsgId: "H44022900158202103301714472004",
  10108. PsnNo: "44020000001101329945",
  10109. Info: "2208",
  10110. }
  10111. customData = append(customData, custom)
  10112. custom1 := &CustomData{
  10113. MsgId: "H4402290015820210330172057803",
  10114. PsnNo: "44020000001101161813",
  10115. Info: "2208",
  10116. }
  10117. customData = append(customData, custom1)
  10118. custom2 := &CustomData{
  10119. MsgId: "H44022900158202103301705198813",
  10120. PsnNo: "44190000133097375417",
  10121. Info: "2208",
  10122. }
  10123. customData = append(customData, custom2)
  10124. custom3 := &CustomData{
  10125. MsgId: "H44022900158202103301715524756",
  10126. PsnNo: "44020000001100187221",
  10127. Info: "2208",
  10128. }
  10129. customData = append(customData, custom3)
  10130. custom4 := &CustomData{
  10131. MsgId: "H44022900158202103301730376224",
  10132. PsnNo: "44020000001101959155",
  10133. Info: "2208",
  10134. }
  10135. customData = append(customData, custom4)
  10136. custom5 := &CustomData{
  10137. MsgId: "H44022900158202103301748008725",
  10138. PsnNo: "44020000001104246641",
  10139. Info: "2208",
  10140. }
  10141. customData = append(customData, custom5)
  10142. custom6 := &CustomData{
  10143. MsgId: "H44022900158202103301718096755",
  10144. PsnNo: "44020000001102211860",
  10145. Info: "2208",
  10146. }
  10147. customData = append(customData, custom6)
  10148. custom7 := &CustomData{
  10149. MsgId: "H44022900158202103301736551640",
  10150. PsnNo: "44020000001102687718",
  10151. Info: "2208",
  10152. }
  10153. customData = append(customData, custom7)
  10154. custom8 := &CustomData{
  10155. MsgId: "H44022900158202103301743097676",
  10156. PsnNo: "44020000001102127785",
  10157. Info: "2208",
  10158. }
  10159. customData = append(customData, custom8)
  10160. custom9 := &CustomData{
  10161. MsgId: "H44022900158202103301712304203",
  10162. PsnNo: "44020000001101518097",
  10163. Info: "2208",
  10164. }
  10165. customData = append(customData, custom9)
  10166. custom10 := &CustomData{
  10167. MsgId: "H44022900158202103301738448785",
  10168. PsnNo: "44020000001100500813",
  10169. Info: "2208",
  10170. }
  10171. customData = append(customData, custom10)
  10172. custom11 := &CustomData{
  10173. MsgId: "H44022900158202103301732455843",
  10174. PsnNo: "44020000001102690557",
  10175. Info: "2208",
  10176. }
  10177. customData = append(customData, custom11)
  10178. custom12 := &CustomData{
  10179. MsgId: "H44022900158202103301745421708",
  10180. PsnNo: "44020000001102211928",
  10181. Info: "2208",
  10182. }
  10183. customData = append(customData, custom12)
  10184. custom1212 := &CustomData{
  10185. MsgId: "H440229001582021033017351627",
  10186. PsnNo: "44020000001102481733",
  10187. Info: "2208",
  10188. }
  10189. customData = append(customData, custom1212)
  10190. custom13 := &CustomData{
  10191. MsgId: "H44022900158202103301740327951",
  10192. PsnNo: "44020000001103174866",
  10193. Info: "2208",
  10194. }
  10195. customData = append(customData, custom13)
  10196. custom14 := &CustomData{
  10197. MsgId: "H4402290015820210330174922668",
  10198. PsnNo: "44020000001102927272",
  10199. Info: "2208",
  10200. }
  10201. customData = append(customData, custom14)
  10202. custom15 := &CustomData{
  10203. MsgId: "H44022900158202103301752362273",
  10204. PsnNo: "44020000001102942890",
  10205. Info: "2208",
  10206. }
  10207. customData = append(customData, custom15)
  10208. custom16 := &CustomData{
  10209. MsgId: "H44022900158202103301751082917",
  10210. PsnNo: "44020000001101662162",
  10211. Info: "2208",
  10212. }
  10213. customData = append(customData, custom16)
  10214. custom17 := &CustomData{
  10215. MsgId: "H44022900158202103301754147728",
  10216. PsnNo: "44020000000229014511",
  10217. Info: "2208",
  10218. }
  10219. customData = append(customData, custom17)
  10220. adminUser := c.GetAdminUserInfo()
  10221. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10222. for _, item := range customData {
  10223. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10224. fmt.Println(result)
  10225. }
  10226. }
  10227. func PathExists(path string) (bool, error) {
  10228. _, err := os.Stat(path)
  10229. if err == nil {
  10230. return true, nil
  10231. }
  10232. if os.IsNotExist(err) {
  10233. return false, nil
  10234. }
  10235. return false, err
  10236. }
  10237. //创建文件夹
  10238. func Mkdir(dir string) {
  10239. // 创建文件夹
  10240. exist, err := PathExists(dir)
  10241. if err != nil {
  10242. fmt.Println(err.Error())
  10243. } else {
  10244. if exist {
  10245. fmt.Println(dir + "文件夹已存在!")
  10246. } else {
  10247. // 文件夹名称,权限
  10248. err := os.Mkdir(dir, os.ModePerm)
  10249. if err != nil {
  10250. fmt.Println(dir+"文件夹创建失败:", err.Error())
  10251. } else {
  10252. fmt.Println(dir + "文件夹创建成功!")
  10253. }
  10254. }
  10255. }
  10256. }
  10257. //压缩文件
  10258. func Zip(srcFile string, destZip string) error {
  10259. zipfile, err := os.Create(destZip)
  10260. if err != nil {
  10261. return err
  10262. }
  10263. defer zipfile.Close()
  10264. archive := zip.NewWriter(zipfile)
  10265. defer archive.Close()
  10266. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  10267. if err != nil {
  10268. return err
  10269. }
  10270. header, err := zip.FileInfoHeader(info)
  10271. if err != nil {
  10272. return err
  10273. }
  10274. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  10275. // header.Name = path
  10276. if info.IsDir() {
  10277. header.Name += "/"
  10278. } else {
  10279. header.Method = zip.Deflate
  10280. }
  10281. writer, err := archive.CreateHeader(header)
  10282. if err != nil {
  10283. return err
  10284. }
  10285. if !info.IsDir() {
  10286. file, err := os.Open(path)
  10287. if err != nil {
  10288. return err
  10289. }
  10290. defer file.Close()
  10291. _, err = io.Copy(writer, file)
  10292. }
  10293. return err
  10294. })
  10295. return err
  10296. }
  10297. func ReadFile(filePath string) []byte {
  10298. f, err := os.Open(filePath)
  10299. if err != nil {
  10300. fmt.Println("read file fail", err)
  10301. return nil
  10302. }
  10303. defer f.Close()
  10304. fd, err := ioutil.ReadAll(f)
  10305. if err != nil {
  10306. fmt.Println("read to fd fail", err)
  10307. return nil
  10308. }
  10309. return fd
  10310. }
  10311. func saveLog(result string, request string, infno string, desc string) {
  10312. org_id, _ := beego.AppConfig.Int64("org_id")
  10313. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  10314. dir := miConfig.OrgName + "日志"
  10315. utils.Mkdir(dir)
  10316. month := time.Unix(1557042972, 0).Format("1")
  10317. year := time.Now().Format("2006")
  10318. month = time.Now().Format("01")
  10319. day := time.Now().Format("02")
  10320. hour := time.Now().Format("15")
  10321. min := time.Now().Format("04")
  10322. sec := time.Now().Format("05")
  10323. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  10324. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  10325. file_name := file + ".txt"
  10326. file_path := miConfig.OrgName + "日志" + "/" + file_name
  10327. exist, _ := utils.PathExists(file_path)
  10328. if exist { //存在
  10329. fmt.Println("存在")
  10330. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  10331. if err != nil {
  10332. fmt.Println("read fail")
  10333. }
  10334. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  10335. n, _ := f.Seek(0, 2)
  10336. _, err = f.WriteAt([]byte(content), n)
  10337. } else { //不存在
  10338. fmt.Println("文件不存在,创建文件")
  10339. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  10340. defer f.Close()
  10341. if err != nil {
  10342. } else {
  10343. _, err = f.Write([]byte("记录日志"))
  10344. }
  10345. }
  10346. }
  10347. type Charset string
  10348. const (
  10349. UTF8 = Charset("UTF-8")
  10350. GB18030 = Charset("GB18030")
  10351. )
  10352. func ConvertToString(src string, srcCode string, tagCode string) string {
  10353. srcCoder := mahonia.NewDecoder(srcCode)
  10354. srcResult := srcCoder.ConvertString(src)
  10355. tagCoder := mahonia.NewDecoder(tagCode)
  10356. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  10357. result := string(cdata)
  10358. return result
  10359. }