his_api_controller.go 422KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552
  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.FixmedinsCode = miConfig.Code
  109. pp.RequestUrl = miConfig.Url
  110. pp.Cainfo = miConfig.Cainfo
  111. pp.SecretKey = miConfig.SecretKey
  112. pp.AccessKey = miConfig.AccessKey
  113. pp.OpterName = roles.UserName
  114. var config []*models.HisXtDiagnoseConfig
  115. for _, item := range diagnosis_ids {
  116. id, _ := strconv.ParseInt(item, 10, 64)
  117. diagnosisConfig, _ := service.FindDiagnoseById(id)
  118. config = append(config, &diagnosisConfig)
  119. }
  120. var pd models.PatientDtos
  121. pd.PatnID = his.PsnNo
  122. pd.PatnName = his.Name
  123. pd.Gend = his.Gend
  124. pd.Brdy = his.Brdy
  125. pd.Poolarea = his.InsuplcAdmdvs
  126. pd.CurrMdtrtID = his.Number
  127. var fed models.FsiEncounterDtos
  128. fed.MdtrtID = his.Number
  129. fed.MedinsID = miConfig.Code
  130. fed.MedinsName = miConfig.OrgName
  131. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  132. fed.MedMdtrtType = "1"
  133. fed.MedinsLv = "11"
  134. tm := time.Unix(his.RecordDate, 0)
  135. s_tm := tm.Format("2006-01-02 15:04:05")
  136. fed.AdmDate = s_tm
  137. fed.DscgDate = s_tm
  138. fed.DscgMainDiseCodg = config[0].CountryCode
  139. fed.DscgMainDiseName = config[0].CountryContentName
  140. //诊断信息
  141. var fdds []*models.FsiDiagnoseDtos
  142. for index, item := range config {
  143. if index == 0 {
  144. var fdd models.FsiDiagnoseDtos
  145. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  146. fdd.InoutDiseType = "1"
  147. fdd.MaindiseFlag = "1"
  148. fdd.DiseDate = s_tm
  149. fdd.DiasSrtNo = "1"
  150. fdd.DiseName = item.CountryContentName
  151. fdd.DiseCodg = item.CountryCode
  152. fdds = append(fdds, &fdd)
  153. } else {
  154. var fdd models.FsiDiagnoseDtos
  155. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  156. fdd.InoutDiseType = "1"
  157. fdd.MaindiseFlag = "1"
  158. fdd.DiseDate = s_tm
  159. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  160. fdd.DiseName = item.CountryContentName
  161. fdd.DiseCodg = item.CountryCode
  162. fdds = append(fdds, &fdd)
  163. }
  164. }
  165. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  166. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  167. fed.AdmDeptName = department.Name
  168. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  169. fed.DscgDeptName = department.Name
  170. fed.MedMdtrtType = ""
  171. if his.Insutype == "390" {
  172. fed.MedType = "1402"
  173. } else {
  174. fed.MedType = "9933"
  175. }
  176. var orders []*models.FsiOrderDtos
  177. if trig_scen == "2" {
  178. //处方医嘱信息
  179. for _, item := range prescriptions {
  180. for _, subItem := range item.HisDoctorAdviceInfo {
  181. var order models.FsiOrderDtos
  182. order.RxID = strconv.FormatInt(item.ID, 10)
  183. order.Rxno = strconv.FormatInt(item.ID, 10)
  184. order.LongDrordFlag = "0"
  185. order.HilistType = "1"
  186. order.ChrgType = "1"
  187. order.DrordBhvr = "-"
  188. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  189. order.HosplistName = subItem.BaseDrugLib.DrugName
  190. order.HilistLv = "1"
  191. order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  192. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  193. order.HosplistName = subItem.BaseDrugLib.DrugName
  194. order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  195. order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  196. order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  197. order.OwnpayAmt = ""
  198. order.SelfpayAmt = ""
  199. order.Spec = ""
  200. order.SpecUnt = ""
  201. order.DrordBegnDate = s_tm
  202. order.DrordStopDate = ""
  203. order.DrordDrCodg = "1"
  204. order.DrordDeptName = department.Name
  205. order.DrordDrCodg = "1"
  206. order.DrordDrName = doctor_info.UserName
  207. order.DrordDrProfttl = ""
  208. order.CurrDrordFlag = "1"
  209. orders = append(orders, &order)
  210. }
  211. for _, subItem := range item.HisPrescriptionProject {
  212. if subItem.Type == 2 {
  213. var order models.FsiOrderDtos
  214. order.RxID = strconv.FormatInt(item.ID, 10)
  215. order.Rxno = strconv.FormatInt(item.ID, 10)
  216. order.LongDrordFlag = "0"
  217. order.HilistType = "1"
  218. order.ChrgType = "1"
  219. order.DrordBhvr = "-"
  220. order.HilistCode = subItem.HisProject.MedicalCode
  221. order.HosplistName = subItem.HisProject.ProjectName
  222. order.HilistLv = "1"
  223. order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  224. order.HosplistCode = subItem.HisProject.MedicalCode
  225. order.HosplistName = subItem.HisProject.ProjectName
  226. order.Cnt = subItem.Count
  227. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  228. order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  229. order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  230. order.OwnpayAmt = ""
  231. order.SelfpayAmt = ""
  232. order.Spec = ""
  233. order.SpecUnt = ""
  234. order.DrordBegnDate = s_tm
  235. order.DrordStopDate = ""
  236. order.DrordDrCodg = "1"
  237. order.DrordDeptName = department.Name
  238. order.DrordDrCodg = "1"
  239. order.DrordDrName = doctor_info.UserName
  240. order.DrordDrProfttl = ""
  241. order.CurrDrordFlag = "1"
  242. orders = append(orders, &order)
  243. }
  244. if subItem.Type == 3 {
  245. var order models.FsiOrderDtos
  246. order.RxID = strconv.FormatInt(item.ID, 10)
  247. order.Rxno = strconv.FormatInt(item.ID, 10)
  248. order.LongDrordFlag = "0"
  249. order.HilistType = "1"
  250. order.ChrgType = "1"
  251. order.DrordBhvr = "-"
  252. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  253. order.HosplistName = subItem.GoodInfo.GoodName
  254. order.HilistLv = "1"
  255. order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  256. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  257. order.HosplistName = subItem.GoodInfo.GoodName
  258. order.Cnt = subItem.Count
  259. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  260. order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  261. order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  262. order.OwnpayAmt = ""
  263. order.SelfpayAmt = ""
  264. order.Spec = ""
  265. order.SpecUnt = ""
  266. order.DrordBegnDate = s_tm
  267. order.DrordStopDate = ""
  268. order.DrordDrCodg = "1"
  269. order.DrordDeptName = department.Name
  270. order.DrordDrCodg = "1"
  271. order.DrordDrName = doctor_info.UserName
  272. order.DrordDrProfttl = ""
  273. order.CurrDrordFlag = "1"
  274. orders = append(orders, &order)
  275. }
  276. }
  277. }
  278. //处方医嘱信息
  279. }
  280. fed.MatnStas = "0"
  281. fed.MedfeeSumamt = "0"
  282. fed.OwnpayAmt = "0"
  283. fed.SelfpayAmt = "0"
  284. fed.AcctPayamt = "0"
  285. fed.MaAmt = "0"
  286. fed.HifpPayamt = "0"
  287. fed.SetlTotlnum = "0"
  288. fed.Insutype = his.Insutype
  289. fed.ReimFlag = "0"
  290. fed.OutSetlFlag = "0"
  291. var fopd []*models.FsiOperationDtosData
  292. data := make(map[string]interface{})
  293. data["fed"] = fed
  294. data["fdd"] = fdds
  295. data["fod"] = orders
  296. data["pd"] = pd
  297. data["pp"] = pp
  298. data["fopd"] = fopd
  299. data["trig_scen"] = trig_scen
  300. fmt.Println(data)
  301. fmt.Println(fed)
  302. fmt.Println(fdds)
  303. fmt.Println(orders)
  304. fmt.Println(pd)
  305. fmt.Println(pp)
  306. fmt.Println(fopd)
  307. client := &http.Client{}
  308. bytesData, _ := json.Marshal(data)
  309. var req *http.Request
  310. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  311. resp, _ := client.Do(req)
  312. defer resp.Body.Close()
  313. body, ioErr := ioutil.ReadAll(resp.Body)
  314. if ioErr != nil {
  315. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  317. return
  318. }
  319. var respJSON map[string]interface{}
  320. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  321. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  323. return
  324. }
  325. //手术操作集合
  326. //手术操作集合
  327. }
  328. func (c *HisApiController) Check3102() {
  329. patient_id, _ := c.GetInt64("patient_id")
  330. order_id, _ := c.GetInt64("order_id")
  331. his_patient_id, _ := c.GetInt64("his_patient_id")
  332. admin_user_id, _ := c.GetInt64("admin_user_id")
  333. trig_scen := c.GetString("trig_scen")
  334. adminUser := c.GetAdminUserInfo()
  335. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  336. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  337. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  338. record_time := c.GetString("record_time")
  339. order, _ := service.GetHisOrderByID(order_id)
  340. timeLayout := "2006-01-02"
  341. loc, _ := time.LoadLocation("Local")
  342. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  343. if err != nil {
  344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  345. return
  346. }
  347. recordDateTime := theTime.Unix()
  348. var patientPrescription models.HisPrescriptionInfo
  349. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  350. if patientPrescription.ID == 0 {
  351. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  352. }
  353. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  354. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  355. //
  356. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  357. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  358. var pp models.PublicParams
  359. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  360. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  361. pp.FixmedinsName = miConfig.OrgName
  362. pp.FixmedinsCode = miConfig.Code
  363. pp.RequestUrl = miConfig.Url
  364. pp.Cainfo = miConfig.Cainfo
  365. pp.SecretKey = miConfig.SecretKey
  366. pp.AccessKey = miConfig.AccessKey
  367. pp.OpterName = roles.UserName
  368. var config []*models.HisXtDiagnoseConfig
  369. for _, item := range diagnosis_ids {
  370. id, _ := strconv.ParseInt(item, 10, 64)
  371. diagnosisConfig, _ := service.FindDiagnoseById(id)
  372. config = append(config, &diagnosisConfig)
  373. }
  374. var pd models.PatientDtos
  375. pd.PatnID = his.PsnNo
  376. pd.PatnName = his.Name
  377. pd.Gend = his.Gend
  378. pd.Brdy = his.Brdy
  379. pd.Poolarea = his.InsuplcAdmdvs
  380. pd.CurrMdtrtID = his.Number
  381. var fed models.FsiEncounterDtos
  382. fed.MdtrtID = his.Number
  383. fed.MedinsID = miConfig.Code
  384. fed.MedinsName = miConfig.OrgName
  385. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  386. fed.MedMdtrtType = "1"
  387. fed.MedinsLv = "11"
  388. tm := time.Unix(his.RecordDate, 0)
  389. s_tm := tm.Format("2006-01-02 15:04:05")
  390. fed.AdmDate = s_tm
  391. fed.DscgDate = s_tm
  392. fed.DscgMainDiseCodg = config[0].CountryCode
  393. fed.DscgMainDiseName = config[0].CountryContentName
  394. //诊断信息
  395. var fdds []*models.FsiDiagnoseDtos
  396. for index, item := range config {
  397. if index == 0 {
  398. var fdd models.FsiDiagnoseDtos
  399. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  400. fdd.InoutDiseType = "1"
  401. fdd.MaindiseFlag = "1"
  402. fdd.DiseDate = s_tm
  403. fdd.DiasSrtNo = "1"
  404. fdd.DiseName = item.CountryContentName
  405. fdd.DiseCodg = item.CountryCode
  406. fdds = append(fdds, &fdd)
  407. } else {
  408. var fdd models.FsiDiagnoseDtos
  409. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  410. fdd.InoutDiseType = "1"
  411. fdd.MaindiseFlag = "1"
  412. fdd.DiseDate = s_tm
  413. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  414. fdd.DiseName = item.CountryContentName
  415. fdd.DiseCodg = item.CountryCode
  416. fdds = append(fdds, &fdd)
  417. }
  418. }
  419. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  420. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  421. fed.AdmDeptName = department.Name
  422. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  423. fed.DscgDeptName = department.Name
  424. fed.MedMdtrtType = ""
  425. fed.MedType = order.MedType
  426. //处方医嘱信息
  427. var orders []*models.FsiOrderDtos
  428. for _, item := range prescriptions {
  429. for _, subItem := range item.HisDoctorAdviceInfo {
  430. var order models.FsiOrderDtos
  431. order.RxID = strconv.FormatInt(item.ID, 10)
  432. order.Rxno = strconv.FormatInt(item.ID, 10)
  433. order.LongDrordFlag = "0"
  434. order.HilistType = "1"
  435. order.ChrgType = "1"
  436. order.DrordBhvr = "-"
  437. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  438. order.HosplistName = subItem.BaseDrugLib.DrugName
  439. order.HilistLv = "1"
  440. order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  441. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  442. order.HosplistName = subItem.BaseDrugLib.DrugName
  443. order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  444. order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  445. order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  446. order.OwnpayAmt = ""
  447. order.SelfpayAmt = ""
  448. order.Spec = ""
  449. order.SpecUnt = ""
  450. order.DrordBegnDate = s_tm
  451. order.DrordStopDate = ""
  452. order.DrordDrCodg = "1"
  453. order.DrordDeptName = department.Name
  454. order.DrordDrCodg = "1"
  455. order.DrordDrName = doctor_info.UserName
  456. order.DrordDrProfttl = ""
  457. order.CurrDrordFlag = "1"
  458. orders = append(orders, &order)
  459. }
  460. for _, subItem := range item.HisPrescriptionProject {
  461. if subItem.Type == 2 {
  462. var order models.FsiOrderDtos
  463. order.RxID = strconv.FormatInt(item.ID, 10)
  464. order.Rxno = strconv.FormatInt(item.ID, 10)
  465. order.LongDrordFlag = "0"
  466. order.HilistType = "1"
  467. order.ChrgType = "1"
  468. order.DrordBhvr = "-"
  469. order.HilistCode = subItem.HisProject.MedicalCode
  470. order.HosplistName = subItem.HisProject.ProjectName
  471. order.HilistLv = "1"
  472. order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  473. order.HosplistCode = subItem.HisProject.MedicalCode
  474. order.HosplistName = subItem.HisProject.ProjectName
  475. order.Cnt = subItem.Count
  476. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  477. order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  478. order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  479. order.OwnpayAmt = ""
  480. order.SelfpayAmt = ""
  481. order.Spec = ""
  482. order.SpecUnt = ""
  483. order.DrordBegnDate = s_tm
  484. order.DrordStopDate = ""
  485. order.DrordDrCodg = "1"
  486. order.DrordDeptName = department.Name
  487. order.DrordDrCodg = "1"
  488. order.DrordDrName = doctor_info.UserName
  489. order.DrordDrProfttl = ""
  490. order.CurrDrordFlag = "1"
  491. orders = append(orders, &order)
  492. }
  493. if subItem.Type == 3 {
  494. var order models.FsiOrderDtos
  495. order.RxID = strconv.FormatInt(item.ID, 10)
  496. order.Rxno = strconv.FormatInt(item.ID, 10)
  497. order.LongDrordFlag = "0"
  498. order.HilistType = "1"
  499. order.ChrgType = "1"
  500. order.DrordBhvr = "-"
  501. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  502. order.HosplistName = subItem.GoodInfo.GoodName
  503. order.HilistLv = "1"
  504. order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  505. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  506. order.HosplistName = subItem.GoodInfo.GoodName
  507. order.Cnt = subItem.Count
  508. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  509. order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  510. order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  511. order.OwnpayAmt = ""
  512. order.SelfpayAmt = ""
  513. order.Spec = ""
  514. order.SpecUnt = ""
  515. order.DrordBegnDate = s_tm
  516. order.DrordStopDate = ""
  517. order.DrordDrCodg = "1"
  518. order.DrordDeptName = department.Name
  519. order.DrordDrCodg = "1"
  520. order.DrordDrName = doctor_info.UserName
  521. order.DrordDrProfttl = ""
  522. order.CurrDrordFlag = "1"
  523. orders = append(orders, &order)
  524. }
  525. }
  526. }
  527. //处方医嘱信息
  528. fed.MatnStas = "0"
  529. fed.MedfeeSumamt = strconv.FormatFloat(order.MedfeeSumamt, 'E', -1, 64)
  530. fed.OwnpayAmt = strconv.FormatFloat(order.FulamtOwnpayAmt, 'E', -1, 64)
  531. fed.SelfpayAmt = strconv.FormatFloat(order.PreselfpayAmt, 'E', -1, 64)
  532. fed.AcctPayamt = strconv.FormatFloat(order.AcctPay, 'E', -1, 64)
  533. fed.MaAmt = strconv.FormatFloat(order.MafPay, 'E', -1, 64)
  534. fed.HifpPayamt = strconv.FormatFloat(order.HifpPay, 'E', -1, 64)
  535. fed.SetlTotlnum = "1"
  536. fed.Insutype = his.Insutype
  537. fed.ReimFlag = "0"
  538. fed.OutSetlFlag = "0"
  539. var fopd []*models.FsiOperationDtosData
  540. data := make(map[string]interface{})
  541. data["fed"] = fed
  542. data["fdd"] = fdds
  543. data["fod"] = orders
  544. data["pd"] = pd
  545. data["pp"] = pp
  546. data["fopd"] = fopd
  547. data["trig_scen"] = trig_scen
  548. fmt.Println(data)
  549. fmt.Println(fed)
  550. fmt.Println(fdds)
  551. fmt.Println(orders)
  552. fmt.Println(pd)
  553. fmt.Println(pp)
  554. fmt.Println(fopd)
  555. client := &http.Client{}
  556. bytesData, _ := json.Marshal(data)
  557. var req *http.Request
  558. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  559. resp, _ := client.Do(req)
  560. defer resp.Body.Close()
  561. body, ioErr := ioutil.ReadAll(resp.Body)
  562. if ioErr != nil {
  563. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  565. return
  566. }
  567. var respJSON map[string]interface{}
  568. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  569. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  571. return
  572. }
  573. //手术操作集合
  574. //手术操作集合
  575. }
  576. func (c *HisApiController) Check() {
  577. psn_no := c.GetString("psn_no")
  578. in := c.GetString("in")
  579. mt := c.GetString("mt")
  580. baseParams := models.BaseParams{
  581. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  582. FixmedinsCode: "H15049901371",
  583. InsuplcAdmdvs: "150499",
  584. MdtrtareaAdmvs: "150499",
  585. OrgName: "赤峰费森血液透析中心",
  586. Doctor: "1111",
  587. }
  588. service.Gdyb2001(baseParams, psn_no, in, mt)
  589. }
  590. func (c *HisApiController) GetPsnNcdsInfo() {
  591. admin_user_id, _ := c.GetInt64("admin_user_id")
  592. patient_id, _ := c.GetInt64("patient_id")
  593. id, _ := c.GetInt64("id")
  594. adminUser := c.GetAdminUserInfo()
  595. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  596. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  597. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  598. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  599. psn_record, _ := service.GetPsnNCDSRecordById(id)
  600. //
  601. //if psn_record.ID == 0 {
  602. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  603. // return
  604. //}
  605. var res Result5301
  606. var res10265 Result5301For10265
  607. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  608. psn_info, _ := service.GetPsnByPatientId(patient_id)
  609. var api string
  610. if miConfig.MdtrtareaAdmvs == "320921" {
  611. 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 +
  612. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  613. } else {
  614. 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 +
  615. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  616. }
  617. resp, requestErr := http.Get(api)
  618. if requestErr != nil {
  619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  620. return
  621. }
  622. body, ioErr := ioutil.ReadAll(resp.Body)
  623. if ioErr != nil {
  624. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  626. return
  627. }
  628. var respJSON map[string]interface{}
  629. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  630. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  632. return
  633. }
  634. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  635. result, _ := json.Marshal(respJSON)
  636. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  637. utils.ErrorLog("解析失败:%v", err)
  638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  639. return
  640. }
  641. res.ErrMsg = res10265.ErrMsg
  642. res.Output = res10265.Output
  643. res.InfRefmsgid = res10265.InfRefmsgid
  644. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  645. res.Infcode = infocode
  646. } else {
  647. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  648. var dat map[string]interface{}
  649. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  650. fmt.Println(dat)
  651. } else {
  652. fmt.Println(err)
  653. }
  654. userJSONBytes, _ := json.Marshal(dat)
  655. if miConfig.Code == "H15049901371" {
  656. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  657. utils.ErrorLog("解析失败:%v", err)
  658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  659. return
  660. }
  661. res.InfRefmsgid = res10265.InfRefmsgid
  662. res.Output = res10265.Output
  663. res.ErrMsg = res10265.ErrMsg
  664. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  665. res.Infcode = infocode
  666. } else {
  667. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  668. utils.ErrorLog("解析失败:%v", err)
  669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  670. return
  671. }
  672. }
  673. }
  674. if res.Infcode == 0 {
  675. c.ServeSuccessJSON(map[string]interface{}{
  676. "result": res.Output.Result,
  677. })
  678. }
  679. }
  680. func (c *HisApiController) CheckInsutype() {
  681. his_patient_id, _ := c.GetInt64("his_patient_id")
  682. admin_user_id, _ := c.GetInt64("admin_user_id")
  683. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  684. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  685. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  686. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  687. var dat map[string]interface{}
  688. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  689. fmt.Println(dat)
  690. } else {
  691. fmt.Println(err)
  692. }
  693. userJSONBytes, _ := json.Marshal(dat)
  694. var res Result90100
  695. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  696. utils.ErrorLog("解析失败:%v", err)
  697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  698. return
  699. }
  700. if res.Infcode != 0 {
  701. c.ServeSuccessJSON(map[string]interface{}{
  702. "failed_code": -10,
  703. "msg": res.ErrMsg,
  704. })
  705. return
  706. } else {
  707. fmt.Println(res)
  708. }
  709. }
  710. func (c *HisApiController) CheckCardPWD() {
  711. card_pwd := c.GetString("card_pwd")
  712. his_patient_id, _ := c.GetInt64("his_patient_id")
  713. admin_user_id, _ := c.GetInt64("admin_user_id")
  714. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  715. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  716. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  717. psn, _ := service.GetPsnByPatientId(his.PatientId)
  718. bas := strings.Split(psn.CardInfo, "|")
  719. basNumber := bas[2]
  720. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  721. var dat map[string]interface{}
  722. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  723. fmt.Println(dat)
  724. } else {
  725. fmt.Println(err)
  726. }
  727. userJSONBytes, _ := json.Marshal(dat)
  728. var res Result90991
  729. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  730. utils.ErrorLog("解析失败:%v", err)
  731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  732. return
  733. }
  734. if res.Infcode != 0 {
  735. c.ServeSuccessJSON(map[string]interface{}{
  736. "failed_code": -10,
  737. "msg": res.ErrMsg,
  738. })
  739. return
  740. } else {
  741. if res.Output.Result.CheckStat == "0" {
  742. var msg string
  743. switch res.Output.Result.CardStat {
  744. case "00":
  745. msg = "未激活"
  746. break
  747. case "10":
  748. msg = "激活"
  749. break
  750. case "20":
  751. msg = "窗口挂失"
  752. break
  753. case "21":
  754. msg = "电话挂失"
  755. break
  756. case "22":
  757. msg = "单位网上申报挂失"
  758. break
  759. case "23":
  760. msg = "保健办挂失"
  761. break
  762. case "24":
  763. msg = "个人网上挂失"
  764. break
  765. case "25":
  766. msg = "网上服务大厅挂失"
  767. break
  768. case "30":
  769. msg = "注销"
  770. break
  771. case "40":
  772. msg = "回收"
  773. break
  774. case "99":
  775. msg = "制卡中(无效卡)"
  776. break
  777. }
  778. c.ServeSuccessJSON(map[string]interface{}{
  779. "failed_code": -10,
  780. "msg": msg,
  781. })
  782. return
  783. } else {
  784. c.ServeSuccessJSON(map[string]interface{}{
  785. "msg": "校验成功",
  786. })
  787. return
  788. }
  789. }
  790. }
  791. func (c *HisApiController) ReadCard() {
  792. id_card_type, _ := c.GetInt64("id_card_type")
  793. admin_user_id, _ := c.GetInt64("admin_user_id")
  794. certificates, _ := c.GetInt64("certificates")
  795. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  796. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  797. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  798. switch id_card_type {
  799. case 1:
  800. if miConfig.MdtrtareaAdmvs == "421300" {
  801. var res ResultTwo
  802. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  803. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  804. "&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)
  805. resp, requestErr := http.Get(api)
  806. if requestErr != nil {
  807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  808. return
  809. }
  810. body, ioErr := ioutil.ReadAll(resp.Body)
  811. if ioErr != nil {
  812. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  814. return
  815. }
  816. var respJSON map[string]interface{}
  817. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  818. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  820. return
  821. }
  822. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  823. result, _ := json.Marshal(respJSON)
  824. fmt.Println("log")
  825. fmt.Println(string(result))
  826. if err := json.Unmarshal([]byte(result), &res); err != nil {
  827. utils.ErrorLog("解析失败:%v", err)
  828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  829. return
  830. }
  831. if res.Infcode == 0 {
  832. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  833. if err == gorm.ErrRecordNotFound {
  834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  835. return
  836. } else if err != nil {
  837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  838. return
  839. } else {
  840. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  841. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  842. infoStr := string(Iinfos)
  843. idetinfoStr := string(Idetinfos)
  844. psn := &models.HisPsn{
  845. PsnNo: res.Output.Baseinfo.PsnNo,
  846. Age: res.Output.Baseinfo.Age,
  847. PatientId: patient.ID,
  848. Certno: res.Output.Baseinfo.Certno,
  849. Brdy: res.Output.Baseinfo.Brdy,
  850. Gend: res.Output.Baseinfo.Gend,
  851. Naty: res.Output.Baseinfo.Naty,
  852. PsnCertType: res.Output.Baseinfo.PsnCertType,
  853. PsnName: res.Output.Baseinfo.PsnName,
  854. Idetinfo: idetinfoStr,
  855. Insuinfo: infoStr,
  856. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  857. }
  858. service.CreateHisPsn(psn)
  859. c.ServeSuccessJSON(map[string]interface{}{
  860. "patient": patient,
  861. "number": res.Output.Baseinfo.Certno,
  862. })
  863. }
  864. } else {
  865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  866. return
  867. }
  868. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  869. var api string
  870. if miConfig.MdtrtareaAdmvs == "320921" {
  871. 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 +
  872. "&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
  873. fmt.Println(api)
  874. } else {
  875. 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 +
  876. "&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)
  877. }
  878. resp, requestErr := http.Get(api)
  879. if requestErr != nil {
  880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  881. return
  882. }
  883. body, ioErr := ioutil.ReadAll(resp.Body)
  884. if ioErr != nil {
  885. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  887. return
  888. }
  889. var respJSON map[string]interface{}
  890. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  891. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  893. return
  894. }
  895. var status string
  896. status = respJSON["data"].(map[string]interface{})["status"].(string)
  897. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  898. //console.log()
  899. fmt.Println("type===")
  900. fmt.Println(card_type)
  901. var token string
  902. var res ResultTwo //1101结果
  903. var res10265 ResultTwo10265 //1101结果
  904. var card_info string //卡信息
  905. var busi_card_info string
  906. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  907. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  908. if status == "0" { //读卡成功
  909. if card_type == "1" {
  910. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  911. result, _ := json.Marshal(respJSON)
  912. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  913. utils.ErrorLog("解析失败:%v", err)
  914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  915. return
  916. }
  917. res.ErrMsg = res10265.ErrMsg
  918. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  919. res.Infcode = infocode
  920. res.Output = res10265.Output
  921. res.InfRefmsgid = res10265.InfRefmsgid
  922. } else {
  923. //var card_info string //卡信息
  924. //var busi_card_info string
  925. token = respJSON["data"].(map[string]interface{})["token"].(string)
  926. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  927. //fmt.Println(card_info)
  928. //fmt.Println(busi_card_info)
  929. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  930. result, _ := json.Marshal(respJSON)
  931. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  932. utils.ErrorLog("解析失败:%v", err)
  933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  934. return
  935. }
  936. res.ErrMsg = res10265.ErrMsg
  937. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  938. res.Infcode = infocode
  939. res.Output = res10265.Output
  940. res.InfRefmsgid = res10265.InfRefmsgid
  941. }
  942. if res.Infcode == 0 {
  943. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  944. if err == gorm.ErrRecordNotFound {
  945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  946. return
  947. } else if err != nil {
  948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  949. return
  950. } else {
  951. if card_type == "1" {
  952. bas := strings.Split(card_info, "|")
  953. basNumber := bas[2]
  954. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  955. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  956. infoStr := string(Iinfos)
  957. idetinfoStr := string(Idetinfos)
  958. psn := &models.HisPsn{
  959. PsnNo: res.Output.Baseinfo.PsnNo,
  960. Age: res.Output.Baseinfo.Age,
  961. PatientId: patient.ID,
  962. Certno: res.Output.Baseinfo.Certno,
  963. Brdy: res.Output.Baseinfo.Brdy,
  964. Gend: res.Output.Baseinfo.Gend,
  965. Naty: res.Output.Baseinfo.Naty,
  966. PsnCertType: res.Output.Baseinfo.PsnCertType,
  967. PsnName: res.Output.Baseinfo.PsnName,
  968. Idetinfo: idetinfoStr,
  969. Insuinfo: infoStr,
  970. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  971. CardInfo: card_info,
  972. VerifyNumber: busi_card_info,
  973. }
  974. service.CreateHisPsn(psn)
  975. c.ServeSuccessJSON(map[string]interface{}{
  976. "patient": patient,
  977. "number": basNumber,
  978. })
  979. } else {
  980. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  981. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  982. infoStr := string(Iinfos)
  983. idetinfoStr := string(Idetinfos)
  984. psn := &models.HisPsn{
  985. PsnNo: res.Output.Baseinfo.PsnNo,
  986. Age: res.Output.Baseinfo.Age,
  987. PatientId: patient.ID,
  988. Certno: res.Output.Baseinfo.Certno,
  989. Brdy: res.Output.Baseinfo.Brdy,
  990. Gend: res.Output.Baseinfo.Gend,
  991. Naty: res.Output.Baseinfo.Naty,
  992. PsnCertType: res.Output.Baseinfo.PsnCertType,
  993. PsnName: res.Output.Baseinfo.PsnName,
  994. Idetinfo: idetinfoStr,
  995. Insuinfo: infoStr,
  996. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  997. CardInfo: card_info,
  998. VerifyNumber: token,
  999. }
  1000. service.CreateHisPsn(psn)
  1001. c.ServeSuccessJSON(map[string]interface{}{
  1002. "patient": patient,
  1003. "number": token,
  1004. })
  1005. }
  1006. }
  1007. } else {
  1008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1009. return
  1010. }
  1011. } else { //读卡失败
  1012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1013. return
  1014. }
  1015. } else {
  1016. if initFlag == 0 {
  1017. c.TestGetBasBaseInit()
  1018. }
  1019. basStr := c.GetBasBaseInfo()
  1020. if len(basStr) == 0 {
  1021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1022. return
  1023. }
  1024. fmt.Println(basStr)
  1025. bas := strings.Split(basStr, "|")
  1026. basNumber := bas[1]
  1027. fmt.Println(basNumber)
  1028. card_sn := bas[3]
  1029. fmt.Println(card_sn)
  1030. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1031. var dat map[string]interface{}
  1032. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1033. fmt.Println(dat)
  1034. } else {
  1035. fmt.Println(err)
  1036. }
  1037. userJSONBytes, _ := json.Marshal(dat)
  1038. var res ResultTwo
  1039. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1040. utils.ErrorLog("解析失败:%v", err)
  1041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1042. return
  1043. }
  1044. if res.Infcode == 0 {
  1045. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1046. if err == gorm.ErrRecordNotFound {
  1047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1048. return
  1049. } else if err != nil {
  1050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1051. return
  1052. } else {
  1053. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1054. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1055. infoStr := string(Iinfos)
  1056. idetinfoStr := string(Idetinfos)
  1057. psn := &models.HisPsn{
  1058. PsnNo: res.Output.Baseinfo.PsnNo,
  1059. Age: res.Output.Baseinfo.Age,
  1060. PatientId: patient.ID,
  1061. Certno: res.Output.Baseinfo.Certno,
  1062. Brdy: res.Output.Baseinfo.Brdy,
  1063. Gend: res.Output.Baseinfo.Gend,
  1064. Naty: res.Output.Baseinfo.Naty,
  1065. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1066. PsnName: res.Output.Baseinfo.PsnName,
  1067. Idetinfo: idetinfoStr,
  1068. Insuinfo: infoStr,
  1069. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1070. CardInfo: basStr,
  1071. VerifyNumber: "",
  1072. }
  1073. service.CreateHisPsn(psn)
  1074. c.ServeSuccessJSON(map[string]interface{}{
  1075. "patient": patient,
  1076. "number": basNumber,
  1077. })
  1078. }
  1079. } else {
  1080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1081. return
  1082. }
  1083. break
  1084. }
  1085. case 2:
  1086. SFZStr := c.GetSFZBaseInfo()
  1087. id_card_str := strings.Split(SFZStr, "^")
  1088. id_card_number := id_card_str[0]
  1089. card_sn := ""
  1090. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1091. var dat map[string]interface{}
  1092. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1093. fmt.Println(dat)
  1094. } else {
  1095. fmt.Println(err)
  1096. }
  1097. userJSONBytes, _ := json.Marshal(dat)
  1098. var res ResultTwo
  1099. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1100. utils.ErrorLog("解析失败:%v", err)
  1101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1102. return
  1103. }
  1104. if res.Infcode == 0 {
  1105. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1106. if err == gorm.ErrRecordNotFound {
  1107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1108. return
  1109. } else if err != nil {
  1110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1111. return
  1112. } else {
  1113. c.ServeSuccessJSON(map[string]interface{}{
  1114. "patient": patient,
  1115. "number": id_card_number,
  1116. })
  1117. }
  1118. } else {
  1119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1120. return
  1121. }
  1122. break
  1123. case 3:
  1124. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1125. var api string
  1126. if miConfig.MdtrtareaAdmvs == "320921" {
  1127. 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 +
  1128. "&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
  1129. fmt.Println(api)
  1130. } else {
  1131. 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 +
  1132. "&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)
  1133. }
  1134. resp, requestErr := http.Get(api)
  1135. if requestErr != nil {
  1136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1137. return
  1138. }
  1139. body, ioErr := ioutil.ReadAll(resp.Body)
  1140. if ioErr != nil {
  1141. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1143. return
  1144. }
  1145. var respJSON map[string]interface{}
  1146. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1147. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1149. return
  1150. }
  1151. var status string
  1152. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1153. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1154. var token string
  1155. var res ResultTwo //1101结果
  1156. var res10265 ResultTwo10265 //1101结果
  1157. var card_info string //卡信息
  1158. var busi_card_info string
  1159. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1160. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1161. if status == "0" { //读卡成功
  1162. if card_type == "1" {
  1163. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1164. result, _ := json.Marshal(respJSON)
  1165. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1166. utils.ErrorLog("解析失败:%v", err)
  1167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1168. return
  1169. }
  1170. res.ErrMsg = res10265.ErrMsg
  1171. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1172. res.Infcode = infocode
  1173. res.Output = res10265.Output
  1174. res.InfRefmsgid = res10265.InfRefmsgid
  1175. } else {
  1176. //var card_info string //卡信息
  1177. //var busi_card_info string
  1178. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1179. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1180. //fmt.Println(card_info)
  1181. //fmt.Println(busi_card_info)
  1182. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1183. result, _ := json.Marshal(respJSON)
  1184. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1185. utils.ErrorLog("解析失败:%v", err)
  1186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1187. return
  1188. }
  1189. res.ErrMsg = res10265.ErrMsg
  1190. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1191. res.Infcode = infocode
  1192. res.Output = res10265.Output
  1193. res.InfRefmsgid = res10265.InfRefmsgid
  1194. }
  1195. if res.Infcode == 0 {
  1196. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1197. if err == gorm.ErrRecordNotFound {
  1198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1199. return
  1200. } else if err != nil {
  1201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1202. return
  1203. } else {
  1204. if card_type == "1" {
  1205. bas := strings.Split(card_info, "|")
  1206. basNumber := bas[2]
  1207. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1208. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1209. infoStr := string(Iinfos)
  1210. idetinfoStr := string(Idetinfos)
  1211. psn := &models.HisPsn{
  1212. PsnNo: res.Output.Baseinfo.PsnNo,
  1213. Age: res.Output.Baseinfo.Age,
  1214. PatientId: patient.ID,
  1215. Certno: res.Output.Baseinfo.Certno,
  1216. Brdy: res.Output.Baseinfo.Brdy,
  1217. Gend: res.Output.Baseinfo.Gend,
  1218. Naty: res.Output.Baseinfo.Naty,
  1219. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1220. PsnName: res.Output.Baseinfo.PsnName,
  1221. Idetinfo: idetinfoStr,
  1222. Insuinfo: infoStr,
  1223. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1224. CardInfo: card_info,
  1225. VerifyNumber: busi_card_info,
  1226. }
  1227. service.CreateHisPsn(psn)
  1228. c.ServeSuccessJSON(map[string]interface{}{
  1229. "patient": patient,
  1230. "number": basNumber,
  1231. })
  1232. } else {
  1233. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1234. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1235. infoStr := string(Iinfos)
  1236. idetinfoStr := string(Idetinfos)
  1237. psn := &models.HisPsn{
  1238. PsnNo: res.Output.Baseinfo.PsnNo,
  1239. Age: res.Output.Baseinfo.Age,
  1240. PatientId: patient.ID,
  1241. Certno: res.Output.Baseinfo.Certno,
  1242. Brdy: res.Output.Baseinfo.Brdy,
  1243. Gend: res.Output.Baseinfo.Gend,
  1244. Naty: res.Output.Baseinfo.Naty,
  1245. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1246. PsnName: res.Output.Baseinfo.PsnName,
  1247. Idetinfo: idetinfoStr,
  1248. Insuinfo: infoStr,
  1249. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1250. CardInfo: card_info,
  1251. VerifyNumber: token,
  1252. }
  1253. service.CreateHisPsn(psn)
  1254. c.ServeSuccessJSON(map[string]interface{}{
  1255. "patient": patient,
  1256. "number": token,
  1257. })
  1258. }
  1259. }
  1260. } else {
  1261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1262. return
  1263. }
  1264. } else { //读卡失败
  1265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1266. return
  1267. }
  1268. }
  1269. break
  1270. case 4:
  1271. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1272. var api string
  1273. if miConfig.MdtrtareaAdmvs == "320921" {
  1274. 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 +
  1275. "&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
  1276. fmt.Println(api)
  1277. } else {
  1278. 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 +
  1279. "&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)
  1280. }
  1281. resp, requestErr := http.Get(api)
  1282. if requestErr != nil {
  1283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1284. return
  1285. }
  1286. body, ioErr := ioutil.ReadAll(resp.Body)
  1287. if ioErr != nil {
  1288. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1290. return
  1291. }
  1292. var respJSON map[string]interface{}
  1293. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1294. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1296. return
  1297. }
  1298. var status string
  1299. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1300. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1301. var token string
  1302. var res ResultTwo //1101结果
  1303. var res10265 ResultTwo10265 //1101结果
  1304. if status == "0" { //读卡成功
  1305. var card_info string //卡信息
  1306. var busi_card_info string
  1307. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1308. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1309. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1310. fmt.Println(card_info)
  1311. fmt.Println(busi_card_info)
  1312. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1313. result, _ := json.Marshal(respJSON)
  1314. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1315. utils.ErrorLog("解析失败:%v", err)
  1316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1317. return
  1318. }
  1319. res.ErrMsg = res10265.ErrMsg
  1320. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1321. res.Infcode = infocode
  1322. res.Output = res10265.Output
  1323. res.InfRefmsgid = res10265.InfRefmsgid
  1324. if res.Infcode == 0 {
  1325. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1326. if err == gorm.ErrRecordNotFound {
  1327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1328. return
  1329. } else if err != nil {
  1330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1331. return
  1332. } else {
  1333. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1334. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1335. infoStr := string(Iinfos)
  1336. idetinfoStr := string(Idetinfos)
  1337. psn := &models.HisPsn{
  1338. PsnNo: res.Output.Baseinfo.PsnNo,
  1339. Age: res.Output.Baseinfo.Age,
  1340. PatientId: patient.ID,
  1341. Certno: res.Output.Baseinfo.Certno,
  1342. Brdy: res.Output.Baseinfo.Brdy,
  1343. Gend: res.Output.Baseinfo.Gend,
  1344. Naty: res.Output.Baseinfo.Naty,
  1345. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1346. PsnName: res.Output.Baseinfo.PsnName,
  1347. Idetinfo: idetinfoStr,
  1348. Insuinfo: infoStr,
  1349. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1350. CardInfo: card_info,
  1351. VerifyNumber: token,
  1352. }
  1353. service.CreateHisPsn(psn)
  1354. c.ServeSuccessJSON(map[string]interface{}{
  1355. "patient": patient,
  1356. "number": token,
  1357. })
  1358. }
  1359. } else {
  1360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1361. return
  1362. }
  1363. } else { //读卡失败
  1364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1365. return
  1366. }
  1367. }
  1368. break
  1369. }
  1370. }
  1371. var initFlag int64 = 0
  1372. func (c *HisApiController) TestGetBasBaseInit() {
  1373. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1374. Iinit := DllDef.MustFindProc("Init")
  1375. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1376. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  1377. if ret != 0 {
  1378. fmt.Println("SSCard的报错原因:", err)
  1379. fmt.Println("SSCard的运算结果为:", ret)
  1380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1381. return
  1382. }
  1383. result := int(ret)
  1384. fmt.Println("SSCard的运算结果为1:", result)
  1385. initFlag = 1
  1386. return
  1387. }
  1388. func (c *HisApiController) GetSFZBaseInfo() string {
  1389. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1390. readCard := DllDef.MustFindProc("ReadSFZ")
  1391. if readCard == nil {
  1392. fmt.Println("readcard is nil")
  1393. readCard = DllDef.MustFindProc("ReadSFZ")
  1394. }
  1395. str := make([]byte, 256)
  1396. str1 := make([]byte, 256)
  1397. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1398. fmt.Println(r)
  1399. return string(str)
  1400. }
  1401. func (c *HisApiController) GetBasBaseInfo() string {
  1402. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1403. readCard := DllDef.MustFindProc("ReadCardBas")
  1404. if readCard == nil {
  1405. fmt.Println("readcard is nil")
  1406. readCard = DllDef.MustFindProc("ReadCardBas")
  1407. }
  1408. str := make([]byte, 1024)
  1409. str1 := make([]byte, 1024)
  1410. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  1411. fmt.Println(string(str1))
  1412. fmt.Println(string(str))
  1413. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1414. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1415. if ret2 != 0 {
  1416. return ""
  1417. }
  1418. return string(str)
  1419. }
  1420. type CustomFundPay struct {
  1421. FundPayType string `json:"fund_pay_type"`
  1422. FundPayamt float64 `json:"fund_payamt"`
  1423. }
  1424. func (c *HisApiController) GetSettleList() {
  1425. order_id, _ := c.GetInt64("order_id")
  1426. admin_user_id, _ := c.GetInt64("admin_user_id")
  1427. order, _ := service.GetHisOrderByIDTwo(order_id)
  1428. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1429. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1430. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1431. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1432. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1433. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1434. if order.ID == 0 {
  1435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1436. return
  1437. }
  1438. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1439. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1440. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1441. fmt.Println(count)
  1442. var zero string
  1443. number := count + 1
  1444. if number >= 1000 {
  1445. zero = "0000" + strconv.FormatInt(number, 10)
  1446. } else if number >= 10000 {
  1447. zero = "000" + strconv.FormatInt(number, 10)
  1448. } else if number >= 100000 {
  1449. zero = "00" + strconv.FormatInt(number, 10)
  1450. } else if number >= 1000000 {
  1451. zero = "0" + strconv.FormatInt(number, 10)
  1452. } else {
  1453. zero = strconv.FormatInt(number, 10)
  1454. }
  1455. fmt.Println(zero)
  1456. struct4101 := service.Struct4101{
  1457. PsnNo: order.PsnNo,
  1458. MdtrtId: order.MdtrtId,
  1459. SetlId: order.SetlId,
  1460. PsnName: order.PsnName,
  1461. Gend: order.Gend,
  1462. Brdy: his.Brdy,
  1463. Age: his.Age,
  1464. Naty: order.Naty,
  1465. PatnCertType: "01",
  1466. Certno: order.Certno,
  1467. Prfs: "90",
  1468. ConerName: roles[0].UserName,
  1469. PatnRlts: "99",
  1470. ConerAddr: miConfig.OrgName,
  1471. ConerTel: admin.Mobile,
  1472. HiType: order.Insutype,
  1473. Insuplc: miConfig.InsuplcAdmdvs,
  1474. MaindiagFlag: "1",
  1475. BillCode: last_order.FaPiaoCode,
  1476. BillNo: zero,
  1477. BizSn: order.Number,
  1478. PsnSelfPay: order.PsnPartAmt,
  1479. PsnOwnPay: order.PsnPartAmt,
  1480. AcctPay: order.AcctPay,
  1481. PsnCashpay: order.PsnCashPay,
  1482. HiPaymtd: "1",
  1483. Hsorg: miConfig.InsuplcAdmdvs,
  1484. HsorgOpter: miConfig.InsuplcAdmdvs,
  1485. MedinsFillPsn: curRoles.UserName,
  1486. MedinsFillDept: depart.Name,
  1487. IptMedType: "2",
  1488. }
  1489. struct4101.SetlBegnDate = order.SetlTime
  1490. struct4101.SetlEndDate = order.SetlTime
  1491. time_arr := strings.Split(order.SetlTime, " ")
  1492. struct4101.AdmTime = time_arr[0]
  1493. struct4101.AdmEndTime = time_arr[0]
  1494. var rf []CustomFundPay
  1495. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1496. var tempFunPays []service.CustomStruct
  1497. for _, item := range rf {
  1498. var tempFunPay service.CustomStruct
  1499. tempFunPay.FundPayamt = item.FundPayamt
  1500. tempFunPay.FundPayType = item.FundPayType
  1501. tempFunPays = append(tempFunPays, tempFunPay)
  1502. }
  1503. struct4101.CustomStruct = tempFunPays
  1504. var tempDiaginfos []service.DiaginfoStructTwo
  1505. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1506. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1507. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  1508. var config []*models.HisXtDiagnoseConfig
  1509. for _, item := range diagnosis_ids {
  1510. id, _ := strconv.ParseInt(item, 10, 64)
  1511. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1512. config = append(config, &diagnosisConfig)
  1513. }
  1514. for index, item := range config {
  1515. if index == 0 {
  1516. var tempDiaginfo service.DiaginfoStructTwo
  1517. tempDiaginfo.DiagCode = item.CountryCode
  1518. tempDiaginfo.DiagName = item.CountryContentName
  1519. tempDiaginfo.DiagType = "1"
  1520. tempDiaginfo.MaindiagFlag = "1"
  1521. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1522. } else {
  1523. var tempDiaginfo service.DiaginfoStructTwo
  1524. tempDiaginfo.DiagCode = item.CountryCode
  1525. tempDiaginfo.DiagName = item.CountryContentName
  1526. tempDiaginfo.DiagType = "2"
  1527. tempDiaginfo.MaindiagFlag = "0"
  1528. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1529. }
  1530. }
  1531. struct4101.Diseinfo = tempDiaginfos
  1532. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1533. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1534. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1535. tempOpspdiseinfo2.OprnOprtCode = ""
  1536. tempOpspdiseinfo2.OprnOprtName = ""
  1537. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1538. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1539. var iteminfo service.IteminfoStruct
  1540. var bedCostTotal float64 = 0 //床位总费
  1541. var bedCostSelfTotal float64 = 0 //床位自费
  1542. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1543. var operationCostTotal float64 = 0 //手术费
  1544. var operationCostSelfTotal float64 = 0 //手术费
  1545. var operationCostPartSelfTotal float64 = 0 //手术费
  1546. var otherCostTotal float64 = 0 //其他费用
  1547. var otherCostSelfTotal float64 = 0 //其他费用
  1548. var otherCostPartSelfTotal float64 = 0 //其他费用
  1549. var materialCostTotal float64 = 0 //材料费
  1550. var materialCostSelfTotal float64 = 0 //材料费
  1551. var materialCostPartSelfTotal float64 = 0 //材料费
  1552. var westernMedicineCostTotal float64 = 0 //西药费
  1553. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1554. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1555. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1556. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1557. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1558. var checkCostTotal float64 = 0 //检查费
  1559. var checkCostSelfTotal float64 = 0 //检查费
  1560. var checkCostPartSelfTotal float64 = 0 //检查费
  1561. var laboratoryCostTotal float64 = 0 //化验费
  1562. var laboratoryCostSelfTotal float64 = 0 //化验费
  1563. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1564. var treatCostTotal float64 = 0 //治疗费用
  1565. var treatCostSelfTotal float64 = 0 //治疗费用
  1566. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1567. decimal.DivisionPrecision = 2
  1568. var bed_fulamt_ownpay_amt float64 = 0
  1569. var operation_fulamt_ownpay_amt float64 = 0
  1570. var other_fulamt_ownpay_amt float64 = 0
  1571. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1572. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1573. var check_fulamt_ownpay_amt float64 = 0
  1574. var material_fulamt_ownpay_amt float64 = 0
  1575. var laboratory_fulamt_ownpay_amt float64 = 0
  1576. var treat_fulamt_ownpay_amt float64 = 0
  1577. var bed_claa_sunmfee float64 = 0
  1578. var bed_clab_amt float64 = 0
  1579. var bed_other_amt float64 = 0
  1580. var operation_claa_sunmfee float64 = 0
  1581. var operation_clab_amt float64 = 0
  1582. var operation_other_amt float64 = 0
  1583. var other_claa_sunmfee float64 = 0
  1584. var other_clab_amt float64 = 0
  1585. var other_other_amt float64 = 0
  1586. var westernMedicine_claa_sunmfee float64 = 0
  1587. var westernMedicine_clab_amt float64 = 0
  1588. var westernMedicine_other_amt float64 = 0
  1589. var chineseTraditional_claa_sunmfee float64 = 0
  1590. var chineseTraditional_clab_amt float64 = 0
  1591. var chineseTraditional_other_amt float64 = 0
  1592. var check_claa_sunmfee float64 = 0
  1593. var check_clab_amt float64 = 0
  1594. var check_other_amt float64 = 0
  1595. var material_claa_sunmfee float64 = 0
  1596. var material_clab_amt float64 = 0
  1597. var material_other_amt float64 = 0
  1598. var laboratory_claa_sunmfee float64 = 0
  1599. var laboratory_clab_amt float64 = 0
  1600. var laboratory_other_amt float64 = 0
  1601. var treat_claa_sunmfee float64 = 0
  1602. var treat_clab_amt float64 = 0
  1603. var treat_other_amt float64 = 0
  1604. for _, item := range order.HisOrderInfo {
  1605. if item.MedChrgitmType == "01" { //床位费
  1606. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1607. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1608. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1609. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1610. if item.ChrgitmLv == "1" {
  1611. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1612. }
  1613. if item.ChrgitmLv == "2" {
  1614. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1615. }
  1616. if item.ChrgitmLv == "3" {
  1617. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1618. }
  1619. }
  1620. if item.MedChrgitmType == "03" { //检查费
  1621. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1622. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1623. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1624. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1625. if item.ChrgitmLv == "1" {
  1626. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1627. }
  1628. if item.ChrgitmLv == "2" {
  1629. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1630. }
  1631. if item.ChrgitmLv == "3" {
  1632. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1633. }
  1634. }
  1635. if item.MedChrgitmType == "04" { //化验费
  1636. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1637. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1638. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1639. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1640. if item.ChrgitmLv == "1" {
  1641. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1642. }
  1643. if item.ChrgitmLv == "2" {
  1644. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1645. }
  1646. if item.ChrgitmLv == "3" {
  1647. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1648. }
  1649. }
  1650. if item.MedChrgitmType == "05" { //治疗费
  1651. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1652. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1653. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1654. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1655. if item.ChrgitmLv == "1" {
  1656. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1657. }
  1658. if item.ChrgitmLv == "2" {
  1659. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1660. }
  1661. if item.ChrgitmLv == "3" {
  1662. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1663. }
  1664. }
  1665. if item.MedChrgitmType == "06" { //手术费
  1666. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1667. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1668. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1669. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1670. if item.ChrgitmLv == "1" {
  1671. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1672. }
  1673. if item.ChrgitmLv == "2" {
  1674. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1675. }
  1676. if item.ChrgitmLv == "3" {
  1677. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1678. }
  1679. }
  1680. if item.MedChrgitmType == "08" { //材料费
  1681. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1682. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1683. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1684. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1685. if item.ChrgitmLv == "1" {
  1686. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1687. }
  1688. if item.ChrgitmLv == "2" {
  1689. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1690. }
  1691. if item.ChrgitmLv == "3" {
  1692. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1693. }
  1694. }
  1695. if item.MedChrgitmType == "09" { //西药费
  1696. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1697. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1698. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1699. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1700. if item.ChrgitmLv == "1" {
  1701. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1702. }
  1703. if item.ChrgitmLv == "2" {
  1704. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1705. }
  1706. if item.ChrgitmLv == "3" {
  1707. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1708. }
  1709. }
  1710. if item.MedChrgitmType == "11" { //中成费
  1711. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1712. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1713. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1714. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1715. if item.ChrgitmLv == "1" {
  1716. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1717. }
  1718. if item.ChrgitmLv == "2" {
  1719. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1720. }
  1721. if item.ChrgitmLv == "3" {
  1722. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1723. }
  1724. }
  1725. if item.MedChrgitmType == "14" { //其他费
  1726. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1727. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1728. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1729. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1730. if item.ChrgitmLv == "1" {
  1731. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1732. }
  1733. if item.ChrgitmLv == "2" {
  1734. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1735. }
  1736. if item.ChrgitmLv == "3" {
  1737. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1738. }
  1739. }
  1740. }
  1741. var iteminfoStructs []service.IteminfoStruct
  1742. if bedCostTotal != 0 {
  1743. iteminfo.MedChrgitm = "01"
  1744. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1745. iteminfo.Amt = bedCostTotal
  1746. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1747. iteminfo.ClabAmt = bed_clab_amt
  1748. iteminfo.OthAmt = bed_other_amt
  1749. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1750. }
  1751. if checkCostTotal != 0 {
  1752. iteminfo.MedChrgitm = "03"
  1753. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1754. iteminfo.Amt = checkCostTotal
  1755. iteminfo.ClaaSumfee = check_claa_sunmfee
  1756. iteminfo.ClabAmt = check_clab_amt
  1757. iteminfo.OthAmt = check_other_amt
  1758. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1759. }
  1760. if laboratoryCostTotal != 0 {
  1761. iteminfo.MedChrgitm = "04"
  1762. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1763. iteminfo.Amt = laboratoryCostTotal
  1764. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1765. iteminfo.ClabAmt = laboratory_clab_amt
  1766. iteminfo.OthAmt = laboratory_other_amt
  1767. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1768. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1769. }
  1770. if treatCostTotal != 0 {
  1771. iteminfo.MedChrgitm = "05"
  1772. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1773. iteminfo.Amt = treatCostTotal
  1774. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1775. iteminfo.ClabAmt = treat_clab_amt
  1776. iteminfo.OthAmt = treat_other_amt
  1777. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1778. //(struct4101.IteminfoStruct, iteminfo)
  1779. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1780. }
  1781. if operationCostTotal != 0 {
  1782. iteminfo.MedChrgitm = "06"
  1783. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1784. iteminfo.Amt = operationCostTotal
  1785. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1786. iteminfo.ClabAmt = operation_clab_amt
  1787. iteminfo.OthAmt = operation_other_amt
  1788. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1789. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1790. }
  1791. if materialCostTotal != 0 {
  1792. iteminfo.MedChrgitm = "08"
  1793. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1794. iteminfo.Amt = materialCostTotal
  1795. iteminfo.ClaaSumfee = material_claa_sunmfee
  1796. iteminfo.ClabAmt = material_clab_amt
  1797. iteminfo.OthAmt = material_other_amt
  1798. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1799. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1800. }
  1801. if westernMedicineCostTotal != 0 {
  1802. iteminfo.MedChrgitm = "09"
  1803. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1804. iteminfo.Amt = westernMedicineCostTotal
  1805. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1806. iteminfo.ClabAmt = westernMedicine_clab_amt
  1807. iteminfo.OthAmt = westernMedicine_other_amt
  1808. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1809. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1810. }
  1811. if chineseTraditionalMedicineCostTotal != 0 {
  1812. iteminfo.MedChrgitm = "11"
  1813. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1814. iteminfo.Amt = westernMedicineCostTotal
  1815. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1816. iteminfo.ClabAmt = westernMedicine_clab_amt
  1817. iteminfo.OthAmt = westernMedicine_other_amt
  1818. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1819. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1820. }
  1821. if otherCostTotal != 0 {
  1822. iteminfo.MedChrgitm = "14"
  1823. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1824. iteminfo.Amt = otherCostTotal
  1825. iteminfo.ClaaSumfee = other_claa_sunmfee
  1826. iteminfo.ClabAmt = other_clab_amt
  1827. iteminfo.OthAmt = other_other_amt
  1828. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1829. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1830. }
  1831. struct4101.IteminfoStruct = iteminfoStructs
  1832. struct4101.Ntly = "中国"
  1833. struct4101.AdmCaty = "A03.06"
  1834. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  1835. fmt.Println(result)
  1836. var dat map[string]interface{}
  1837. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1838. fmt.Println(dat)
  1839. } else {
  1840. fmt.Println(err)
  1841. }
  1842. userJSONBytes, _ := json.Marshal(dat)
  1843. var res ResultSeventeen
  1844. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1845. utils.ErrorLog("解析失败:%v", err)
  1846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1847. return
  1848. }
  1849. if res.Infcode != 0 {
  1850. c.ServeSuccessJSON(map[string]interface{}{
  1851. "failed_code": -10,
  1852. "msg": res.ErrMsg,
  1853. })
  1854. return
  1855. } else {
  1856. order.FaPiaoNumber = zero
  1857. order.FaPiaoCode = last_order.FaPiaoCode
  1858. service.UpdateOrder(order)
  1859. hisFundSettleListResult := &models.HisFundSettleListResult{
  1860. Number: res.Output.SetlListId,
  1861. Status: 1,
  1862. Ctime: time.Now().Unix(),
  1863. Mtime: time.Now().Unix(),
  1864. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1865. IsUpload: 1,
  1866. OrderId: order_id,
  1867. }
  1868. service.CreateUploadRecord(hisFundSettleListResult)
  1869. c.ServeSuccessJSON(map[string]interface{}{
  1870. "msg": "上传成功",
  1871. "result": hisFundSettleListResult,
  1872. })
  1873. return
  1874. }
  1875. }
  1876. func (c *HisApiController) GetSettleListHospital() {
  1877. order_id, _ := c.GetInt64("order_id")
  1878. admin_user_id, _ := c.GetInt64("admin_user_id")
  1879. order, _ := service.GetHisOrderByIDTwo(order_id)
  1880. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1881. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1882. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1883. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1884. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1885. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1886. if order.ID == 0 {
  1887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1888. return
  1889. }
  1890. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1891. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1892. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1893. fmt.Println(count)
  1894. var zero string
  1895. number := count + 1
  1896. if number >= 1000 {
  1897. zero = "0000" + strconv.FormatInt(number, 10)
  1898. } else if number >= 10000 {
  1899. zero = "000" + strconv.FormatInt(number, 10)
  1900. } else if number >= 100000 {
  1901. zero = "00" + strconv.FormatInt(number, 10)
  1902. } else if number >= 1000000 {
  1903. zero = "0" + strconv.FormatInt(number, 10)
  1904. } else {
  1905. zero = strconv.FormatInt(number, 10)
  1906. }
  1907. fmt.Println(zero)
  1908. struct4101 := service.Struct4101{
  1909. PsnNo: order.PsnNo,
  1910. MdtrtId: order.MdtrtId,
  1911. SetlId: order.SetlId,
  1912. PsnName: order.PsnName,
  1913. Gend: order.Gend,
  1914. Brdy: his.Brdy,
  1915. Age: int64(order.Age),
  1916. Naty: order.Naty,
  1917. PatnCertType: "01",
  1918. Certno: order.Certno,
  1919. Prfs: "90",
  1920. ConerName: roles[0].UserName,
  1921. PatnRlts: "99",
  1922. ConerAddr: miConfig.OrgName,
  1923. ConerTel: admin.Mobile,
  1924. HiType: order.Insutype,
  1925. Insuplc: miConfig.InsuplcAdmdvs,
  1926. MaindiagFlag: "1",
  1927. BillCode: last_order.FaPiaoCode,
  1928. BillNo: zero,
  1929. BizSn: order.Number,
  1930. PsnSelfPay: order.PsnPartAmt,
  1931. PsnOwnPay: order.PsnPartAmt,
  1932. AcctPay: order.AcctPay,
  1933. PsnCashpay: order.PsnCashPay,
  1934. HiPaymtd: "1",
  1935. Hsorg: miConfig.InsuplcAdmdvs,
  1936. HsorgOpter: miConfig.InsuplcAdmdvs,
  1937. MedinsFillPsn: curRoles.UserName,
  1938. MedinsFillDept: depart.Name,
  1939. IptMedType: "2",
  1940. AdmTime: his.InHosptialTime,
  1941. AdmEndTime: his.OutHosptialTime,
  1942. }
  1943. struct4101.SetlBegnDate = order.SetlTime
  1944. struct4101.SetlEndDate = order.SetlTime
  1945. var rf []CustomFundPay
  1946. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1947. var tempFunPays []service.CustomStruct
  1948. for _, item := range rf {
  1949. var tempFunPay service.CustomStruct
  1950. tempFunPay.FundPayamt = item.FundPayamt
  1951. tempFunPay.FundPayType = item.FundPayType
  1952. tempFunPays = append(tempFunPays, tempFunPay)
  1953. }
  1954. struct4101.CustomStruct = tempFunPays
  1955. var tempDiaginfos []service.DiaginfoStructTwo
  1956. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1957. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1958. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1959. var config []*models.HisXtDiagnoseConfig
  1960. for _, item := range diagnosis_ids {
  1961. id, _ := strconv.ParseInt(item, 10, 64)
  1962. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1963. config = append(config, &diagnosisConfig)
  1964. }
  1965. for index, item := range config {
  1966. if index == 0 {
  1967. var tempDiaginfo service.DiaginfoStructTwo
  1968. tempDiaginfo.DiagCode = item.CountryCode
  1969. tempDiaginfo.DiagName = item.CountryContentName
  1970. tempDiaginfo.DiagType = "1"
  1971. tempDiaginfo.MaindiagFlag = "1"
  1972. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1973. } else {
  1974. var tempDiaginfo service.DiaginfoStructTwo
  1975. tempDiaginfo.DiagCode = item.CountryCode
  1976. tempDiaginfo.DiagName = item.CountryContentName
  1977. tempDiaginfo.DiagType = "2"
  1978. tempDiaginfo.MaindiagFlag = "0"
  1979. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1980. }
  1981. }
  1982. struct4101.Diseinfo = tempDiaginfos
  1983. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1984. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1985. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1986. tempOpspdiseinfo2.OprnOprtCode = ""
  1987. tempOpspdiseinfo2.OprnOprtName = ""
  1988. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1989. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1990. var iteminfo service.IteminfoStruct
  1991. var bedCostTotal float64 = 0 //床位总费
  1992. var bedCostSelfTotal float64 = 0 //床位自费
  1993. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1994. var operationCostTotal float64 = 0 //手术费
  1995. var operationCostSelfTotal float64 = 0 //手术费
  1996. var operationCostPartSelfTotal float64 = 0 //手术费
  1997. var otherCostTotal float64 = 0 //其他费用
  1998. var otherCostSelfTotal float64 = 0 //其他费用
  1999. var otherCostPartSelfTotal float64 = 0 //其他费用
  2000. var materialCostTotal float64 = 0 //材料费
  2001. var materialCostSelfTotal float64 = 0 //材料费
  2002. var materialCostPartSelfTotal float64 = 0 //材料费
  2003. var westernMedicineCostTotal float64 = 0 //西药费
  2004. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2005. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2006. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2007. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2008. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2009. var checkCostTotal float64 = 0 //检查费
  2010. var checkCostSelfTotal float64 = 0 //检查费
  2011. var checkCostPartSelfTotal float64 = 0 //检查费
  2012. var laboratoryCostTotal float64 = 0 //化验费
  2013. var laboratoryCostSelfTotal float64 = 0 //化验费
  2014. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2015. var treatCostTotal float64 = 0 //治疗费用
  2016. var treatCostSelfTotal float64 = 0 //治疗费用
  2017. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2018. decimal.DivisionPrecision = 2
  2019. var bed_fulamt_ownpay_amt float64 = 0
  2020. var operation_fulamt_ownpay_amt float64 = 0
  2021. var other_fulamt_ownpay_amt float64 = 0
  2022. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2023. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2024. var check_fulamt_ownpay_amt float64 = 0
  2025. var material_fulamt_ownpay_amt float64 = 0
  2026. var laboratory_fulamt_ownpay_amt float64 = 0
  2027. var treat_fulamt_ownpay_amt float64 = 0
  2028. var bed_claa_sunmfee float64 = 0
  2029. var bed_clab_amt float64 = 0
  2030. var bed_other_amt float64 = 0
  2031. var operation_claa_sunmfee float64 = 0
  2032. var operation_clab_amt float64 = 0
  2033. var operation_other_amt float64 = 0
  2034. var other_claa_sunmfee float64 = 0
  2035. var other_clab_amt float64 = 0
  2036. var other_other_amt float64 = 0
  2037. var westernMedicine_claa_sunmfee float64 = 0
  2038. var westernMedicine_clab_amt float64 = 0
  2039. var westernMedicine_other_amt float64 = 0
  2040. var chineseTraditional_claa_sunmfee float64 = 0
  2041. var chineseTraditional_clab_amt float64 = 0
  2042. var chineseTraditional_other_amt float64 = 0
  2043. var check_claa_sunmfee float64 = 0
  2044. var check_clab_amt float64 = 0
  2045. var check_other_amt float64 = 0
  2046. var material_claa_sunmfee float64 = 0
  2047. var material_clab_amt float64 = 0
  2048. var material_other_amt float64 = 0
  2049. var laboratory_claa_sunmfee float64 = 0
  2050. var laboratory_clab_amt float64 = 0
  2051. var laboratory_other_amt float64 = 0
  2052. var treat_claa_sunmfee float64 = 0
  2053. var treat_clab_amt float64 = 0
  2054. var treat_other_amt float64 = 0
  2055. for _, item := range order.HisOrderInfo {
  2056. if item.MedChrgitmType == "01" { //床位费
  2057. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2058. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2059. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2060. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2061. if item.ChrgitmLv == "1" {
  2062. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2063. }
  2064. if item.ChrgitmLv == "2" {
  2065. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2066. }
  2067. if item.ChrgitmLv == "3" {
  2068. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2069. }
  2070. }
  2071. if item.MedChrgitmType == "03" { //检查费
  2072. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2073. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2074. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2075. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2076. if item.ChrgitmLv == "1" {
  2077. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2078. }
  2079. if item.ChrgitmLv == "2" {
  2080. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2081. }
  2082. if item.ChrgitmLv == "3" {
  2083. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2084. }
  2085. }
  2086. if item.MedChrgitmType == "04" { //化验费
  2087. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2088. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2089. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2090. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2091. if item.ChrgitmLv == "1" {
  2092. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2093. }
  2094. if item.ChrgitmLv == "2" {
  2095. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2096. }
  2097. if item.ChrgitmLv == "3" {
  2098. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2099. }
  2100. }
  2101. if item.MedChrgitmType == "05" { //治疗费
  2102. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2103. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2104. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2105. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2106. if item.ChrgitmLv == "1" {
  2107. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2108. }
  2109. if item.ChrgitmLv == "2" {
  2110. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2111. }
  2112. if item.ChrgitmLv == "3" {
  2113. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2114. }
  2115. }
  2116. if item.MedChrgitmType == "06" { //手术费
  2117. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2118. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2119. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2120. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2121. if item.ChrgitmLv == "1" {
  2122. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2123. }
  2124. if item.ChrgitmLv == "2" {
  2125. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2126. }
  2127. if item.ChrgitmLv == "3" {
  2128. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2129. }
  2130. }
  2131. if item.MedChrgitmType == "08" { //材料费
  2132. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2133. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2134. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2135. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2136. if item.ChrgitmLv == "1" {
  2137. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2138. }
  2139. if item.ChrgitmLv == "2" {
  2140. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2141. }
  2142. if item.ChrgitmLv == "3" {
  2143. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2144. }
  2145. }
  2146. if item.MedChrgitmType == "09" { //西药费
  2147. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2148. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2149. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2150. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2151. if item.ChrgitmLv == "1" {
  2152. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2153. }
  2154. if item.ChrgitmLv == "2" {
  2155. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2156. }
  2157. if item.ChrgitmLv == "3" {
  2158. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2159. }
  2160. }
  2161. if item.MedChrgitmType == "11" { //中成费
  2162. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2163. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2164. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2165. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2166. if item.ChrgitmLv == "1" {
  2167. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2168. }
  2169. if item.ChrgitmLv == "2" {
  2170. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2171. }
  2172. if item.ChrgitmLv == "3" {
  2173. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2174. }
  2175. }
  2176. if item.MedChrgitmType == "14" { //其他费
  2177. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2178. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2179. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2180. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2181. if item.ChrgitmLv == "1" {
  2182. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2183. }
  2184. if item.ChrgitmLv == "2" {
  2185. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2186. }
  2187. if item.ChrgitmLv == "3" {
  2188. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2189. }
  2190. }
  2191. }
  2192. var iteminfoStructs []service.IteminfoStruct
  2193. if bedCostTotal != 0 {
  2194. iteminfo.MedChrgitm = "01"
  2195. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2196. iteminfo.Amt = bedCostTotal
  2197. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2198. iteminfo.ClabAmt = bed_clab_amt
  2199. iteminfo.OthAmt = bed_other_amt
  2200. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2201. }
  2202. if checkCostTotal != 0 {
  2203. iteminfo.MedChrgitm = "03"
  2204. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2205. iteminfo.Amt = checkCostTotal
  2206. iteminfo.ClaaSumfee = check_claa_sunmfee
  2207. iteminfo.ClabAmt = check_clab_amt
  2208. iteminfo.OthAmt = check_other_amt
  2209. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2210. }
  2211. if laboratoryCostTotal != 0 {
  2212. iteminfo.MedChrgitm = "04"
  2213. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2214. iteminfo.Amt = laboratoryCostTotal
  2215. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2216. iteminfo.ClabAmt = laboratory_clab_amt
  2217. iteminfo.OthAmt = laboratory_other_amt
  2218. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2219. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2220. }
  2221. if treatCostTotal != 0 {
  2222. iteminfo.MedChrgitm = "05"
  2223. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2224. iteminfo.Amt = treatCostTotal
  2225. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2226. iteminfo.ClabAmt = treat_clab_amt
  2227. iteminfo.OthAmt = treat_other_amt
  2228. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2229. //(struct4101.IteminfoStruct, iteminfo)
  2230. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2231. }
  2232. if operationCostTotal != 0 {
  2233. iteminfo.MedChrgitm = "06"
  2234. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2235. iteminfo.Amt = operationCostTotal
  2236. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2237. iteminfo.ClabAmt = operation_clab_amt
  2238. iteminfo.OthAmt = operation_other_amt
  2239. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2240. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2241. }
  2242. if materialCostTotal != 0 {
  2243. iteminfo.MedChrgitm = "08"
  2244. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2245. iteminfo.Amt = materialCostTotal
  2246. iteminfo.ClaaSumfee = material_claa_sunmfee
  2247. iteminfo.ClabAmt = material_clab_amt
  2248. iteminfo.OthAmt = material_other_amt
  2249. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2250. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2251. }
  2252. if westernMedicineCostTotal != 0 {
  2253. iteminfo.MedChrgitm = "09"
  2254. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2255. iteminfo.Amt = westernMedicineCostTotal
  2256. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2257. iteminfo.ClabAmt = westernMedicine_clab_amt
  2258. iteminfo.OthAmt = westernMedicine_other_amt
  2259. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2260. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2261. }
  2262. if chineseTraditionalMedicineCostTotal != 0 {
  2263. iteminfo.MedChrgitm = "11"
  2264. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2265. iteminfo.Amt = westernMedicineCostTotal
  2266. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2267. iteminfo.ClabAmt = westernMedicine_clab_amt
  2268. iteminfo.OthAmt = westernMedicine_other_amt
  2269. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2270. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2271. }
  2272. if otherCostTotal != 0 {
  2273. iteminfo.MedChrgitm = "14"
  2274. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2275. iteminfo.Amt = otherCostTotal
  2276. iteminfo.ClaaSumfee = other_claa_sunmfee
  2277. iteminfo.ClabAmt = other_clab_amt
  2278. iteminfo.OthAmt = other_other_amt
  2279. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2280. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2281. }
  2282. struct4101.IteminfoStruct = iteminfoStructs
  2283. struct4101.Ntly = "中国"
  2284. struct4101.AdmCaty = "A03.06"
  2285. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2286. fmt.Println(result)
  2287. var dat map[string]interface{}
  2288. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2289. fmt.Println(dat)
  2290. } else {
  2291. fmt.Println(err)
  2292. }
  2293. userJSONBytes, _ := json.Marshal(dat)
  2294. var res ResultSeventeen
  2295. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2296. utils.ErrorLog("解析失败:%v", err)
  2297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2298. return
  2299. }
  2300. if res.Infcode != 0 {
  2301. c.ServeSuccessJSON(map[string]interface{}{
  2302. "failed_code": -10,
  2303. "msg": res.ErrMsg,
  2304. })
  2305. return
  2306. } else {
  2307. order.FaPiaoNumber = zero
  2308. order.FaPiaoCode = last_order.FaPiaoCode
  2309. service.UpdateOrder(order)
  2310. hisFundSettleListResult := &models.HisFundSettleListResult{
  2311. Number: res.Output.SetlListId,
  2312. Status: 1,
  2313. Ctime: time.Now().Unix(),
  2314. Mtime: time.Now().Unix(),
  2315. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2316. IsUpload: 1,
  2317. OrderId: order_id,
  2318. }
  2319. service.CreateUploadRecord(hisFundSettleListResult)
  2320. c.ServeSuccessJSON(map[string]interface{}{
  2321. "msg": "上传成功",
  2322. "result": hisFundSettleListResult,
  2323. })
  2324. return
  2325. }
  2326. }
  2327. func (c *HisApiController) GetBatchSettleList() {
  2328. orders, _ := service.GetAllHisOrder(10106)
  2329. for _, item := range orders {
  2330. order_id := item.ID
  2331. order, _ := service.GetHisOrderByIDTwo(order_id)
  2332. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2333. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2334. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2335. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  2336. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2337. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2338. if order.ID == 0 {
  2339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2340. return
  2341. }
  2342. if his.BalanceAccountsType == 2 {
  2343. continue
  2344. }
  2345. struct4101 := service.Struct4101{
  2346. PsnNo: order.PsnNo,
  2347. MdtrtId: order.MdtrtId,
  2348. SetlId: order.SetlId,
  2349. PsnName: order.PsnName,
  2350. Gend: order.Gend,
  2351. Brdy: his.Brdy,
  2352. Age: his.Age,
  2353. Naty: order.Naty,
  2354. PatnCertType: "01",
  2355. Certno: order.Certno,
  2356. Prfs: "90",
  2357. ConerName: roles[0].UserName,
  2358. PatnRlts: "99",
  2359. ConerAddr: miConfig.OrgName,
  2360. ConerTel: admin.Mobile,
  2361. HiType: order.Insutype,
  2362. Insuplc: his.InsuplcAdmdvs,
  2363. MaindiagFlag: "1",
  2364. BillCode: order.FaPiaoCode,
  2365. BillNo: order.FaPiaoNumber,
  2366. BizSn: order.Number,
  2367. PsnSelfPay: order.PsnPartAmt,
  2368. PsnOwnPay: order.PsnPartAmt,
  2369. AcctPay: order.AcctPay,
  2370. PsnCashpay: order.PsnCashPay,
  2371. HiPaymtd: "1",
  2372. Hsorg: his.InsuplcAdmdvs,
  2373. HsorgOpter: his.InsuplcAdmdvs,
  2374. MedinsFillPsn: curRoles.UserName,
  2375. MedinsFillDept: depart.Name,
  2376. IptMedType: "2",
  2377. }
  2378. struct4101.SetlBegnDate = order.SetlTime
  2379. struct4101.SetlEndDate = order.SetlTime
  2380. //if order.SettleType == 1 {
  2381. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  2382. // dateStr := t.Format("2006-01-02")
  2383. // struct4101.SetlBegnDate = dateStr
  2384. // struct4101.SetlEndDate = dateStr
  2385. //} else {
  2386. // t := time.Unix(int64(order.SettleStartTime), 0)
  2387. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  2388. // dateStartStr := t.Format("2006-01-02")
  2389. // dateEndStr := t2.Format("2006-01-02")
  2390. // struct4101.SetlBegnDate = dateStartStr
  2391. // struct4101.SetlEndDate = dateEndStr
  2392. //}
  2393. var rf []CustomFundPay
  2394. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2395. var tempFunPays []service.CustomStruct
  2396. var tempFunPay610100 service.CustomStruct
  2397. for _, item := range rf {
  2398. if item.FundPayType == "610100" {
  2399. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  2400. tempFunPay610100.FundPayType = item.FundPayType
  2401. } else {
  2402. var tempFunPay service.CustomStruct
  2403. tempFunPay.FundPayamt = item.FundPayamt
  2404. tempFunPay.FundPayType = item.FundPayType
  2405. tempFunPays = append(tempFunPays, tempFunPay)
  2406. }
  2407. }
  2408. tempFunPays = append(tempFunPays, tempFunPay610100)
  2409. struct4101.CustomStruct = tempFunPays
  2410. var tempDiaginfos []service.DiaginfoStructTwo
  2411. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2412. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2413. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2414. var config []*models.HisXtDiagnoseConfig
  2415. for _, item := range diagnosis_ids {
  2416. id, _ := strconv.ParseInt(item, 10, 64)
  2417. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2418. config = append(config, &diagnosisConfig)
  2419. }
  2420. for index, item := range config {
  2421. if index == 0 {
  2422. var tempDiaginfo service.DiaginfoStructTwo
  2423. tempDiaginfo.DiagCode = item.CountryCode
  2424. tempDiaginfo.DiagName = item.CountryContentName
  2425. tempDiaginfo.DiagType = "1"
  2426. tempDiaginfo.MaindiagFlag = "1"
  2427. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2428. } else {
  2429. var tempDiaginfo service.DiaginfoStructTwo
  2430. tempDiaginfo.DiagCode = item.CountryCode
  2431. tempDiaginfo.DiagName = item.CountryContentName
  2432. tempDiaginfo.DiagType = "2"
  2433. tempDiaginfo.MaindiagFlag = "0"
  2434. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2435. }
  2436. }
  2437. struct4101.Diseinfo = tempDiaginfos
  2438. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2439. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2440. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2441. tempOpspdiseinfo2.OprnOprtCode = ""
  2442. tempOpspdiseinfo2.OprnOprtName = ""
  2443. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2444. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2445. var iteminfo service.IteminfoStruct
  2446. var bedCostTotal float64 = 0 //床位总费
  2447. var bedCostSelfTotal float64 = 0 //床位自费
  2448. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2449. var examineCostTotal float64 = 0 //诊查总费
  2450. var examineCostSelfTotal float64 = 0 //诊查自费
  2451. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  2452. var nursingCostTotal float64 = 0 //护理总费
  2453. var nursingCostSelfTotal float64 = 0 //护理自费
  2454. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  2455. var chineseMedicineCostTotal float64 = 0 //中成药
  2456. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  2457. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  2458. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  2459. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  2460. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  2461. var registerCostTotal float64 = 0 //一般诊疗费
  2462. var registerCostSelfTotal float64 = 0 //一般诊疗费
  2463. var registerPartSelfTotal float64 = 0 //一般诊疗费
  2464. var operationCostTotal float64 = 0 //手术费
  2465. var operationCostSelfTotal float64 = 0 //手术费
  2466. var operationCostPartSelfTotal float64 = 0 //手术费
  2467. var otherCostTotal float64 = 0 //其他费用
  2468. var otherCostSelfTotal float64 = 0 //其他费用
  2469. var otherCostPartSelfTotal float64 = 0 //其他费用
  2470. var materialCostTotal float64 = 0 //材料费
  2471. var materialCostSelfTotal float64 = 0 //材料费
  2472. var materialCostPartSelfTotal float64 = 0 //材料费
  2473. var westernMedicineCostTotal float64 = 0 //西药费
  2474. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2475. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2476. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2477. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2478. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2479. var checkCostTotal float64 = 0 //检查费
  2480. var checkCostSelfTotal float64 = 0 //检查费
  2481. var checkCostPartSelfTotal float64 = 0 //检查费
  2482. var laboratoryCostTotal float64 = 0 //化验费
  2483. var laboratoryCostSelfTotal float64 = 0 //化验费
  2484. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2485. var treatCostTotal float64 = 0 //治疗费用
  2486. var treatCostSelfTotal float64 = 0 //治疗费用
  2487. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2488. decimal.DivisionPrecision = 2
  2489. var bed_fulamt_ownpay_amt float64 = 0
  2490. var examine_fulamt_ownpay_amt float64 = 0
  2491. var nursing_fulamt_ownpay_amt float64 = 0
  2492. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  2493. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  2494. var register_fulamt_ownpay_amt float64 = 0
  2495. var operation_fulamt_ownpay_amt float64 = 0
  2496. var other_fulamt_ownpay_amt float64 = 0
  2497. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2498. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2499. var check_fulamt_ownpay_amt float64 = 0
  2500. var material_fulamt_ownpay_amt float64 = 0
  2501. var laboratory_fulamt_ownpay_amt float64 = 0
  2502. var treat_fulamt_ownpay_amt float64 = 0
  2503. var bed_claa_sunmfee float64 = 0
  2504. var bed_clab_amt float64 = 0
  2505. var bed_other_amt float64 = 0
  2506. var examine_claa_sunmfee float64 = 0
  2507. var examine_clab_amt float64 = 0
  2508. var examine_other_amt float64 = 0
  2509. var nursing_claa_sunmfee float64 = 0
  2510. var nursing_clab_amt float64 = 0
  2511. var nursing_other_amt float64 = 0
  2512. var chinese_medicine_claa_sunmfee float64 = 0
  2513. var chinese_medicine_clab_amt float64 = 0
  2514. var chinese_medicine_other_amt float64 = 0
  2515. var commonly_treatment_claa_sunmfee float64 = 0
  2516. var commonly_treatment_clab_amt float64 = 0
  2517. var commonly_treatment_other_amt float64 = 0
  2518. var operation_claa_sunmfee float64 = 0
  2519. var operation_clab_amt float64 = 0
  2520. var operation_other_amt float64 = 0
  2521. var other_claa_sunmfee float64 = 0
  2522. var other_clab_amt float64 = 0
  2523. var other_other_amt float64 = 0
  2524. var westernMedicine_claa_sunmfee float64 = 0
  2525. var westernMedicine_clab_amt float64 = 0
  2526. var westernMedicine_other_amt float64 = 0
  2527. var chineseTraditional_claa_sunmfee float64 = 0
  2528. var chineseTraditional_clab_amt float64 = 0
  2529. var chineseTraditional_other_amt float64 = 0
  2530. var check_claa_sunmfee float64 = 0
  2531. var check_clab_amt float64 = 0
  2532. var check_other_amt float64 = 0
  2533. var material_claa_sunmfee float64 = 0
  2534. var material_clab_amt float64 = 0
  2535. var material_other_amt float64 = 0
  2536. var laboratory_claa_sunmfee float64 = 0
  2537. var laboratory_clab_amt float64 = 0
  2538. var laboratory_other_amt float64 = 0
  2539. var treat_claa_sunmfee float64 = 0
  2540. var treat_clab_amt float64 = 0
  2541. var treat_other_amt float64 = 0
  2542. var register_claa_sunmfee float64 = 0
  2543. var register_clab_amt float64 = 0
  2544. var register_other_amt float64 = 0
  2545. for _, item := range order.HisOrderInfo {
  2546. if item.MedChrgitmType == "01" { //床位费
  2547. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2548. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2549. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2550. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2551. if item.ChrgitmLv == "1" {
  2552. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2553. }
  2554. if item.ChrgitmLv == "2" {
  2555. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2556. }
  2557. if item.ChrgitmLv == "3" {
  2558. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2559. }
  2560. }
  2561. if item.MedChrgitmType == "02" { //诊查
  2562. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2563. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2564. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2565. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2566. if item.ChrgitmLv == "1" {
  2567. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2568. }
  2569. if item.ChrgitmLv == "2" {
  2570. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2571. }
  2572. if item.ChrgitmLv == "3" {
  2573. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2574. }
  2575. }
  2576. if item.MedChrgitmType == "03" { //检查费
  2577. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2578. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2579. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2580. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2581. if item.ChrgitmLv == "1" {
  2582. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2583. }
  2584. if item.ChrgitmLv == "2" {
  2585. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2586. }
  2587. if item.ChrgitmLv == "3" {
  2588. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2589. }
  2590. }
  2591. if item.MedChrgitmType == "04" { //化验费
  2592. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2593. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2594. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2595. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2596. if item.ChrgitmLv == "1" {
  2597. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2598. }
  2599. if item.ChrgitmLv == "2" {
  2600. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2601. }
  2602. if item.ChrgitmLv == "3" {
  2603. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2604. }
  2605. }
  2606. if item.MedChrgitmType == "05" { //治疗费
  2607. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2608. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2609. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2610. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2611. if item.ChrgitmLv == "1" {
  2612. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2613. }
  2614. if item.ChrgitmLv == "2" {
  2615. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2616. }
  2617. if item.ChrgitmLv == "3" {
  2618. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2619. }
  2620. }
  2621. if item.MedChrgitmType == "06" { //手术费
  2622. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2623. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2624. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2625. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2626. if item.ChrgitmLv == "1" {
  2627. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2628. }
  2629. if item.ChrgitmLv == "2" {
  2630. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2631. }
  2632. if item.ChrgitmLv == "3" {
  2633. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2634. }
  2635. }
  2636. if item.MedChrgitmType == "07" { //手术费
  2637. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2638. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2639. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2640. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2641. if item.ChrgitmLv == "1" {
  2642. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2643. }
  2644. if item.ChrgitmLv == "2" {
  2645. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2646. }
  2647. if item.ChrgitmLv == "3" {
  2648. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2649. }
  2650. }
  2651. if item.MedChrgitmType == "08" { //材料费
  2652. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2653. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2654. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2655. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2656. if item.ChrgitmLv == "1" {
  2657. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2658. }
  2659. if item.ChrgitmLv == "2" {
  2660. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2661. }
  2662. if item.ChrgitmLv == "3" {
  2663. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2664. }
  2665. }
  2666. if item.MedChrgitmType == "09" { //西药费
  2667. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2668. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2669. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2670. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2671. if item.ChrgitmLv == "1" {
  2672. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2673. }
  2674. if item.ChrgitmLv == "2" {
  2675. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2676. }
  2677. if item.ChrgitmLv == "3" {
  2678. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2679. }
  2680. }
  2681. if item.MedChrgitmType == "10" { //中药饮片
  2682. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2683. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2684. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2685. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2686. if item.ChrgitmLv == "1" {
  2687. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2688. }
  2689. if item.ChrgitmLv == "2" {
  2690. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2691. }
  2692. if item.ChrgitmLv == "3" {
  2693. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2694. }
  2695. }
  2696. if item.MedChrgitmType == "11" { //中成费
  2697. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2698. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2699. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2700. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2701. if item.ChrgitmLv == "1" {
  2702. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2703. }
  2704. if item.ChrgitmLv == "2" {
  2705. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2706. }
  2707. if item.ChrgitmLv == "3" {
  2708. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2709. }
  2710. }
  2711. if item.MedChrgitmType == "12" { //中成费
  2712. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2713. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2714. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2715. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2716. if item.ChrgitmLv == "1" {
  2717. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2718. }
  2719. if item.ChrgitmLv == "2" {
  2720. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2721. }
  2722. if item.ChrgitmLv == "3" {
  2723. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2724. }
  2725. }
  2726. if item.MedChrgitmType == "13" { //中成费
  2727. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2728. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2729. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2730. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2731. if item.ChrgitmLv == "1" {
  2732. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2733. }
  2734. if item.ChrgitmLv == "2" {
  2735. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2736. }
  2737. if item.ChrgitmLv == "3" {
  2738. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2739. }
  2740. }
  2741. if item.MedChrgitmType == "14" { //其他费
  2742. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2743. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2744. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2745. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2746. if item.ChrgitmLv == "1" {
  2747. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2748. }
  2749. if item.ChrgitmLv == "2" {
  2750. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2751. }
  2752. if item.ChrgitmLv == "3" {
  2753. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2754. }
  2755. }
  2756. }
  2757. var iteminfoStructs []service.IteminfoStruct
  2758. if bedCostTotal != 0 {
  2759. iteminfo.MedChrgitm = "01"
  2760. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2761. iteminfo.Amt = bedCostTotal
  2762. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2763. iteminfo.ClabAmt = bed_clab_amt
  2764. iteminfo.OthAmt = bed_other_amt
  2765. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2766. }
  2767. if examineCostTotal != 0 {
  2768. iteminfo.MedChrgitm = "02"
  2769. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  2770. iteminfo.Amt = examineCostTotal
  2771. iteminfo.ClaaSumfee = examine_claa_sunmfee
  2772. iteminfo.ClabAmt = examine_clab_amt
  2773. iteminfo.OthAmt = examine_other_amt
  2774. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2775. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2776. }
  2777. if checkCostTotal != 0 {
  2778. iteminfo.MedChrgitm = "03"
  2779. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2780. iteminfo.Amt = checkCostTotal
  2781. iteminfo.ClaaSumfee = check_claa_sunmfee
  2782. iteminfo.ClabAmt = check_clab_amt
  2783. iteminfo.OthAmt = check_other_amt
  2784. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2785. }
  2786. if laboratoryCostTotal != 0 {
  2787. iteminfo.MedChrgitm = "04"
  2788. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2789. iteminfo.Amt = laboratoryCostTotal
  2790. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2791. iteminfo.ClabAmt = laboratory_clab_amt
  2792. iteminfo.OthAmt = laboratory_other_amt
  2793. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2794. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2795. }
  2796. if treatCostTotal != 0 {
  2797. iteminfo.MedChrgitm = "05"
  2798. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2799. iteminfo.Amt = treatCostTotal
  2800. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2801. iteminfo.ClabAmt = treat_clab_amt
  2802. iteminfo.OthAmt = treat_other_amt
  2803. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2804. //(struct4101.IteminfoStruct, iteminfo)
  2805. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2806. }
  2807. if operationCostTotal != 0 {
  2808. iteminfo.MedChrgitm = "06"
  2809. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2810. iteminfo.Amt = operationCostTotal
  2811. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2812. iteminfo.ClabAmt = operation_clab_amt
  2813. iteminfo.OthAmt = operation_other_amt
  2814. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2815. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2816. }
  2817. if nursingCostTotal != 0 {
  2818. iteminfo.MedChrgitm = "07"
  2819. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  2820. iteminfo.Amt = nursingCostTotal
  2821. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  2822. iteminfo.ClabAmt = nursing_clab_amt
  2823. iteminfo.OthAmt = nursing_other_amt
  2824. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2825. }
  2826. if materialCostTotal != 0 {
  2827. iteminfo.MedChrgitm = "08"
  2828. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2829. iteminfo.Amt = materialCostTotal
  2830. iteminfo.ClaaSumfee = material_claa_sunmfee
  2831. iteminfo.ClabAmt = material_clab_amt
  2832. iteminfo.OthAmt = material_other_amt
  2833. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2834. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2835. }
  2836. if westernMedicineCostTotal != 0 {
  2837. iteminfo.MedChrgitm = "09"
  2838. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2839. iteminfo.Amt = westernMedicineCostTotal
  2840. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2841. iteminfo.ClabAmt = westernMedicine_clab_amt
  2842. iteminfo.OthAmt = westernMedicine_other_amt
  2843. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2844. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2845. }
  2846. if chineseMedicineCostTotal != 0 {
  2847. iteminfo.MedChrgitm = "10"
  2848. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  2849. iteminfo.Amt = chineseMedicineCostTotal
  2850. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  2851. iteminfo.ClabAmt = chinese_medicine_clab_amt
  2852. iteminfo.OthAmt = chinese_medicine_other_amt
  2853. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2854. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2855. }
  2856. if chineseTraditionalMedicineCostTotal != 0 {
  2857. iteminfo.MedChrgitm = "11"
  2858. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2859. iteminfo.Amt = westernMedicineCostTotal
  2860. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2861. iteminfo.ClabAmt = westernMedicine_clab_amt
  2862. iteminfo.OthAmt = westernMedicine_other_amt
  2863. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2864. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2865. }
  2866. if commonlyTreatmentCostTotal != 0 {
  2867. iteminfo.MedChrgitm = "12"
  2868. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  2869. iteminfo.Amt = commonlyTreatmentCostTotal
  2870. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  2871. iteminfo.ClabAmt = commonly_treatment_clab_amt
  2872. iteminfo.OthAmt = commonly_treatment_other_amt
  2873. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2874. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2875. }
  2876. if registerCostTotal != 0 {
  2877. iteminfo.MedChrgitm = "13"
  2878. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  2879. iteminfo.Amt = registerCostTotal
  2880. iteminfo.ClaaSumfee = register_claa_sunmfee
  2881. iteminfo.ClabAmt = register_clab_amt
  2882. iteminfo.OthAmt = register_other_amt
  2883. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2884. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2885. }
  2886. if otherCostTotal != 0 {
  2887. iteminfo.MedChrgitm = "14"
  2888. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2889. iteminfo.Amt = otherCostTotal
  2890. iteminfo.ClaaSumfee = other_claa_sunmfee
  2891. iteminfo.ClabAmt = other_clab_amt
  2892. iteminfo.OthAmt = other_other_amt
  2893. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2894. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2895. }
  2896. struct4101.IteminfoStruct = iteminfoStructs
  2897. struct4101.Ntly = "中国"
  2898. struct4101.AdmCaty = "A03.06"
  2899. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  2900. fmt.Println(result)
  2901. var dat map[string]interface{}
  2902. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2903. fmt.Println(dat)
  2904. } else {
  2905. fmt.Println(err)
  2906. }
  2907. userJSONBytes, _ := json.Marshal(dat)
  2908. var res ResultSeventeen
  2909. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2910. utils.ErrorLog("解析失败:%v", err)
  2911. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2912. adminUser := c.GetAdminUserInfo()
  2913. errlog := &models.HisOrderError{
  2914. UserOrgId: adminUser.CurrentOrgId,
  2915. Ctime: time.Now().Unix(),
  2916. Mtime: time.Now().Unix(),
  2917. ErrMsg: res.ErrMsg + "解析失败",
  2918. Status: 1,
  2919. PatientId: order_id,
  2920. Stage: 10106,
  2921. }
  2922. service.CreateErrMsgLog(errlog)
  2923. continue
  2924. }
  2925. if res.Infcode != 0 {
  2926. adminUser := c.GetAdminUserInfo()
  2927. errlog := &models.HisOrderError{
  2928. UserOrgId: adminUser.CurrentOrgId,
  2929. Ctime: time.Now().Unix(),
  2930. Mtime: time.Now().Unix(),
  2931. ErrMsg: res.ErrMsg,
  2932. Status: 1,
  2933. PatientId: order_id,
  2934. Stage: 10106,
  2935. }
  2936. service.CreateErrMsgLog(errlog)
  2937. continue
  2938. } else {
  2939. hisFundSettleListResult := &models.HisFundSettleListResult{
  2940. Number: res.Output.SetlListId,
  2941. Status: 1,
  2942. Ctime: time.Now().Unix(),
  2943. Mtime: time.Now().Unix(),
  2944. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2945. IsUpload: 1,
  2946. OrderId: order_id,
  2947. }
  2948. service.CreateUploadRecord(hisFundSettleListResult)
  2949. continue
  2950. }
  2951. }
  2952. }
  2953. func (c *HisApiController) GetOrgInfo() {
  2954. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  2955. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  2956. }
  2957. func (c *HisApiController) GetHisPatientInfo() {
  2958. medical_insurance_card := c.GetString("medical_insurance_card")
  2959. id_card_type, _ := c.GetInt64("id_card_type")
  2960. id_card := c.GetString("id_card")
  2961. adminInfo := c.GetAdminUserInfo()
  2962. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  2963. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  2964. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  2965. IdCardNo := ""
  2966. if id_card_type == 1 {
  2967. IdCardNo = medical_insurance_card
  2968. } else if id_card_type == 2 {
  2969. IdCardNo = id_card
  2970. }
  2971. if config.IsOpen == 1 {
  2972. 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
  2973. resp, requestErr := http.Get(api)
  2974. if requestErr != nil {
  2975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2976. return
  2977. }
  2978. defer resp.Body.Close()
  2979. body, ioErr := ioutil.ReadAll(resp.Body)
  2980. if ioErr != nil {
  2981. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2983. return
  2984. }
  2985. var respJSON map[string]interface{}
  2986. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2987. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2989. return
  2990. }
  2991. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2992. userJSONBytes, _ := json.Marshal(userJSON)
  2993. var res ResultTwo
  2994. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2995. utils.ErrorLog("解析失败:%v", err)
  2996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2997. return
  2998. }
  2999. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3000. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3001. infoStr := string(Iinfos)
  3002. idetinfoStr := string(Idetinfos)
  3003. if res.Infcode == 0 {
  3004. his := models.VMHisPatient{
  3005. Status: 1,
  3006. Ctime: time.Now().Unix(),
  3007. Mtime: time.Now().Unix(),
  3008. PsnNo: res.Output.Baseinfo.PsnNo,
  3009. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3010. Certno: res.Output.Baseinfo.Certno,
  3011. PsnName: res.Output.Baseinfo.PsnName,
  3012. Gend: res.Output.Baseinfo.Gend,
  3013. Naty: res.Output.Baseinfo.Naty,
  3014. Brdy: res.Output.Baseinfo.Brdy,
  3015. Age: res.Output.Baseinfo.Age,
  3016. Iinfo: infoStr,
  3017. Idetinfo: idetinfoStr,
  3018. UserOrgId: adminInfo.CurrentOrgId,
  3019. IsReturn: 1,
  3020. IdCardType: id_card_type,
  3021. }
  3022. c.ServeSuccessJSON(map[string]interface{}{
  3023. "info": his,
  3024. })
  3025. } else {
  3026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3027. return
  3028. }
  3029. }
  3030. }
  3031. //func GetBasBaseInfo() (jsonStr string, err error) {
  3032. //
  3033. // handle := syscall.NewLazyDLL("SSCard.dll")
  3034. // add := handle.NewProc("ReadCardBas")
  3035. // str := make([]byte, 1024)
  3036. // str1 := make([]byte, 1024)
  3037. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3038. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3039. //
  3040. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3041. //
  3042. // fmt.Println("> Add(4,5)的结果为:", ret)
  3043. // handle.Release()
  3044. //
  3045. // return "", nil
  3046. //
  3047. //}
  3048. //func GetQRBaseInfo() (jsonStr string, err error) {
  3049. // handle := syscall.LoadDLL("SSCard.dll")
  3050. // ReadCardBas := handle.FindProc("GetQRBase")
  3051. //
  3052. // str := make([]byte, 256)
  3053. // str1 := make([]byte, 256)
  3054. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3055. //
  3056. // fmt.Println(string(str))
  3057. // fmt.Println(r)
  3058. // return string(str), nil
  3059. //}
  3060. //func CardInit() int {
  3061. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  3062. // add := DllTestDef.MustFindProc("Init")
  3063. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3064. // if err != nil {
  3065. // fmt.Println("SSCard的运算结果为:", ret)
  3066. // }
  3067. // result := int(ret)
  3068. // return result
  3069. //}
  3070. //func CardInit() int {
  3071. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3072. // if err != nil {
  3073. // fmt.Println("SSCard的运算结果为:", ret)
  3074. // }
  3075. // fmt.Println(err)
  3076. // result := int(ret)
  3077. // return result
  3078. //}
  3079. func IntPtr(n int) uintptr {
  3080. return uintptr(n)
  3081. }
  3082. func StrPtr(s string) uintptr {
  3083. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3084. }
  3085. type Result2001 struct {
  3086. Cainfo interface{} `json:"cainfo"`
  3087. ErrMsg string `json:"err_msg"`
  3088. InfRefmsgid string `json:"inf_refmsgid"`
  3089. Infcode int64 `json:"infcode"`
  3090. Output struct {
  3091. Trtinfo struct {
  3092. PsnNo string `json:"psn_no"`
  3093. TrtChkType string `json:"trt_chk_type"`
  3094. FundPayType string `json:"fund_pay_type"`
  3095. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3096. Begndate string `json:"begndate"`
  3097. Enddate string `json:"enddate"`
  3098. TrtChkRslt string `json:"trt_chk_rslt"`
  3099. } `json:"trtinfo"`
  3100. } `json:"output"`
  3101. RefmsgTime string `json:"refmsg_time"`
  3102. RespondTime string `json:"respond_time"`
  3103. Signtype interface{} `json:"signtype"`
  3104. WarnMsg interface{} `json:"warn_msg"`
  3105. }
  3106. type Result2001Org10265 struct {
  3107. Cainfo interface{} `json:"cainfo"`
  3108. ErrMsg string `json:"err_msg"`
  3109. InfRefmsgid string `json:"inf_refmsgid"`
  3110. Infcode string `json:"infcode"`
  3111. Output struct {
  3112. Trtinfo struct {
  3113. PsnNo string `json:"psn_no"`
  3114. TrtChkType string `json:"trt_chk_type"`
  3115. FundPayType string `json:"fund_pay_type"`
  3116. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3117. Begndate string `json:"begndate"`
  3118. Enddate string `json:"enddate"`
  3119. TrtChkRslt string `json:"trt_chk_rslt"`
  3120. } `json:"trtinfo"`
  3121. } `json:"output"`
  3122. RefmsgTime string `json:"refmsg_time"`
  3123. RespondTime string `json:"respond_time"`
  3124. Signtype interface{} `json:"signtype"`
  3125. WarnMsg interface{} `json:"warn_msg"`
  3126. }
  3127. type ResultTwo struct {
  3128. ErrMsg string `json:"err_msg"`
  3129. InfRefmsgid string `json:"inf_refmsgid"`
  3130. Infcode int64 `json:"infcode"`
  3131. Output struct {
  3132. Baseinfo struct {
  3133. Age float64 `json:"age"`
  3134. Brdy string `json:"brdy"`
  3135. Certno string `json:"certno"`
  3136. Gend string `json:"gend"`
  3137. Naty string `json:"naty"`
  3138. PsnCertType string `json:"psn_cert_type"`
  3139. PsnName string `json:"psn_name"`
  3140. PsnNo string `json:"psn_no"`
  3141. } `json:"baseinfo"`
  3142. Idetinfo []interface{} `json:"idetinfo"`
  3143. Iinfo []struct {
  3144. Balc float64 `json:"balc"`
  3145. CvlservFlag string `json:"cvlserv_flag"`
  3146. EmpName string `json:"emp_name"`
  3147. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3148. Insutype string `json:"insutype"`
  3149. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3150. PausInsuDate string `json:"paus_insu_date"`
  3151. PsnInsuDate string `json:"psn_insu_date"`
  3152. PsnInsuStas string `json:"psn_insu_stas"`
  3153. PsnType string `json:"psn_type"`
  3154. } `json:"insuinfo"`
  3155. } `json:"output"`
  3156. RefmsgTime string `json:"refmsg_time"`
  3157. RespondTime string `json:"respond_time"`
  3158. Signtype interface{} `json:"signtype"`
  3159. WarnInfo interface{} `json:"warn_info"`
  3160. }
  3161. type ResultTwo10265 struct {
  3162. ErrMsg string `json:"err_msg"`
  3163. InfRefmsgid string `json:"inf_refmsgid"`
  3164. Infcode string `json:"infcode"`
  3165. Output struct {
  3166. Baseinfo struct {
  3167. Age float64 `json:"age"`
  3168. Brdy string `json:"brdy"`
  3169. Certno string `json:"certno"`
  3170. Gend string `json:"gend"`
  3171. Naty string `json:"naty"`
  3172. PsnCertType string `json:"psn_cert_type"`
  3173. PsnName string `json:"psn_name"`
  3174. PsnNo string `json:"psn_no"`
  3175. } `json:"baseinfo"`
  3176. Idetinfo []interface{} `json:"idetinfo"`
  3177. Iinfo []struct {
  3178. Balc float64 `json:"balc"`
  3179. CvlservFlag string `json:"cvlserv_flag"`
  3180. EmpName string `json:"emp_name"`
  3181. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3182. Insutype string `json:"insutype"`
  3183. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3184. PausInsuDate string `json:"paus_insu_date"`
  3185. PsnInsuDate string `json:"psn_insu_date"`
  3186. PsnInsuStas string `json:"psn_insu_stas"`
  3187. PsnType string `json:"psn_type"`
  3188. } `json:"insuinfo"`
  3189. } `json:"output"`
  3190. RefmsgTime string `json:"refmsg_time"`
  3191. RespondTime string `json:"respond_time"`
  3192. Signtype interface{} `json:"signtype"`
  3193. WarnInfo interface{} `json:"warn_info"`
  3194. }
  3195. type ResultThree struct {
  3196. Cainfo interface{} `json:"cainfo"`
  3197. ErrMsg string `json:"err_msg"`
  3198. InfRefmsgid string `json:"inf_refmsgid"`
  3199. Infcode int64 `json:"infcode"`
  3200. Output struct {
  3201. Data struct {
  3202. IptOtpNo string `json:"ipt_otp_no"`
  3203. MdtrtID string `json:"mdtrt_id"`
  3204. PsnNo string `json:"psn_no"`
  3205. } `json:"data"`
  3206. } `json:"output"`
  3207. RefmsgTime string `json:"refmsg_time"`
  3208. RespondTime string `json:"respond_time"`
  3209. Signtype interface{} `json:"signtype"`
  3210. WarnMsg interface{} `json:"warn_msg"`
  3211. }
  3212. type ResultThree10265 struct {
  3213. Cainfo interface{} `json:"cainfo"`
  3214. ErrMsg string `json:"err_msg"`
  3215. InfRefmsgid string `json:"inf_refmsgid"`
  3216. Infcode string `json:"infcode"`
  3217. Output struct {
  3218. Data struct {
  3219. IptOtpNo string `json:"ipt_otp_no"`
  3220. MdtrtID string `json:"mdtrt_id"`
  3221. PsnNo string `json:"psn_no"`
  3222. } `json:"data"`
  3223. } `json:"output"`
  3224. RefmsgTime string `json:"refmsg_time"`
  3225. RespondTime string `json:"respond_time"`
  3226. Signtype interface{} `json:"signtype"`
  3227. WarnMsg interface{} `json:"warn_msg"`
  3228. }
  3229. type ResultFour struct {
  3230. Cainfo string `json:"cainfo"`
  3231. ErrMsg string `json:"err_msg"`
  3232. InfRefmsgid string `json:"inf_refmsgid"`
  3233. Infcode int64 `json:"infcode"`
  3234. Output struct {
  3235. Result []struct {
  3236. BasMednFlag string `json:"bas_medn_flag"`
  3237. ChldMedcFlag string `json:"chld_medc_flag"`
  3238. ChrgitmLv string `json:"chrgitm_lv"`
  3239. Cnt float64 `json:"cnt"`
  3240. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3241. DrtReimFlag string `json:"drt_reim_flag"`
  3242. FeedetlSn string `json:"feedetl_sn"`
  3243. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3244. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3245. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3246. ListSpItemFlag string `json:"list_sp_item_flag"`
  3247. LmtUsedFlag string `json:"lmt_used_flag"`
  3248. MedChrgitmType string `json:"med_chrgitm_type"`
  3249. Memo string `json:"memo"`
  3250. OverlmtAmt float64 `json:"overlmt_amt"`
  3251. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3252. Pric float64 `json:"pric"`
  3253. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3254. SelfpayProp float64 `json:"selfpay_prop"`
  3255. } `json:"result"`
  3256. } `json:"output"`
  3257. RefmsgTime string `json:"refmsg_time"`
  3258. RespondTime string `json:"respond_time"`
  3259. Signtype string `json:"signtype"`
  3260. WarnMsg string `json:"warn_msg"`
  3261. }
  3262. type ResultFour10265 struct {
  3263. Cainfo string `json:"cainfo"`
  3264. ErrMsg string `json:"err_msg"`
  3265. InfRefmsgid string `json:"inf_refmsgid"`
  3266. Infcode string `json:"infcode"`
  3267. Output struct {
  3268. Result []struct {
  3269. BasMednFlag string `json:"bas_medn_flag"`
  3270. ChldMedcFlag string `json:"chld_medc_flag"`
  3271. ChrgitmLv string `json:"chrgitm_lv"`
  3272. Cnt float64 `json:"cnt"`
  3273. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3274. DrtReimFlag string `json:"drt_reim_flag"`
  3275. FeedetlSn string `json:"feedetl_sn"`
  3276. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3277. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3278. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3279. ListSpItemFlag string `json:"list_sp_item_flag"`
  3280. LmtUsedFlag string `json:"lmt_used_flag"`
  3281. MedChrgitmType string `json:"med_chrgitm_type"`
  3282. Memo string `json:"memo"`
  3283. OverlmtAmt float64 `json:"overlmt_amt"`
  3284. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3285. Pric float64 `json:"pric"`
  3286. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3287. SelfpayProp float64 `json:"selfpay_prop"`
  3288. } `json:"result"`
  3289. } `json:"output"`
  3290. RefmsgTime string `json:"refmsg_time"`
  3291. RespondTime string `json:"respond_time"`
  3292. Signtype string `json:"signtype"`
  3293. WarnMsg string `json:"warn_msg"`
  3294. }
  3295. type ResultFive struct {
  3296. Balc float64 `json:"balc"`
  3297. CvlservFlag string `json:"cvlserv_flag"`
  3298. EmpName string `json:"emp_name"`
  3299. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3300. Insutype string `json:"insutype"`
  3301. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3302. PausInsuDate string `json:"paus_insu_date"`
  3303. PsnInsuDate string `json:"psn_insu_date"`
  3304. PsnInsuStas string `json:"psn_insu_stas"`
  3305. PsnType string `json:"psn_type"`
  3306. }
  3307. type ResultSix struct {
  3308. Cainfo interface{} `json:"cainfo"`
  3309. ErrMsg string `json:"err_msg"`
  3310. InfRefmsgid string `json:"inf_refmsgid"`
  3311. Infcode int64 `json:"infcode"`
  3312. Output struct {
  3313. } `json:"output"`
  3314. RefmsgTime string `json:"refmsg_time"`
  3315. RespondTime string `json:"respond_time"`
  3316. Signtype interface{} `json:"signtype"`
  3317. WarnMsg interface{} `json:"warn_msg"`
  3318. }
  3319. type ResultSix10265 struct {
  3320. Cainfo interface{} `json:"cainfo"`
  3321. ErrMsg string `json:"err_msg"`
  3322. InfRefmsgid string `json:"inf_refmsgid"`
  3323. Infcode string `json:"infcode"`
  3324. Output struct {
  3325. } `json:"output"`
  3326. RefmsgTime string `json:"refmsg_time"`
  3327. RespondTime string `json:"respond_time"`
  3328. Signtype interface{} `json:"signtype"`
  3329. WarnMsg interface{} `json:"warn_msg"`
  3330. }
  3331. type ResultSeven struct {
  3332. Cainfo string `json:"cainfo"`
  3333. ErrMsg string `json:"err_msg"`
  3334. InfRefmsgid string `json:"inf_refmsgid"`
  3335. Infcode int64 `json:"infcode"`
  3336. Output struct {
  3337. Setldetail []interface{} `json:"setldetail"`
  3338. Setlinfo struct {
  3339. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3340. AcctPay float64 `json:"acct_pay"`
  3341. ActPayDedc float64 `json:"act_pay_dedc"`
  3342. Age float64 `json:"age"`
  3343. Balc float64 `json:"balc"`
  3344. Brdy string `json:"brdy"`
  3345. Certno string `json:"certno"`
  3346. ClrOptins string `json:"clr_optins"`
  3347. ClrType string `json:"clr_type"`
  3348. ClrWay string `json:"clr_way"`
  3349. CvlservFlag string `json:"cvlserv_flag"`
  3350. CvlservPay float64 `json:"cvlserv_pay"`
  3351. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3352. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3353. Gend string `json:"gend"`
  3354. HifesPay float64 `json:"hifes_pay"`
  3355. HifmiPay float64 `json:"hifmi_pay"`
  3356. HifpPay float64 `json:"hifp_pay"`
  3357. HospPartAmt float64 `json:"hosp_part_amt"`
  3358. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3359. Insutype string `json:"insutype"`
  3360. MafPay float64 `json:"maf_pay"`
  3361. MdtrtCertType string `json:"mdtrt_cert_type"`
  3362. HifobPay float64 `json:"hifob_pay"`
  3363. MdtrtID string `json:"mdtrt_id"`
  3364. MedType string `json:"med_type"`
  3365. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3366. MedinsSetlID string `json:"medins_setl_id"`
  3367. Naty string `json:"naty"`
  3368. OthPay float64 `json:"oth_pay"`
  3369. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3370. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3371. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3372. PsnCashPay float64 `json:"psn_cash_pay"`
  3373. PsnCertType string `json:"psn_cert_type"`
  3374. PsnName string `json:"psn_name"`
  3375. PsnNo string `json:"psn_no"`
  3376. PsnPartAmt float64 `json:"psn_part_amt"`
  3377. PsnType string `json:"psn_type"`
  3378. SetlID string `json:"setl_id"`
  3379. SetlTime string `json:"setl_time"`
  3380. } `json:"setlinfo"`
  3381. } `json:"output"`
  3382. RefmsgTime string `json:"refmsg_time"`
  3383. RespondTime string `json:"respond_time"`
  3384. Signtype interface{} `json:"signtype"`
  3385. WarnMsg interface{} `json:"warn_msg"`
  3386. }
  3387. type ResultSeven10265 struct {
  3388. Cainfo string `json:"cainfo"`
  3389. ErrMsg string `json:"err_msg"`
  3390. InfRefmsgid string `json:"inf_refmsgid"`
  3391. Infcode string `json:"infcode"`
  3392. Output struct {
  3393. Setldetail []interface{} `json:"setldetail"`
  3394. Setlinfo struct {
  3395. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3396. AcctPay float64 `json:"acct_pay"`
  3397. ActPayDedc float64 `json:"act_pay_dedc"`
  3398. Age float64 `json:"age"`
  3399. Balc float64 `json:"balc"`
  3400. Brdy string `json:"brdy"`
  3401. Certno string `json:"certno"`
  3402. ClrOptins string `json:"clr_optins"`
  3403. ClrType string `json:"clr_type"`
  3404. ClrWay string `json:"clr_way"`
  3405. CvlservFlag string `json:"cvlserv_flag"`
  3406. CvlservPay float64 `json:"cvlserv_pay"`
  3407. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3408. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3409. Gend string `json:"gend"`
  3410. HifesPay float64 `json:"hifes_pay"`
  3411. HifmiPay float64 `json:"hifmi_pay"`
  3412. HifpPay float64 `json:"hifp_pay"`
  3413. HospPartAmt float64 `json:"hosp_part_amt"`
  3414. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3415. Insutype string `json:"insutype"`
  3416. MafPay float64 `json:"maf_pay"`
  3417. MdtrtCertType string `json:"mdtrt_cert_type"`
  3418. HifobPay float64 `json:"hifob_pay"`
  3419. MdtrtID string `json:"mdtrt_id"`
  3420. MedType string `json:"med_type"`
  3421. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3422. MedinsSetlID string `json:"medins_setl_id"`
  3423. Naty string `json:"naty"`
  3424. OthPay float64 `json:"oth_pay"`
  3425. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3426. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3427. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3428. PsnCashPay float64 `json:"psn_cash_pay"`
  3429. PsnCertType string `json:"psn_cert_type"`
  3430. PsnName string `json:"psn_name"`
  3431. PsnNo string `json:"psn_no"`
  3432. PsnPartAmt float64 `json:"psn_part_amt"`
  3433. PsnType string `json:"psn_type"`
  3434. SetlID string `json:"setl_id"`
  3435. SetlTime string `json:"setl_time"`
  3436. } `json:"setlinfo"`
  3437. } `json:"output"`
  3438. RefmsgTime string `json:"refmsg_time"`
  3439. RespondTime string `json:"respond_time"`
  3440. Signtype interface{} `json:"signtype"`
  3441. WarnMsg interface{} `json:"warn_msg"`
  3442. }
  3443. type ResultEight struct {
  3444. Cainfo string `json:"cainfo"`
  3445. ErrMsg string `json:"err_msg"`
  3446. InfRefmsgid string `json:"inf_refmsgid"`
  3447. Infcode int64 `json:"infcode"`
  3448. Output struct {
  3449. Stmtinfo struct {
  3450. SetlOptins string `json:"setl_optins"`
  3451. StmtRslt string `json:"stmt_rslt"`
  3452. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3453. } `json:"stmtinfo"`
  3454. } `json:"output"`
  3455. RefmsgTime string `json:"refmsg_time"`
  3456. RespondTime string `json:"respond_time"`
  3457. Signtype interface{} `json:"signtype"`
  3458. WarnMsg interface{} `json:"warn_msg"`
  3459. }
  3460. type ResultEightFor10188 struct {
  3461. Cainfo string `json:"cainfo"`
  3462. ErrMsg string `json:"err_msg"`
  3463. InfRefmsgid string `json:"inf_refmsgid"`
  3464. Infcode string `json:"infcode"`
  3465. Output struct {
  3466. Stmtinfo struct {
  3467. SetlOptins string `json:"setl_optins"`
  3468. StmtRslt string `json:"stmt_rslt"`
  3469. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3470. } `json:"stmtinfo"`
  3471. } `json:"output"`
  3472. RefmsgTime string `json:"refmsg_time"`
  3473. RespondTime string `json:"respond_time"`
  3474. Signtype interface{} `json:"signtype"`
  3475. WarnMsg interface{} `json:"warn_msg"`
  3476. }
  3477. type ResultNine struct {
  3478. Cainfo string `json:"cainfo"`
  3479. ErrMsg string `json:"err_msg"`
  3480. InfRefmsgid string `json:"inf_refmsgid"`
  3481. Infcode int64 `json:"infcode"`
  3482. Output struct {
  3483. FileQuryNo string `json:"file_qury_no"`
  3484. } `json:"output"`
  3485. RefmsgTime string `json:"refmsg_time"`
  3486. RespondTime string `json:"respond_time"`
  3487. Signtype interface{} `json:"signtype"`
  3488. WarnMsg interface{} `json:"warn_msg"`
  3489. }
  3490. type ResultTen struct {
  3491. Cainfo string `json:"cainfo"`
  3492. ErrMsg string `json:"err_msg"`
  3493. InfRefmsgid string `json:"inf_refmsgid"`
  3494. Infcode int64 `json:"infcode"`
  3495. Output struct {
  3496. DldEndtime string `json:"dld_endtime"`
  3497. FileQuryNo string `json:"file_qury_no"`
  3498. Filename string `json:"filename"`
  3499. } `json:"output"`
  3500. RefmsgTime string `json:"refmsg_time"`
  3501. RespondTime string `json:"respond_time"`
  3502. Signtype interface{} `json:"signtype"`
  3503. WarnMsg interface{} `json:"warn_msg"`
  3504. }
  3505. //type Autogenerated struct {
  3506. // Output struct {
  3507. // Setlinfo struct {
  3508. // SetlTime string `json:"setl_time"`
  3509. // CvlservPay float64 `json:"cvlserv_pay"`
  3510. // Year string `json:"year"`
  3511. // MedType string `json:"med_type"`
  3512. // PsnPay float64 `json:"psn_pay"`
  3513. // OpterID string `json:"opter_id"`
  3514. // Begndate string `json:"begndate"`
  3515. // FlxempeFlag string `json:"flxempe_flag"`
  3516. // HifmiPay float64 `json:"hifmi_pay"`
  3517. // PsnNo string `json:"psn_no"`
  3518. // ActPayDedc float64 `json:"act_pay_dedc"`
  3519. // MedinsSetlID interface{} `json:"medins_setl_id"`
  3520. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3521. // ClrWay string `json:"clr_way"`
  3522. // OthPay float64 `json:"oth_pay"`
  3523. // Gend string `json:"gend"`
  3524. // MdtrtID string `json:"mdtrt_id"`
  3525. // AcctPay float64 `json:"acct_pay"`
  3526. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  3527. // Insutype string `json:"insutype"`
  3528. // Invono interface{} `json:"invono"`
  3529. // Enddate string `json:"enddate"`
  3530. // CashPayamt float64 `json:"cash_payamt"`
  3531. // PsnType string `json:"psn_type"`
  3532. // FixmedinsName string `json:"fixmedins_name"`
  3533. // HifpPay float64 `json:"hifp_pay"`
  3534. // NewFlag interface{} `json:"new_flag"`
  3535. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3536. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  3537. // PayLoc string `json:"pay_loc"`
  3538. // ClrType string `json:"clr_type"`
  3539. // RefdSetlFlag string `json:"refd_setl_flag"`
  3540. // CvlservFlag string `json:"cvlserv_flag"`
  3541. // EmpName string `json:"emp_name"`
  3542. // Brdy string `json:"brdy"`
  3543. // Naty string `json:"naty"`
  3544. // Certno string `json:"certno"`
  3545. // DiseCode string `json:"dise_code"`
  3546. // FixmedinsCode string `json:"fixmedins_code"`
  3547. // DedcHospLv string `json:"dedc_hosp_lv"`
  3548. // OpterName string `json:"opter_name"`
  3549. // Balc float64 `json:"balc"`
  3550. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3551. // PsnCertType string `json:"psn_cert_type"`
  3552. // HifobPay float64 `json:"hifob_pay"`
  3553. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  3554. // HifesPay float64 `json:"hifes_pay"`
  3555. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3556. // OptTime string `json:"opt_time"`
  3557. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3558. // SetlID string `json:"setl_id"`
  3559. // MafPay float64 `json:"maf_pay"`
  3560. // PsnName string `json:"psn_name"`
  3561. // InsuOptins interface{} `json:"insu_optins"`
  3562. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3563. // ClrOptins string `json:"clr_optins"`
  3564. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3565. // DiseName string `json:"dise_name"`
  3566. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3567. // Age float64 `json:"age"`
  3568. // DtrtCertType string `json:"dtrt_cert_type"`
  3569. // HospLv string `json:"hosp_lv"`
  3570. // } `json:"setlinfo"`
  3571. // Setldetail []struct {
  3572. // FundPayType string `json:"fund_pay_type"`
  3573. // FundPayamt float64 `json:"fund_payamt"`
  3574. // SetlProcInfo interface{} `json:"setl_proc_info"`
  3575. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  3576. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  3577. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  3578. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3579. // } `json:"setldetail"`
  3580. // } `json:"output"`
  3581. // Infcode int `json:"infcode"`
  3582. // WarnMsg interface{} `json:"warn_msg"`
  3583. // Cainfo interface{} `json:"cainfo"`
  3584. // ErrMsg interface{} `json:"err_msg"`
  3585. // RefmsgTime string `json:"refmsg_time"`
  3586. // Signtype interface{} `json:"signtype"`
  3587. // RespondTime string `json:"respond_time"`
  3588. // InfRefmsgid string `json:"inf_refmsgid"`
  3589. //}
  3590. type ResultEleven struct {
  3591. Cainfo string `json:"cainfo"`
  3592. ErrMsg string `json:"err_msg"`
  3593. InfRefmsgid string `json:"inf_refmsgid"`
  3594. Infcode int64 `json:"infcode"`
  3595. Output struct {
  3596. Setlinfo struct {
  3597. SetlTime string `json:"setl_time"`
  3598. CvlservPay float64 `json:"cvlserv_pay"`
  3599. Year string `json:"year"`
  3600. MedType string `json:"med_type"`
  3601. PsnPay float64 `json:"psn_pay"`
  3602. OpterID string `json:"opter_id"`
  3603. Begndate string `json:"begndate"`
  3604. FlxempeFlag string `json:"flxempe_flag"`
  3605. HifmiPay float64 `json:"hifmi_pay"`
  3606. PsnNo string `json:"psn_no"`
  3607. ActPayDedc float64 `json:"act_pay_dedc"`
  3608. MedinsSetlID interface{} `json:"medins_setl_id"`
  3609. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3610. ClrWay string `json:"clr_way"`
  3611. OthPay float64 `json:"oth_pay"`
  3612. Gend string `json:"gend"`
  3613. MdtrtID string `json:"mdtrt_id"`
  3614. AcctPay float64 `json:"acct_pay"`
  3615. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3616. Insutype string `json:"insutype"`
  3617. Invono interface{} `json:"invono"`
  3618. Enddate string `json:"enddate"`
  3619. CashPayamt float64 `json:"cash_payamt"`
  3620. PsnType string `json:"psn_type"`
  3621. FixmedinsName string `json:"fixmedins_name"`
  3622. HifpPay float64 `json:"hifp_pay"`
  3623. NewFlag interface{} `json:"new_flag"`
  3624. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3625. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3626. PayLoc string `json:"pay_loc"`
  3627. ClrType string `json:"clr_type"`
  3628. RefdSetlFlag string `json:"refd_setl_flag"`
  3629. CvlservFlag string `json:"cvlserv_flag"`
  3630. EmpName string `json:"emp_name"`
  3631. Brdy string `json:"brdy"`
  3632. Naty string `json:"naty"`
  3633. Certno string `json:"certno"`
  3634. DiseCode string `json:"dise_code"`
  3635. FixmedinsCode string `json:"fixmedins_code"`
  3636. DedcHospLv string `json:"dedc_hosp_lv"`
  3637. OpterName string `json:"opter_name"`
  3638. Balc float64 `json:"balc"`
  3639. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3640. PsnCertType string `json:"psn_cert_type"`
  3641. HifobPay float64 `json:"hifob_pay"`
  3642. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3643. HifesPay float64 `json:"hifes_pay"`
  3644. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3645. OptTime string `json:"opt_time"`
  3646. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3647. SetlID string `json:"setl_id"`
  3648. MafPay float64 `json:"maf_pay"`
  3649. PsnName string `json:"psn_name"`
  3650. InsuOptins interface{} `json:"insu_optins"`
  3651. PrefFundPay interface{} `json:"pref_fund_pay"`
  3652. ClrOptins string `json:"clr_optins"`
  3653. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3654. DiseName string `json:"dise_name"`
  3655. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3656. Age float64 `json:"age"`
  3657. DtrtCertType string `json:"dtrt_cert_type"`
  3658. HospLv string `json:"hosp_lv"`
  3659. } `json:"setlinfo"`
  3660. } `json:"output"`
  3661. RefmsgTime string `json:"refmsg_time"`
  3662. RespondTime string `json:"respond_time"`
  3663. Signtype interface{} `json:"signtype"`
  3664. WarnMsg interface{} `json:"warn_msg"`
  3665. }
  3666. type ResultEleven10265 struct {
  3667. Cainfo string `json:"cainfo"`
  3668. ErrMsg string `json:"err_msg"`
  3669. InfRefmsgid string `json:"inf_refmsgid"`
  3670. Infcode string `json:"infcode"`
  3671. Output struct {
  3672. Setlinfo struct {
  3673. SetlTime string `json:"setl_time"`
  3674. CvlservPay float64 `json:"cvlserv_pay"`
  3675. Year string `json:"year"`
  3676. MedType string `json:"med_type"`
  3677. PsnPay float64 `json:"psn_pay"`
  3678. OpterID string `json:"opter_id"`
  3679. Begndate string `json:"begndate"`
  3680. FlxempeFlag string `json:"flxempe_flag"`
  3681. HifmiPay float64 `json:"hifmi_pay"`
  3682. PsnNo string `json:"psn_no"`
  3683. ActPayDedc float64 `json:"act_pay_dedc"`
  3684. MedinsSetlID interface{} `json:"medins_setl_id"`
  3685. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3686. ClrWay string `json:"clr_way"`
  3687. OthPay float64 `json:"oth_pay"`
  3688. Gend string `json:"gend"`
  3689. MdtrtID string `json:"mdtrt_id"`
  3690. AcctPay float64 `json:"acct_pay"`
  3691. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3692. Insutype string `json:"insutype"`
  3693. Invono interface{} `json:"invono"`
  3694. Enddate string `json:"enddate"`
  3695. CashPayamt float64 `json:"cash_payamt"`
  3696. PsnType string `json:"psn_type"`
  3697. FixmedinsName string `json:"fixmedins_name"`
  3698. HifpPay float64 `json:"hifp_pay"`
  3699. NewFlag interface{} `json:"new_flag"`
  3700. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3701. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3702. PayLoc string `json:"pay_loc"`
  3703. ClrType string `json:"clr_type"`
  3704. RefdSetlFlag string `json:"refd_setl_flag"`
  3705. CvlservFlag string `json:"cvlserv_flag"`
  3706. EmpName string `json:"emp_name"`
  3707. Brdy string `json:"brdy"`
  3708. Naty string `json:"naty"`
  3709. Certno string `json:"certno"`
  3710. DiseCode string `json:"dise_code"`
  3711. FixmedinsCode string `json:"fixmedins_code"`
  3712. DedcHospLv string `json:"dedc_hosp_lv"`
  3713. OpterName string `json:"opter_name"`
  3714. Balc float64 `json:"balc"`
  3715. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3716. PsnCertType string `json:"psn_cert_type"`
  3717. HifobPay float64 `json:"hifob_pay"`
  3718. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3719. HifesPay float64 `json:"hifes_pay"`
  3720. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3721. OptTime string `json:"opt_time"`
  3722. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3723. SetlID string `json:"setl_id"`
  3724. MafPay float64 `json:"maf_pay"`
  3725. PsnName string `json:"psn_name"`
  3726. InsuOptins interface{} `json:"insu_optins"`
  3727. PrefFundPay interface{} `json:"pref_fund_pay"`
  3728. ClrOptins string `json:"clr_optins"`
  3729. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3730. DiseName string `json:"dise_name"`
  3731. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3732. Age float64 `json:"age"`
  3733. DtrtCertType string `json:"dtrt_cert_type"`
  3734. HospLv string `json:"hosp_lv"`
  3735. } `json:"setlinfo"`
  3736. } `json:"output"`
  3737. RefmsgTime string `json:"refmsg_time"`
  3738. RespondTime string `json:"respond_time"`
  3739. Signtype interface{} `json:"signtype"`
  3740. WarnMsg interface{} `json:"warn_msg"`
  3741. }
  3742. type ResultTwelve struct {
  3743. Cainfo string `json:"cainfo"`
  3744. ErrMsg string `json:"err_msg"`
  3745. InfRefmsgid string `json:"inf_refmsgid"`
  3746. Infcode int64 `json:"infcode"`
  3747. Output struct {
  3748. MdtrtId string `json:"mdtrt_id"`
  3749. ChrgBchno string `json:"chrg_bchno"`
  3750. PsnNo string `json:"psn_no"`
  3751. } `json:"output"`
  3752. RefmsgTime string `json:"refmsg_time"`
  3753. RespondTime string `json:"respond_time"`
  3754. Signtype interface{} `json:"signtype"`
  3755. WarnMsg interface{} `json:"warn_msg"`
  3756. }
  3757. type ResultThirteen struct {
  3758. ErrMsg string `json:"err_msg"`
  3759. InfRefmsgid string `json:"inf_refmsgid"`
  3760. Infcode int64 `json:"infcode"`
  3761. Output struct {
  3762. Result struct {
  3763. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3764. } `json:"result"`
  3765. } `json:"output"`
  3766. RefmsgTime string `json:"refmsg_time"`
  3767. RespondTime string `json:"respond_time"`
  3768. Signtype interface{} `json:"signtype"`
  3769. WarnInfo interface{} `json:"warn_info"`
  3770. }
  3771. type ResultThirteen10265 struct {
  3772. ErrMsg string `json:"err_msg"`
  3773. InfRefmsgid string `json:"inf_refmsgid"`
  3774. Infcode string `json:"infcode"`
  3775. Output struct {
  3776. Result struct {
  3777. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3778. } `json:"result"`
  3779. } `json:"output"`
  3780. RefmsgTime string `json:"refmsg_time"`
  3781. RespondTime string `json:"respond_time"`
  3782. Signtype interface{} `json:"signtype"`
  3783. WarnInfo interface{} `json:"warn_info"`
  3784. }
  3785. type ResultFourteen struct {
  3786. ErrMsg string `json:"err_msg"`
  3787. InfRefmsgid string `json:"inf_refmsgid"`
  3788. Infcode int64 `json:"infcode"`
  3789. Output struct {
  3790. } `json:"output"`
  3791. RefmsgTime string `json:"refmsg_time"`
  3792. RespondTime string `json:"respond_time"`
  3793. Signtype interface{} `json:"signtype"`
  3794. WarnInfo interface{} `json:"warn_info"`
  3795. }
  3796. type ResultFourteen10265 struct {
  3797. ErrMsg string `json:"err_msg"`
  3798. InfRefmsgid string `json:"inf_refmsgid"`
  3799. Infcode string `json:"infcode"`
  3800. Output struct {
  3801. } `json:"output"`
  3802. RefmsgTime string `json:"refmsg_time"`
  3803. RespondTime string `json:"respond_time"`
  3804. Signtype interface{} `json:"signtype"`
  3805. WarnInfo interface{} `json:"warn_info"`
  3806. }
  3807. type ResultSixteen struct {
  3808. Cainfo string `json:"cainfo"`
  3809. ErrMsg string `json:"err_msg"`
  3810. InfRefmsgid string `json:"inf_refmsgid"`
  3811. Infcode int64 `json:"infcode"`
  3812. Output struct {
  3813. Setldetail []interface{} `json:"setldetail"`
  3814. Setlinfo struct {
  3815. MdtrtID string `json:"mdtrt_id"`
  3816. SetlID string `json:"setl_id"`
  3817. ClrOptins string `json:"clr_optins"`
  3818. SetlTime string `json:"setl_time"`
  3819. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3820. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3821. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3822. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3823. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3824. ActPayDedc float64 `json:"act_pay_dedc"`
  3825. HifpPay float64 `json:"hifp_pay"`
  3826. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3827. Lfpay float64 `json:"selfpay"`
  3828. CvlservPay float64 `json:"cvlserv_pay"`
  3829. HifesPay float64 `json:"hifes_pay"`
  3830. HifmiPay float64 `json:"hifmi_pay"`
  3831. HifobPay float64 `json:"hifob_pay"`
  3832. MafPay float64 `json:"maf_pay"`
  3833. OthPay float64 `json:"oth_pay"`
  3834. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3835. PsnPartAmt float64 `json:"psn_part_amt"`
  3836. AcctPay float64 `json:"acct_pay"`
  3837. Balc float64 `json:"balc"`
  3838. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3839. HospPartAmt float64 `json:"hosp_part_amt"`
  3840. MedinsSetlID string `json:"medins_setl_id"`
  3841. PdnCashPay string `json:"pdn_cash_pay"`
  3842. } `json:"setlinfo"`
  3843. } `json:"output"`
  3844. RefmsgTime string `json:"refmsg_time"`
  3845. RespondTime string `json:"respond_time"`
  3846. Signtype interface{} `json:"signtype"`
  3847. WarnMsg interface{} `json:"warn_msg"`
  3848. }
  3849. type ResultSixteen10265 struct {
  3850. Cainfo string `json:"cainfo"`
  3851. ErrMsg string `json:"err_msg"`
  3852. InfRefmsgid string `json:"inf_refmsgid"`
  3853. Infcode string `json:"infcode"`
  3854. Output struct {
  3855. Setldetail []interface{} `json:"setldetail"`
  3856. Setlinfo struct {
  3857. MdtrtID string `json:"mdtrt_id"`
  3858. SetlID string `json:"setl_id"`
  3859. ClrOptins string `json:"clr_optins"`
  3860. SetlTime string `json:"setl_time"`
  3861. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3862. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3863. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3864. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3865. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3866. ActPayDedc float64 `json:"act_pay_dedc"`
  3867. HifpPay float64 `json:"hifp_pay"`
  3868. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3869. Lfpay float64 `json:"selfpay"`
  3870. CvlservPay float64 `json:"cvlserv_pay"`
  3871. HifesPay float64 `json:"hifes_pay"`
  3872. HifmiPay float64 `json:"hifmi_pay"`
  3873. HifobPay float64 `json:"hifob_pay"`
  3874. MafPay float64 `json:"maf_pay"`
  3875. OthPay float64 `json:"oth_pay"`
  3876. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3877. PsnPartAmt float64 `json:"psn_part_amt"`
  3878. AcctPay float64 `json:"acct_pay"`
  3879. Balc float64 `json:"balc"`
  3880. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3881. HospPartAmt float64 `json:"hosp_part_amt"`
  3882. MedinsSetlID string `json:"medins_setl_id"`
  3883. PdnCashPay string `json:"pdn_cash_pay"`
  3884. } `json:"setlinfo"`
  3885. } `json:"output"`
  3886. RefmsgTime string `json:"refmsg_time"`
  3887. RespondTime string `json:"respond_time"`
  3888. Signtype interface{} `json:"signtype"`
  3889. WarnMsg interface{} `json:"warn_msg"`
  3890. }
  3891. type ResultSeventeen struct {
  3892. ErrMsg string `json:"err_msg"`
  3893. InfRefmsgid string `json:"inf_refmsgid"`
  3894. Infcode int64 `json:"infcode"`
  3895. Output struct {
  3896. SetlListId string `json:"setl_list_id"`
  3897. } `json:"output"`
  3898. RefmsgTime string `json:"refmsg_time"`
  3899. RespondTime string `json:"respond_time"`
  3900. Signtype string `json:"signtype"`
  3901. WarnInfo string `json:"warn_info"`
  3902. }
  3903. type Result90991 struct {
  3904. ErrMsg string `json:"err_msg"`
  3905. InfRefmsgid string `json:"inf_refmsgid"`
  3906. Infcode int64 `json:"infcode"`
  3907. Output struct {
  3908. Result struct {
  3909. PsnNo string `json:"psn_no"`
  3910. CardStat string `json:"card_stat"`
  3911. Certno string `json:"certno"`
  3912. PsnName string `json:"psn_name"`
  3913. CheckStat string `json:"check_stat"`
  3914. } `json:"result"`
  3915. } `json:"output"`
  3916. RefmsgTime string `json:"refmsg_time"`
  3917. RespondTime string `json:"respond_time"`
  3918. Signtype interface{} `json:"signtype"`
  3919. WarnInfo interface{} `json:"warn_info"`
  3920. }
  3921. type Result90100 struct {
  3922. ErrMsg string `json:"err_msg"`
  3923. InfRefmsgid string `json:"inf_refmsgid"`
  3924. Infcode int64 `json:"infcode"`
  3925. Output struct {
  3926. PoolareaNo string `json:"poolarea_no"`
  3927. PoolareaNoName string `json:"poolarea_no_name"`
  3928. Insutype string `json:"insutype"`
  3929. InsutypeName string `json:"insutype_name"`
  3930. ClctType string `json:"clct_type"`
  3931. ClctTypeName string `json:"clct_type_name"`
  3932. ClctFlag string `json:"clct_flag"`
  3933. ClctFlagName string `json:"clct_flag_name"`
  3934. AccrymBegn string `json:"accrym_begn"`
  3935. AccrymEnd string `json:"accrym_end"`
  3936. ClctTime string `json:"clct_time"`
  3937. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  3938. } `json:"output"`
  3939. RefmsgTime string `json:"refmsg_time"`
  3940. RespondTime string `json:"respond_time"`
  3941. Signtype interface{} `json:"signtype"`
  3942. WarnInfo interface{} `json:"warn_info"`
  3943. }
  3944. type Custom struct {
  3945. DetItemFeeSumamt string
  3946. Cut string
  3947. FeedetlSn string
  3948. Price string
  3949. MedListCodg string
  3950. Type int64
  3951. AdviceId int64
  3952. ProjectId int64
  3953. ItemId int64
  3954. }
  3955. type Result5301 struct {
  3956. ErrMsg string `json:"err_msg"`
  3957. InfRefmsgid string `json:"inf_refmsgid"`
  3958. Infcode int64 `json:"infcode"`
  3959. Output struct {
  3960. Result []struct {
  3961. OpspDiseCode string `json:"opsp_dise_code"`
  3962. OpspDiseName string `json:"opsp_dise_name"`
  3963. Begndate string `json:"begndate"`
  3964. Enddate string `json:"enddate"`
  3965. } `json:"feedetail"`
  3966. } `json:"output"`
  3967. RefmsgTime string `json:"refmsg_time"`
  3968. RespondTime string `json:"respond_time"`
  3969. Signtype interface{} `json:"signtype"`
  3970. WarnInfo interface{} `json:"warn_info"`
  3971. }
  3972. type Result5301For10265 struct {
  3973. ErrMsg string `json:"err_msg"`
  3974. InfRefmsgid string `json:"inf_refmsgid"`
  3975. Infcode string `json:"infcode"`
  3976. Output struct {
  3977. Result []struct {
  3978. OpspDiseCode string `json:"opsp_dise_code"`
  3979. OpspDiseName string `json:"opsp_dise_name"`
  3980. Begndate string `json:"begndate"`
  3981. Enddate string `json:"enddate"`
  3982. } `json:"feedetail"`
  3983. } `json:"output"`
  3984. RefmsgTime string `json:"refmsg_time"`
  3985. RespondTime string `json:"respond_time"`
  3986. Signtype interface{} `json:"signtype"`
  3987. WarnInfo interface{} `json:"warn_info"`
  3988. }
  3989. //获取个人信息----挂号-----上传就诊信息
  3990. func (c *HisApiController) GetRegisterInfo() {
  3991. id, _ := c.GetInt64("id")
  3992. record_time := c.GetString("record_time")
  3993. settlementValue, _ := c.GetInt64("settlement_value")
  3994. medical_insurance_card := c.GetString("medical_insurance_card")
  3995. name := c.GetString("name")
  3996. id_card_type, _ := c.GetInt64("id_card_type")
  3997. certificates, _ := c.GetInt64("certificates")
  3998. medical_care, _ := c.GetInt64("medical_care")
  3999. birthday := c.GetString("birthday")
  4000. id_card := c.GetString("id_card")
  4001. register_type, _ := c.GetInt64("register")
  4002. doctor, _ := c.GetInt64("doctor")
  4003. department, _ := c.GetInt64("department")
  4004. gender, _ := c.GetInt64("sex")
  4005. registration_fee, _ := c.GetFloat("registration_fee")
  4006. medical_expenses, _ := c.GetFloat("medical_expenses")
  4007. social_type, _ := c.GetInt64("social_type")
  4008. med_type := c.GetString("social_type")
  4009. admin_user_id, _ := c.GetInt64("admin_user_id")
  4010. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4011. timeLayout := "2006-01-02"
  4012. loc, _ := time.LoadLocation("Local")
  4013. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4014. birthUnix := birthdays.Unix()
  4015. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4016. if err != nil {
  4017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4018. return
  4019. }
  4020. recordDateTime := theTime.Unix()
  4021. adminInfo := c.GetAdminUserInfo()
  4022. var patient service.Patients
  4023. if id == 0 {
  4024. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4025. } else {
  4026. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4027. }
  4028. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4029. if patientPrescription.ID == 0 {
  4030. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4031. }
  4032. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4033. if patient.ID == 0 {
  4034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4035. return
  4036. }
  4037. if len(patient.IdCardNo) == 0 {
  4038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4039. return
  4040. }
  4041. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4042. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4043. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4044. //就诊结算未完成,不能进行二次挂号
  4045. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4046. if len(his) >= 1 {
  4047. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  4048. if len(his) >= 1 && order.ID == 0 {
  4049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  4050. return
  4051. }
  4052. }
  4053. //var register_log string
  4054. if config.IsOpen == 1 {
  4055. var res ResultTwo
  4056. var res10265 ResultTwo10265
  4057. var PsnNo string
  4058. var PsnCertType string
  4059. var Certno string
  4060. var PsnName string
  4061. var Gend string
  4062. var Naty string
  4063. var Brdy string
  4064. var Age float64
  4065. var infoStr string
  4066. var idetinfoStr string
  4067. var infocode int64
  4068. var verify_number string
  4069. fmt.Println(verify_number)
  4070. if miConfig.MdtrtareaAdmvs == "421300" {
  4071. psn_info, _ := service.GetPsnByPatientId(id)
  4072. PsnNo = psn_info.PsnNo
  4073. PsnCertType = psn_info.PsnCertType
  4074. Certno = psn_info.Certno
  4075. PsnName = psn_info.PsnName
  4076. Gend = psn_info.Gend
  4077. Naty = psn_info.Naty
  4078. Brdy = psn_info.Brdy
  4079. Age = psn_info.Age
  4080. infoStr = psn_info.Insuinfo
  4081. idetinfoStr = psn_info.Idetinfo
  4082. infocode = 0
  4083. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4084. psn_info, _ := service.GetPsnByPatientId(id)
  4085. PsnNo = psn_info.PsnNo
  4086. PsnCertType = psn_info.PsnCertType
  4087. Certno = psn_info.Certno
  4088. PsnName = psn_info.PsnName
  4089. Gend = psn_info.Gend
  4090. Naty = psn_info.Naty
  4091. Brdy = psn_info.Brdy
  4092. Age = psn_info.Age
  4093. infoStr = psn_info.Insuinfo
  4094. idetinfoStr = psn_info.Idetinfo
  4095. infocode = 0
  4096. verify_number = psn_info.VerifyNumber
  4097. } else {
  4098. var result string
  4099. var requestLog string
  4100. if miConfig.UserOrgId == 10138 {
  4101. 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)
  4102. } else {
  4103. 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)
  4104. }
  4105. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4106. if miConfig.Code == "H15049901371" {
  4107. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4108. utils.ErrorLog("解析失败:%v", err)
  4109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4110. return
  4111. }
  4112. res.ErrMsg = res10265.ErrMsg
  4113. res.Output = res10265.Output
  4114. res.InfRefmsgid = res10265.InfRefmsgid
  4115. } else {
  4116. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4117. utils.ErrorLog("解析失败:%v", err)
  4118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4119. return
  4120. }
  4121. }
  4122. PsnNo = res.Output.Baseinfo.PsnNo
  4123. PsnCertType = res.Output.Baseinfo.PsnCertType
  4124. Certno = res.Output.Baseinfo.Certno
  4125. PsnName = res.Output.Baseinfo.PsnName
  4126. Gend = res.Output.Baseinfo.Gend
  4127. Naty = res.Output.Baseinfo.Naty
  4128. Brdy = res.Output.Baseinfo.Brdy
  4129. Age = res.Output.Baseinfo.Age
  4130. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4131. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4132. infoStr = string(Iinfos)
  4133. idetinfoStr = string(Idetinfos)
  4134. if miConfig.Code == "H15049901371" {
  4135. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  4136. } else {
  4137. infocode = res.Infcode
  4138. }
  4139. }
  4140. if infocode == 0 {
  4141. his := models.VMHisPatient{
  4142. Name: name,
  4143. Gender: gender,
  4144. Birthday: birthUnix,
  4145. MedicalTreatmentType: medical_care,
  4146. IdType: certificates,
  4147. IdCardNo: id_card,
  4148. BalanceAccountsType: settlementValue,
  4149. SocialType: social_type,
  4150. MedicalInsuranceNumber: medical_insurance_card,
  4151. RegisterType: register_type,
  4152. RegisterCost: registration_fee,
  4153. TreatmentCost: medical_expenses,
  4154. Status: 1,
  4155. Ctime: time.Now().Unix(),
  4156. Mtime: time.Now().Unix(),
  4157. PsnNo: PsnNo,
  4158. PsnCertType: PsnCertType,
  4159. Certno: Certno,
  4160. PsnName: PsnName,
  4161. Gend: Gend,
  4162. Naty: Naty,
  4163. Brdy: Brdy,
  4164. Age: Age,
  4165. Iinfo: infoStr,
  4166. Idetinfo: idetinfoStr,
  4167. PatientId: patient.ID,
  4168. RecordDate: theTime.Unix(),
  4169. UserOrgId: adminInfo.CurrentOrgId,
  4170. AdminUserId: admin_user_id,
  4171. IsReturn: 1,
  4172. IdCardType: id_card_type,
  4173. Doctor: doctor,
  4174. Departments: department,
  4175. }
  4176. timestamp := time.Now().Unix()
  4177. tempTime := time.Unix(timestamp, 0)
  4178. timeFormat := tempTime.Format("20060102150405")
  4179. chrgBchno := rand.Intn(100000) + 10000
  4180. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4181. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  4182. department, _ := service.GetDepartMentDetail(department)
  4183. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  4184. IdCardNo := ""
  4185. if id_card_type == 1 {
  4186. // IdCardNo = medical_insurance_card
  4187. IdCardNo = patient.IdCardNo
  4188. } else {
  4189. IdCardNo = patient.IdCardNo
  4190. }
  4191. var rf []*ResultFive
  4192. json.Unmarshal([]byte(his.Iinfo), &rf)
  4193. var insutypes []*ResultFive
  4194. var insutype string
  4195. var insuplc_admdvs_temp string
  4196. var is390 int = 0
  4197. var is310 int = 0
  4198. for _, item := range rf {
  4199. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4200. insutypes = append(insutypes, item)
  4201. }
  4202. }
  4203. if len(insutypes) == 1 {
  4204. insutype = insutypes[0].Insutype
  4205. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4206. } else {
  4207. for _, i := range insutypes {
  4208. if i.Insutype == "390" {
  4209. is390 = 1
  4210. }
  4211. if i.Insutype == "310" {
  4212. is310 = 1
  4213. }
  4214. }
  4215. }
  4216. if is390 == 1 {
  4217. insutype = "390"
  4218. }
  4219. if is310 == 1 {
  4220. insutype = "310"
  4221. }
  4222. if len(insutypes) == 0 {
  4223. insutype = "310"
  4224. }
  4225. if len(insutypes) == 2 {
  4226. insutype = med_type
  4227. }
  4228. if len(med_type) > 0 {
  4229. insutype = med_type
  4230. }
  4231. //for _, item := range rf {
  4232. // if item.Insutype == insutype {
  4233. // insuplc_admdvs = item.InsuplcAdmdvs
  4234. // }
  4235. //}
  4236. var infocode int64
  4237. var resThree ResultThree
  4238. var resThree10265 ResultThree10265
  4239. if len(insuplc_admdvs) == 0 {
  4240. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  4241. } else {
  4242. insuplc_admdvs_temp = insuplc_admdvs
  4243. }
  4244. if miConfig.MdtrtareaAdmvs == "421300" {
  4245. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  4246. "&org_name=" + miConfig.OrgName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4247. "&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
  4248. resp, requestErr := http.Get(api)
  4249. if requestErr != nil {
  4250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4251. return
  4252. }
  4253. body, ioErr := ioutil.ReadAll(resp.Body)
  4254. if ioErr != nil {
  4255. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4257. return
  4258. }
  4259. var respJSON map[string]interface{}
  4260. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4261. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4263. return
  4264. }
  4265. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4266. result, _ := json.Marshal(respJSON)
  4267. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4268. utils.ErrorLog("解析失败:%v", err)
  4269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4270. return
  4271. }
  4272. infocode = resThree.Infcode
  4273. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4274. psn_info, _ := service.GetPsnByPatientId(id)
  4275. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4276. var cert_no string
  4277. if id_card_type == 3 {
  4278. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  4279. cert_no = IdCardNo
  4280. } else {
  4281. bas := strings.Split(psn_info.CardInfo, "|")
  4282. cert_no = bas[2]
  4283. }
  4284. var api string
  4285. if miConfig.MdtrtareaAdmvs == "320921" {
  4286. api = "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4287. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4288. "&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
  4289. } else {
  4290. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4291. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4292. "&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
  4293. }
  4294. resp, requestErr := http.Get(api)
  4295. if requestErr != nil {
  4296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4297. return
  4298. }
  4299. body, ioErr := ioutil.ReadAll(resp.Body)
  4300. if ioErr != nil {
  4301. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4303. return
  4304. }
  4305. var respJSON map[string]interface{}
  4306. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4307. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4309. return
  4310. }
  4311. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4312. result, _ := json.Marshal(respJSON)
  4313. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4314. utils.ErrorLog("解析失败:%v", err)
  4315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4316. return
  4317. }
  4318. resThree.ErrMsg = resThree10265.ErrMsg
  4319. resThree.Output = resThree10265.Output
  4320. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4321. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4322. } else {
  4323. 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)
  4324. saveLog(result, requestLog, "2201A", "挂号")
  4325. if miConfig.Code == "H15049901371" {
  4326. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4327. utils.ErrorLog("解析失败:%v", err)
  4328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4329. return
  4330. }
  4331. resThree.ErrMsg = resThree10265.ErrMsg
  4332. resThree.Output = resThree10265.Output
  4333. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4334. } else {
  4335. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4336. utils.ErrorLog("解析失败:%v", err)
  4337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4338. return
  4339. }
  4340. }
  4341. if miConfig.Code == "H15049901371" {
  4342. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4343. } else {
  4344. infocode = resThree.Infcode
  4345. }
  4346. }
  4347. if infocode != 0 {
  4348. adminUser := c.GetAdminUserInfo()
  4349. errlog := &models.HisOrderError{
  4350. UserOrgId: adminUser.CurrentOrgId,
  4351. Ctime: time.Now().Unix(),
  4352. Mtime: time.Now().Unix(),
  4353. ErrMsg: resThree.ErrMsg,
  4354. Status: 1,
  4355. PatientId: id,
  4356. RecordTime: recordDateTime,
  4357. Stage: 2,
  4358. }
  4359. service.CreateErrMsgLog(errlog)
  4360. c.ServeSuccessJSON(map[string]interface{}{
  4361. "failed_code": -10,
  4362. "msg": resThree.ErrMsg,
  4363. })
  4364. return
  4365. }
  4366. his.Number = resThree.Output.Data.MdtrtID
  4367. his.PsnNo = resThree.Output.Data.PsnNo
  4368. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  4369. his.IdCardNo = patient.IdCardNo
  4370. his.PhoneNumber = patient.Phone
  4371. his.UserOrgId = adminInfo.CurrentOrgId
  4372. his.Insutype = insutype
  4373. his.Ctime = time.Now().Unix()
  4374. his.Mtime = time.Now().Unix()
  4375. his.InsuplcAdmdvs = insuplc_admdvs_temp
  4376. his.Status = 1
  4377. service.UpdateHisPatientStatus(&his)
  4378. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  4379. c.ServeSuccessJSON(map[string]interface{}{
  4380. "his_info": his,
  4381. })
  4382. } else {
  4383. adminUser := c.GetAdminUserInfo()
  4384. errlog := &models.HisOrderError{
  4385. UserOrgId: adminUser.CurrentOrgId,
  4386. Ctime: time.Now().Unix(),
  4387. Mtime: time.Now().Unix(),
  4388. ErrMsg: res.ErrMsg,
  4389. Status: 1,
  4390. PatientId: id,
  4391. RecordTime: recordDateTime,
  4392. Stage: 1,
  4393. }
  4394. service.CreateErrMsgLog(errlog)
  4395. c.ServeSuccessJSON(map[string]interface{}{
  4396. "failed_code": -10,
  4397. "msg": res.ErrMsg,
  4398. })
  4399. return
  4400. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  4401. }
  4402. }
  4403. }
  4404. //上传明细----预结算----确认订单
  4405. func (c *HisApiController) GetUploadInfo() {
  4406. id, _ := c.GetInt64("id")
  4407. record_time := c.GetString("record_time")
  4408. his_patient_id, _ := c.GetInt64("his_patient_id")
  4409. order_id, _ := c.GetInt64("order_id")
  4410. pay_way, _ := c.GetInt64("pay_way")
  4411. pay_price, _ := c.GetFloat("pay_price")
  4412. pay_card_no := c.GetString("pay_card_no")
  4413. discount_price, _ := c.GetFloat("discount_price")
  4414. preferential_price, _ := c.GetFloat("preferential_price")
  4415. reality_price, _ := c.GetFloat("reality_price")
  4416. found_price, _ := c.GetFloat("found_price")
  4417. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  4418. private_price, _ := c.GetFloat("private_price")
  4419. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4420. admin_user_id, _ := c.GetInt64("admin_user_id")
  4421. fapiao_code := c.GetString("fapiao_code")
  4422. fapiao_number := c.GetString("fapiao_number")
  4423. diagnosis_id := c.GetString("diagnosis")
  4424. sick_type, _ := c.GetInt64("sick_type")
  4425. reg_type, _ := c.GetInt64("p_type")
  4426. begin_time := c.GetString("begin_time")
  4427. id_str := c.GetString("ids")
  4428. ids_arr := strings.Split(id_str, ",")
  4429. timeLayout := "2006-01-02"
  4430. loc, _ := time.LoadLocation("Local")
  4431. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4432. if err != nil {
  4433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4434. return
  4435. }
  4436. recordDateTime := theTime.Unix()
  4437. adminUser := c.GetAdminUserInfo()
  4438. var tempOrder models.HisOrder
  4439. tempOrder, _ = service.GetHisOrderByID(order_id)
  4440. var prescriptions []*models.HisPrescription
  4441. var start_time int64
  4442. var end_time int64
  4443. //if adminUser.CurrentOrgId == 10106{
  4444. // if len(fapiao_code) == 0{
  4445. // fapiao_code = "144072080589"
  4446. // }
  4447. // if len(fapiao_number) == 0{
  4448. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  4449. // if order.ID == 0{
  4450. // fapiao_number = "00001520"
  4451. // }else{
  4452. // //fapiao_code = "00001520"
  4453. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  4454. // var zero string
  4455. // if fpNumber >= 1000{
  4456. // zero = "0000" + strconv.Itoa(fpNumber)
  4457. // }else if fpNumber >= 10000{
  4458. // zero = "000" + strconv.Itoa(fpNumber)
  4459. // } else if fpNumber >= 100000{
  4460. // zero = "00" + strconv.Itoa(fpNumber)
  4461. // } else if fpNumber >= 1000000{
  4462. // zero = "0" + strconv.Itoa(fpNumber)
  4463. // }else {
  4464. // zero = strconv.Itoa(fpNumber)
  4465. // }
  4466. // fapiao_number = zero
  4467. // }
  4468. // }
  4469. //}
  4470. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4471. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4472. var patientPrescription models.HisPrescriptionInfo
  4473. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4474. if patientPrescription.ID == 0 {
  4475. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4476. }
  4477. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4478. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4479. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4480. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4481. var config []*models.HisXtDiagnoseConfig
  4482. for _, item := range diagnosis_ids {
  4483. id, _ := strconv.ParseInt(item, 10, 64)
  4484. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4485. config = append(config, &diagnosisConfig)
  4486. }
  4487. sickConfig, _ := service.FindSickById(sick_type)
  4488. //if tempOrder.ID == 0 {
  4489. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  4490. //}
  4491. if tempOrder.ID == 0 {
  4492. var result string
  4493. var requestLog string
  4494. var res2 ResultSix
  4495. var ressix10265 ResultSix10265
  4496. if miConfig.MdtrtareaAdmvs == "421300" {
  4497. data := make(map[string]interface{})
  4498. client := &http.Client{}
  4499. data["psn_no"] = his.PsnNo
  4500. data["mdtrt_id"] = his.Number
  4501. data["doctor"] = roles.UserName
  4502. data["department"] = department.Name
  4503. data["org_name"] = miConfig.OrgName
  4504. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4505. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4506. data["fixmedins_code"] = miConfig.Code
  4507. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4508. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4509. data["secret_key"] = miConfig.SecretKey
  4510. data["sick_code"] = sickConfig.CountryCode
  4511. data["sick_name"] = sickConfig.ClassName
  4512. data["dept"] = strconv.FormatInt(department.ID, 10)
  4513. data["config"] = config
  4514. data["begin_time"] = begin_time
  4515. bytesData, _ := json.Marshal(data)
  4516. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  4517. resp, _ := client.Do(req)
  4518. defer resp.Body.Close()
  4519. body, ioErr := ioutil.ReadAll(resp.Body)
  4520. if ioErr != nil {
  4521. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4523. return
  4524. }
  4525. var respJSON map[string]interface{}
  4526. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4527. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4529. return
  4530. }
  4531. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4532. userJSONBytes, _ := json.Marshal(respJSON)
  4533. fmt.Println("log")
  4534. fmt.Println(string(userJSONBytes))
  4535. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4536. utils.ErrorLog("解析失败:%v", err)
  4537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4538. return
  4539. }
  4540. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4541. //江苏地区国家医保医疗类别
  4542. //职工透析:医疗类别选特殊情况门诊9933
  4543. //居民血透门慢: 医疗类别选门诊慢病1402
  4544. //var med_type string
  4545. //if his.Insutype == "310" {
  4546. // if reg_type == 14 {
  4547. // med_type = "9933"
  4548. // } else if reg_type == 11 {
  4549. // med_type = "11"
  4550. //
  4551. // }
  4552. //} else if his.Insutype == "390" {
  4553. // if reg_type == 14 {
  4554. // med_type = "1402"
  4555. // } else if reg_type == 11 {
  4556. // med_type = "11"
  4557. // }
  4558. //}
  4559. data := make(map[string]interface{})
  4560. client := &http.Client{}
  4561. data["psn_no"] = his.PsnNo
  4562. data["mdtrt_id"] = his.Number
  4563. data["doctor"] = roles.UserName
  4564. data["department"] = department.Name
  4565. data["org_name"] = miConfig.OrgName
  4566. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4567. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4568. data["fixmedins_code"] = miConfig.Code
  4569. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4570. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4571. data["secret_key"] = miConfig.SecretKey
  4572. data["sick_code"] = sickConfig.CountryCode
  4573. data["sick_name"] = sickConfig.ClassName
  4574. data["url"] = miConfig.Url
  4575. data["ak"] = miConfig.AccessKey
  4576. data["begin_time"] = begin_time
  4577. data["cainfo"] = miConfig.Cainfo
  4578. data["dept"] = strconv.FormatInt(department.ID, 10)
  4579. data["config"] = config
  4580. bytesData, _ := json.Marshal(data)
  4581. var req *http.Request
  4582. if miConfig.MdtrtareaAdmvs == "320921" {
  4583. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4584. //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 +
  4585. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  4586. } else {
  4587. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4588. }
  4589. resp, _ := client.Do(req)
  4590. defer resp.Body.Close()
  4591. body, ioErr := ioutil.ReadAll(resp.Body)
  4592. if ioErr != nil {
  4593. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4595. return
  4596. }
  4597. var respJSON map[string]interface{}
  4598. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4599. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4601. return
  4602. }
  4603. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4604. userJSONBytes, _ := json.Marshal(respJSON)
  4605. fmt.Println("log")
  4606. fmt.Println(string(userJSONBytes))
  4607. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  4608. utils.ErrorLog("解析失败:%v", err)
  4609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4610. return
  4611. }
  4612. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4613. res2.Output = ressix10265.Output
  4614. res2.ErrMsg = ressix10265.ErrMsg
  4615. res2.Cainfo = ressix10265.Cainfo
  4616. res2.WarnMsg = ressix10265.WarnMsg
  4617. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4618. res2.Infcode = infocode
  4619. } else {
  4620. if miConfig.MdtrtareaAdmvs == "440781" { //
  4621. 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)
  4622. } else {
  4623. if miConfig.Code == "H15049901371" {
  4624. //赤峰地区国家医保医疗类别
  4625. //职工透析:医疗类别选特殊情况门诊990502
  4626. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4627. var med_type string
  4628. if his.Insutype == "390" {
  4629. if reg_type == 14 {
  4630. med_type = "9933"
  4631. } else if reg_type == 11 {
  4632. med_type = "11"
  4633. }
  4634. } else if his.Insutype == "310" {
  4635. if reg_type == 14 {
  4636. med_type = "990502"
  4637. } else if reg_type == 11 {
  4638. med_type = "11"
  4639. }
  4640. }
  4641. 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)
  4642. } else {
  4643. 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)
  4644. }
  4645. }
  4646. saveLog(result, requestLog, "2203", "上传就诊信息")
  4647. var respJSON2 map[string]interface{}
  4648. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4649. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4651. return
  4652. }
  4653. userJSONBytes2, _ := json.Marshal(respJSON2)
  4654. if miConfig.Code == "H15049901371" {
  4655. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  4656. utils.ErrorLog("解析失败:%v", err)
  4657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4658. return
  4659. }
  4660. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4661. res2.Output = ressix10265.Output
  4662. res2.ErrMsg = ressix10265.ErrMsg
  4663. res2.Cainfo = ressix10265.Cainfo
  4664. res2.WarnMsg = ressix10265.WarnMsg
  4665. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4666. res2.Infcode = infocode
  4667. } else {
  4668. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4669. utils.ErrorLog("解析失败:%v", err)
  4670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4671. return
  4672. }
  4673. }
  4674. }
  4675. if res2.Infcode != 0 {
  4676. adminUser := c.GetAdminUserInfo()
  4677. errlog := &models.HisOrderError{
  4678. UserOrgId: adminUser.CurrentOrgId,
  4679. Ctime: time.Now().Unix(),
  4680. Mtime: time.Now().Unix(),
  4681. ErrMsg: res2.ErrMsg,
  4682. Status: 1,
  4683. PatientId: id,
  4684. RecordTime: recordDateTime,
  4685. Stage: 3,
  4686. }
  4687. service.CreateErrMsgLog(errlog)
  4688. c.ServeSuccessJSON(map[string]interface{}{
  4689. "failed_code": -10,
  4690. "msg": res2.ErrMsg,
  4691. })
  4692. return
  4693. } else {
  4694. his.Diagnosis = diagnosis_id
  4695. his.SickType = sickConfig.ID
  4696. //var p_type int64
  4697. //if reg_type == 1111 || reg_type == 1112 {
  4698. // p_type = 11
  4699. //
  4700. //}
  4701. his.PType = fmt.Sprintf("%d", reg_type)
  4702. service.UpdateHisPatientThree(&his)
  4703. data := make(map[string]interface{})
  4704. if settle_accounts_type == 1 { //日结
  4705. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  4706. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  4707. } else {
  4708. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  4709. }
  4710. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  4711. data["pre"] = prescriptions
  4712. } else { //月结
  4713. start_time_str := c.GetString("start_time")
  4714. end_time_str := c.GetString("end_time")
  4715. timeLayout := "2006-01-02"
  4716. loc, _ := time.LoadLocation("Local")
  4717. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4718. if err != nil {
  4719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4720. return
  4721. }
  4722. recordStartTime := theStartTime.Unix()
  4723. start_time = recordStartTime
  4724. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4725. if err != nil {
  4726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4727. return
  4728. }
  4729. recordEndTime := theEndTime.Unix()
  4730. end_time = recordEndTime
  4731. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  4732. data["pre"] = prescriptions
  4733. }
  4734. timestamp := time.Now().Unix()
  4735. tempTime := time.Unix(timestamp, 0)
  4736. timeFormat := tempTime.Format("20060102150405")
  4737. chrgBchno := rand.Intn(100000) + 10000
  4738. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4739. strconv.FormatInt(his.PatientId, 10)
  4740. client := &http.Client{}
  4741. data["psn_no"] = his.PsnNo
  4742. data["mdtrt_id"] = his.Number
  4743. data["chrg_bchno"] = chrg_bchno
  4744. data["org_name"] = miConfig.OrgName
  4745. data["doctor"] = roles.UserName
  4746. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4747. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4748. data["fixmedins_code"] = miConfig.Code
  4749. //if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  4750. // data["dept_code"] = "15"
  4751. //} else {
  4752. data["dept_code"] = department.Number
  4753. //}
  4754. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4755. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4756. data["secret_key"] = miConfig.SecretKey
  4757. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  4758. data["url"] = miConfig.Url
  4759. data["ak"] = miConfig.AccessKey
  4760. data["new_doctor_name"] = patientPrescription.Doctor
  4761. data["diag_code"] = sickConfig.CountryCode
  4762. data["cainfo"] = miConfig.Cainfo
  4763. var ids []int64
  4764. for _, item := range prescriptions {
  4765. ids = append(ids, item.ID)
  4766. }
  4767. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4768. if config.IsOpen == 1 { //对接了医保,走医保流程
  4769. var res ResultFour
  4770. var resFour10265 ResultFour10265
  4771. if miConfig.MdtrtareaAdmvs == "421300" {
  4772. bytesData, _ := json.Marshal(data)
  4773. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  4774. resp, _ := client.Do(req)
  4775. defer resp.Body.Close()
  4776. body, ioErr := ioutil.ReadAll(resp.Body)
  4777. if ioErr != nil {
  4778. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4780. return
  4781. }
  4782. var respJSON map[string]interface{}
  4783. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4784. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4786. return
  4787. }
  4788. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4789. userJSONBytes, _ := json.Marshal(respJSON)
  4790. fmt.Println("log")
  4791. fmt.Println(string(userJSONBytes))
  4792. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4793. utils.ErrorLog("解析失败:%v", err)
  4794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4795. return
  4796. }
  4797. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4798. bytesData, _ := json.Marshal(data)
  4799. var req *http.Request
  4800. if miConfig.MdtrtareaAdmvs == "320921" {
  4801. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4802. } else {
  4803. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4804. }
  4805. resp, _ := client.Do(req)
  4806. defer resp.Body.Close()
  4807. body, ioErr := ioutil.ReadAll(resp.Body)
  4808. if ioErr != nil {
  4809. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4811. return
  4812. }
  4813. var respJSON map[string]interface{}
  4814. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4815. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4817. return
  4818. }
  4819. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4820. userJSONBytes, _ := json.Marshal(respJSON)
  4821. fmt.Println("log")
  4822. fmt.Println(string(userJSONBytes))
  4823. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4824. utils.ErrorLog("解析失败:%v", err)
  4825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4826. return
  4827. }
  4828. res.InfRefmsgid = resFour10265.InfRefmsgid
  4829. res.Output = resFour10265.Output
  4830. res.ErrMsg = resFour10265.ErrMsg
  4831. res.Cainfo = resFour10265.Cainfo
  4832. res.WarnMsg = resFour10265.WarnMsg
  4833. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4834. res.Infcode = infocode
  4835. } else {
  4836. if miConfig.Code == "H15049901371" {
  4837. 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)
  4838. var dat map[string]interface{}
  4839. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4840. fmt.Println(dat)
  4841. } else {
  4842. fmt.Println(err)
  4843. }
  4844. saveLog(result, request_log, "2204", "上传费用明细")
  4845. userJSONBytes, _ := json.Marshal(dat)
  4846. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4847. utils.ErrorLog("解析失败:%v", err)
  4848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4849. return
  4850. }
  4851. res.InfRefmsgid = resFour10265.InfRefmsgid
  4852. res.Output = resFour10265.Output
  4853. res.ErrMsg = resFour10265.ErrMsg
  4854. res.Cainfo = resFour10265.Cainfo
  4855. res.WarnMsg = resFour10265.WarnMsg
  4856. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4857. res.Infcode = infocode
  4858. } else {
  4859. 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)
  4860. var dat map[string]interface{}
  4861. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4862. fmt.Println(dat)
  4863. } else {
  4864. fmt.Println(err)
  4865. }
  4866. saveLog(result, request_log, "2204", "上传费用明细")
  4867. userJSONBytes, _ := json.Marshal(dat)
  4868. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4869. utils.ErrorLog("解析失败:%v", err)
  4870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4871. return
  4872. }
  4873. }
  4874. }
  4875. if res.Infcode == 0 {
  4876. order := &models.HisOrder{
  4877. UserOrgId: adminUser.CurrentOrgId,
  4878. HisPatientId: his.ID,
  4879. PatientId: his.PatientId,
  4880. SettleAccountsDate: recordDateTime,
  4881. MdtrtId: his.Number,
  4882. PsnNo: his.PsnNo,
  4883. MedType: strconv.FormatInt(reg_type, 10),
  4884. Ctime: time.Now().Unix(),
  4885. Mtime: time.Now().Unix(),
  4886. Status: 1,
  4887. Number: chrg_bchno,
  4888. Infcode: res.Infcode,
  4889. WarnMsg: res.WarnMsg,
  4890. Cainfo: res.Cainfo,
  4891. ErrMsg: res.ErrMsg,
  4892. RespondTime: res.RefmsgTime,
  4893. InfRefmsgid: res.InfRefmsgid,
  4894. OrderStatus: 1,
  4895. PayWay: pay_way,
  4896. PayPrice: pay_price,
  4897. PayCardNo: pay_card_no,
  4898. DiscountPrice: discount_price,
  4899. PreferentialPrice: preferential_price,
  4900. RealityPrice: reality_price,
  4901. FoundPrice: found_price,
  4902. MedicalInsurancePrice: medical_insurance_price,
  4903. PrivatePrice: private_price,
  4904. IsMedicineInsurance: 1,
  4905. SettleType: settle_accounts_type,
  4906. SettleStartTime: start_time,
  4907. SettleEndTime: end_time,
  4908. Creator: roles.AdminUserId,
  4909. Modify: roles.AdminUserId,
  4910. FaPiaoNumber: fapiao_number,
  4911. FaPiaoCode: fapiao_code,
  4912. PType: 2,
  4913. Diagnosis: diagnosis_id,
  4914. }
  4915. err = service.CreateOrder(order)
  4916. if err != nil {
  4917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4918. return
  4919. }
  4920. for _, item := range res.Output.Result {
  4921. temp := strings.Split(item.FeedetlSn, "-")
  4922. var advice_id int64 = 0
  4923. var project_id int64 = 0
  4924. var types int64 = 0
  4925. id, _ := strconv.ParseInt(temp[2], 10, 64)
  4926. types, _ = strconv.ParseInt(temp[1], 10, 64)
  4927. if temp[1] == "1" {
  4928. advice_id = id
  4929. project_id = 0
  4930. } else if temp[1] == "2" {
  4931. advice_id = 0
  4932. project_id = id
  4933. }
  4934. info := &models.HisOrderInfo{
  4935. OrderNumber: order.Number,
  4936. FeedetlSn: item.FeedetlSn,
  4937. UploadDate: time.Now().Unix(),
  4938. AdviceId: advice_id,
  4939. DetItemFeeSumamt: item.DetItemFeeSumamt,
  4940. Cnt: item.Cnt,
  4941. Pric: float64(item.Pric),
  4942. PatientId: his.PatientId,
  4943. PricUplmtAmt: item.PricUplmtAmt,
  4944. SelfpayProp: item.SelfpayProp,
  4945. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4946. OverlmtAmt: item.OverlmtAmt,
  4947. PreselfpayAmt: item.PreselfpayAmt,
  4948. BasMednFlag: item.BasMednFlag,
  4949. MedChrgitmType: item.MedChrgitmType,
  4950. HiNegoDrugFlag: item.HiNegoDrugFlag,
  4951. Status: 1,
  4952. Memo: item.Memo,
  4953. Mtime: time.Now().Unix(),
  4954. InscpScpAmt: item.InscpScpAmt,
  4955. DrtReimFlag: item.DrtReimFlag,
  4956. Ctime: time.Now().Unix(),
  4957. ListSpItemFlag: item.ListSpItemFlag,
  4958. ChldMedcFlag: item.ChldMedcFlag,
  4959. LmtUsedFlag: item.LmtUsedFlag,
  4960. ChrgitmLv: item.ChrgitmLv,
  4961. UserOrgId: adminUser.CurrentOrgId,
  4962. HisPatientId: his.ID,
  4963. OrderId: order.ID,
  4964. ProjectId: project_id,
  4965. Type: types,
  4966. }
  4967. service.CreateOrderInfo(info)
  4968. }
  4969. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4970. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  4971. var total float64
  4972. for _, item := range prescriptions {
  4973. if item.Type == 1 { //药品
  4974. for _, subItem := range item.HisDoctorAdviceInfo {
  4975. total = total + (subItem.Price * subItem.PrescribingNumber)
  4976. }
  4977. }
  4978. if item.Type == 2 { //项目
  4979. for _, subItem := range item.HisPrescriptionProject {
  4980. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4981. total = total + (subItem.Price * cnt)
  4982. }
  4983. }
  4984. }
  4985. for _, item := range prescriptions {
  4986. for _, subItem := range item.HisAdditionalCharge {
  4987. total = total + (subItem.Price * float64(subItem.Count))
  4988. }
  4989. }
  4990. var allTotal string
  4991. if adminUser.CurrentOrgId == 9919 {
  4992. allTotal = fmt.Sprintf("%.4f", total)
  4993. } else {
  4994. allTotal = fmt.Sprintf("%.4f", total)
  4995. }
  4996. if res.Infcode == 0 {
  4997. var rf []*ResultFive
  4998. json.Unmarshal([]byte(his.Iinfo), &rf)
  4999. chrg_bchno := chrg_bchno
  5000. cert_no := his.Certno
  5001. var insutypes []string
  5002. var insutype string
  5003. var is390 int = 0
  5004. var is310 int = 0
  5005. for _, item := range rf {
  5006. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5007. insutypes = append(insutypes, item.Insutype)
  5008. }
  5009. }
  5010. if len(insutypes) == 1 {
  5011. insutype = insutypes[0]
  5012. } else {
  5013. for _, i := range insutypes {
  5014. if i == "390" {
  5015. is390 = 1
  5016. }
  5017. if i == "310" {
  5018. is310 = 1
  5019. }
  5020. }
  5021. }
  5022. if is390 == 1 {
  5023. insutype = "390"
  5024. }
  5025. if is310 == 1 {
  5026. insutype = "310"
  5027. }
  5028. if len(insutypes) == 0 {
  5029. insutype = "310"
  5030. }
  5031. if len(insutypes) == 2 {
  5032. insutype = strconv.FormatInt(his.SocialType, 10)
  5033. }
  5034. insutype = strconv.FormatInt(his.SocialType, 10)
  5035. //insutype = "390"
  5036. if his.IdCardType == 1 {
  5037. // cert_no = his.MedicalInsuranceNumber
  5038. cert_no = his.Certno
  5039. } else {
  5040. cert_no = his.Certno
  5041. }
  5042. var res ResultSeven
  5043. var resSeven10265 ResultSeven10265
  5044. var src_resquest string
  5045. var result2 string
  5046. var acct_used_flag string
  5047. fmt.Println("pay_way")
  5048. fmt.Println(pay_way)
  5049. fmt.Println("pay_way")
  5050. if pay_way == 4 {
  5051. acct_used_flag = "1"
  5052. } else {
  5053. acct_used_flag = "0"
  5054. }
  5055. if miConfig.MdtrtareaAdmvs == "421300" {
  5056. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5057. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5058. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5059. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5060. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5061. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5062. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5063. resp, requestErr := http.Get(api)
  5064. if requestErr != nil {
  5065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5066. return
  5067. }
  5068. body, ioErr := ioutil.ReadAll(resp.Body)
  5069. if ioErr != nil {
  5070. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5072. return
  5073. }
  5074. var respJSON map[string]interface{}
  5075. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5076. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5078. return
  5079. }
  5080. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5081. result, _ := json.Marshal(respJSON)
  5082. if miConfig.Code == "H15049901371" {
  5083. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5084. utils.ErrorLog("解析失败:%v", err)
  5085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5086. return
  5087. }
  5088. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5089. res.Output = resSeven10265.Output
  5090. res.ErrMsg = resSeven10265.ErrMsg
  5091. res.Cainfo = resSeven10265.Cainfo
  5092. res.WarnMsg = resSeven10265.WarnMsg
  5093. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5094. res.Infcode = infocode
  5095. } else {
  5096. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5097. utils.ErrorLog("解析失败:%v", err)
  5098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5099. return
  5100. }
  5101. }
  5102. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5103. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5104. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5105. //psn_info, _ := service.GetPsnByPatientId(id)
  5106. bas := strings.Split(psn_info.CardInfo, "|")
  5107. if his.IdCardType == 1 {
  5108. cert_no = bas[2]
  5109. } else if his.IdCardType == 3 {
  5110. cert_no = his.Certno
  5111. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  5112. } else {
  5113. cert_no = bas[1]
  5114. }
  5115. //江苏地区国家医保医疗类别
  5116. //职工透析:医疗类别选特殊情况门诊9933
  5117. //居民血透门慢: 医疗类别选门诊慢病1402
  5118. //var med_type string
  5119. //if his.Insutype == "310" {
  5120. // if reg_type == 14 {
  5121. // med_type = "9933"
  5122. // } else if reg_type == 11 {
  5123. // med_type = "11"
  5124. //
  5125. // }
  5126. //} else if his.Insutype == "390" {
  5127. // if reg_type == 14 {
  5128. // med_type = "1402"
  5129. // } else if reg_type == 11 {
  5130. // med_type = "11"
  5131. // }
  5132. //}
  5133. //psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5134. var api string
  5135. if miConfig.MdtrtareaAdmvs == "320921" {
  5136. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5137. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5138. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5139. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5140. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5141. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5142. "&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
  5143. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5144. } else {
  5145. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5146. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5147. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5148. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5149. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5150. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5151. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5152. "&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
  5153. }
  5154. resp, requestErr := http.Get(api)
  5155. if requestErr != nil {
  5156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5157. return
  5158. }
  5159. body, ioErr := ioutil.ReadAll(resp.Body)
  5160. if ioErr != nil {
  5161. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5163. return
  5164. }
  5165. var respJSON map[string]interface{}
  5166. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5167. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5169. return
  5170. }
  5171. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5172. result, _ := json.Marshal(respJSON)
  5173. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5174. utils.ErrorLog("解析失败:%v", err)
  5175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5176. return
  5177. }
  5178. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5179. res.Output = resSeven10265.Output
  5180. res.ErrMsg = resSeven10265.ErrMsg
  5181. res.Cainfo = resSeven10265.Cainfo
  5182. res.WarnMsg = resSeven10265.WarnMsg
  5183. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5184. res.Infcode = infocode
  5185. } else {
  5186. if miConfig.Code == "H15049901371" {
  5187. //赤峰地区国家医保医疗类别
  5188. //职工透析:医疗类别选特殊情况门诊990502
  5189. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5190. var med_type string
  5191. if his.Insutype == "390" {
  5192. if reg_type == 14 {
  5193. med_type = "9933"
  5194. } else if reg_type == 11 {
  5195. med_type = "11"
  5196. }
  5197. } else if his.Insutype == "310" {
  5198. if reg_type == 14 {
  5199. med_type = "990502"
  5200. } else if reg_type == 11 {
  5201. med_type = "11"
  5202. }
  5203. }
  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, med_type, his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  5205. } else {
  5206. 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)
  5207. }
  5208. //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)
  5209. var dat map[string]interface{}
  5210. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5211. fmt.Println(dat)
  5212. } else {
  5213. fmt.Println(err)
  5214. }
  5215. saveLog(result2, src_resquest, "2207", "结算")
  5216. userJSONBytes, _ := json.Marshal(dat)
  5217. if miConfig.Code == "H15049901371" {
  5218. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5219. utils.ErrorLog("解析失败:%v", err)
  5220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5221. return
  5222. }
  5223. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5224. res.Output = resSeven10265.Output
  5225. res.ErrMsg = resSeven10265.ErrMsg
  5226. res.Cainfo = resSeven10265.Cainfo
  5227. res.WarnMsg = resSeven10265.WarnMsg
  5228. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5229. res.Infcode = infocode
  5230. } else {
  5231. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5232. utils.ErrorLog("解析失败:%v", err)
  5233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5234. return
  5235. }
  5236. }
  5237. }
  5238. if res.Infcode != 0 {
  5239. errlog := &models.HisOrderError{
  5240. UserOrgId: adminUser.CurrentOrgId,
  5241. Ctime: time.Now().Unix(),
  5242. Mtime: time.Now().Unix(),
  5243. Number: chrg_bchno,
  5244. ErrMsg: res.ErrMsg,
  5245. Status: 1,
  5246. PatientId: id,
  5247. RecordTime: recordDateTime,
  5248. Stage: 6,
  5249. }
  5250. service.CreateErrMsgLog(errlog)
  5251. c.ServeSuccessJSON(map[string]interface{}{
  5252. "failed_code": -10,
  5253. "msg": res.ErrMsg,
  5254. })
  5255. return
  5256. } else {
  5257. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5258. order.OrderStatus = 2
  5259. order.Status = 1
  5260. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5261. order.SetlId = res.Output.Setlinfo.SetlID
  5262. order.PsnNo = res.Output.Setlinfo.PsnNo
  5263. order.PsnName = res.Output.Setlinfo.PsnName
  5264. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5265. order.Certno = res.Output.Setlinfo.Certno
  5266. order.Gend = res.Output.Setlinfo.Gend
  5267. order.Naty = res.Output.Setlinfo.Naty
  5268. order.Age = res.Output.Setlinfo.Age
  5269. order.Insutype = res.Output.Setlinfo.Insutype
  5270. order.PsnType = res.Output.Setlinfo.PsnType
  5271. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5272. order.SetlTime = res.Output.Setlinfo.SetlTime
  5273. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5274. if res.Output.Setlinfo.MedType == "140101" {
  5275. order.MedType = "14"
  5276. } else {
  5277. order.MedType = res.Output.Setlinfo.MedType
  5278. }
  5279. if reg_type == 1112 {
  5280. order.MedType = "1112"
  5281. }
  5282. if reg_type == 1111 {
  5283. order.MedType = "1111"
  5284. }
  5285. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5286. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5287. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5288. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5289. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5290. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5291. order.HifpPay = res.Output.Setlinfo.HifpPay
  5292. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5293. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5294. order.HifesPay = res.Output.Setlinfo.HifesPay
  5295. order.HifobPay = res.Output.Setlinfo.HifobPay
  5296. order.MafPay = res.Output.Setlinfo.MafPay
  5297. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5298. order.OthPay = res.Output.Setlinfo.OthPay
  5299. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5300. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5301. order.AcctPay = res.Output.Setlinfo.AcctPay
  5302. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5303. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5304. order.Balc = res.Output.Setlinfo.Balc
  5305. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5306. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5307. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5308. order.ClrType = res.Output.Setlinfo.ClrType
  5309. order.ClrWay = res.Output.Setlinfo.ClrWay
  5310. order.Creator = order.Creator
  5311. order.Modify = roles.AdminUserId
  5312. order.RequestLog = src_resquest
  5313. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5314. detailStr := string(setlDetail)
  5315. order.SetlDetail = detailStr
  5316. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5317. err = service.UpDateOrder(order)
  5318. if err == nil {
  5319. c.ServeSuccessJSON(map[string]interface{}{
  5320. "msg": "结算成功",
  5321. })
  5322. } else {
  5323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5324. return
  5325. }
  5326. }
  5327. } else {
  5328. adminUser := c.GetAdminUserInfo()
  5329. errlog := &models.HisOrderError{
  5330. UserOrgId: adminUser.CurrentOrgId,
  5331. Ctime: time.Now().Unix(),
  5332. Mtime: time.Now().Unix(),
  5333. ErrMsg: res.ErrMsg,
  5334. Status: 1,
  5335. PatientId: id,
  5336. RecordTime: recordDateTime,
  5337. Stage: 4,
  5338. }
  5339. service.CreateErrMsgLog(errlog)
  5340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5341. return
  5342. }
  5343. } else {
  5344. adminUser := c.GetAdminUserInfo()
  5345. errlog := &models.HisOrderError{
  5346. UserOrgId: adminUser.CurrentOrgId,
  5347. Ctime: time.Now().Unix(),
  5348. Mtime: time.Now().Unix(),
  5349. ErrMsg: res.ErrMsg,
  5350. Status: 1,
  5351. PatientId: id,
  5352. RecordTime: recordDateTime,
  5353. Stage: 4,
  5354. }
  5355. service.CreateErrMsgLog(errlog)
  5356. c.ServeSuccessJSON(map[string]interface{}{
  5357. "failed_code": -10,
  5358. "msg": res.ErrMsg,
  5359. })
  5360. return
  5361. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5362. //return
  5363. }
  5364. }
  5365. }
  5366. } else if tempOrder.ID > 0 {
  5367. if tempOrder.IsPre == 1 {
  5368. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  5369. var rf []*ResultFive
  5370. json.Unmarshal([]byte(his.Iinfo), &rf)
  5371. chrg_bchno := tempOrder.Number
  5372. cert_no := his.Certno
  5373. var insutypes []string
  5374. var insutype string
  5375. var is390 int = 0
  5376. var is310 int = 0
  5377. for _, item := range rf {
  5378. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5379. insutypes = append(insutypes, item.Insutype)
  5380. }
  5381. }
  5382. if len(insutypes) == 1 {
  5383. insutype = insutypes[0]
  5384. } else {
  5385. for _, i := range insutypes {
  5386. if i == "390" {
  5387. is390 = 1
  5388. }
  5389. if i == "310" {
  5390. is310 = 1
  5391. }
  5392. }
  5393. }
  5394. if is390 == 1 {
  5395. insutype = "390"
  5396. }
  5397. if is310 == 1 {
  5398. insutype = "310"
  5399. }
  5400. if len(insutypes) == 0 {
  5401. insutype = "310"
  5402. }
  5403. if len(insutypes) == 2 {
  5404. insutype = strconv.FormatInt(his.SocialType, 64)
  5405. }
  5406. //insutype = "390"
  5407. if his.IdCardType == 1 {
  5408. // cert_no = his.MedicalInsuranceNumber
  5409. cert_no = his.Certno
  5410. } else {
  5411. cert_no = his.Certno
  5412. }
  5413. var res ResultSeven
  5414. var resSeven10265 ResultSeven10265
  5415. var src_resquest string
  5416. var result2 string
  5417. var acct_used_flag string
  5418. fmt.Println("pay_way")
  5419. fmt.Println(pay_way)
  5420. fmt.Println("pay_way")
  5421. if pay_way == 4 {
  5422. acct_used_flag = "1"
  5423. } else {
  5424. acct_used_flag = "0"
  5425. }
  5426. if miConfig.MdtrtareaAdmvs == "421300" {
  5427. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5428. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5429. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5430. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5431. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5432. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5433. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5434. resp, requestErr := http.Get(api)
  5435. if requestErr != nil {
  5436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5437. return
  5438. }
  5439. body, ioErr := ioutil.ReadAll(resp.Body)
  5440. if ioErr != nil {
  5441. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5443. return
  5444. }
  5445. var respJSON map[string]interface{}
  5446. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5447. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5449. return
  5450. }
  5451. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5452. result, _ := json.Marshal(respJSON)
  5453. fmt.Println("log")
  5454. fmt.Println(string(result))
  5455. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5456. utils.ErrorLog("解析失败:%v", err)
  5457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5458. return
  5459. }
  5460. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5461. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5462. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5463. //psn_info, _ := service.GetPsnByPatientId(id)
  5464. bas := strings.Split(psn_info.CardInfo, "|")
  5465. if his.IdCardType == 1 {
  5466. cert_no = bas[2]
  5467. } else {
  5468. cert_no = bas[1]
  5469. }
  5470. //江苏地区国家医保医疗类别
  5471. //职工透析:医疗类别选特殊情况门诊9933
  5472. //居民血透门慢: 医疗类别选门诊慢病1402
  5473. //var med_type string
  5474. //if his.Insutype == "310" {
  5475. // if reg_type == 14 {
  5476. // med_type = "9933"
  5477. // } else if reg_type == 11 {
  5478. // med_type = "11"
  5479. //
  5480. // }
  5481. //} else if his.Insutype == "390" {
  5482. // if reg_type == 14 {
  5483. // med_type = "1402"
  5484. // } else if reg_type == 11 {
  5485. // med_type = "11"
  5486. // }
  5487. //}
  5488. var api string
  5489. if miConfig.MdtrtareaAdmvs == "320921" {
  5490. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5491. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5492. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5493. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5494. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5495. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5496. "&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
  5497. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5498. } else {
  5499. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5500. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5501. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5502. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5503. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5504. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5505. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5506. "&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
  5507. }
  5508. resp, requestErr := http.Get(api)
  5509. if requestErr != nil {
  5510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5511. return
  5512. }
  5513. body, ioErr := ioutil.ReadAll(resp.Body)
  5514. if ioErr != nil {
  5515. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5517. return
  5518. }
  5519. var respJSON map[string]interface{}
  5520. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5521. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5523. return
  5524. }
  5525. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5526. result, _ := json.Marshal(respJSON)
  5527. fmt.Println("log")
  5528. fmt.Println(string(result))
  5529. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5530. utils.ErrorLog("解析失败:%v", err)
  5531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5532. return
  5533. }
  5534. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5535. res.Output = resSeven10265.Output
  5536. res.ErrMsg = resSeven10265.ErrMsg
  5537. res.Cainfo = resSeven10265.Cainfo
  5538. res.WarnMsg = resSeven10265.WarnMsg
  5539. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5540. res.Infcode = infocode
  5541. } else {
  5542. var src_resquest string
  5543. if miConfig.Code == "H15049901371" {
  5544. //赤峰地区国家医保医疗类别
  5545. //职工透析:医疗类别选特殊情况门诊990502
  5546. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5547. var med_type string
  5548. if his.Insutype == "390" {
  5549. if reg_type == 14 {
  5550. med_type = "9933"
  5551. } else if reg_type == 11 {
  5552. med_type = "11"
  5553. }
  5554. } else if his.Insutype == "310" {
  5555. if reg_type == 14 {
  5556. med_type = "990502"
  5557. } else if reg_type == 11 {
  5558. med_type = "11"
  5559. }
  5560. }
  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, med_type, his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  5562. } else {
  5563. 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)
  5564. }
  5565. var dat map[string]interface{}
  5566. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5567. fmt.Println(dat)
  5568. } else {
  5569. fmt.Println(err)
  5570. }
  5571. saveLog(result2, src_resquest, "2207", "结算")
  5572. userJSONBytes, _ := json.Marshal(dat)
  5573. if miConfig.Code == "H15049901371" {
  5574. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5575. utils.ErrorLog("解析失败:%v", err)
  5576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5577. return
  5578. }
  5579. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5580. res.Output = resSeven10265.Output
  5581. res.ErrMsg = resSeven10265.ErrMsg
  5582. res.Cainfo = resSeven10265.Cainfo
  5583. res.WarnMsg = resSeven10265.WarnMsg
  5584. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5585. res.Infcode = infocode
  5586. } else {
  5587. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5588. utils.ErrorLog("解析失败:%v", err)
  5589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5590. return
  5591. }
  5592. }
  5593. }
  5594. if res.Infcode != 0 {
  5595. errlog := &models.HisOrderError{
  5596. UserOrgId: adminUser.CurrentOrgId,
  5597. Ctime: time.Now().Unix(),
  5598. Mtime: time.Now().Unix(),
  5599. Number: chrg_bchno,
  5600. ErrMsg: res.ErrMsg,
  5601. Status: 1,
  5602. PatientId: id,
  5603. RecordTime: recordDateTime,
  5604. Stage: 6,
  5605. }
  5606. service.CreateErrMsgLog(errlog)
  5607. c.ServeSuccessJSON(map[string]interface{}{
  5608. "failed_code": -10,
  5609. "msg": res.ErrMsg,
  5610. })
  5611. return
  5612. } else {
  5613. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5614. order.OrderStatus = 2
  5615. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5616. order.SetlId = res.Output.Setlinfo.SetlID
  5617. order.PsnNo = res.Output.Setlinfo.PsnNo
  5618. order.PsnName = res.Output.Setlinfo.PsnName
  5619. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5620. order.Certno = res.Output.Setlinfo.Certno
  5621. order.Gend = res.Output.Setlinfo.Gend
  5622. order.Naty = res.Output.Setlinfo.Naty
  5623. order.Age = res.Output.Setlinfo.Age
  5624. order.Insutype = res.Output.Setlinfo.Insutype
  5625. order.PsnType = res.Output.Setlinfo.PsnType
  5626. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5627. order.SetlTime = res.Output.Setlinfo.SetlTime
  5628. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5629. //order.MedType = res.Output.Setlinfo.MedType
  5630. if reg_type == 1112 {
  5631. order.MedType = "1112"
  5632. }
  5633. if reg_type == 1111 {
  5634. order.MedType = "1111"
  5635. }
  5636. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5637. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5638. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5639. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5640. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5641. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5642. order.HifpPay = res.Output.Setlinfo.HifpPay
  5643. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5644. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5645. order.HifesPay = res.Output.Setlinfo.HifesPay
  5646. order.HifobPay = res.Output.Setlinfo.HifobPay
  5647. order.MafPay = res.Output.Setlinfo.MafPay
  5648. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5649. order.OthPay = res.Output.Setlinfo.OthPay
  5650. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5651. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5652. order.AcctPay = res.Output.Setlinfo.AcctPay
  5653. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5654. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5655. order.Balc = res.Output.Setlinfo.Balc
  5656. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5657. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5658. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5659. order.ClrWay = res.Output.Setlinfo.ClrWay
  5660. order.Creator = order.Creator
  5661. order.Modify = roles.AdminUserId
  5662. order.RequestLog = src_resquest
  5663. order.Diagnosis = diagnosis_id
  5664. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5665. detailStr := string(setlDetail)
  5666. order.SetlDetail = detailStr
  5667. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5668. err = service.UpDateOrder(order)
  5669. if err == nil {
  5670. c.ServeSuccessJSON(map[string]interface{}{
  5671. "msg": "结算成功",
  5672. })
  5673. } else {
  5674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5675. return
  5676. }
  5677. }
  5678. }
  5679. }
  5680. }
  5681. //func (c *HisApiController) GetPreUploadInfo() {
  5682. // id, _ := c.GetInt64("id")
  5683. // record_time := c.GetString("record_time")
  5684. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5685. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5686. //
  5687. // timeLayout := "2006-01-02"
  5688. // loc, _ := time.LoadLocation("Local")
  5689. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5690. // if err != nil {
  5691. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5692. // return
  5693. // }
  5694. // recordDateTime := theTime.Unix()
  5695. // adminUser := c.GetAdminUserInfo()
  5696. //
  5697. // var prescriptions []*models.HisPrescription
  5698. //
  5699. // var start_time int64
  5700. // var end_time int64
  5701. //
  5702. // data := make(map[string]interface{})
  5703. // if settle_accounts_type == 1 { //日结
  5704. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  5705. // data["pre"] = prescriptions
  5706. //
  5707. // } else { //月结
  5708. // start_time_str := c.GetString("start_time")
  5709. // end_time_str := c.GetString("end_time")
  5710. // timeLayout := "2006-01-02"
  5711. // loc, _ := time.LoadLocation("Local")
  5712. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5713. // if err != nil {
  5714. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5715. // return
  5716. // }
  5717. // recordStartTime := theStartTime.Unix()
  5718. // start_time = recordStartTime
  5719. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5720. // if err != nil {
  5721. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5722. // return
  5723. // }
  5724. // recordEndTime := theEndTime.Unix()
  5725. // end_time = recordEndTime
  5726. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  5727. // data["pre"] = prescriptions
  5728. //
  5729. // }
  5730. //
  5731. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5732. //
  5733. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5734. // timestamp := time.Now().Unix()
  5735. // tempTime := time.Unix(timestamp, 0)
  5736. // timeFormat := tempTime.Format("20060102150405")
  5737. // chrgBchno := rand.Intn(100000) + 10000
  5738. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5739. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5740. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5741. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5742. // strconv.FormatInt(his.PatientId, 10)
  5743. // client := &http.Client{}
  5744. // data["psn_no"] = his.PsnNo
  5745. // data["mdtrt_id"] = his.Number
  5746. // data["chrg_bchno"] = chrg_bchno
  5747. // data["org_name"] = miConfig.OrgName
  5748. // data["doctor"] = roles.UserName
  5749. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5750. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5751. // data["fixmedins_code"] = miConfig.Code
  5752. // data["dept_code"] = department.Number
  5753. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5754. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5755. // data["secret_key"] = miConfig.SecretKey
  5756. // var ids []int64
  5757. //
  5758. // for _, item := range prescriptions {
  5759. // ids = append(ids, item.ID)
  5760. // }
  5761. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5762. // if config.IsOpen == 1 { //对接了医保,走医保流程
  5763. // bytesData, _ := json.Marshal(data)
  5764. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  5765. // resp, _ := client.Do(req)
  5766. // defer resp.Body.Close()
  5767. // body, ioErr := ioutil.ReadAll(resp.Body)
  5768. // if ioErr != nil {
  5769. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5770. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5771. // return
  5772. // }
  5773. // var respJSON map[string]interface{}
  5774. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5775. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5776. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5777. // return
  5778. // }
  5779. //
  5780. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5781. // userJSONBytes, _ := json.Marshal(respJSON)
  5782. // var res ResultFour
  5783. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5784. // utils.ErrorLog("解析失败:%v", err)
  5785. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5786. // return
  5787. // }
  5788. //
  5789. // if res.Infcode == 0 {
  5790. // order := &models.HisOrder{
  5791. // UserOrgId: adminUser.CurrentOrgId,
  5792. // HisPatientId: his.ID,
  5793. // PatientId: his.PatientId,
  5794. // SettleAccountsDate: recordDateTime,
  5795. // Ctime: time.Now().Unix(),
  5796. // Mtime: time.Now().Unix(),
  5797. // Status: 1,
  5798. // Number: chrg_bchno,
  5799. // Infcode: res.Infcode,
  5800. // WarnMsg: res.WarnMsg,
  5801. // Cainfo: res.Cainfo,
  5802. // ErrMsg: res.ErrMsg,
  5803. // RespondTime: res.RefmsgTime,
  5804. // InfRefmsgid: res.InfRefmsgid,
  5805. // OrderStatus: 1,
  5806. // IsMedicineInsurance: 1,
  5807. // SettleType: settle_accounts_type,
  5808. // SettleStartTime: start_time,
  5809. // SettleEndTime: end_time,
  5810. // Creator: roles.ID,
  5811. // Modify: roles.ID,
  5812. // PType: 2,
  5813. // }
  5814. // err = service.CreateOrder(order)
  5815. // if err != nil {
  5816. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5817. // return
  5818. // }
  5819. //
  5820. // for _, item := range res.Output.Result {
  5821. // temp := strings.Split(item.FeedetlSn, "-")
  5822. // var advice_id int64 = 0
  5823. // var project_id int64 = 0
  5824. // var types int64 = 0
  5825. //
  5826. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  5827. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  5828. //
  5829. // if temp[1] == "1" {
  5830. // advice_id = id
  5831. // project_id = 0
  5832. // } else if temp[1] == "2" {
  5833. // advice_id = 0
  5834. // project_id = id
  5835. // }
  5836. //
  5837. // info := &models.HisOrderInfo{
  5838. // OrderNumber: order.Number,
  5839. // FeedetlSn: item.FeedetlSn,
  5840. // UploadDate: time.Now().Unix(),
  5841. // AdviceId: advice_id,
  5842. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  5843. // Cnt: item.Cnt,
  5844. // Pric: float64(item.Pric),
  5845. // PatientId: his.PatientId,
  5846. // PricUplmtAmt: item.PricUplmtAmt,
  5847. // SelfpayProp: item.SelfpayProp,
  5848. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5849. // OverlmtAmt: item.OverlmtAmt,
  5850. // PreselfpayAmt: item.PreselfpayAmt,
  5851. // BasMednFlag: item.BasMednFlag,
  5852. // MedChrgitmType: item.MedChrgitmType,
  5853. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  5854. // Status: 1,
  5855. // Memo: item.Memo,
  5856. // Mtime: time.Now().Unix(),
  5857. // InscpScpAmt: item.InscpScpAmt,
  5858. // DrtReimFlag: item.DrtReimFlag,
  5859. // Ctime: time.Now().Unix(),
  5860. // ListSpItemFlag: item.ListSpItemFlag,
  5861. // ChldMedcFlag: item.ChldMedcFlag,
  5862. // LmtUsedFlag: item.LmtUsedFlag,
  5863. // ChrgitmLv: item.ChrgitmLv,
  5864. // UserOrgId: adminUser.CurrentOrgId,
  5865. // HisPatientId: his.ID,
  5866. // OrderId: order.ID,
  5867. // ProjectId: project_id,
  5868. // Type: types,
  5869. // }
  5870. // service.CreateOrderInfo(info)
  5871. //
  5872. // }
  5873. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5874. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  5875. //
  5876. // var total float64
  5877. // for _, item := range prescriptions {
  5878. // if item.Type == 1 { //药品
  5879. // for _, subItem := range item.HisDoctorAdviceInfo {
  5880. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5881. // }
  5882. // }
  5883. // if item.Type == 2 { //项目
  5884. // for _, subItem := range item.HisPrescriptionProject {
  5885. // total = total + (subItem.Price * float64(subItem.Count))
  5886. // }
  5887. // }
  5888. // }
  5889. //
  5890. // for _, item := range prescriptions {
  5891. // for _, subItem := range item.HisAdditionalCharge {
  5892. // total = total + (subItem.Price * float64(subItem.Count))
  5893. // }
  5894. // }
  5895. //
  5896. // allTotal := fmt.Sprintf("%.2f", total)
  5897. // if res.Infcode == 0 {
  5898. // var rf []*ResultFive
  5899. // json.Unmarshal([]byte(his.Iinfo), &rf)
  5900. // psn_no := his.PsnNo
  5901. // mdtrt_id := his.Number
  5902. // chrg_bchno := chrg_bchno
  5903. // cert_no := his.Certno
  5904. // insutype := rf[0].Insutype
  5905. //
  5906. // if his.IdCardType == 1 {
  5907. // cert_no = his.MedicalInsuranceNumber
  5908. //
  5909. // } else {
  5910. //
  5911. // cert_no = his.Certno
  5912. //
  5913. // }
  5914. //
  5915. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  5916. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  5917. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  5918. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  5919. // resp, requestErr := http.Get(api)
  5920. // if requestErr != nil {
  5921. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5922. // return
  5923. // }
  5924. // defer resp.Body.Close()
  5925. // body, ioErr := ioutil.ReadAll(resp.Body)
  5926. // if ioErr != nil {
  5927. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5928. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5929. // return
  5930. // }
  5931. // var respJSON map[string]interface{}
  5932. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5933. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5934. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5935. // return
  5936. // }
  5937. // fmt.Println(respJSON)
  5938. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5939. // userJSONBytes, _ := json.Marshal(respJSON)
  5940. // var res ResultSeven
  5941. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5942. // utils.ErrorLog("解析失败:%v", err)
  5943. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5944. // return
  5945. // }
  5946. // if res.Infcode != 0 {
  5947. // errlog := &models.HisOrderError{
  5948. // UserOrgId: adminUser.CurrentOrgId,
  5949. // Ctime: time.Now().Unix(),
  5950. // Mtime: time.Now().Unix(),
  5951. // Number: chrg_bchno,
  5952. // ErrMsg: res.ErrMsg,
  5953. // Status: 1,
  5954. // PatientId: id,
  5955. // RecordTime: recordDateTime,
  5956. // Stage: 7,
  5957. // }
  5958. // service.CreateErrMsgLog(errlog)
  5959. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5960. // return
  5961. // } else {
  5962. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5963. // order.OrderStatus = 1
  5964. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5965. // order.SetlId = res.Output.Setlinfo.SetlID
  5966. // order.PsnNo = res.Output.Setlinfo.PsnNo
  5967. // order.PsnName = res.Output.Setlinfo.PsnName
  5968. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5969. // order.Certno = res.Output.Setlinfo.Certno
  5970. // order.Gend = res.Output.Setlinfo.Gend
  5971. // order.Naty = res.Output.Setlinfo.Naty
  5972. // order.Age = res.Output.Setlinfo.Age
  5973. // order.Insutype = res.Output.Setlinfo.Insutype
  5974. // order.PsnType = res.Output.Setlinfo.PsnType
  5975. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5976. // order.SetlTime = res.Output.Setlinfo.SetlTime
  5977. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5978. // order.MedType = res.Output.Setlinfo.MedType
  5979. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5980. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5981. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5982. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5983. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5984. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5985. // order.HifpPay = res.Output.Setlinfo.HifpPay
  5986. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5987. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5988. // order.HifesPay = res.Output.Setlinfo.HifesPay
  5989. // order.HifobPay = res.Output.Setlinfo.HifobPay
  5990. // order.MafPay = res.Output.Setlinfo.MafPay
  5991. // order.OthPay = res.Output.Setlinfo.OthPay
  5992. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5993. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5994. // order.AcctPay = res.Output.Setlinfo.AcctPay
  5995. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5996. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5997. // order.Balc = res.Output.Setlinfo.Balc
  5998. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5999. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6000. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6001. // order.ClrWay = res.Output.Setlinfo.ClrWay
  6002. // order.Creator = order.Creator
  6003. // order.Modify = roles.ID
  6004. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6005. // detailStr := string(setlDetail)
  6006. // order.SetlDetail = detailStr
  6007. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6008. // err = service.UpDateOrder(order)
  6009. // if err == nil {
  6010. // c.ServeSuccessJSON(map[string]interface{}{
  6011. // "msg": "预结算成功",
  6012. // })
  6013. // } else {
  6014. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6015. // return
  6016. // }
  6017. // }
  6018. // } else {
  6019. // adminUser := c.GetAdminUserInfo()
  6020. // errlog := &models.HisOrderError{
  6021. // UserOrgId: adminUser.CurrentOrgId,
  6022. // Ctime: time.Now().Unix(),
  6023. // Mtime: time.Now().Unix(),
  6024. // ErrMsg: res.ErrMsg,
  6025. // Status: 1,
  6026. // PatientId: id,
  6027. // RecordTime: recordDateTime,
  6028. // Stage: 4,
  6029. // }
  6030. // service.CreateErrMsgLog(errlog)
  6031. //
  6032. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6033. // return
  6034. // }
  6035. // } else {
  6036. // adminUser := c.GetAdminUserInfo()
  6037. // errlog := &models.HisOrderError{
  6038. // UserOrgId: adminUser.CurrentOrgId,
  6039. // Ctime: time.Now().Unix(),
  6040. // Mtime: time.Now().Unix(),
  6041. // ErrMsg: res.ErrMsg,
  6042. // Status: 1,
  6043. // PatientId: id,
  6044. // RecordTime: recordDateTime,
  6045. // Stage: 4,
  6046. // }
  6047. // service.CreateErrMsgLog(errlog)
  6048. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6049. // return
  6050. // }
  6051. //
  6052. // } else {
  6053. // var total float64
  6054. // for _, item := range prescriptions {
  6055. // if item.Type == 1 { //药品
  6056. // for _, subItem := range item.HisDoctorAdviceInfo {
  6057. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6058. // }
  6059. // }
  6060. // if item.Type == 2 { //项目
  6061. // for _, subItem := range item.HisPrescriptionProject {
  6062. // total = total + (subItem.Price * float64(subItem.Count))
  6063. // }
  6064. // }
  6065. //
  6066. // for _, subItem := range item.HisAdditionalCharge {
  6067. // total = total + (subItem.Price * float64(subItem.Count))
  6068. // }
  6069. // }
  6070. //
  6071. // allTotal := fmt.Sprintf("%.2f", total)
  6072. // totals, _ := strconv.ParseFloat(allTotal, 64)
  6073. // order := &models.HisOrder{
  6074. // UserOrgId: adminUser.CurrentOrgId,
  6075. // HisPatientId: his.ID,
  6076. // PatientId: id,
  6077. // SettleAccountsDate: recordDateTime,
  6078. // Ctime: time.Now().Unix(),
  6079. // Mtime: time.Now().Unix(),
  6080. // Status: 1,
  6081. // OrderStatus: 2,
  6082. // Number: chrg_bchno,
  6083. // MedfeeSumamt: totals,
  6084. // }
  6085. // err = service.CreateOrder(order)
  6086. // if err != nil {
  6087. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6088. // return
  6089. // }
  6090. //
  6091. // var customs []*Custom
  6092. // for _, item := range prescriptions {
  6093. //
  6094. // if item.Type == 1 { //药品
  6095. // for _, subItem := range item.HisDoctorAdviceInfo {
  6096. // cus := &Custom{
  6097. // AdviceId: subItem.ID,
  6098. // ProjectId: 0,
  6099. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  6100. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  6101. // FeedetlSn: subItem.FeedetlSn,
  6102. // Price: fmt.Sprintf("%.2f", subItem.Price),
  6103. // MedListCodg: subItem.MedListCodg,
  6104. // Type: 1,
  6105. // }
  6106. // customs = append(customs, cus)
  6107. // }
  6108. // }
  6109. //
  6110. // if item.Type == 2 { //项目
  6111. // for _, subItem := range item.HisPrescriptionProject {
  6112. //
  6113. // cus := &Custom{
  6114. // AdviceId: 0,
  6115. // ProjectId: subItem.ID,
  6116. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  6117. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  6118. // FeedetlSn: subItem.FeedetlSn,
  6119. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  6120. // MedListCodg: subItem.MedListCodg,
  6121. // Type: 2,
  6122. // }
  6123. //
  6124. // customs = append(customs, cus)
  6125. // }
  6126. // }
  6127. //
  6128. // for _, item := range item.HisAdditionalCharge {
  6129. // cus := &Custom{
  6130. // ItemId: item.ID,
  6131. // AdviceId: 0,
  6132. // ProjectId: 0,
  6133. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  6134. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  6135. // FeedetlSn: item.FeedetlSn,
  6136. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  6137. // MedListCodg: item.XtHisAddtionConfig.Code,
  6138. // Type: 3,
  6139. // }
  6140. //
  6141. // customs = append(customs, cus)
  6142. // }
  6143. //
  6144. // }
  6145. //
  6146. // for _, item := range customs {
  6147. // var advice_id int64 = 0
  6148. // var project_id int64 = 0
  6149. // var item_id int64 = 0
  6150. //
  6151. // var types int64 = 0
  6152. //
  6153. // if item.Type == 1 {
  6154. // advice_id = item.AdviceId
  6155. // project_id = 0
  6156. // item_id = 0
  6157. // } else if item.Type == 2 {
  6158. // advice_id = 0
  6159. // item_id = 0
  6160. //
  6161. // project_id = item.ProjectId
  6162. // } else if item.Type == 3 {
  6163. // advice_id = 0
  6164. // item_id = item.ItemId
  6165. // project_id = 0
  6166. // }
  6167. //
  6168. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  6169. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  6170. // pric, _ := strconv.ParseFloat(item.Price, 32)
  6171. //
  6172. // info := &models.HisOrderInfo{
  6173. // OrderNumber: order.Number,
  6174. // UploadDate: time.Now().Unix(),
  6175. // AdviceId: advice_id,
  6176. // DetItemFeeSumamt: detItemFeeSumamt,
  6177. // Cnt: cut,
  6178. // Pric: pric,
  6179. // PatientId: id,
  6180. // Status: 1,
  6181. // Mtime: time.Now().Unix(),
  6182. // Ctime: time.Now().Unix(),
  6183. // UserOrgId: adminUser.CurrentOrgId,
  6184. // HisPatientId: his.ID,
  6185. // OrderId: order.ID,
  6186. // ProjectId: project_id,
  6187. // Type: types,
  6188. // ItemId: item_id,
  6189. // }
  6190. // service.CreateOrderInfo(info)
  6191. // }
  6192. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6193. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6194. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  6195. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6196. // if err == nil {
  6197. // c.ServeSuccessJSON(map[string]interface{}{
  6198. // "msg": "结算成功",
  6199. // })
  6200. // } else {
  6201. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6202. // return
  6203. // }
  6204. // }
  6205. //}
  6206. //上传明细-预结算-
  6207. func (c *HisApiController) GetPreUploadInfo() {
  6208. id, _ := c.GetInt64("id")
  6209. record_time := c.GetString("record_time")
  6210. his_patient_id, _ := c.GetInt64("his_patient_id")
  6211. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6212. admin_user_id, _ := c.GetInt64("admin_user_id")
  6213. diagnosis_id := c.GetString("diagnosis")
  6214. sick_type, _ := c.GetInt64("sick_type")
  6215. reg_type, _ := c.GetInt64("p_type")
  6216. begin_time := c.GetString("begin_time")
  6217. id_str := c.GetString("ids")
  6218. ids_arr := strings.Split(id_str, ",")
  6219. timeLayout := "2006-01-02"
  6220. loc, _ := time.LoadLocation("Local")
  6221. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6222. if err != nil {
  6223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6224. return
  6225. }
  6226. recordDateTime := theTime.Unix()
  6227. adminUser := c.GetAdminUserInfo()
  6228. diagnosis_ids := strings.Split(diagnosis_id, ",")
  6229. var config []*models.HisXtDiagnoseConfig
  6230. for _, item := range diagnosis_ids {
  6231. id, _ := strconv.ParseInt(item, 10, 64)
  6232. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6233. config = append(config, &diagnosisConfig)
  6234. }
  6235. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  6236. sickConfig, _ := service.FindSickById(sick_type)
  6237. var prescriptions []*models.HisPrescription
  6238. var start_time int64
  6239. var end_time int64
  6240. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6241. fmt.Println(his_patient_id)
  6242. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6243. timestamp := time.Now().Unix()
  6244. tempTime := time.Unix(timestamp, 0)
  6245. timeFormat := tempTime.Format("20060102150405")
  6246. chrgBchno := rand.Intn(100000) + 10000
  6247. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6248. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6249. var patientPrescription models.HisPrescriptionInfo
  6250. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6251. if patientPrescription.ID == 0 {
  6252. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6253. }
  6254. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6255. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6256. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6257. strconv.FormatInt(his.PatientId, 10)
  6258. var res2 ResultSix
  6259. var resSix10265 ResultSix10265
  6260. var time_stamp string
  6261. if miConfig.MdtrtareaAdmvs == "421300" {
  6262. data := make(map[string]interface{})
  6263. client := &http.Client{}
  6264. data["psn_no"] = his.PsnNo
  6265. data["mdtrt_id"] = his.Number
  6266. data["doctor"] = roles.UserName
  6267. data["department"] = department.Name
  6268. data["org_name"] = miConfig.OrgName
  6269. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6270. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6271. data["fixmedins_code"] = miConfig.Code
  6272. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6273. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6274. data["secret_key"] = miConfig.SecretKey
  6275. data["sick_code"] = sickConfig.CountryCode
  6276. data["sick_name"] = sickConfig.ClassName
  6277. data["begin_time"] = begin_time
  6278. data["dept"] = strconv.FormatInt(department.ID, 10)
  6279. data["config"] = config
  6280. fmt.Println(data)
  6281. bytesData, _ := json.Marshal(data)
  6282. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  6283. resp, _ := client.Do(req)
  6284. defer resp.Body.Close()
  6285. body, ioErr := ioutil.ReadAll(resp.Body)
  6286. if ioErr != nil {
  6287. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6289. return
  6290. }
  6291. var respJSON map[string]interface{}
  6292. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6293. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6295. return
  6296. }
  6297. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6298. userJSONBytes, _ := json.Marshal(respJSON)
  6299. fmt.Println("log")
  6300. fmt.Println(string(userJSONBytes))
  6301. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6302. utils.ErrorLog("解析失败:%v", err)
  6303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6304. return
  6305. }
  6306. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6307. //江苏地区国家医保医疗类别
  6308. //职工透析:医疗类别选特殊情况门诊9933
  6309. //居民血透门慢: 医疗类别选门诊慢病1402
  6310. //var med_type string
  6311. //if his.Insutype == "310" {
  6312. // if reg_type == 14 {
  6313. // med_type = "9933"
  6314. // } else if reg_type == 11 {
  6315. // med_type = "11"
  6316. //
  6317. // }
  6318. //} else if his.Insutype == "390" {
  6319. // if reg_type == 14 {
  6320. // med_type = "1402"
  6321. // } else if reg_type == 11 {
  6322. // med_type = "11"
  6323. // }
  6324. //}
  6325. data := make(map[string]interface{})
  6326. client := &http.Client{}
  6327. data["psn_no"] = his.PsnNo
  6328. data["mdtrt_id"] = his.Number
  6329. data["doctor"] = roles.UserName
  6330. data["department"] = department.Name
  6331. data["org_name"] = miConfig.OrgName
  6332. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6333. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6334. data["fixmedins_code"] = miConfig.Code
  6335. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6336. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6337. data["secret_key"] = miConfig.SecretKey
  6338. data["sick_code"] = sickConfig.CountryCode
  6339. data["sick_name"] = sickConfig.ClassName
  6340. data["begin_time"] = begin_time
  6341. data["dept"] = strconv.FormatInt(department.ID, 10)
  6342. data["config"] = config
  6343. data["url"] = miConfig.Url
  6344. data["ak"] = miConfig.AccessKey
  6345. data["cainfo"] = miConfig.Cainfo
  6346. bytesData, _ := json.Marshal(data)
  6347. var req *http.Request
  6348. if miConfig.MdtrtareaAdmvs == "320921" {
  6349. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6350. //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 +
  6351. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  6352. } else {
  6353. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6354. }
  6355. resp, _ := client.Do(req)
  6356. defer resp.Body.Close()
  6357. body, ioErr := ioutil.ReadAll(resp.Body)
  6358. if ioErr != nil {
  6359. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6361. return
  6362. }
  6363. var respJSON map[string]interface{}
  6364. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6365. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6367. return
  6368. }
  6369. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  6370. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  6371. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  6372. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6373. userJSONBytes, _ := json.Marshal(respJSON)
  6374. fmt.Println("log")
  6375. fmt.Println(string(userJSONBytes))
  6376. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6377. utils.ErrorLog("解析失败:%v", err)
  6378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6379. return
  6380. }
  6381. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6382. res2.Output = resSix10265.Output
  6383. res2.ErrMsg = resSix10265.ErrMsg
  6384. res2.Cainfo = resSix10265.Cainfo
  6385. res2.WarnMsg = resSix10265.WarnMsg
  6386. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6387. res2.Infcode = infocode
  6388. } else {
  6389. var result string
  6390. var requestLog string
  6391. if miConfig.MdtrtareaAdmvs == "440781" { //
  6392. 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)
  6393. } else {
  6394. if miConfig.Code == "H15049901371" {
  6395. //赤峰地区国家医保医疗类别
  6396. //职工透析:医疗类别选特殊情况门诊990502
  6397. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6398. var med_type string
  6399. if his.Insutype == "390" {
  6400. if reg_type == 14 {
  6401. med_type = "9933"
  6402. } else if reg_type == 11 {
  6403. med_type = "11"
  6404. }
  6405. } else if his.Insutype == "310" {
  6406. if reg_type == 14 {
  6407. med_type = "990502"
  6408. } else if reg_type == 11 {
  6409. med_type = "11"
  6410. }
  6411. }
  6412. 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)
  6413. } else {
  6414. 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)
  6415. }
  6416. saveLog(result, requestLog, "2203", "上传就诊信息")
  6417. var respJSON2 map[string]interface{}
  6418. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6419. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6421. return
  6422. }
  6423. userJSONBytes2, _ := json.Marshal(respJSON2)
  6424. if miConfig.Code == "H15049901371" {
  6425. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  6426. utils.ErrorLog("解析失败:%v", err)
  6427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6428. return
  6429. }
  6430. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6431. res2.Output = resSix10265.Output
  6432. res2.ErrMsg = resSix10265.ErrMsg
  6433. res2.Cainfo = resSix10265.Cainfo
  6434. res2.WarnMsg = resSix10265.WarnMsg
  6435. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6436. res2.Infcode = infocode
  6437. } else {
  6438. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  6439. utils.ErrorLog("解析失败:%v", err)
  6440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6441. return
  6442. }
  6443. }
  6444. }
  6445. }
  6446. if res2.Infcode != 0 {
  6447. adminUser := c.GetAdminUserInfo()
  6448. errlog := &models.HisOrderError{
  6449. UserOrgId: adminUser.CurrentOrgId,
  6450. Ctime: time.Now().Unix(),
  6451. Mtime: time.Now().Unix(),
  6452. ErrMsg: res2.ErrMsg,
  6453. Status: 1,
  6454. PatientId: id,
  6455. RecordTime: recordDateTime,
  6456. Stage: 3,
  6457. }
  6458. service.CreateErrMsgLog(errlog)
  6459. c.ServeSuccessJSON(map[string]interface{}{
  6460. "failed_code": -10,
  6461. "msg": res2.ErrMsg,
  6462. })
  6463. return
  6464. } else {
  6465. his.Diagnosis = diagnosis_id
  6466. his.SickType = sickConfig.ID
  6467. his.PType = fmt.Sprintf("%d", reg_type)
  6468. service.UpdateHisPatientThree(&his)
  6469. data := make(map[string]interface{})
  6470. if settle_accounts_type == 1 { //日结
  6471. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  6472. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  6473. } else {
  6474. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  6475. }
  6476. data["pre"] = prescriptions
  6477. } else { //月结
  6478. start_time_str := c.GetString("start_time")
  6479. end_time_str := c.GetString("end_time")
  6480. timeLayout := "2006-01-02"
  6481. loc, _ := time.LoadLocation("Local")
  6482. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6483. if err != nil {
  6484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6485. return
  6486. }
  6487. recordStartTime := theStartTime.Unix()
  6488. start_time = recordStartTime
  6489. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6490. if err != nil {
  6491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6492. return
  6493. }
  6494. recordEndTime := theEndTime.Unix()
  6495. end_time = recordEndTime
  6496. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  6497. data["pre"] = prescriptions
  6498. }
  6499. client := &http.Client{}
  6500. data["psn_no"] = his.PsnNo
  6501. data["mdtrt_id"] = his.Number
  6502. data["chrg_bchno"] = chrg_bchno
  6503. data["org_name"] = miConfig.OrgName
  6504. data["doctor"] = roles.UserName
  6505. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6506. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6507. data["fixmedins_code"] = miConfig.Code
  6508. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  6509. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  6510. data["dept_code"] = "15"
  6511. } else {
  6512. data["dept_code"] = department.Number
  6513. }
  6514. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6515. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6516. data["secret_key"] = miConfig.SecretKey
  6517. data["url"] = miConfig.Url
  6518. data["ak"] = miConfig.AccessKey
  6519. data["new_doctor_name"] = patientPrescription.Doctor
  6520. data["diag_code"] = sickConfig.CountryCode
  6521. data["time_stamp"] = time_stamp
  6522. data["cainfo"] = miConfig.Cainfo
  6523. var ids []int64
  6524. for _, item := range prescriptions {
  6525. ids = append(ids, item.ID)
  6526. }
  6527. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6528. if config.IsOpen == 1 { //对接了医保,走医保流程
  6529. var res ResultFour
  6530. var resFour10265 ResultFour10265
  6531. if miConfig.MdtrtareaAdmvs == "421300" {
  6532. bytesData, _ := json.Marshal(data)
  6533. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  6534. resp, _ := client.Do(req)
  6535. defer resp.Body.Close()
  6536. body, ioErr := ioutil.ReadAll(resp.Body)
  6537. if ioErr != nil {
  6538. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6540. return
  6541. }
  6542. var respJSON map[string]interface{}
  6543. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6544. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6546. return
  6547. }
  6548. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6549. userJSONBytes, _ := json.Marshal(respJSON)
  6550. fmt.Println("log")
  6551. fmt.Println(string(userJSONBytes))
  6552. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6553. utils.ErrorLog("解析失败:%v", err)
  6554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6555. return
  6556. }
  6557. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6558. bytesData, _ := json.Marshal(data)
  6559. var req *http.Request
  6560. if miConfig.MdtrtareaAdmvs == "320921" {
  6561. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6562. } else {
  6563. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6564. }
  6565. resp, _ := client.Do(req)
  6566. defer resp.Body.Close()
  6567. body, ioErr := ioutil.ReadAll(resp.Body)
  6568. if ioErr != nil {
  6569. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6571. return
  6572. }
  6573. var respJSON map[string]interface{}
  6574. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6575. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6577. return
  6578. }
  6579. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6580. userJSONBytes, _ := json.Marshal(respJSON)
  6581. fmt.Println("log")
  6582. fmt.Println(string(userJSONBytes))
  6583. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6584. utils.ErrorLog("解析失败:%v", err)
  6585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6586. return
  6587. }
  6588. res.InfRefmsgid = resFour10265.InfRefmsgid
  6589. res.Output = resFour10265.Output
  6590. res.ErrMsg = resFour10265.ErrMsg
  6591. res.Cainfo = resFour10265.Cainfo
  6592. res.WarnMsg = resFour10265.WarnMsg
  6593. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6594. res.Infcode = infocode
  6595. } else {
  6596. if miConfig.Code == "H15049901371" {
  6597. 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)
  6598. var dat map[string]interface{}
  6599. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6600. fmt.Println(dat)
  6601. } else {
  6602. fmt.Println(err)
  6603. }
  6604. saveLog(result, request_log, "2204", "上传费用明细")
  6605. userJSONBytes, _ := json.Marshal(dat)
  6606. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6607. utils.ErrorLog("解析失败:%v", err)
  6608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6609. return
  6610. }
  6611. res.InfRefmsgid = resFour10265.InfRefmsgid
  6612. res.Output = resFour10265.Output
  6613. res.ErrMsg = resFour10265.ErrMsg
  6614. res.Cainfo = resFour10265.Cainfo
  6615. res.WarnMsg = resFour10265.WarnMsg
  6616. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6617. res.Infcode = infocode
  6618. } else {
  6619. 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)
  6620. var dat map[string]interface{}
  6621. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6622. fmt.Println(dat)
  6623. } else {
  6624. fmt.Println(err)
  6625. }
  6626. saveLog(result, request_log, "2204", "上传费用明细")
  6627. userJSONBytes, _ := json.Marshal(dat)
  6628. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6629. utils.ErrorLog("解析失败:%v", err)
  6630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6631. return
  6632. }
  6633. }
  6634. }
  6635. if res.Infcode == 0 {
  6636. order := &models.HisOrder{
  6637. UserOrgId: adminUser.CurrentOrgId,
  6638. HisPatientId: his.ID,
  6639. PatientId: his.PatientId,
  6640. SettleAccountsDate: recordDateTime,
  6641. Ctime: time.Now().Unix(),
  6642. Mtime: time.Now().Unix(),
  6643. MdtrtId: his.Number,
  6644. PsnNo: his.PsnNo,
  6645. MedType: strconv.FormatInt(reg_type, 10),
  6646. Status: 1,
  6647. Number: chrg_bchno,
  6648. Infcode: res.Infcode,
  6649. WarnMsg: res.WarnMsg,
  6650. Cainfo: res.Cainfo,
  6651. ErrMsg: res.ErrMsg,
  6652. RespondTime: res.RefmsgTime,
  6653. InfRefmsgid: res.InfRefmsgid,
  6654. OrderStatus: 1,
  6655. IsMedicineInsurance: 1,
  6656. SettleType: settle_accounts_type,
  6657. SettleStartTime: start_time,
  6658. SettleEndTime: end_time,
  6659. Creator: roles.AdminUserId,
  6660. Modify: roles.AdminUserId,
  6661. PType: 2,
  6662. Diagnosis: diagnosis_id,
  6663. }
  6664. err = service.CreateOrder(order)
  6665. if err != nil {
  6666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6667. return
  6668. }
  6669. for _, item := range res.Output.Result {
  6670. temp := strings.Split(item.FeedetlSn, "-")
  6671. var advice_id int64 = 0
  6672. var project_id int64 = 0
  6673. var types int64 = 0
  6674. id, _ := strconv.ParseInt(temp[2], 10, 64)
  6675. types, _ = strconv.ParseInt(temp[1], 10, 64)
  6676. if temp[1] == "1" {
  6677. advice_id = id
  6678. project_id = 0
  6679. } else if temp[1] == "2" {
  6680. advice_id = 0
  6681. project_id = id
  6682. }
  6683. info := &models.HisOrderInfo{
  6684. OrderNumber: order.Number,
  6685. FeedetlSn: item.FeedetlSn,
  6686. UploadDate: time.Now().Unix(),
  6687. AdviceId: advice_id,
  6688. DetItemFeeSumamt: item.DetItemFeeSumamt,
  6689. Cnt: item.Cnt,
  6690. Pric: float64(item.Pric),
  6691. PatientId: his.PatientId,
  6692. PricUplmtAmt: item.PricUplmtAmt,
  6693. SelfpayProp: item.SelfpayProp,
  6694. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6695. OverlmtAmt: item.OverlmtAmt,
  6696. PreselfpayAmt: item.PreselfpayAmt,
  6697. BasMednFlag: item.BasMednFlag,
  6698. MedChrgitmType: item.MedChrgitmType,
  6699. HiNegoDrugFlag: item.HiNegoDrugFlag,
  6700. Status: 1,
  6701. Memo: item.Memo,
  6702. Mtime: time.Now().Unix(),
  6703. InscpScpAmt: item.InscpScpAmt,
  6704. DrtReimFlag: item.DrtReimFlag,
  6705. Ctime: time.Now().Unix(),
  6706. ListSpItemFlag: item.ListSpItemFlag,
  6707. ChldMedcFlag: item.ChldMedcFlag,
  6708. LmtUsedFlag: item.LmtUsedFlag,
  6709. ChrgitmLv: item.ChrgitmLv,
  6710. UserOrgId: adminUser.CurrentOrgId,
  6711. HisPatientId: his.ID,
  6712. OrderId: order.ID,
  6713. ProjectId: project_id,
  6714. Type: types,
  6715. }
  6716. service.CreateOrderInfo(info)
  6717. }
  6718. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6719. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  6720. var total float64
  6721. for _, item := range prescriptions {
  6722. if item.Type == 1 { //药品
  6723. for _, subItem := range item.HisDoctorAdviceInfo {
  6724. total = total + (subItem.Price * subItem.PrescribingNumber)
  6725. }
  6726. }
  6727. if item.Type == 2 { //项目
  6728. for _, subItem := range item.HisPrescriptionProject {
  6729. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6730. total = total + (subItem.Price * cnt)
  6731. }
  6732. }
  6733. }
  6734. for _, item := range prescriptions {
  6735. for _, subItem := range item.HisAdditionalCharge {
  6736. total = total + (subItem.Price * float64(subItem.Count))
  6737. }
  6738. }
  6739. allTotal := fmt.Sprintf("%.4f", total)
  6740. if res.Infcode == 0 {
  6741. var rf []*ResultFive
  6742. json.Unmarshal([]byte(his.Iinfo), &rf)
  6743. chrg_bchno := chrg_bchno
  6744. cert_no := his.Certno
  6745. var insutypes []string
  6746. var insutype string
  6747. var is390 int = 0
  6748. var is310 int = 0
  6749. for _, item := range rf {
  6750. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6751. insutypes = append(insutypes, item.Insutype)
  6752. }
  6753. }
  6754. if len(insutypes) == 1 {
  6755. insutype = insutypes[0]
  6756. } else {
  6757. for _, i := range insutypes {
  6758. if i == "390" {
  6759. is390 = 1
  6760. }
  6761. if i == "310" {
  6762. is310 = 1
  6763. }
  6764. }
  6765. }
  6766. if is390 == 1 {
  6767. insutype = "390"
  6768. }
  6769. if is310 == 1 {
  6770. insutype = "310"
  6771. }
  6772. if len(insutypes) == 0 {
  6773. insutype = "310"
  6774. }
  6775. if len(insutypes) == 2 {
  6776. insutype = strconv.FormatInt(his.SocialType, 64)
  6777. }
  6778. //insutype = "390"
  6779. if his.IdCardType == 1 {
  6780. cert_no = his.MedicalInsuranceNumber
  6781. } else {
  6782. cert_no = his.Certno
  6783. }
  6784. var res ResultSeven
  6785. var resSeven10265 ResultSeven10265
  6786. if miConfig.MdtrtareaAdmvs == "421300" {
  6787. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6788. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6789. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6790. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6791. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6792. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6793. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  6794. resp, requestErr := http.Get(api)
  6795. if requestErr != nil {
  6796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6797. return
  6798. }
  6799. body, ioErr := ioutil.ReadAll(resp.Body)
  6800. if ioErr != nil {
  6801. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6803. return
  6804. }
  6805. var respJSON map[string]interface{}
  6806. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6807. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6809. return
  6810. }
  6811. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6812. result, _ := json.Marshal(respJSON)
  6813. fmt.Println("log")
  6814. fmt.Println(string(result))
  6815. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6816. utils.ErrorLog("解析失败:%v", err)
  6817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6818. return
  6819. }
  6820. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6821. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6822. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6823. bas := strings.Split(psn_info.CardInfo, "|")
  6824. if his.IdCardType == 1 {
  6825. cert_no = bas[2]
  6826. } else {
  6827. cert_no = bas[1]
  6828. }
  6829. //江苏地区国家医保医疗类别
  6830. //职工透析:医疗类别选特殊情况门诊9933
  6831. //居民血透门慢: 医疗类别选门诊慢病1402
  6832. //var med_type string
  6833. //if his.Insutype == "310" {
  6834. // if reg_type == 14 {
  6835. // med_type = "9933"
  6836. // } else if reg_type == 11 {
  6837. // med_type = "11"
  6838. //
  6839. // }
  6840. //} else if his.Insutype == "390" {
  6841. // if reg_type == 14 {
  6842. // med_type = "1402"
  6843. // } else if reg_type == 11 {
  6844. // med_type = "11"
  6845. // }
  6846. //}
  6847. var api string
  6848. if miConfig.MdtrtareaAdmvs == "320921" {
  6849. api = "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6850. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6851. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6852. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6853. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6854. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6855. "&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
  6856. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6857. } else {
  6858. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6859. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6860. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6861. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6862. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6863. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6864. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6865. "&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
  6866. }
  6867. resp, requestErr := http.Get(api)
  6868. if requestErr != nil {
  6869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6870. return
  6871. }
  6872. body, ioErr := ioutil.ReadAll(resp.Body)
  6873. if ioErr != nil {
  6874. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6876. return
  6877. }
  6878. var respJSON map[string]interface{}
  6879. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6880. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6882. return
  6883. }
  6884. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6885. result, _ := json.Marshal(respJSON)
  6886. fmt.Println("log")
  6887. fmt.Println(string(result))
  6888. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6889. utils.ErrorLog("解析失败:%v", err)
  6890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6891. return
  6892. }
  6893. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6894. res.Output = resSeven10265.Output
  6895. res.ErrMsg = resSeven10265.ErrMsg
  6896. res.Cainfo = resSeven10265.Cainfo
  6897. res.WarnMsg = resSeven10265.WarnMsg
  6898. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6899. res.Infcode = infocode
  6900. } else {
  6901. var result string
  6902. var request_log string
  6903. if miConfig.Code == "H15049901371" {
  6904. //赤峰地区国家医保医疗类别
  6905. //职工透析:医疗类别选特殊情况门诊990502
  6906. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6907. var med_type string
  6908. if his.Insutype == "390" {
  6909. if reg_type == 14 {
  6910. med_type = "9933"
  6911. } else if reg_type == 11 {
  6912. med_type = "11"
  6913. }
  6914. } else if his.Insutype == "310" {
  6915. if reg_type == 14 {
  6916. med_type = "990502"
  6917. } else if reg_type == 11 {
  6918. med_type = "11"
  6919. }
  6920. }
  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, med_type, his.IdCardType, 0, 0, 0, 0, his.IdType)
  6922. } else {
  6923. 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)
  6924. }
  6925. var dat map[string]interface{}
  6926. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6927. fmt.Println(dat)
  6928. } else {
  6929. fmt.Println(err)
  6930. }
  6931. saveLog(result, request_log, "2206", "预结算")
  6932. //userJSONBytes, _ := json.Marshal(dat)
  6933. //
  6934. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6935. // utils.ErrorLog("解析失败:%v", err)
  6936. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6937. // return
  6938. //}
  6939. userJSONBytes, _ := json.Marshal(dat)
  6940. if miConfig.Code == "H15049901371" {
  6941. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6942. utils.ErrorLog("解析失败:%v", err)
  6943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6944. return
  6945. }
  6946. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6947. res.Output = resSeven10265.Output
  6948. res.ErrMsg = resSeven10265.ErrMsg
  6949. res.Cainfo = resSeven10265.Cainfo
  6950. res.WarnMsg = resSeven10265.WarnMsg
  6951. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6952. res.Infcode = infocode
  6953. } else {
  6954. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6955. utils.ErrorLog("解析失败:%v", err)
  6956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6957. return
  6958. }
  6959. }
  6960. }
  6961. if res.Infcode != 0 {
  6962. errlog := &models.HisOrderError{
  6963. UserOrgId: adminUser.CurrentOrgId,
  6964. Ctime: time.Now().Unix(),
  6965. Mtime: time.Now().Unix(),
  6966. Number: chrg_bchno,
  6967. ErrMsg: res.ErrMsg,
  6968. Status: 1,
  6969. PatientId: id,
  6970. RecordTime: recordDateTime,
  6971. Stage: 20,
  6972. }
  6973. service.CreateErrMsgLog(errlog)
  6974. c.ServeSuccessJSON(map[string]interface{}{
  6975. "failed_code": -10,
  6976. "msg": res.ErrMsg,
  6977. })
  6978. return
  6979. } else {
  6980. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6981. order.OrderStatus = 1
  6982. order.IsPre = 1
  6983. order.Status = 1
  6984. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6985. order.SetlId = res.Output.Setlinfo.SetlID
  6986. order.PsnNo = res.Output.Setlinfo.PsnNo
  6987. order.PsnName = res.Output.Setlinfo.PsnName
  6988. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6989. order.Certno = res.Output.Setlinfo.Certno
  6990. order.Gend = res.Output.Setlinfo.Gend
  6991. order.Naty = res.Output.Setlinfo.Naty
  6992. order.Age = res.Output.Setlinfo.Age
  6993. order.Insutype = res.Output.Setlinfo.Insutype
  6994. order.PsnType = res.Output.Setlinfo.PsnType
  6995. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6996. order.SetlTime = res.Output.Setlinfo.SetlTime
  6997. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6998. if res.Output.Setlinfo.MedType == "140101" {
  6999. order.MedType = "14"
  7000. } else {
  7001. order.MedType = res.Output.Setlinfo.MedType
  7002. }
  7003. if reg_type == 1112 {
  7004. order.MedType = "1112"
  7005. }
  7006. if reg_type == 1111 {
  7007. order.MedType = "1111"
  7008. }
  7009. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7010. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7011. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7012. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7013. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7014. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7015. order.HifpPay = res.Output.Setlinfo.HifpPay
  7016. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7017. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7018. order.HifesPay = res.Output.Setlinfo.HifesPay
  7019. order.HifobPay = res.Output.Setlinfo.HifobPay
  7020. order.MafPay = res.Output.Setlinfo.MafPay
  7021. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  7022. order.OthPay = res.Output.Setlinfo.OthPay
  7023. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7024. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7025. order.AcctPay = res.Output.Setlinfo.AcctPay
  7026. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7027. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7028. order.Balc = res.Output.Setlinfo.Balc
  7029. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7030. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7031. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7032. order.ClrWay = res.Output.Setlinfo.ClrWay
  7033. order.Creator = order.Creator
  7034. order.Modify = roles.AdminUserId
  7035. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7036. detailStr := string(setlDetail)
  7037. order.SetlDetail = detailStr
  7038. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7039. err = service.UpDateOrder(order)
  7040. if err == nil {
  7041. c.ServeSuccessJSON(map[string]interface{}{
  7042. "msg": "预结算成功",
  7043. })
  7044. } else {
  7045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7046. return
  7047. }
  7048. }
  7049. } else {
  7050. adminUser := c.GetAdminUserInfo()
  7051. errlog := &models.HisOrderError{
  7052. UserOrgId: adminUser.CurrentOrgId,
  7053. Ctime: time.Now().Unix(),
  7054. Mtime: time.Now().Unix(),
  7055. ErrMsg: res.ErrMsg,
  7056. Status: 1,
  7057. PatientId: id,
  7058. RecordTime: recordDateTime,
  7059. Stage: 4,
  7060. }
  7061. service.CreateErrMsgLog(errlog)
  7062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7063. return
  7064. }
  7065. } else {
  7066. adminUser := c.GetAdminUserInfo()
  7067. errlog := &models.HisOrderError{
  7068. UserOrgId: adminUser.CurrentOrgId,
  7069. Ctime: time.Now().Unix(),
  7070. Mtime: time.Now().Unix(),
  7071. ErrMsg: res.ErrMsg,
  7072. Status: 1,
  7073. PatientId: id,
  7074. RecordTime: recordDateTime,
  7075. Stage: 4,
  7076. }
  7077. service.CreateErrMsgLog(errlog)
  7078. c.ServeSuccessJSON(map[string]interface{}{
  7079. "failed_code": -10,
  7080. "msg": res.ErrMsg,
  7081. })
  7082. return
  7083. }
  7084. }
  7085. }
  7086. }
  7087. //func (c *HisApiController) GetSettleInfo() {
  7088. // id, _ := c.GetInt64("id")
  7089. // order_id, _ := c.GetInt64("order_id")
  7090. //
  7091. // record_time := c.GetString("record_time")
  7092. // pay_way, _ := c.GetInt64("pay_way")
  7093. // pay_price, _ := c.GetFloat("pay_price")
  7094. // pay_card_no := c.GetString("pay_card_no")
  7095. // discount_price, _ := c.GetFloat("discount_price")
  7096. // preferential_price, _ := c.GetFloat("preferential_price")
  7097. // reality_price, _ := c.GetFloat("reality_price")
  7098. // found_price, _ := c.GetFloat("found_price")
  7099. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  7100. // private_price, _ := c.GetFloat("private_price")
  7101. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7102. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7103. //
  7104. // timeLayout := "2006-01-02"
  7105. // loc, _ := time.LoadLocation("Local")
  7106. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7107. // if err != nil {
  7108. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7109. // return
  7110. // }
  7111. // recordDateTime := theTime.Unix()
  7112. // adminUser := c.GetAdminUserInfo()
  7113. //
  7114. // var prescriptions []*models.HisPrescription
  7115. //
  7116. // data := make(map[string]interface{})
  7117. // if settle_accounts_type == 1 { //日结
  7118. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  7119. // data["pre"] = prescriptions
  7120. //
  7121. // } else { //月结
  7122. // start_time_str := c.GetString("start_time")
  7123. // end_time_str := c.GetString("end_time")
  7124. // timeLayout := "2006-01-02"
  7125. // loc, _ := time.LoadLocation("Local")
  7126. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7127. // if err != nil {
  7128. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7129. // return
  7130. // }
  7131. // recordStartTime := theStartTime.Unix()
  7132. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7133. // if err != nil {
  7134. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7135. // return
  7136. // }
  7137. // recordEndTime := theEndTime.Unix()
  7138. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  7139. // data["pre"] = prescriptions
  7140. //
  7141. // }
  7142. //
  7143. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7144. //
  7145. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7146. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7147. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7148. // strconv.FormatInt(his.PatientId, 10)
  7149. //
  7150. // order_src, _ := service.GetHisOrderByID(order_id)
  7151. //
  7152. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7153. // if config.IsOpen == 1 { //对接了医保,走医保流程
  7154. //
  7155. // var total float64
  7156. // for _, item := range prescriptions {
  7157. // if item.Type == 1 { //药品
  7158. // for _, subItem := range item.HisDoctorAdviceInfo {
  7159. // total = total + (subItem.Price * subItem.PrescribingNumber)
  7160. // }
  7161. // }
  7162. // if item.Type == 2 { //项目
  7163. // for _, subItem := range item.HisPrescriptionProject {
  7164. // total = total + (subItem.Price * float64(subItem.Count))
  7165. // }
  7166. // }
  7167. // }
  7168. //
  7169. // for _, item := range prescriptions {
  7170. // for _, subItem := range item.HisAdditionalCharge {
  7171. // total = total + (subItem.Price * float64(subItem.Count))
  7172. // }
  7173. // }
  7174. //
  7175. // allTotal := fmt.Sprintf("%.2f", total)
  7176. // var rf []*ResultFive
  7177. // json.Unmarshal([]byte(his.Iinfo), &rf)
  7178. // psn_no := order_src.PsnNo
  7179. // mdtrt_id := order_src.MdtrtId
  7180. // chrg_bchno := order_src.Number
  7181. // cert_no := order_src.Certno
  7182. // insutype := rf[0].Insutype
  7183. //
  7184. // if his.IdCardType == 1 {
  7185. // cert_no = his.MedicalInsuranceNumber
  7186. // } else {
  7187. // cert_no = his.Certno
  7188. // }
  7189. //
  7190. // 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)
  7191. // var dat map[string]interface{}
  7192. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7193. // fmt.Println(dat)
  7194. // } else {
  7195. // fmt.Println(err)
  7196. // }
  7197. //
  7198. // userJSONBytes, _ := json.Marshal(dat)
  7199. //
  7200. //
  7201. //
  7202. // var res ResultSeven
  7203. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7204. // utils.ErrorLog("解析失败:%v", err)
  7205. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7206. // return
  7207. // }
  7208. // if res.Infcode == -1 {
  7209. // errlog := &models.HisOrderError{
  7210. // UserOrgId: adminUser.CurrentOrgId,
  7211. // Ctime: time.Now().Unix(),
  7212. // Mtime: time.Now().Unix(),
  7213. // Number: chrg_bchno,
  7214. // ErrMsg: res.ErrMsg,
  7215. // Status: 1,
  7216. // PatientId: id,
  7217. // RecordTime: recordDateTime,
  7218. // Stage: 6,
  7219. // }
  7220. // service.CreateErrMsgLog(errlog)
  7221. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7222. // return
  7223. // } else {
  7224. // order_src.OrderStatus = 2
  7225. // order_src.PayWay = pay_way
  7226. // order_src.PayPrice = pay_price
  7227. // order_src.PayCardNo = pay_card_no
  7228. // order_src.DiscountPrice = discount_price
  7229. // order_src.PreferentialPrice = preferential_price
  7230. // order_src.RealityPrice = reality_price
  7231. // order_src.FoundPrice = found_price
  7232. // order_src.MedicalInsurancePrice = medical_insurance_price
  7233. // order_src.PrivatePrice = private_price
  7234. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  7235. // order_src.SetlId = res.Output.Setlinfo.SetlID
  7236. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  7237. // order_src.PsnName = res.Output.Setlinfo.PsnName
  7238. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  7239. // order_src.Certno = res.Output.Setlinfo.Certno
  7240. // order_src.Gend = res.Output.Setlinfo.Gend
  7241. // order_src.Naty = res.Output.Setlinfo.Naty
  7242. // order_src.Age = res.Output.Setlinfo.Age
  7243. // order_src.Insutype = res.Output.Setlinfo.Insutype
  7244. // order_src.PsnType = res.Output.Setlinfo.PsnType
  7245. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7246. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  7247. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7248. // order_src.MedType = res.Output.Setlinfo.MedType
  7249. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7250. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7251. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7252. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7253. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7254. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7255. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  7256. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  7257. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7258. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  7259. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  7260. // order_src.MafPay = res.Output.Setlinfo.MafPay
  7261. // order_src.OthPay = res.Output.Setlinfo.OthPay
  7262. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7263. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7264. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  7265. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7266. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7267. // order_src.Balc = res.Output.Setlinfo.Balc
  7268. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7269. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7270. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  7271. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  7272. // order_src.Creator = order_src.Creator
  7273. // order_src.Modify = roles.ID
  7274. // order_src.RequestLog = src_resquest
  7275. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7276. // detailStr := string(setlDetail)
  7277. // order_src.SetlDetail = detailStr
  7278. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7279. // err = service.UpDateOrder(order_src)
  7280. //
  7281. // if err == nil {
  7282. // c.ServeSuccessJSON(map[string]interface{}{
  7283. // "msg": "结算成功",
  7284. // })
  7285. // } else {
  7286. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7287. // return
  7288. // }
  7289. // }
  7290. // }
  7291. //}
  7292. //退款
  7293. func (c *HisApiController) Refund() {
  7294. order_id, _ := c.GetInt64("order_id")
  7295. admin_user_id, _ := c.GetInt64("admin_user_id")
  7296. adminUser := c.GetAdminUserInfo()
  7297. var order models.HisOrder
  7298. order, _ = service.GetHisOrderByID(order_id)
  7299. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7300. if order.ID == 0 {
  7301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7302. return
  7303. }
  7304. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7305. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7306. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7307. if config.IsOpen == 1 { //对接了医保,走医保流程
  7308. var res ResultSixteen
  7309. var resSixteen10265 ResultSixteen10265
  7310. var src_resquest string
  7311. var result string
  7312. if miConfig.MdtrtareaAdmvs == "421300" {
  7313. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  7314. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7315. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7316. resp3, requestErr3 := http.Get(api3)
  7317. if requestErr3 != nil {
  7318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7319. return
  7320. }
  7321. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7322. if ioErr3 != nil {
  7323. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7325. return
  7326. }
  7327. var respJSON3 map[string]interface{}
  7328. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7329. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7331. return
  7332. }
  7333. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7334. userJSONBytes3, _ := json.Marshal(respJSON3)
  7335. fmt.Println("log")
  7336. fmt.Println(string(userJSONBytes3))
  7337. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  7338. utils.ErrorLog("解析失败:%v", err)
  7339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7340. return
  7341. }
  7342. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7343. var api3 string
  7344. if miConfig.MdtrtareaAdmvs == "320921" {
  7345. api3 = "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7346. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7347. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7348. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7349. } else {
  7350. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7351. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7352. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7353. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7354. }
  7355. resp3, requestErr3 := http.Get(api3)
  7356. if requestErr3 != nil {
  7357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7358. return
  7359. }
  7360. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7361. if ioErr3 != nil {
  7362. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7364. return
  7365. }
  7366. var respJSON3 map[string]interface{}
  7367. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7368. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7370. return
  7371. }
  7372. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7373. userJSONBytes3, _ := json.Marshal(respJSON3)
  7374. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  7375. utils.ErrorLog("解析失败:%v", err)
  7376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7377. return
  7378. }
  7379. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7380. res.Output = resSixteen10265.Output
  7381. res.ErrMsg = resSixteen10265.ErrMsg
  7382. res.Cainfo = resSixteen10265.Cainfo
  7383. res.WarnMsg = resSixteen10265.WarnMsg
  7384. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7385. res.Infcode = infocode
  7386. } else {
  7387. if miConfig.Code == "H15049901371" {
  7388. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7389. var dat map[string]interface{}
  7390. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7391. fmt.Println(dat)
  7392. } else {
  7393. fmt.Println(err)
  7394. }
  7395. saveLog(result, src_resquest, "2208", "退费")
  7396. userJSONBytes, _ := json.Marshal(dat)
  7397. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  7398. utils.ErrorLog("解析失败:%v", err)
  7399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7400. return
  7401. }
  7402. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7403. res.Output = resSixteen10265.Output
  7404. res.ErrMsg = resSixteen10265.ErrMsg
  7405. res.Cainfo = resSixteen10265.Cainfo
  7406. res.WarnMsg = resSixteen10265.WarnMsg
  7407. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7408. res.Infcode = infocode
  7409. } else {
  7410. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7411. var dat map[string]interface{}
  7412. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7413. fmt.Println(dat)
  7414. } else {
  7415. fmt.Println(err)
  7416. }
  7417. saveLog(result, src_resquest, "2208", "退费")
  7418. userJSONBytes, _ := json.Marshal(dat)
  7419. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7420. utils.ErrorLog("解析失败:%v", err)
  7421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7422. return
  7423. }
  7424. }
  7425. }
  7426. if res.Infcode == 0 {
  7427. var res2 ResultSix
  7428. var resSix10265 ResultSix10265
  7429. if miConfig.MdtrtareaAdmvs == "421300" {
  7430. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7431. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7432. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7433. resp3, requestErr3 := http.Get(api3)
  7434. if requestErr3 != nil {
  7435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7436. return
  7437. }
  7438. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7439. if ioErr3 != nil {
  7440. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7442. return
  7443. }
  7444. var respJSON3 map[string]interface{}
  7445. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7446. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7448. return
  7449. }
  7450. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7451. userJSONBytes3, _ := json.Marshal(respJSON3)
  7452. fmt.Println("log")
  7453. fmt.Println(string(userJSONBytes3))
  7454. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7455. utils.ErrorLog("解析失败:%v", err)
  7456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7457. return
  7458. }
  7459. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7460. var api3 string
  7461. if miConfig.MdtrtareaAdmvs == "320921" {
  7462. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7463. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7464. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7465. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7466. } else {
  7467. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7468. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7469. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7470. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7471. }
  7472. resp3, requestErr3 := http.Get(api3)
  7473. if requestErr3 != nil {
  7474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7475. return
  7476. }
  7477. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7478. if ioErr3 != nil {
  7479. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7481. return
  7482. }
  7483. var respJSON3 map[string]interface{}
  7484. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7485. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7487. return
  7488. }
  7489. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7490. userJSONBytes3, _ := json.Marshal(respJSON3)
  7491. fmt.Println("log")
  7492. fmt.Println(string(userJSONBytes3))
  7493. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7494. utils.ErrorLog("解析失败:%v", err)
  7495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7496. return
  7497. }
  7498. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7499. res2.Output = resSix10265.Output
  7500. res2.ErrMsg = resSix10265.ErrMsg
  7501. res2.Cainfo = resSix10265.Cainfo
  7502. res2.WarnMsg = resSix10265.WarnMsg
  7503. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7504. res2.Infcode = infocode
  7505. } else {
  7506. if miConfig.Code == "H15049901371" {
  7507. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7508. var dat map[string]interface{}
  7509. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7510. fmt.Println(dat)
  7511. } else {
  7512. fmt.Println(err)
  7513. }
  7514. saveLog(result2, src_request, "2205", "撤销明细")
  7515. userJSONBytes, _ := json.Marshal(dat)
  7516. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7517. utils.ErrorLog("解析失败:%v", err)
  7518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7519. return
  7520. }
  7521. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7522. res2.Output = resSix10265.Output
  7523. res2.ErrMsg = resSix10265.ErrMsg
  7524. res2.Cainfo = resSix10265.Cainfo
  7525. res2.WarnMsg = resSix10265.WarnMsg
  7526. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7527. res2.Infcode = infocode
  7528. } else {
  7529. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7530. var dat map[string]interface{}
  7531. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7532. fmt.Println(dat)
  7533. } else {
  7534. fmt.Println(err)
  7535. }
  7536. saveLog(result2, src_request, "2205", "撤销明细")
  7537. userJSONBytes, _ := json.Marshal(dat)
  7538. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7539. utils.ErrorLog("解析失败:%v", err)
  7540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7541. return
  7542. }
  7543. }
  7544. }
  7545. if res2.Infcode == 0 {
  7546. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  7547. if err == nil {
  7548. c.ServeSuccessJSON(map[string]interface{}{
  7549. "msg": "退费成功",
  7550. })
  7551. } else {
  7552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7553. return
  7554. }
  7555. } else {
  7556. c.ServeSuccessJSON(map[string]interface{}{
  7557. "code": -10,
  7558. "msg": res2.ErrMsg,
  7559. })
  7560. }
  7561. } else {
  7562. c.ServeSuccessJSON(map[string]interface{}{
  7563. "code": -10,
  7564. "msg": res.ErrMsg,
  7565. })
  7566. }
  7567. }
  7568. }
  7569. func (c *HisApiController) RefundNumber() {
  7570. record_time := c.GetString("record_time")
  7571. //patient_id, _ := c.GetInt64("patient_id")
  7572. admin_user_id, _ := c.GetInt64("admin_user_id")
  7573. his_patient_id, _ := c.GetInt64("id")
  7574. timeLayout := "2006-01-02"
  7575. loc, _ := time.LoadLocation("Local")
  7576. adminUser := c.GetAdminUserInfo()
  7577. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7578. fmt.Println(err)
  7579. if err != nil {
  7580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7581. return
  7582. }
  7583. recordDateTime := theTime.Unix()
  7584. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7585. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  7586. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7587. //order, _ := service.GetHisOrderByID(order_id)
  7588. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7589. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7590. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7591. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  7592. if count > 0 {
  7593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  7594. return
  7595. }
  7596. if config.IsOpen == 1 { //对接了医保,走医保流程
  7597. var res2 ResultSix
  7598. var resSix10265 ResultSix10265
  7599. if miConfig.MdtrtareaAdmvs == "421300" {
  7600. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  7601. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7602. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7603. resp3, requestErr3 := http.Get(api3)
  7604. if requestErr3 != nil {
  7605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7606. return
  7607. }
  7608. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7609. if ioErr3 != nil {
  7610. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7612. return
  7613. }
  7614. var respJSON3 map[string]interface{}
  7615. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7616. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7618. return
  7619. }
  7620. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7621. userJSONBytes3, _ := json.Marshal(respJSON3)
  7622. fmt.Println("log")
  7623. fmt.Println(string(userJSONBytes3))
  7624. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7625. utils.ErrorLog("解析失败:%v", err)
  7626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7627. return
  7628. }
  7629. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7630. var api3 string
  7631. if miConfig.MdtrtareaAdmvs == "320921" {
  7632. api3 = "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  7633. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7634. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7635. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7636. } else {
  7637. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7638. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  7639. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7640. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7641. }
  7642. resp3, requestErr3 := http.Get(api3)
  7643. if requestErr3 != nil {
  7644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7645. return
  7646. }
  7647. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7648. if ioErr3 != nil {
  7649. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7651. return
  7652. }
  7653. var respJSON3 map[string]interface{}
  7654. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7655. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7657. return
  7658. }
  7659. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7660. userJSONBytes3, _ := json.Marshal(respJSON3)
  7661. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7662. utils.ErrorLog("解析失败:%v", err)
  7663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7664. return
  7665. }
  7666. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7667. res2.Output = resSix10265.Output
  7668. res2.ErrMsg = resSix10265.ErrMsg
  7669. res2.Cainfo = resSix10265.Cainfo
  7670. res2.WarnMsg = resSix10265.WarnMsg
  7671. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7672. res2.Infcode = infocode
  7673. } else {
  7674. var api3 string
  7675. if miConfig.Code == "H15049901371" {
  7676. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7677. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7678. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7679. } else {
  7680. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7681. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7682. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7683. }
  7684. resp3, requestErr3 := http.Get(api3)
  7685. if requestErr3 != nil {
  7686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7687. return
  7688. }
  7689. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7690. if ioErr3 != nil {
  7691. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7693. return
  7694. }
  7695. var respJSON3 map[string]interface{}
  7696. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7697. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7699. return
  7700. }
  7701. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7702. userJSONBytes3, _ := json.Marshal(respJSON3)
  7703. if miConfig.Code == "H15049901371" {
  7704. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7705. utils.ErrorLog("解析失败:%v", err)
  7706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7707. return
  7708. }
  7709. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7710. res2.Output = resSix10265.Output
  7711. res2.ErrMsg = resSix10265.ErrMsg
  7712. res2.Cainfo = resSix10265.Cainfo
  7713. res2.WarnMsg = resSix10265.WarnMsg
  7714. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7715. res2.Infcode = infocode
  7716. } else {
  7717. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7718. utils.ErrorLog("解析失败:%v", err)
  7719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7720. return
  7721. }
  7722. }
  7723. }
  7724. if res2.Infcode == 0 {
  7725. if err == nil {
  7726. c.ServeSuccessJSON(map[string]interface{}{
  7727. "msg": "退号成功",
  7728. })
  7729. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  7730. } else {
  7731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7732. return
  7733. }
  7734. } else {
  7735. c.ServeSuccessJSON(map[string]interface{}{
  7736. "code": -10,
  7737. "msg": res2.ErrMsg,
  7738. })
  7739. }
  7740. } else {
  7741. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  7742. //if err == nil {
  7743. // c.ServeSuccessJSON(map[string]interface{}{
  7744. // "msg": "退费成功",
  7745. // })
  7746. //} else {
  7747. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7748. // return
  7749. //}
  7750. }
  7751. }
  7752. func (c *HisApiController) RefundDetail() {
  7753. order_id, _ := c.GetInt64("order_id")
  7754. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7755. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7756. number := c.GetString("number")
  7757. record_time := c.GetString("record_time")
  7758. patient_id, _ := c.GetInt64("patient_id")
  7759. //med_type, _ := c.GetInt64("med_type")
  7760. timeLayout := "2006-01-02"
  7761. loc, _ := time.LoadLocation("Local")
  7762. adminUser := c.GetAdminUserInfo()
  7763. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7764. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7765. fmt.Println(err)
  7766. if err != nil {
  7767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7768. return
  7769. }
  7770. recordDateTime := theTime.Unix()
  7771. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7772. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7773. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7774. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7775. var order models.HisOrder
  7776. order, _ = service.GetHisOrderByID(order_id)
  7777. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7778. if config.IsOpen == 1 { //对接了医保,走医保流程
  7779. var res2 ResultSix
  7780. if miConfig.MdtrtareaAdmvs == "421300" {
  7781. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7782. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7783. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7784. resp3, requestErr3 := http.Get(api3)
  7785. if requestErr3 != nil {
  7786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7787. return
  7788. }
  7789. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7790. if ioErr3 != nil {
  7791. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7793. return
  7794. }
  7795. var respJSON3 map[string]interface{}
  7796. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7797. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7799. return
  7800. }
  7801. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7802. userJSONBytes3, _ := json.Marshal(respJSON3)
  7803. fmt.Println("log")
  7804. fmt.Println(string(userJSONBytes3))
  7805. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7806. utils.ErrorLog("解析失败:%v", err)
  7807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7808. return
  7809. }
  7810. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7811. if err == nil {
  7812. c.ServeSuccessJSON(map[string]interface{}{
  7813. "msg": "撤销明细成功",
  7814. })
  7815. return
  7816. } else {
  7817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7818. return
  7819. }
  7820. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7821. var resSix10265 ResultSix10265
  7822. var api3 string
  7823. if miConfig.MdtrtareaAdmvs == "320921" {
  7824. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7825. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7826. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7827. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7828. } else {
  7829. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7830. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7831. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7832. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7833. }
  7834. resp3, requestErr3 := http.Get(api3)
  7835. if requestErr3 != nil {
  7836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7837. return
  7838. }
  7839. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7840. if ioErr3 != nil {
  7841. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7843. return
  7844. }
  7845. var respJSON3 map[string]interface{}
  7846. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7847. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7849. return
  7850. }
  7851. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7852. userJSONBytes3, _ := json.Marshal(respJSON3)
  7853. fmt.Println("log")
  7854. fmt.Println(string(userJSONBytes3))
  7855. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7856. utils.ErrorLog("解析失败:%v", err)
  7857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7858. return
  7859. }
  7860. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7861. res2.Output = resSix10265.Output
  7862. res2.ErrMsg = resSix10265.ErrMsg
  7863. res2.Cainfo = resSix10265.Cainfo
  7864. res2.WarnMsg = resSix10265.WarnMsg
  7865. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7866. res2.Infcode = infocode
  7867. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7868. if err == nil {
  7869. c.ServeSuccessJSON(map[string]interface{}{
  7870. "msg": "撤销明细成功",
  7871. })
  7872. return
  7873. } else {
  7874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7875. return
  7876. }
  7877. } else {
  7878. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  7879. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7880. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7881. resp2, requestErr2 := http.Get(api2)
  7882. if requestErr2 != nil {
  7883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7884. return
  7885. }
  7886. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7887. if ioErr2 != nil {
  7888. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7890. return
  7891. }
  7892. var respJSON2 map[string]interface{}
  7893. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  7894. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7896. return
  7897. }
  7898. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7899. if err == nil {
  7900. c.ServeSuccessJSON(map[string]interface{}{
  7901. "msg": "撤销明细成功",
  7902. })
  7903. return
  7904. } else {
  7905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7906. return
  7907. }
  7908. }
  7909. } else {
  7910. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7911. if err == nil {
  7912. c.ServeSuccessJSON(map[string]interface{}{
  7913. "msg": "退费成功",
  7914. })
  7915. } else {
  7916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7917. return
  7918. }
  7919. }
  7920. }
  7921. //对账
  7922. func (c *HisApiController) GetCheckAccount() {
  7923. start_time := c.GetString("start_time")
  7924. end_time := c.GetString("end_time")
  7925. insutype := c.GetString("insutype")
  7926. clr_type := c.GetString("clr_type")
  7927. clr_org := c.GetString("clr_optins")
  7928. admin_user_id, _ := c.GetInt64("admin_user_id")
  7929. adminUser := c.GetAdminUserInfo()
  7930. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7931. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7932. if len(clr_org) == 0 {
  7933. clr_org = miConfig.MdtrtareaAdmvs
  7934. }
  7935. timeLayout := "2006-01-02"
  7936. loc, _ := time.LoadLocation("Local")
  7937. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  7938. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  7939. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_org, clr_type)
  7940. fixmedins_setl_cnt := int64(len(orders))
  7941. var medfee_sumamt float64
  7942. var acct_pay float64
  7943. var fund_pay_sumamt float64
  7944. for _, item := range orders {
  7945. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  7946. acct_pay = acct_pay + item.AcctPay
  7947. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  7948. }
  7949. var user_name string
  7950. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7951. if role.ID == 0 {
  7952. user_name = "xxx"
  7953. } else {
  7954. user_name = role.UserName
  7955. }
  7956. var res ResultEight
  7957. var res10188 ResultEightFor10188
  7958. if config.IsOpen == 1 {
  7959. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7960. api := "http://192.168.3.111:9532/" + "jsyb/3201?" +
  7961. "insutype=" + insutype +
  7962. "&clr_type=" + "11" +
  7963. "&setl_optins=" + clr_org +
  7964. "&stmt_begndate=" + start_time +
  7965. "&stm_enddate=" + end_time +
  7966. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7967. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7968. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7969. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7970. "&fixmedins_code=" + miConfig.Code +
  7971. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7972. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7973. "&secret_key=" + miConfig.SecretKey +
  7974. "&org_name=" + miConfig.OrgName +
  7975. "&doctor=" + user_name +
  7976. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7977. fmt.Println(api)
  7978. resp, requestErr := http.Get(api)
  7979. if requestErr != nil {
  7980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7981. return
  7982. }
  7983. body, ioErr := ioutil.ReadAll(resp.Body)
  7984. fmt.Println(body)
  7985. if ioErr != nil {
  7986. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7988. return
  7989. }
  7990. var respJSON map[string]interface{}
  7991. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7992. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7994. return
  7995. }
  7996. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7997. userJSONBytes, _ := json.Marshal(respJSON)
  7998. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7999. utils.ErrorLog("解析失败:%v", err)
  8000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8001. return
  8002. }
  8003. res.InfRefmsgid = res10188.InfRefmsgid
  8004. res.Output = res10188.Output
  8005. res.ErrMsg = res10188.ErrMsg
  8006. res.Cainfo = res10188.Cainfo
  8007. res.WarnMsg = res10188.WarnMsg
  8008. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8009. res.Infcode = infocode
  8010. } else {
  8011. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8012. "insutype=" + insutype +
  8013. "&clr_type=" + clr_type +
  8014. "&setl_optins=" + clr_org +
  8015. "&stmt_begndate=" + start_time +
  8016. "&stm_enddate=" + end_time +
  8017. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8018. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8019. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8020. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8021. "&fixmedins_code=" + miConfig.Code +
  8022. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8023. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8024. "&secret_key=" + miConfig.SecretKey +
  8025. "&org_name=" + miConfig.OrgName +
  8026. "&doctor=" + user_name
  8027. fmt.Println(api)
  8028. resp, requestErr := http.Get(api)
  8029. if requestErr != nil {
  8030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8031. return
  8032. }
  8033. body, ioErr := ioutil.ReadAll(resp.Body)
  8034. fmt.Println(body)
  8035. if ioErr != nil {
  8036. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8038. return
  8039. }
  8040. var respJSON map[string]interface{}
  8041. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8042. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8044. return
  8045. }
  8046. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8047. userJSONBytes, _ := json.Marshal(respJSON)
  8048. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8049. utils.ErrorLog("解析失败:%v", err)
  8050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8051. return
  8052. }
  8053. }
  8054. if res.Infcode == 0 {
  8055. if res.Output.Stmtinfo.StmtRslt == "0" {
  8056. micc := &models.MedicalInsuranceCostCompare{
  8057. StartTime: startime.Unix(),
  8058. EndTime: endtime.Unix(),
  8059. Insutype: insutype,
  8060. CheckType: 1,
  8061. Num: fixmedins_setl_cnt,
  8062. Mtime: time.Now().Unix(),
  8063. Status: 1,
  8064. UserOrgId: adminUser.CurrentOrgId,
  8065. CostTotal: medfee_sumamt,
  8066. FuncTotal: fund_pay_sumamt,
  8067. PsnPay: acct_pay,
  8068. Creator: admin_user_id,
  8069. Ctime: time.Now().Unix(),
  8070. ClrType: clr_type,
  8071. }
  8072. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  8073. if err == nil {
  8074. c.ServeSuccessJSON(map[string]interface{}{
  8075. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8076. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8077. })
  8078. } else {
  8079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8080. }
  8081. } else {
  8082. c.ServeSuccessJSON(map[string]interface{}{
  8083. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8084. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8085. })
  8086. }
  8087. } else {
  8088. c.ServeSuccessJSON(map[string]interface{}{
  8089. "code": -10,
  8090. "msg": res.ErrMsg,
  8091. })
  8092. }
  8093. }
  8094. }
  8095. func (c *HisApiController) Check310() {
  8096. adminUser := c.GetAdminUserInfo()
  8097. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8098. var user_name string
  8099. user_name = "高慧裕"
  8100. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8101. "insutype=" + "310" +
  8102. "&clr_type=" + "" +
  8103. "&setl_optins=" + "441202" +
  8104. "&stmt_begndate=" + "2022-03-01" +
  8105. "&stm_enddate=" + "2022-03-31" +
  8106. "&medfee_sumamt=" + "194930.12" +
  8107. "&fund_pay_sumamt=" + "188741.46" +
  8108. "&acct_pay=" + "0" +
  8109. "&fixmedins_setl_cnt=" + "452" +
  8110. "&fixmedins_code=" + miConfig.Code +
  8111. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8112. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8113. "&secret_key=" + miConfig.SecretKey +
  8114. "&org_name=" + miConfig.OrgName +
  8115. "&doctor=" + user_name
  8116. fmt.Println(api)
  8117. resp, requestErr := http.Get(api)
  8118. if requestErr != nil {
  8119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8120. return
  8121. }
  8122. body, ioErr := ioutil.ReadAll(resp.Body)
  8123. fmt.Println(body)
  8124. if ioErr != nil {
  8125. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8127. return
  8128. }
  8129. var respJSON map[string]interface{}
  8130. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8131. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8133. return
  8134. }
  8135. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8136. userJSONBytes, _ := json.Marshal(respJSON)
  8137. var res ResultEight
  8138. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8139. utils.ErrorLog("解析失败:%v", err)
  8140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8141. return
  8142. }
  8143. }
  8144. func (c *HisApiController) Check390() {
  8145. adminUser := c.GetAdminUserInfo()
  8146. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8147. var user_name string
  8148. user_name = "高慧裕"
  8149. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8150. "insutype=" + "390" +
  8151. "&clr_type=" + "" +
  8152. "&setl_optins=" + "441202" +
  8153. "&stmt_begndate=" + "2022-03-01" +
  8154. "&stm_enddate=" + "2022-03-31" +
  8155. "&medfee_sumamt=" + "1068448.89" +
  8156. "&fund_pay_sumamt=" + "1014677.62" +
  8157. "&acct_pay=" + "0" +
  8158. "&fixmedins_setl_cnt=" + "1950" +
  8159. "&fixmedins_code=" + miConfig.Code +
  8160. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8161. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8162. "&secret_key=" + miConfig.SecretKey +
  8163. "&org_name=" + miConfig.OrgName +
  8164. "&doctor=" + user_name
  8165. fmt.Println(api)
  8166. resp, requestErr := http.Get(api)
  8167. if requestErr != nil {
  8168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8169. return
  8170. }
  8171. body, ioErr := ioutil.ReadAll(resp.Body)
  8172. fmt.Println(body)
  8173. if ioErr != nil {
  8174. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8176. return
  8177. }
  8178. var respJSON map[string]interface{}
  8179. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8180. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8182. return
  8183. }
  8184. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8185. userJSONBytes, _ := json.Marshal(respJSON)
  8186. var res ResultEight
  8187. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8188. utils.ErrorLog("解析失败:%v", err)
  8189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8190. return
  8191. }
  8192. }
  8193. //对账明细
  8194. func (c *HisApiController) GetCheckDetailAccount() {
  8195. start_time := c.GetString("start_time")
  8196. end_time := c.GetString("end_time")
  8197. admin_user_id, _ := c.GetInt64("admin_user_id")
  8198. adminUser := c.GetAdminUserInfo()
  8199. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8200. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8201. timeLayout := "2006-01-02"
  8202. loc, _ := time.LoadLocation("Local")
  8203. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8204. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8205. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  8206. Mkdir(miConfig.OrgName)
  8207. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  8208. file_name := file + ".txt"
  8209. zip_name := file + ".zip"
  8210. zip_path := miConfig.OrgName + "/" + zip_name
  8211. file_path := miConfig.OrgName + "/" + file_name
  8212. decimal.DivisionPrecision = 2
  8213. var medfee_sumamt float64
  8214. var psn_cash_pay float64
  8215. var fund_pay_sumamt float64
  8216. fixmedins_setl_cnt := int64(len(orders))
  8217. for _, item := range orders {
  8218. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8219. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  8220. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8221. }
  8222. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  8223. defer f.Close()
  8224. if err != nil {
  8225. fmt.Println(err.Error())
  8226. } else {
  8227. for _, item := range orders {
  8228. var refd_setl_flag string
  8229. if item.OrderStatus == 2 {
  8230. refd_setl_flag = "0"
  8231. var str string
  8232. str = item.SetlId + " " +
  8233. item.MdtrtId + " " +
  8234. item.PsnNo + " " +
  8235. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8236. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8237. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  8238. _, err = f.Write([]byte(str))
  8239. }
  8240. if item.OrderStatus == 3 {
  8241. var str string
  8242. str = item.SetlId + " " +
  8243. item.MdtrtId + " " +
  8244. item.PsnNo + " " +
  8245. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8246. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8247. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  8248. _, err = f.Write([]byte(str))
  8249. var str2 string
  8250. str2 = item.SetlId + " " +
  8251. item.MdtrtId + " " +
  8252. item.PsnNo + " " +
  8253. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  8254. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  8255. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  8256. _, err = f.Write([]byte(str2))
  8257. }
  8258. }
  8259. }
  8260. Zip(file_path, zip_path)
  8261. fmt.Println(ReadFile(zip_path))
  8262. fmt.Println(string(ReadFile(zip_path)))
  8263. if config.IsOpen == 1 {
  8264. var user_name string
  8265. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8266. if role.ID == 0 {
  8267. user_name = "管理员"
  8268. } else {
  8269. user_name = role.UserName
  8270. }
  8271. baseParams := models.BaseParams{
  8272. SecretKey: miConfig.SecretKey,
  8273. FixmedinsCode: miConfig.Code,
  8274. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8275. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8276. OrgName: miConfig.OrgName,
  8277. Doctor: user_name,
  8278. }
  8279. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  8280. var dat map[string]interface{}
  8281. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8282. fmt.Println(dat)
  8283. } else {
  8284. fmt.Println(err)
  8285. }
  8286. userJSONBytes, _ := json.Marshal(dat)
  8287. var res ResultNine
  8288. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8289. utils.ErrorLog("解析失败:%v", err)
  8290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8291. return
  8292. }
  8293. if res.Infcode == 0 {
  8294. fileNo := res.Output.FileQuryNo
  8295. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  8296. "file_qury_no=" + fileNo +
  8297. "&setl_optins=" + "定点医保中心" +
  8298. "&stmt_begndate=" + start_time +
  8299. "&stm_enddate=" + end_time +
  8300. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8301. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8302. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  8303. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8304. "&fixmedins_code=" + miConfig.Code +
  8305. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8306. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8307. "&secret_key=" + miConfig.SecretKey +
  8308. "&org_name=" + miConfig.OrgName +
  8309. "&doctor=" + user_name
  8310. resp, requestErr := http.Get(api)
  8311. if requestErr != nil {
  8312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8313. return
  8314. }
  8315. body, ioErr := ioutil.ReadAll(resp.Body)
  8316. if ioErr != nil {
  8317. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8319. return
  8320. }
  8321. var respJSON map[string]interface{}
  8322. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8323. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8325. return
  8326. }
  8327. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8328. userJSONBytes, _ := json.Marshal(respJSON)
  8329. var res ResultTen
  8330. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8331. utils.ErrorLog("解析失败:%v", err)
  8332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8333. return
  8334. }
  8335. if res.Infcode == 0 {
  8336. service.Gdyb9102(baseParams, zip_name, fileNo)
  8337. micc := &models.MedicalInsuranceCostCompare{
  8338. StartTime: startime.Unix(),
  8339. EndTime: endtime.Unix(),
  8340. Insutype: "0",
  8341. CheckType: 2,
  8342. Num: fixmedins_setl_cnt,
  8343. Mtime: time.Now().Unix(),
  8344. Status: 1,
  8345. UserOrgId: adminUser.CurrentOrgId,
  8346. CostTotal: medfee_sumamt,
  8347. FuncTotal: fund_pay_sumamt,
  8348. PsnPay: psn_cash_pay,
  8349. Creator: admin_user_id,
  8350. Ctime: time.Now().Unix(),
  8351. }
  8352. service.CreateMedicalInsuranceCostCompareRecord(micc)
  8353. c.ServeSuccessJSON(map[string]interface{}{
  8354. "msg": "明细对账成功",
  8355. })
  8356. }
  8357. } else {
  8358. }
  8359. }
  8360. }
  8361. type CustomOrderInfo struct {
  8362. Name string
  8363. Spec string
  8364. Unit string
  8365. Count float64
  8366. Price float64
  8367. Total float64
  8368. }
  8369. func (c *HisApiController) GetSettleAccounts() {
  8370. //id, _ := c.GetInt64("id")
  8371. //record_time := c.GetString("record_time")
  8372. order_id, _ := c.GetInt64("order_id")
  8373. admin_user_id, _ := c.GetInt64("admin_user_id")
  8374. //timeLayout := "2006-01-02"
  8375. //loc, _ := time.LoadLocation("Local")
  8376. //
  8377. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8378. //if err != nil {
  8379. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8380. // return
  8381. //}
  8382. //recordDateTime := theTime.Unix()
  8383. adminUser := c.GetAdminUserInfo()
  8384. order, _ := service.GetHisOrderByID(order_id)
  8385. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8386. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  8387. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8388. orderInfos = append(orderInfos, orderInfos_two...)
  8389. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8390. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  8391. var diagnosis_ids []string
  8392. if his.ID > 0 {
  8393. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  8394. } else {
  8395. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  8396. }
  8397. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  8398. var dia_config []*models.HisXtDiagnoseConfig
  8399. var name string
  8400. for _, item := range diagnosis_ids {
  8401. id, _ := strconv.ParseInt(item, 10, 64)
  8402. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8403. dia_config = append(dia_config, &diagnosisConfig)
  8404. if len(name) == 0 {
  8405. name = diagnosisConfig.ClassName
  8406. } else {
  8407. name = name + "," + diagnosisConfig.ClassName
  8408. }
  8409. }
  8410. var bedCostTotal float64 = 0 //床位总费
  8411. var bedCostSelfTotal float64 = 0 //床位自费
  8412. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  8413. var operationCostTotal float64 = 0 //手术费
  8414. var operationCostSelfTotal float64 = 0 //手术费
  8415. var operationCostPartSelfTotal float64 = 0 //手术费
  8416. var otherCostTotal float64 = 0 //其他费用
  8417. var otherCostSelfTotal float64 = 0 //其他费用
  8418. var otherCostPartSelfTotal float64 = 0 //其他费用
  8419. var materialCostTotal float64 = 0 //材料费
  8420. var materialCostSelfTotal float64 = 0 //材料费
  8421. var materialCostPartSelfTotal float64 = 0 //材料费
  8422. var westernMedicineCostTotal float64 = 0 //西药费
  8423. var westernMedicineCostSelfTotal float64 = 0 //西药费
  8424. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  8425. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  8426. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  8427. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  8428. var checkCostTotal float64 = 0 //检查费
  8429. var checkCostSelfTotal float64 = 0 //检查费
  8430. var checkCostPartSelfTotal float64 = 0 //检查费
  8431. var laboratoryCostTotal float64 = 0 //化验费
  8432. var laboratoryCostSelfTotal float64 = 0 //化验费
  8433. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  8434. var treatCostTotal float64 = 0 //治疗费用
  8435. var treatCostSelfTotal float64 = 0 //治疗费用
  8436. var treatCostPartSelfTotal float64 = 0 //治疗费用
  8437. decimal.DivisionPrecision = 2
  8438. for _, item := range orderInfos {
  8439. if item.MedChrgitmType == "01" { //床位费
  8440. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8441. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8442. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8443. }
  8444. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  8445. if item.MedChrgitmType == "03" { //检查费
  8446. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8447. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8448. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8449. }
  8450. } else {
  8451. if item.MedChrgitmType == "03" { //检查费
  8452. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8453. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8454. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8455. }
  8456. }
  8457. if item.MedChrgitmType == "04" { //化验费
  8458. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8459. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8460. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8461. }
  8462. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  8463. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8464. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8465. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8466. }
  8467. if item.MedChrgitmType == "06" { //手术费
  8468. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8469. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8470. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8471. }
  8472. if item.MedChrgitmType == "08" { //材料费
  8473. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8474. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8475. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8476. }
  8477. if item.MedChrgitmType == "09" { //西药费
  8478. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8479. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8480. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8481. }
  8482. if item.MedChrgitmType == "11" { //中成费
  8483. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8484. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8485. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8486. }
  8487. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  8488. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8489. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8490. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8491. }
  8492. }
  8493. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8494. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8495. var user_name string
  8496. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8497. if role.ID == 0 {
  8498. user_name = "管理员"
  8499. } else {
  8500. user_name = role.UserName
  8501. }
  8502. baseParams := models.BaseParams{
  8503. SecretKey: miConfig.SecretKey,
  8504. FixmedinsCode: miConfig.Code,
  8505. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8506. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8507. OrgName: miConfig.OrgName,
  8508. Doctor: user_name,
  8509. }
  8510. businessParams := models.BusinessParams{
  8511. PsnNo: order.PsnNo,
  8512. MdtrtId: order.MdtrtId,
  8513. SetlId: order.SetlId,
  8514. }
  8515. var res ResultEleven
  8516. var resEleven10265 ResultEleven10265
  8517. if config.IsOpen == 1 {
  8518. if miConfig.MdtrtareaAdmvs == "421300" {
  8519. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8520. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8521. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8522. resp, requestErr := http.Get(api)
  8523. if requestErr != nil {
  8524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8525. return
  8526. }
  8527. body, ioErr := ioutil.ReadAll(resp.Body)
  8528. if ioErr != nil {
  8529. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8531. return
  8532. }
  8533. var respJSON map[string]interface{}
  8534. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8535. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8537. return
  8538. }
  8539. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8540. result, _ := json.Marshal(respJSON)
  8541. fmt.Println("log")
  8542. fmt.Println(string(result))
  8543. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8544. utils.ErrorLog("解析失败:%v", err)
  8545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8546. return
  8547. }
  8548. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8549. var api string
  8550. if miConfig.MdtrtareaAdmvs == "320921" {
  8551. api = "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8552. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8553. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8554. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8555. } else {
  8556. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8557. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8558. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8559. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8560. }
  8561. resp, requestErr := http.Get(api)
  8562. if requestErr != nil {
  8563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8564. return
  8565. }
  8566. body, ioErr := ioutil.ReadAll(resp.Body)
  8567. if ioErr != nil {
  8568. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8570. return
  8571. }
  8572. var respJSON map[string]interface{}
  8573. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8574. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8576. return
  8577. }
  8578. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8579. result, _ := json.Marshal(respJSON)
  8580. fmt.Println("log")
  8581. fmt.Println(string(result))
  8582. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  8583. utils.ErrorLog("解析失败:%v", err)
  8584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8585. return
  8586. }
  8587. res.InfRefmsgid = resEleven10265.InfRefmsgid
  8588. res.Output = resEleven10265.Output
  8589. res.ErrMsg = resEleven10265.ErrMsg
  8590. res.Cainfo = resEleven10265.Cainfo
  8591. res.WarnMsg = resEleven10265.WarnMsg
  8592. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  8593. res.Infcode = infocode
  8594. } else {
  8595. //result2 := service.Gdyb1101()
  8596. //result2 := service.Gdyb5204(baseParams, businessParams)
  8597. //saveLog(result2, "", "5204", "查询")
  8598. result := service.Gdyb5203(baseParams, businessParams)
  8599. var dat map[string]interface{}
  8600. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8601. fmt.Println(dat)
  8602. } else {
  8603. fmt.Println(err)
  8604. }
  8605. userJSONBytes, _ := json.Marshal(dat)
  8606. if miConfig.Code == "H15049901371" {
  8607. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  8608. utils.ErrorLog("解析失败:%v", err)
  8609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8610. return
  8611. }
  8612. res.InfRefmsgid = resEleven10265.InfRefmsgid
  8613. res.Output = resEleven10265.Output
  8614. res.ErrMsg = resEleven10265.ErrMsg
  8615. res.Cainfo = resEleven10265.Cainfo
  8616. res.WarnMsg = resEleven10265.WarnMsg
  8617. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  8618. res.Infcode = infocode
  8619. } else {
  8620. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8621. utils.ErrorLog("解析失败:%v", err)
  8622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8623. return
  8624. }
  8625. }
  8626. }
  8627. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8628. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  8629. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  8630. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  8631. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  8632. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8633. var doctor_name string
  8634. if roles.ID == 0 {
  8635. doctor_name = "管理员"
  8636. } else {
  8637. doctor_name = roles.UserName
  8638. }
  8639. yiliao_leibie := ""
  8640. switch order.MedType {
  8641. case "11":
  8642. yiliao_leibie = "普通门诊"
  8643. break
  8644. case "12":
  8645. yiliao_leibie = "门诊挂号"
  8646. break
  8647. case "13":
  8648. yiliao_leibie = "急诊"
  8649. break
  8650. case "14":
  8651. yiliao_leibie = "门诊特殊病"
  8652. break
  8653. case "15":
  8654. yiliao_leibie = "门诊统筹"
  8655. break
  8656. case "16":
  8657. yiliao_leibie = "门诊慢性病"
  8658. break
  8659. case "21":
  8660. yiliao_leibie = "普通住院"
  8661. break
  8662. }
  8663. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8664. if res.Infcode == 0 {
  8665. c.ServeSuccessJSON(map[string]interface{}{
  8666. "diagnosis": name,
  8667. "order_infos": orderInfos,
  8668. "number": order.MdtrtId,
  8669. "date": order.SettleAccountsDate,
  8670. "charge_admin": charge_admin,
  8671. "printor_admin": printor_admin,
  8672. "info": res.Output.Setlinfo,
  8673. "order": order,
  8674. "bedCostTotal": bedCostTotal,
  8675. "bedCostSelfTotal": bedCostSelfTotal,
  8676. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  8677. "operationCostTotal": operationCostTotal,
  8678. "operationCostSelfTotal": operationCostSelfTotal,
  8679. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  8680. "otherCostTotal": otherCostTotal,
  8681. "otherCostSelfTotal": otherCostSelfTotal,
  8682. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  8683. "materialCostTotal": materialCostTotal,
  8684. "materialCostSelfTotal": materialCostSelfTotal,
  8685. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  8686. "westernMedicineCostTotal": westernMedicineCostTotal,
  8687. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  8688. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  8689. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  8690. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  8691. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  8692. "checkCostTotal": checkCostTotal,
  8693. "checkCostSelfTotal": checkCostSelfTotal,
  8694. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  8695. "laboratoryCostTotal": laboratoryCostTotal,
  8696. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  8697. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  8698. "treatCostTotal": treatCostTotal,
  8699. "treatCostSelfTotal": treatCostSelfTotal,
  8700. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  8701. "doctor_info": doctor_info,
  8702. "doctor_code": adminRole_two.DoctorCode,
  8703. "doctor_name": doctor_name,
  8704. "health_card_no": order.PsnNo,
  8705. "department": departments.Name,
  8706. "yiliao_leibie": yiliao_leibie,
  8707. "after_money": order.AccountPrice,
  8708. "patient": patient,
  8709. "org_name": miConfig.OrgName,
  8710. "org_code": miConfig.Code,
  8711. "order_number": order.Number,
  8712. "his_hospital": his_hospital,
  8713. "his": his,
  8714. "dia_config": dia_config,
  8715. //"check_order_info": cus_slice,
  8716. })
  8717. }
  8718. }
  8719. }
  8720. func (c *HisApiController) CheckTreatment() {
  8721. patient_id, _ := c.GetInt64("patient_id")
  8722. id_card_no := c.GetString("id_card_no")
  8723. insutype := c.GetString("insutype")
  8724. med_type := c.GetString("med_type")
  8725. admin_user_id, _ := c.GetInt64("admin_user_id")
  8726. adminUser := c.GetAdminUserInfo()
  8727. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8728. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8729. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8730. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8731. if miConfig.MdtrtareaAdmvs == "421300" {
  8732. var res ResultTwo
  8733. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  8734. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8735. "&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)
  8736. resp, requestErr := http.Get(api)
  8737. if requestErr != nil {
  8738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8739. return
  8740. }
  8741. body, ioErr := ioutil.ReadAll(resp.Body)
  8742. if ioErr != nil {
  8743. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8745. return
  8746. }
  8747. var respJSON map[string]interface{}
  8748. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8749. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8751. return
  8752. }
  8753. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8754. result, _ := json.Marshal(respJSON)
  8755. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8756. utils.ErrorLog("解析失败:%v", err)
  8757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8758. return
  8759. }
  8760. if res.Infcode == 0 {
  8761. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  8762. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8763. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  8764. resp, requestErr := http.Get(api)
  8765. if requestErr != nil {
  8766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8767. return
  8768. }
  8769. body, ioErr := ioutil.ReadAll(resp.Body)
  8770. if ioErr != nil {
  8771. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8773. return
  8774. }
  8775. var respJSON map[string]interface{}
  8776. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8777. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8779. return
  8780. }
  8781. var res Result2001
  8782. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8783. result2, _ := json.Marshal(respJSON)
  8784. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  8785. utils.ErrorLog("解析失败:%v", err)
  8786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8787. return
  8788. }
  8789. if res.Infcode == 0 {
  8790. c.ServeSuccessJSON(map[string]interface{}{
  8791. "msg": res.Output.Trtinfo,
  8792. })
  8793. }
  8794. } else {
  8795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8796. return
  8797. }
  8798. } else {
  8799. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  8800. var dat map[string]interface{}
  8801. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8802. fmt.Println(dat)
  8803. } else {
  8804. fmt.Println(err)
  8805. }
  8806. userJSONBytes, _ := json.Marshal(dat)
  8807. var res ResultTwo
  8808. var res10265 ResultTwo10265
  8809. if miConfig.Code == "H15049901371" {
  8810. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8811. utils.ErrorLog("解析失败:%v", err)
  8812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8813. return
  8814. }
  8815. res.ErrMsg = res10265.ErrMsg
  8816. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8817. res.Infcode = infocode
  8818. res.Output = res10265.Output
  8819. res.InfRefmsgid = res10265.InfRefmsgid
  8820. } else {
  8821. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8822. utils.ErrorLog("解析失败:%v", err)
  8823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8824. return
  8825. }
  8826. }
  8827. var user_name string
  8828. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  8829. if role.ID == 0 {
  8830. user_name = "xxx"
  8831. } else {
  8832. user_name = role.UserName
  8833. }
  8834. baseParams := models.BaseParams{
  8835. SecretKey: miConfig.SecretKey,
  8836. FixmedinsCode: miConfig.Code,
  8837. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8838. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8839. OrgName: miConfig.OrgName,
  8840. Doctor: user_name,
  8841. }
  8842. if config.IsOpen == 1 {
  8843. if miConfig.Code == "H15049901371" {
  8844. if med_type == "14" {
  8845. if insutype == "390" {
  8846. med_type = "9933"
  8847. } else if insutype == "310" {
  8848. med_type = "990502"
  8849. }
  8850. } else if med_type == "11" {
  8851. med_type = "11"
  8852. }
  8853. }
  8854. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  8855. var dat map[string]interface{}
  8856. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8857. fmt.Println(dat)
  8858. } else {
  8859. fmt.Println(err)
  8860. }
  8861. var res Result2001
  8862. var res10265 Result2001Org10265
  8863. if miConfig.Code == "H15049901371" {
  8864. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8865. utils.ErrorLog("解析失败:%v", err)
  8866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8867. return
  8868. }
  8869. res.ErrMsg = res10265.ErrMsg
  8870. res.Output = res10265.Output
  8871. res.InfRefmsgid = res10265.InfRefmsgid
  8872. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8873. res.Infcode = infocode
  8874. } else {
  8875. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8876. utils.ErrorLog("解析失败:%v", err)
  8877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8878. return
  8879. }
  8880. }
  8881. if res.Infcode == 0 {
  8882. c.ServeSuccessJSON(map[string]interface{}{
  8883. "msg": res.Output.Trtinfo,
  8884. })
  8885. }
  8886. }
  8887. }
  8888. }
  8889. //func (c *HisApiController) PutRecord() {
  8890. // id, _ := c.GetInt64("id")
  8891. // record_time := c.GetString("record_time")
  8892. // timeLayout := "2006-01-02"
  8893. // loc, _ := time.LoadLocation("Local")
  8894. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8895. // if err != nil {
  8896. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8897. // return
  8898. // }
  8899. // recordDateTime := theTime.Unix()
  8900. //
  8901. // adminInfo := c.GetAdminUserInfo()
  8902. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  8903. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8904. //
  8905. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8906. //
  8907. // fmt.Println(miConfig.SecretKey)
  8908. //
  8909. // if patient == nil {
  8910. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  8911. // return
  8912. // }
  8913. // if len(patient.IdCardNo) == 0 {
  8914. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  8915. // return
  8916. // }
  8917. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  8918. // if config.IsOpen == 1 {
  8919. // 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
  8920. // resp, requestErr := http.Get(api)
  8921. // if requestErr != nil {
  8922. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8923. // return
  8924. // }
  8925. // defer resp.Body.Close()
  8926. // body, ioErr := ioutil.ReadAll(resp.Body)
  8927. // if ioErr != nil {
  8928. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8929. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8930. // return
  8931. // }
  8932. // var respJSON map[string]interface{}
  8933. //
  8934. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8935. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8936. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8937. // return
  8938. // }
  8939. //
  8940. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8941. // userJSONBytes, _ := json.Marshal(userJSON)
  8942. // var res ResultTwo
  8943. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8944. // utils.ErrorLog("解析失败:%v", err)
  8945. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8946. // return
  8947. // }
  8948. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8949. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8950. // infoStr := string(Iinfos)
  8951. // idetinfoStr := string(Idetinfos)
  8952. //
  8953. // if res.Infcode == 0 {
  8954. // his := models.VMHisPatient{
  8955. // Status: 1,
  8956. // Ctime: time.Now().Unix(),
  8957. // Mtime: time.Now().Unix(),
  8958. // PsnNo: res.Output.Baseinfo.PsnNo,
  8959. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  8960. // Certno: res.Output.Baseinfo.Certno,
  8961. // PsnName: res.Output.Baseinfo.PsnName,
  8962. // Gend: res.Output.Baseinfo.Gend,
  8963. // Naty: res.Output.Baseinfo.Naty,
  8964. // Brdy: res.Output.Baseinfo.Brdy,
  8965. // Age: res.Output.Baseinfo.Age,
  8966. // Iinfo: infoStr,
  8967. // Idetinfo: idetinfoStr,
  8968. // PatientId: patient.ID,
  8969. // RecordDate: theTime.Unix(),
  8970. // UserOrgId: adminInfo.CurrentOrgId,
  8971. // AdminUserId: adminInfo.AdminUser.Id,
  8972. // IsReturn: 1,
  8973. // }
  8974. //
  8975. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  8976. // //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")
  8977. // //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")
  8978. //
  8979. // //var dat map[string]interface{}
  8980. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8981. // // fmt.Println(dat)
  8982. // //} else {
  8983. // // fmt.Println(err)
  8984. // //}
  8985. //
  8986. // var dat2 map[string]interface{}
  8987. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  8988. // fmt.Println(dat2)
  8989. // } else {
  8990. // fmt.Println(err)
  8991. // }
  8992. //
  8993. // } else {
  8994. // adminUser := c.GetAdminUserInfo()
  8995. // errlog := &models.HisOrderError{
  8996. // UserOrgId: adminUser.CurrentOrgId,
  8997. // Ctime: time.Now().Unix(),
  8998. // Mtime: time.Now().Unix(),
  8999. // ErrMsg: res.ErrMsg,
  9000. // Status: 1,
  9001. // PatientId: id,
  9002. // RecordTime: recordDateTime,
  9003. // Stage: 1,
  9004. // }
  9005. // service.CreateErrMsgLog(errlog)
  9006. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  9007. // return
  9008. // }
  9009. // }
  9010. //
  9011. //}
  9012. //func (c *HisApiController) GetUploadDiag() {
  9013. // id, _ := c.GetInt64("id")
  9014. // record_time := c.GetString("record_time")
  9015. //
  9016. // diagnosis_id, _ := c.GetInt64("diagnosis")
  9017. // sick_type, _ := c.GetInt64("sick_type")
  9018. // reg_type, _ := c.GetInt64("reg_type")
  9019. //
  9020. // timeLayout := "2006-01-02"
  9021. // loc, _ := time.LoadLocation("Local")
  9022. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9023. // if err != nil {
  9024. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9025. // return
  9026. // }
  9027. //
  9028. // var patientPrescription models.HisPrescriptionInfo
  9029. // recordDateTime := theTime.Unix()
  9030. // adminInfo := c.GetAdminUserInfo()
  9031. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9032. //
  9033. // if patientPrescription.ID == 0 {
  9034. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9035. // }
  9036. //
  9037. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9038. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9039. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9040. // sickConfig, _ := service.FindSickById(sick_type)
  9041. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9042. //
  9043. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  9044. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  9045. // "&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 +
  9046. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  9047. // resp2, requestErr2 := http.Get(api2)
  9048. // if requestErr2 != nil {
  9049. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9050. // return
  9051. // }
  9052. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  9053. // if ioErr2 != nil {
  9054. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  9055. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9056. // return
  9057. // }
  9058. // var respJSON2 map[string]interface{}
  9059. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  9060. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9061. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9062. // return
  9063. // }
  9064. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9065. // userJSONBytes2, _ := json.Marshal(respJSON2)
  9066. //
  9067. // var res2 ResultSix
  9068. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9069. // utils.ErrorLog("解析失败:%v", err)
  9070. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9071. // return
  9072. // }
  9073. // if res2.Infcode != 0 {
  9074. // adminUser := c.GetAdminUserInfo()
  9075. // errlog := &models.HisOrderError{
  9076. // UserOrgId: adminUser.CurrentOrgId,
  9077. // Ctime: time.Now().Unix(),
  9078. // Mtime: time.Now().Unix(),
  9079. // ErrMsg: res2.ErrMsg,
  9080. // Status: 1,
  9081. // PatientId: id,
  9082. // RecordTime: recordDateTime,
  9083. // Stage: 3,
  9084. // }
  9085. // service.CreateErrMsgLog(errlog)
  9086. //
  9087. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  9088. // return
  9089. // }
  9090. //
  9091. // c.ServeSuccessJSON(map[string]interface{}{
  9092. // "msg": "上传成功",
  9093. // })
  9094. //
  9095. //}
  9096. type QueryResult struct {
  9097. ID int64
  9098. Name string
  9099. Code string
  9100. List_type_code string
  9101. }
  9102. func (c *HisApiController) GetCheckCode() {
  9103. ids_str := c.GetString("ids")
  9104. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9105. ids_arr := strings.Split(ids_str, ",")
  9106. var queryResult []QueryResult
  9107. ids := make([]int64, 0)
  9108. for _, item := range ids_arr {
  9109. id, _ := strconv.ParseInt(item, 10, 64)
  9110. ids = append(ids, id)
  9111. }
  9112. if record_type == 1 {
  9113. drugs, _ := service.GetBatchDrugList(ids)
  9114. for _, item := range drugs {
  9115. result := QueryResult{
  9116. ID: item.ID,
  9117. Name: item.DrugName,
  9118. Code: item.MedicalInsuranceNumber,
  9119. List_type_code: "101",
  9120. }
  9121. queryResult = append(queryResult, result)
  9122. }
  9123. } else if record_type == 2 {
  9124. goods, _ := service.GetBatchGoodInformationList(ids)
  9125. for _, item := range goods {
  9126. result := QueryResult{
  9127. ID: item.ID,
  9128. Name: item.GoodName,
  9129. Code: item.MedicalInsuranceNumber,
  9130. List_type_code: "301",
  9131. }
  9132. queryResult = append(queryResult, result)
  9133. }
  9134. } else if record_type == 3 {
  9135. projects, _ := service.GetBathchMyPorjecgList(ids)
  9136. for _, item := range projects {
  9137. result := QueryResult{
  9138. ID: item.ID,
  9139. Name: item.ProjectName,
  9140. Code: item.MedicalCode,
  9141. List_type_code: "201",
  9142. }
  9143. queryResult = append(queryResult, result)
  9144. }
  9145. }
  9146. admin_user_id, _ := c.GetInt64("admin_user_id")
  9147. adminUser := c.GetAdminUserInfo()
  9148. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9149. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9150. var user_name string
  9151. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9152. if role.ID == 0 {
  9153. user_name = "xxx"
  9154. } else {
  9155. user_name = role.UserName
  9156. }
  9157. baseParams := &models.BaseParams{
  9158. SecretKey: miConfig.SecretKey,
  9159. FixmedinsCode: miConfig.Code,
  9160. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9161. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9162. OrgName: miConfig.OrgName,
  9163. Doctor: user_name,
  9164. }
  9165. if config.IsOpen == 1 {
  9166. for _, item := range queryResult {
  9167. var result string
  9168. if record_type == 1 {
  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 == 2 {
  9171. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9172. } else if record_type == 3 {
  9173. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9174. }
  9175. var dat map[string]interface{}
  9176. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9177. fmt.Println(dat)
  9178. } else {
  9179. fmt.Println(err)
  9180. }
  9181. userJSONBytes, _ := json.Marshal(dat)
  9182. var res ResultSix
  9183. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9184. utils.ErrorLog("解析失败:%v", err)
  9185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9186. return
  9187. }
  9188. if res.Infcode == 0 {
  9189. if record_type == 1 {
  9190. service.UpdateBaseDrugById(item.ID)
  9191. } else if record_type == 2 {
  9192. service.UpdateGoodInformaitonByDetail(item.ID)
  9193. } else if record_type == 3 {
  9194. service.UpdateProjectById(item.ID)
  9195. }
  9196. c.ServeSuccessJSON(map[string]interface{}{
  9197. "failed_code": 0,
  9198. "msg": "目录对照成功",
  9199. })
  9200. } else {
  9201. c.ServeSuccessJSON(map[string]interface{}{
  9202. "failed_code": -10,
  9203. "msg": res.ErrMsg,
  9204. })
  9205. }
  9206. }
  9207. }
  9208. }
  9209. func (c *HisApiController) UnCheckCode() {
  9210. ids_str := c.GetString("ids")
  9211. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9212. admin_user_id, _ := c.GetInt64("admin_user_id")
  9213. ids_arr := strings.Split(ids_str, ",")
  9214. var queryResult []QueryResult
  9215. ids := make([]int64, 0)
  9216. for _, item := range ids_arr {
  9217. id, _ := strconv.ParseInt(item, 10, 64)
  9218. ids = append(ids, id)
  9219. }
  9220. if record_type == 1 {
  9221. drugs, _ := service.GetBatchDrugList(ids)
  9222. for _, item := range drugs {
  9223. result := QueryResult{
  9224. ID: item.ID,
  9225. Name: item.DrugName,
  9226. Code: item.MedicalInsuranceNumber,
  9227. List_type_code: "101",
  9228. }
  9229. queryResult = append(queryResult, result)
  9230. }
  9231. } else if record_type == 2 {
  9232. goods, _ := service.GetBatchGoodInformationList(ids)
  9233. for _, item := range goods {
  9234. result := QueryResult{
  9235. ID: item.ID,
  9236. Name: item.GoodName,
  9237. Code: item.MedicalInsuranceNumber,
  9238. List_type_code: "301",
  9239. }
  9240. queryResult = append(queryResult, result)
  9241. }
  9242. } else if record_type == 3 {
  9243. projects, _ := service.GetBathchMyPorjecgList(ids)
  9244. for _, item := range projects {
  9245. result := QueryResult{
  9246. ID: item.ID,
  9247. Name: item.ProjectName,
  9248. Code: item.MedicalCode,
  9249. List_type_code: "201",
  9250. }
  9251. queryResult = append(queryResult, result)
  9252. }
  9253. }
  9254. adminUser := c.GetAdminUserInfo()
  9255. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9256. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9257. var user_name string
  9258. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9259. if role.ID == 0 {
  9260. user_name = "xxx"
  9261. } else {
  9262. user_name = role.UserName
  9263. }
  9264. baseParams := &models.BaseParams{
  9265. SecretKey: miConfig.SecretKey,
  9266. FixmedinsCode: miConfig.Code,
  9267. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9268. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9269. OrgName: miConfig.OrgName,
  9270. Doctor: user_name,
  9271. }
  9272. if config.IsOpen == 1 {
  9273. for _, item := range queryResult {
  9274. var result string
  9275. if record_type == 1 {
  9276. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9277. } else if record_type == 2 {
  9278. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9279. } else if record_type == 3 {
  9280. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9281. }
  9282. var dat2 map[string]interface{}
  9283. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  9284. fmt.Println(dat2)
  9285. } else {
  9286. fmt.Println(err)
  9287. }
  9288. userJSONBytes, _ := json.Marshal(dat2)
  9289. var res ResultSix
  9290. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9291. utils.ErrorLog("解析失败:%v", err)
  9292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9293. return
  9294. }
  9295. if res.Infcode == 0 {
  9296. if record_type == 1 {
  9297. service.UpdateDrugByIdDetail(item.ID)
  9298. } else if record_type == 2 {
  9299. service.UpdateGoodInfoById(item.ID)
  9300. } else if record_type == 3 {
  9301. service.UpdateMyProjectById(item.ID)
  9302. }
  9303. c.ServeSuccessJSON(map[string]interface{}{
  9304. "failed_code": 0,
  9305. "msg": "撤销目录对照成功",
  9306. })
  9307. } else {
  9308. c.ServeSuccessJSON(map[string]interface{}{
  9309. "failed_code": -10,
  9310. "msg": res.ErrMsg,
  9311. })
  9312. }
  9313. }
  9314. }
  9315. }
  9316. func (c *HisApiController) GetPatientInfo() {
  9317. id_card_no := c.GetString("id_card_no")
  9318. admin_user_id, _ := c.GetInt64("admin_user_id")
  9319. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  9320. if patient.ID == 0 {
  9321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9322. return
  9323. }
  9324. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9325. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9326. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  9327. if config.IsOpen == 1 {
  9328. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9329. var dat map[string]interface{}
  9330. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9331. fmt.Println(dat)
  9332. } else {
  9333. fmt.Println(err)
  9334. }
  9335. userJSONBytes, _ := json.Marshal(dat)
  9336. var res ResultTwo
  9337. var res10265 ResultTwo10265
  9338. if miConfig.Code == "H15049901371" {
  9339. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9340. utils.ErrorLog("解析失败:%v", err)
  9341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9342. return
  9343. }
  9344. res.ErrMsg = res10265.ErrMsg
  9345. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9346. res.Infcode = infocode
  9347. res.Output = res10265.Output
  9348. res.InfRefmsgid = res10265.InfRefmsgid
  9349. } else {
  9350. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9351. utils.ErrorLog("解析失败:%v", err)
  9352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9353. return
  9354. }
  9355. }
  9356. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9357. // utils.ErrorLog("解析失败:%v", err)
  9358. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9359. // return
  9360. //}
  9361. if res.Infcode != 0 {
  9362. c.ServeSuccessJSON(map[string]interface{}{
  9363. "failed_code": -10,
  9364. "msg": res.ErrMsg,
  9365. })
  9366. } else {
  9367. c.ServeSuccessJSON(map[string]interface{}{
  9368. "failed_code": 0,
  9369. "info": res,
  9370. })
  9371. }
  9372. }
  9373. }
  9374. func (c *HisApiController) PsnPutOnRecord() {
  9375. record_type, _ := c.GetInt64("type")
  9376. patient_id, _ := c.GetInt64("patient_id")
  9377. admin_user_id, _ := c.GetInt64("admin_user_id")
  9378. start_time := c.GetString("start_time")
  9379. end_time := c.GetString("end_time")
  9380. adminUser := c.GetAdminUserInfo()
  9381. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9382. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9383. var patients []*models.Patients
  9384. if record_type == 1 { //全部备案
  9385. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  9386. patients = append(patients, patient...)
  9387. } else { //单个备案
  9388. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9389. patients = append(patients, patient)
  9390. }
  9391. var user_name string
  9392. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9393. if role.ID == 0 {
  9394. user_name = "xxx"
  9395. } else {
  9396. user_name = role.UserName
  9397. }
  9398. if config.IsOpen == 1 {
  9399. for _, item := range patients {
  9400. 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
  9401. resp, requestErr := http.Get(api)
  9402. if requestErr != nil {
  9403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9404. return
  9405. }
  9406. defer resp.Body.Close()
  9407. body, ioErr := ioutil.ReadAll(resp.Body)
  9408. if ioErr != nil {
  9409. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9411. return
  9412. }
  9413. var respJSON map[string]interface{}
  9414. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9415. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9417. return
  9418. }
  9419. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9420. userJSONBytes, _ := json.Marshal(userJSON)
  9421. var res ResultTwo
  9422. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9423. utils.ErrorLog("解析失败:%v", err)
  9424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9425. return
  9426. }
  9427. if res.Infcode == 0 {
  9428. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  9429. var dat map[string]interface{}
  9430. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9431. fmt.Println(dat)
  9432. } else {
  9433. fmt.Println(err)
  9434. }
  9435. userJSONBytes, _ := json.Marshal(dat)
  9436. var res2 ResultThirteen
  9437. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9438. utils.ErrorLog("解析失败:%v", err)
  9439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9440. return
  9441. }
  9442. if res2.Infcode == 0 {
  9443. psnResult := &models.GdybPsnRecord{
  9444. UserOrgId: adminUser.CurrentOrgId,
  9445. PatientId: item.ID,
  9446. PsnNo: res.Output.Baseinfo.PsnNo,
  9447. Ctime: time.Now().Unix(),
  9448. Mtime: time.Now().Unix(),
  9449. Status: 1,
  9450. IsCancel: 1,
  9451. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  9452. }
  9453. service.CreatePsnRecord(psnResult)
  9454. } else {
  9455. c.ServeSuccessJSON(map[string]interface{}{
  9456. "failed_code": -10,
  9457. "msg": res2.ErrMsg,
  9458. })
  9459. return
  9460. }
  9461. }
  9462. }
  9463. }
  9464. }
  9465. func (c *HisApiController) PsnUnPutOnRecord() {
  9466. id, _ := c.GetInt64("id")
  9467. //record_type, _ := c.GetInt64("type")
  9468. admin_user_id, _ := c.GetInt64("admin_user_id")
  9469. adminUser := c.GetAdminUserInfo()
  9470. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9471. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9472. var user_name string
  9473. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9474. if role.ID == 0 {
  9475. user_name = "xxx"
  9476. } else {
  9477. user_name = role.UserName
  9478. }
  9479. psn_record, _ := service.GetPsnRecordById(id)
  9480. if psn_record.ID == 0 {
  9481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  9482. return
  9483. }
  9484. if config.IsOpen == 1 {
  9485. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  9486. var dat map[string]interface{}
  9487. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9488. fmt.Println(dat)
  9489. } else {
  9490. fmt.Println(err)
  9491. }
  9492. userJSONBytes, _ := json.Marshal(dat)
  9493. var res ResultFourteen
  9494. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9495. utils.ErrorLog("解析失败:%v", err)
  9496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9497. return
  9498. }
  9499. if res.Infcode == 0 {
  9500. psn_record.IsCancel = 2
  9501. service.CreatePsnRecord(&psn_record)
  9502. } else {
  9503. c.ServeSuccessJSON(map[string]interface{}{
  9504. "failed_code": -10,
  9505. "msg": res.ErrMsg,
  9506. })
  9507. return
  9508. }
  9509. }
  9510. }
  9511. func (c *HisApiController) PsnPutNCDSOnRecord() {
  9512. patient_id, _ := c.GetInt64("patient_id")
  9513. insutype_two := c.GetString("insutype")
  9514. psn_no := c.GetString("psn_no")
  9515. doctor_id, _ := c.GetInt64("doctor_id")
  9516. sick_id, _ := c.GetInt64("sick_id")
  9517. department_id, _ := c.GetInt64("department_id")
  9518. start_time := c.GetString("start_time")
  9519. end_time := c.GetString("end_time")
  9520. check_time := c.GetString("check_time")
  9521. adminUser := c.GetAdminUserInfo()
  9522. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9523. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9524. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9525. sick, _ := service.FindSickById(sick_id)
  9526. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  9527. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  9528. var res ResultTwo
  9529. var res10265 ResultTwo10265
  9530. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9531. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  9532. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  9533. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  9534. "&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
  9535. resp, requestErr := http.Get(api)
  9536. if requestErr != nil {
  9537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9538. return
  9539. }
  9540. body, ioErr := ioutil.ReadAll(resp.Body)
  9541. if ioErr != nil {
  9542. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9544. return
  9545. }
  9546. var respJSON map[string]interface{}
  9547. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9548. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9550. return
  9551. }
  9552. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9553. result, _ := json.Marshal(respJSON)
  9554. fmt.Println("log")
  9555. fmt.Println(string(result))
  9556. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9557. utils.ErrorLog("解析失败:%v", err)
  9558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9559. return
  9560. }
  9561. res.ErrMsg = res10265.ErrMsg
  9562. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9563. res.Infcode = infocode
  9564. res.Output = res10265.Output
  9565. res.InfRefmsgid = res10265.InfRefmsgid
  9566. } else {
  9567. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  9568. if miConfig.Code == "H15049901371" {
  9569. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9570. utils.ErrorLog("解析失败:%v", err)
  9571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9572. return
  9573. }
  9574. res.ErrMsg = res10265.ErrMsg
  9575. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9576. res.Infcode = infocode
  9577. res.Output = res10265.Output
  9578. res.InfRefmsgid = res10265.InfRefmsgid
  9579. } else {
  9580. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9581. utils.ErrorLog("解析失败:%v", err)
  9582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9583. return
  9584. }
  9585. }
  9586. }
  9587. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9588. infoStr := string(Iinfos)
  9589. var rf []*ResultFive
  9590. json.Unmarshal([]byte(infoStr), &rf)
  9591. var insuplc_admdvs string
  9592. var insutype string
  9593. var is390 int = 0
  9594. var is310 int = 0
  9595. var insutypes []*ResultFive
  9596. for _, item := range rf {
  9597. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9598. insutypes = append(insutypes, item)
  9599. }
  9600. }
  9601. if len(insutypes) == 1 {
  9602. insutype = insutypes[0].Insutype
  9603. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9604. } else {
  9605. for _, i := range insutypes {
  9606. if i.Insutype == "390" {
  9607. is390 = 1
  9608. }
  9609. if i.Insutype == "310" {
  9610. is310 = 1
  9611. }
  9612. }
  9613. }
  9614. if is390 == 1 {
  9615. insutype = "390"
  9616. }
  9617. if is310 == 1 {
  9618. insutype = "310"
  9619. }
  9620. if len(insutypes) == 2 {
  9621. insutype = insutype_two
  9622. }
  9623. if len(insutypes) == 0 {
  9624. insutype = "310"
  9625. }
  9626. insutype = insutype_two
  9627. fmt.Println(insutype)
  9628. for _, item := range rf {
  9629. fmt.Println(item.Insutype)
  9630. fmt.Println(insutype)
  9631. if item.Insutype == insutype {
  9632. fmt.Println(item.Insutype)
  9633. fmt.Println(insutype)
  9634. insuplc_admdvs = item.InsuplcAdmdvs
  9635. }
  9636. }
  9637. fmt.Println(insuplc_admdvs)
  9638. var res2 ResultThirteen
  9639. var res10265_2 ResultThirteen10265
  9640. if config.IsOpen == 1 {
  9641. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9642. } else {
  9643. 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)
  9644. var dat map[string]interface{}
  9645. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9646. fmt.Println(dat)
  9647. } else {
  9648. fmt.Println(err)
  9649. }
  9650. userJSONBytes, _ := json.Marshal(dat)
  9651. if miConfig.Code == "H15049901371" {
  9652. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  9653. utils.ErrorLog("解析失败:%v", err)
  9654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9655. return
  9656. }
  9657. res2.ErrMsg = res10265_2.ErrMsg
  9658. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  9659. res2.Infcode = infocode
  9660. res2.Output = res10265_2.Output
  9661. res2.InfRefmsgid = res10265_2.InfRefmsgid
  9662. } else {
  9663. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9664. utils.ErrorLog("解析失败:%v", err)
  9665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9666. return
  9667. }
  9668. }
  9669. }
  9670. if res2.Infcode == 0 {
  9671. psnResult := &models.GdybPsnNcdsRecord{
  9672. UserOrgId: adminUser.CurrentOrgId,
  9673. PatientId: patient.ID,
  9674. PsnNo: psn_no,
  9675. DoctorId: doctor.AdminUserId,
  9676. DepartmentId: department_id,
  9677. SickType: sick_id,
  9678. Insutype: insutype,
  9679. Ctime: time.Now().Unix(),
  9680. Mtime: time.Now().Unix(),
  9681. Status: 1,
  9682. IsCancel: 1,
  9683. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  9684. }
  9685. service.CreatePsnNCDSRecord(psnResult)
  9686. c.ServeSuccessJSON(map[string]interface{}{
  9687. "failed_code": 0,
  9688. "msg": "备案成功",
  9689. "result": psnResult,
  9690. })
  9691. } else {
  9692. c.ServeSuccessJSON(map[string]interface{}{
  9693. "failed_code": -10,
  9694. "msg": res2.ErrMsg,
  9695. })
  9696. return
  9697. }
  9698. }
  9699. }
  9700. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  9701. id, _ := c.GetInt64("id")
  9702. admin_user_id, _ := c.GetInt64("admin_user_id")
  9703. adminUser := c.GetAdminUserInfo()
  9704. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9705. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9706. //config, _ := service.Ge(adminUser.CurrentOrgId)
  9707. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  9708. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9709. //var user_name string
  9710. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9711. //if role.ID == 0 {
  9712. // user_name = "xxx"
  9713. //} else {
  9714. // user_name = role.UserName
  9715. //}
  9716. psn_record, _ := service.GetPsnNCDSRecordById(id)
  9717. if psn_record.ID == 0 {
  9718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  9719. return
  9720. }
  9721. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  9722. var res ResultTwo
  9723. var res10265 ResultTwo10265
  9724. if miConfig.Code == "H15049901371" {
  9725. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9726. utils.ErrorLog("解析失败:%v", err)
  9727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9728. return
  9729. }
  9730. res.ErrMsg = res10265.ErrMsg
  9731. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9732. res.Infcode = infocode
  9733. res.Output = res10265.Output
  9734. res.InfRefmsgid = res10265.InfRefmsgid
  9735. } else {
  9736. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9737. utils.ErrorLog("解析失败:%v", err)
  9738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9739. return
  9740. }
  9741. }
  9742. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9743. infoStr := string(Iinfos)
  9744. var rf []*ResultFive
  9745. json.Unmarshal([]byte(infoStr), &rf)
  9746. var insuplc_admdvs string
  9747. var insutype string
  9748. var is390 int = 0
  9749. var is310 int = 0
  9750. var insutypes []*ResultFive
  9751. for _, item := range rf {
  9752. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9753. insutypes = append(insutypes, item)
  9754. }
  9755. }
  9756. if len(insutypes) == 1 {
  9757. insutype = insutypes[0].Insutype
  9758. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9759. } else {
  9760. for _, i := range insutypes {
  9761. if i.Insutype == "390" {
  9762. is390 = 1
  9763. }
  9764. if i.Insutype == "310" {
  9765. is310 = 1
  9766. }
  9767. }
  9768. }
  9769. if is390 == 1 {
  9770. insutype = "390"
  9771. }
  9772. if is310 == 1 {
  9773. insutype = "310"
  9774. }
  9775. if len(insutypes) == 0 {
  9776. insutype = "310"
  9777. }
  9778. insutype = psn_record.Insutype
  9779. for _, item := range rf {
  9780. if item.Insutype == insutype {
  9781. insuplc_admdvs = item.InsuplcAdmdvs
  9782. }
  9783. }
  9784. if config.IsOpen == 1 {
  9785. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  9786. var dat map[string]interface{}
  9787. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9788. fmt.Println(dat)
  9789. } else {
  9790. fmt.Println(err)
  9791. }
  9792. userJSONBytes, _ := json.Marshal(dat)
  9793. var res ResultFourteen
  9794. var res10265 ResultFourteen10265
  9795. if miConfig.Code == "H15049901371" {
  9796. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9797. utils.ErrorLog("解析失败:%v", err)
  9798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9799. return
  9800. }
  9801. res.ErrMsg = res10265.ErrMsg
  9802. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9803. res.Infcode = infocode
  9804. res.Output = res10265.Output
  9805. res.InfRefmsgid = res10265.InfRefmsgid
  9806. } else {
  9807. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9808. utils.ErrorLog("解析失败:%v", err)
  9809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9810. return
  9811. }
  9812. }
  9813. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9814. // utils.ErrorLog("解析失败:%v", err)
  9815. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9816. // return
  9817. //}
  9818. if res.Infcode == 0 {
  9819. psn_record.IsCancel = 2
  9820. service.CreatePsnNCDSRecord(&psn_record)
  9821. c.ServeSuccessJSON(map[string]interface{}{
  9822. "failed_code": 0,
  9823. "msg": "撤销备案成功",
  9824. })
  9825. } else {
  9826. c.ServeSuccessJSON(map[string]interface{}{
  9827. "failed_code": -10,
  9828. "msg": res.ErrMsg,
  9829. })
  9830. return
  9831. }
  9832. }
  9833. }
  9834. func (c *HisApiController) TestTest() {
  9835. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  9836. fmt.Println(patient.Iinfo)
  9837. }
  9838. type CustomData struct {
  9839. MsgId string
  9840. PsnNo string
  9841. Info string
  9842. }
  9843. func (c *HisApiController) ReversalData() {
  9844. var customData []*CustomData
  9845. custom := &CustomData{
  9846. MsgId: "H44022900158202103301714472004",
  9847. PsnNo: "44020000001101329945",
  9848. Info: "2207",
  9849. }
  9850. customData = append(customData, custom)
  9851. custom1 := &CustomData{
  9852. MsgId: "H4402290015820210330172057803",
  9853. PsnNo: "44020000001101161813",
  9854. Info: "2207",
  9855. }
  9856. customData = append(customData, custom1)
  9857. custom2 := &CustomData{
  9858. MsgId: "H44022900158202103301705198813",
  9859. PsnNo: "44190000133097375417",
  9860. Info: "2207",
  9861. }
  9862. customData = append(customData, custom2)
  9863. custom3 := &CustomData{
  9864. MsgId: "H44022900158202103301715524756",
  9865. PsnNo: "44020000001100187221",
  9866. Info: "2207",
  9867. }
  9868. customData = append(customData, custom3)
  9869. custom4 := &CustomData{
  9870. MsgId: "H44022900158202103301730376224",
  9871. PsnNo: "44020000001101959155",
  9872. Info: "2207",
  9873. }
  9874. customData = append(customData, custom4)
  9875. custom5 := &CustomData{
  9876. MsgId: "H44022900158202103301748008725",
  9877. PsnNo: "44020000001104246641",
  9878. Info: "2207",
  9879. }
  9880. customData = append(customData, custom5)
  9881. custom6 := &CustomData{
  9882. MsgId: "H44022900158202103301718096755",
  9883. PsnNo: "44020000001102211860",
  9884. Info: "2207",
  9885. }
  9886. customData = append(customData, custom6)
  9887. custom7 := &CustomData{
  9888. MsgId: "H44022900158202103301736551640",
  9889. PsnNo: "44020000001102687718",
  9890. Info: "2207",
  9891. }
  9892. customData = append(customData, custom7)
  9893. custom8 := &CustomData{
  9894. MsgId: "H44022900158202103301743097676",
  9895. PsnNo: "44020000001102127785",
  9896. Info: "2207",
  9897. }
  9898. customData = append(customData, custom8)
  9899. custom9 := &CustomData{
  9900. MsgId: "H44022900158202103301712304203",
  9901. PsnNo: "44020000001101518097",
  9902. Info: "2207",
  9903. }
  9904. customData = append(customData, custom9)
  9905. custom10 := &CustomData{
  9906. MsgId: "H44022900158202103301738448785",
  9907. PsnNo: "44020000001100500813",
  9908. Info: "2207",
  9909. }
  9910. customData = append(customData, custom10)
  9911. custom11 := &CustomData{
  9912. MsgId: "H44022900158202103301732455843",
  9913. PsnNo: "44020000001102690557",
  9914. Info: "2207",
  9915. }
  9916. customData = append(customData, custom11)
  9917. custom12 := &CustomData{
  9918. MsgId: "H44022900158202103301745421708",
  9919. PsnNo: "44020000001102211928",
  9920. Info: "2207",
  9921. }
  9922. customData = append(customData, custom12)
  9923. custom1212 := &CustomData{
  9924. MsgId: "H440229001582021033017351627",
  9925. PsnNo: "44020000001102481733",
  9926. Info: "2207",
  9927. }
  9928. customData = append(customData, custom1212)
  9929. custom13 := &CustomData{
  9930. MsgId: "H44022900158202103301740327951",
  9931. PsnNo: "44020000001103174866",
  9932. Info: "2207",
  9933. }
  9934. customData = append(customData, custom13)
  9935. custom14 := &CustomData{
  9936. MsgId: "H4402290015820210330174922668",
  9937. PsnNo: "44020000001102927272",
  9938. Info: "2207",
  9939. }
  9940. customData = append(customData, custom14)
  9941. custom15 := &CustomData{
  9942. MsgId: "H44022900158202103301752362273",
  9943. PsnNo: "44020000001102942890",
  9944. Info: "2207",
  9945. }
  9946. customData = append(customData, custom15)
  9947. custom16 := &CustomData{
  9948. MsgId: "H44022900158202103301751082917",
  9949. PsnNo: "44020000001101662162",
  9950. Info: "2207",
  9951. }
  9952. customData = append(customData, custom16)
  9953. custom17 := &CustomData{
  9954. MsgId: "H44022900158202103301754147728",
  9955. PsnNo: "44020000000229014511",
  9956. Info: "2207",
  9957. }
  9958. customData = append(customData, custom17)
  9959. adminUser := c.GetAdminUserInfo()
  9960. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9961. for _, item := range customData {
  9962. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  9963. fmt.Println(result)
  9964. }
  9965. }
  9966. func (c *HisApiController) GetAllopatry() {
  9967. year := c.GetString("year")
  9968. month := c.GetString("month")
  9969. admin_user_id, _ := c.GetInt64("admin_user_id")
  9970. adminUser := c.GetAdminUserInfo()
  9971. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9972. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9973. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9974. var dat map[string]interface{}
  9975. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9976. fmt.Println(dat)
  9977. } else {
  9978. fmt.Println(err)
  9979. }
  9980. userJSONBytes, _ := json.Marshal(dat)
  9981. var res models.Result9001
  9982. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9983. utils.ErrorLog("解析失败:%v", err)
  9984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9985. return
  9986. }
  9987. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9988. var dat2 map[string]interface{}
  9989. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9990. fmt.Println(dat)
  9991. } else {
  9992. fmt.Println(err)
  9993. }
  9994. userJSONBytes2, _ := json.Marshal(dat2)
  9995. var res2 models.Result3260
  9996. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9997. utils.ErrorLog("解析失败:%v", err)
  9998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9999. return
  10000. }
  10001. if res2.Infcode == 0 {
  10002. c.ServeSuccessJSON(map[string]interface{}{
  10003. "list": res2.Output.Data,
  10004. })
  10005. return
  10006. } else {
  10007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10008. return
  10009. }
  10010. }
  10011. func (c *HisApiController) ComfirmAllopatry() {
  10012. year := c.GetString("year")
  10013. month := c.GetString("month")
  10014. admin_user_id, _ := c.GetInt64("admin_user_id")
  10015. adminUser := c.GetAdminUserInfo()
  10016. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10017. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10018. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10019. var dat map[string]interface{}
  10020. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10021. fmt.Println(dat)
  10022. } else {
  10023. fmt.Println(err)
  10024. }
  10025. userJSONBytes, _ := json.Marshal(dat)
  10026. var res models.Result9001
  10027. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10028. utils.ErrorLog("解析失败:%v", err)
  10029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10030. return
  10031. }
  10032. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10033. var dat2 map[string]interface{}
  10034. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10035. fmt.Println(dat)
  10036. } else {
  10037. fmt.Println(err)
  10038. }
  10039. userJSONBytes2, _ := json.Marshal(dat2)
  10040. var res2 models.Result3260
  10041. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10042. utils.ErrorLog("解析失败:%v", err)
  10043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10044. return
  10045. }
  10046. if res2.Infcode == 0 {
  10047. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  10048. var dat map[string]interface{}
  10049. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10050. fmt.Println(dat)
  10051. } else {
  10052. fmt.Println(err)
  10053. }
  10054. userJSONBytes, _ := json.Marshal(dat)
  10055. var res3 models.Result3261
  10056. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  10057. utils.ErrorLog("解析失败:%v", err)
  10058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10059. return
  10060. }
  10061. if res3.Infcode == 0 {
  10062. record := &models.HisYidiClearRecord{
  10063. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10064. Ctime: time.Now().Unix(),
  10065. Mtime: time.Now().Unix(),
  10066. Status: 1,
  10067. MsgId: msgId,
  10068. }
  10069. service.SaveClearRecord(record)
  10070. c.ServeSuccessJSON(map[string]interface{}{
  10071. "msg": "提取成功",
  10072. })
  10073. }
  10074. }
  10075. }
  10076. func (c *HisApiController) RefundAllopatry() {
  10077. year := c.GetString("year")
  10078. month := c.GetString("month")
  10079. id, _ := c.GetInt64("id")
  10080. admin_user_id, _ := c.GetInt64("admin_user_id")
  10081. adminUser := c.GetAdminUserInfo()
  10082. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10083. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10084. record, _ := service.GetClearRecordById(id)
  10085. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  10086. var dat map[string]interface{}
  10087. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10088. fmt.Println(dat)
  10089. } else {
  10090. fmt.Println(err)
  10091. }
  10092. userJSONBytes, _ := json.Marshal(dat)
  10093. var empty ResultFourteen
  10094. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  10095. utils.ErrorLog("解析失败:%v", err)
  10096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10097. return
  10098. }
  10099. if empty.Infcode == 0 {
  10100. c.ServeSuccessJSON(map[string]interface{}{
  10101. "msg": "撤销成功",
  10102. })
  10103. return
  10104. }
  10105. }
  10106. func (c *HisApiController) ReversalOtherData() {
  10107. var customData []*CustomData
  10108. custom := &CustomData{
  10109. MsgId: "H44022900158202103301714472004",
  10110. PsnNo: "44020000001101329945",
  10111. Info: "2208",
  10112. }
  10113. customData = append(customData, custom)
  10114. custom1 := &CustomData{
  10115. MsgId: "H4402290015820210330172057803",
  10116. PsnNo: "44020000001101161813",
  10117. Info: "2208",
  10118. }
  10119. customData = append(customData, custom1)
  10120. custom2 := &CustomData{
  10121. MsgId: "H44022900158202103301705198813",
  10122. PsnNo: "44190000133097375417",
  10123. Info: "2208",
  10124. }
  10125. customData = append(customData, custom2)
  10126. custom3 := &CustomData{
  10127. MsgId: "H44022900158202103301715524756",
  10128. PsnNo: "44020000001100187221",
  10129. Info: "2208",
  10130. }
  10131. customData = append(customData, custom3)
  10132. custom4 := &CustomData{
  10133. MsgId: "H44022900158202103301730376224",
  10134. PsnNo: "44020000001101959155",
  10135. Info: "2208",
  10136. }
  10137. customData = append(customData, custom4)
  10138. custom5 := &CustomData{
  10139. MsgId: "H44022900158202103301748008725",
  10140. PsnNo: "44020000001104246641",
  10141. Info: "2208",
  10142. }
  10143. customData = append(customData, custom5)
  10144. custom6 := &CustomData{
  10145. MsgId: "H44022900158202103301718096755",
  10146. PsnNo: "44020000001102211860",
  10147. Info: "2208",
  10148. }
  10149. customData = append(customData, custom6)
  10150. custom7 := &CustomData{
  10151. MsgId: "H44022900158202103301736551640",
  10152. PsnNo: "44020000001102687718",
  10153. Info: "2208",
  10154. }
  10155. customData = append(customData, custom7)
  10156. custom8 := &CustomData{
  10157. MsgId: "H44022900158202103301743097676",
  10158. PsnNo: "44020000001102127785",
  10159. Info: "2208",
  10160. }
  10161. customData = append(customData, custom8)
  10162. custom9 := &CustomData{
  10163. MsgId: "H44022900158202103301712304203",
  10164. PsnNo: "44020000001101518097",
  10165. Info: "2208",
  10166. }
  10167. customData = append(customData, custom9)
  10168. custom10 := &CustomData{
  10169. MsgId: "H44022900158202103301738448785",
  10170. PsnNo: "44020000001100500813",
  10171. Info: "2208",
  10172. }
  10173. customData = append(customData, custom10)
  10174. custom11 := &CustomData{
  10175. MsgId: "H44022900158202103301732455843",
  10176. PsnNo: "44020000001102690557",
  10177. Info: "2208",
  10178. }
  10179. customData = append(customData, custom11)
  10180. custom12 := &CustomData{
  10181. MsgId: "H44022900158202103301745421708",
  10182. PsnNo: "44020000001102211928",
  10183. Info: "2208",
  10184. }
  10185. customData = append(customData, custom12)
  10186. custom1212 := &CustomData{
  10187. MsgId: "H440229001582021033017351627",
  10188. PsnNo: "44020000001102481733",
  10189. Info: "2208",
  10190. }
  10191. customData = append(customData, custom1212)
  10192. custom13 := &CustomData{
  10193. MsgId: "H44022900158202103301740327951",
  10194. PsnNo: "44020000001103174866",
  10195. Info: "2208",
  10196. }
  10197. customData = append(customData, custom13)
  10198. custom14 := &CustomData{
  10199. MsgId: "H4402290015820210330174922668",
  10200. PsnNo: "44020000001102927272",
  10201. Info: "2208",
  10202. }
  10203. customData = append(customData, custom14)
  10204. custom15 := &CustomData{
  10205. MsgId: "H44022900158202103301752362273",
  10206. PsnNo: "44020000001102942890",
  10207. Info: "2208",
  10208. }
  10209. customData = append(customData, custom15)
  10210. custom16 := &CustomData{
  10211. MsgId: "H44022900158202103301751082917",
  10212. PsnNo: "44020000001101662162",
  10213. Info: "2208",
  10214. }
  10215. customData = append(customData, custom16)
  10216. custom17 := &CustomData{
  10217. MsgId: "H44022900158202103301754147728",
  10218. PsnNo: "44020000000229014511",
  10219. Info: "2208",
  10220. }
  10221. customData = append(customData, custom17)
  10222. adminUser := c.GetAdminUserInfo()
  10223. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10224. for _, item := range customData {
  10225. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10226. fmt.Println(result)
  10227. }
  10228. }
  10229. func PathExists(path string) (bool, error) {
  10230. _, err := os.Stat(path)
  10231. if err == nil {
  10232. return true, nil
  10233. }
  10234. if os.IsNotExist(err) {
  10235. return false, nil
  10236. }
  10237. return false, err
  10238. }
  10239. //创建文件夹
  10240. func Mkdir(dir string) {
  10241. // 创建文件夹
  10242. exist, err := PathExists(dir)
  10243. if err != nil {
  10244. fmt.Println(err.Error())
  10245. } else {
  10246. if exist {
  10247. fmt.Println(dir + "文件夹已存在!")
  10248. } else {
  10249. // 文件夹名称,权限
  10250. err := os.Mkdir(dir, os.ModePerm)
  10251. if err != nil {
  10252. fmt.Println(dir+"文件夹创建失败:", err.Error())
  10253. } else {
  10254. fmt.Println(dir + "文件夹创建成功!")
  10255. }
  10256. }
  10257. }
  10258. }
  10259. //压缩文件
  10260. func Zip(srcFile string, destZip string) error {
  10261. zipfile, err := os.Create(destZip)
  10262. if err != nil {
  10263. return err
  10264. }
  10265. defer zipfile.Close()
  10266. archive := zip.NewWriter(zipfile)
  10267. defer archive.Close()
  10268. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  10269. if err != nil {
  10270. return err
  10271. }
  10272. header, err := zip.FileInfoHeader(info)
  10273. if err != nil {
  10274. return err
  10275. }
  10276. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  10277. // header.Name = path
  10278. if info.IsDir() {
  10279. header.Name += "/"
  10280. } else {
  10281. header.Method = zip.Deflate
  10282. }
  10283. writer, err := archive.CreateHeader(header)
  10284. if err != nil {
  10285. return err
  10286. }
  10287. if !info.IsDir() {
  10288. file, err := os.Open(path)
  10289. if err != nil {
  10290. return err
  10291. }
  10292. defer file.Close()
  10293. _, err = io.Copy(writer, file)
  10294. }
  10295. return err
  10296. })
  10297. return err
  10298. }
  10299. func ReadFile(filePath string) []byte {
  10300. f, err := os.Open(filePath)
  10301. if err != nil {
  10302. fmt.Println("read file fail", err)
  10303. return nil
  10304. }
  10305. defer f.Close()
  10306. fd, err := ioutil.ReadAll(f)
  10307. if err != nil {
  10308. fmt.Println("read to fd fail", err)
  10309. return nil
  10310. }
  10311. return fd
  10312. }
  10313. func saveLog(result string, request string, infno string, desc string) {
  10314. org_id, _ := beego.AppConfig.Int64("org_id")
  10315. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  10316. dir := miConfig.OrgName + "日志"
  10317. utils.Mkdir(dir)
  10318. month := time.Unix(1557042972, 0).Format("1")
  10319. year := time.Now().Format("2006")
  10320. month = time.Now().Format("01")
  10321. day := time.Now().Format("02")
  10322. hour := time.Now().Format("15")
  10323. min := time.Now().Format("04")
  10324. sec := time.Now().Format("05")
  10325. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  10326. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  10327. file_name := file + ".txt"
  10328. file_path := miConfig.OrgName + "日志" + "/" + file_name
  10329. exist, _ := utils.PathExists(file_path)
  10330. if exist { //存在
  10331. fmt.Println("存在")
  10332. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  10333. if err != nil {
  10334. fmt.Println("read fail")
  10335. }
  10336. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  10337. n, _ := f.Seek(0, 2)
  10338. _, err = f.WriteAt([]byte(content), n)
  10339. } else { //不存在
  10340. fmt.Println("文件不存在,创建文件")
  10341. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  10342. defer f.Close()
  10343. if err != nil {
  10344. } else {
  10345. _, err = f.Write([]byte("记录日志"))
  10346. }
  10347. }
  10348. }
  10349. type Charset string
  10350. const (
  10351. UTF8 = Charset("UTF-8")
  10352. GB18030 = Charset("GB18030")
  10353. )
  10354. func ConvertToString(src string, srcCode string, tagCode string) string {
  10355. srcCoder := mahonia.NewDecoder(srcCode)
  10356. srcResult := srcCoder.ConvertString(src)
  10357. tagCoder := mahonia.NewDecoder(tagCode)
  10358. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  10359. result := string(cdata)
  10360. return result
  10361. }