his_api_controller.go 426KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654
  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.MedinsType = "1"
  134. fed.MedinsLv = "11"
  135. tm := time.Unix(his.RecordDate, 0)
  136. s_tm := tm.Format("2006-01-02 15:04:05")
  137. fed.AdmDate = s_tm
  138. fed.DscgDate = s_tm
  139. fed.DscgMainDiseCodg = config[0].CountryCode
  140. fed.DscgMainDiseName = config[0].CountryContentName
  141. //诊断信息
  142. var fdds []*models.FsiDiagnoseDtos
  143. for index, item := range config {
  144. if index == 0 {
  145. var fdd models.FsiDiagnoseDtos
  146. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  147. fdd.InoutDiseType = "1"
  148. fdd.MaindiseFlag = "1"
  149. fdd.DiseDate = s_tm
  150. fdd.DiasSrtNo = "1"
  151. fdd.DiseName = item.CountryContentName
  152. fdd.DiseCodg = item.CountryCode
  153. fdds = append(fdds, &fdd)
  154. } else {
  155. var fdd models.FsiDiagnoseDtos
  156. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  157. fdd.InoutDiseType = "1"
  158. fdd.MaindiseFlag = "1"
  159. fdd.DiseDate = s_tm
  160. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  161. fdd.DiseName = item.CountryContentName
  162. fdd.DiseCodg = item.CountryCode
  163. fdds = append(fdds, &fdd)
  164. }
  165. }
  166. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  167. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  168. fed.AdmDeptName = department.Name
  169. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  170. fed.DscgDeptName = department.Name
  171. fed.MedMdtrtType = "1"
  172. if his.Insutype == "390" {
  173. fed.MedType = "1402"
  174. } else {
  175. fed.MedType = "9933"
  176. }
  177. var orders []*models.FsiOrderDtos
  178. if trig_scen == "2" {
  179. //处方医嘱信息
  180. for _, item := range prescriptions {
  181. for _, subItem := range item.HisDoctorAdviceInfo {
  182. var order models.FsiOrderDtos
  183. order.RxID = strconv.FormatInt(item.ID, 10)
  184. order.Rxno = strconv.FormatInt(item.ID, 10)
  185. order.LongDrordFlag = "0"
  186. order.HilistType = "1"
  187. order.ChrgType = "1"
  188. order.DrordBhvr = "-"
  189. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  190. order.HosplistName = subItem.BaseDrugLib.DrugName
  191. order.HilistLv = "1"
  192. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  193. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  194. order.HosplistName = subItem.BaseDrugLib.DrugName
  195. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  196. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  197. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  198. order.OwnpayAmt = ""
  199. order.SelfpayAmt = ""
  200. order.Spec = ""
  201. order.SpecUnt = ""
  202. order.DrordBegnDate = s_tm
  203. order.DrordStopDate = ""
  204. order.DrordDrCodg = "1"
  205. order.DrordDeptName = department.Name
  206. order.DrordDrCodg = "1"
  207. order.DrordDrName = doctor_info.UserName
  208. order.DrordDrProfttl = ""
  209. order.CurrDrordFlag = "1"
  210. orders = append(orders, &order)
  211. }
  212. for _, subItem := range item.HisPrescriptionProject {
  213. if subItem.Type == 2 {
  214. var order models.FsiOrderDtos
  215. order.RxID = strconv.FormatInt(item.ID, 10)
  216. order.Rxno = strconv.FormatInt(item.ID, 10)
  217. order.LongDrordFlag = "0"
  218. order.HilistType = "1"
  219. order.ChrgType = "1"
  220. order.DrordBhvr = "-"
  221. order.HilistCode = subItem.HisProject.MedicalCode
  222. order.HosplistName = subItem.HisProject.ProjectName
  223. order.HilistLv = "1"
  224. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  225. order.HosplistCode = subItem.HisProject.MedicalCode
  226. order.HosplistName = subItem.HisProject.ProjectName
  227. order.Cnt = subItem.Count
  228. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  229. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  230. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  231. order.OwnpayAmt = ""
  232. order.SelfpayAmt = ""
  233. order.Spec = ""
  234. order.SpecUnt = ""
  235. order.DrordBegnDate = s_tm
  236. order.DrordStopDate = ""
  237. order.DrordDrCodg = "1"
  238. order.DrordDeptName = department.Name
  239. order.DrordDrCodg = "1"
  240. order.DrordDrName = doctor_info.UserName
  241. order.DrordDrProfttl = ""
  242. order.CurrDrordFlag = "1"
  243. orders = append(orders, &order)
  244. }
  245. if subItem.Type == 3 {
  246. var order models.FsiOrderDtos
  247. order.RxID = strconv.FormatInt(item.ID, 10)
  248. order.Rxno = strconv.FormatInt(item.ID, 10)
  249. order.LongDrordFlag = "0"
  250. order.HilistType = "1"
  251. order.ChrgType = "1"
  252. order.DrordBhvr = "-"
  253. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  254. order.HosplistName = subItem.GoodInfo.GoodName
  255. order.HilistLv = "1"
  256. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  257. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  258. order.HosplistName = subItem.GoodInfo.GoodName
  259. order.Cnt = subItem.Count
  260. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  261. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  262. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  263. order.OwnpayAmt = ""
  264. order.SelfpayAmt = ""
  265. order.Spec = ""
  266. order.SpecUnt = ""
  267. order.DrordBegnDate = s_tm
  268. order.DrordStopDate = ""
  269. order.DrordDrCodg = "1"
  270. order.DrordDeptName = department.Name
  271. order.DrordDrCodg = "1"
  272. order.DrordDrName = doctor_info.UserName
  273. order.DrordDrProfttl = ""
  274. order.CurrDrordFlag = "1"
  275. orders = append(orders, &order)
  276. }
  277. }
  278. }
  279. //处方医嘱信息
  280. }
  281. fed.MatnStas = "0"
  282. fed.MedfeeSumamt = "0"
  283. fed.OwnpayAmt = "0"
  284. fed.SelfpayAmt = "0"
  285. fed.AcctPayamt = "0"
  286. fed.MaAmt = "0"
  287. fed.HifpPayamt = "0"
  288. fed.SetlTotlnum = "1"
  289. fed.Insutype = his.Insutype
  290. fed.ReimFlag = "0"
  291. fed.OutSetlFlag = "0"
  292. var fopd []*models.FsiOperationDtosData
  293. data := make(map[string]interface{})
  294. data["fed"] = fed
  295. data["fdd"] = fdds
  296. data["fod"] = orders
  297. data["pd"] = pd
  298. data["pp"] = pp
  299. data["fopd"] = fopd
  300. data["trig_scen"] = trig_scen
  301. fmt.Println(data)
  302. fmt.Println(fed)
  303. fmt.Println(fdds)
  304. fmt.Println(orders)
  305. fmt.Println(pd)
  306. fmt.Println(pp)
  307. fmt.Println(fopd)
  308. client := &http.Client{}
  309. bytesData, _ := json.Marshal(data)
  310. var req *http.Request
  311. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  312. resp, _ := client.Do(req)
  313. defer resp.Body.Close()
  314. body, ioErr := ioutil.ReadAll(resp.Body)
  315. if ioErr != nil {
  316. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  318. return
  319. }
  320. var respJSON map[string]interface{}
  321. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  322. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  324. return
  325. }
  326. //手术操作集合
  327. //手术操作集合
  328. }
  329. func (c *HisApiController) Check3102() {
  330. patient_id, _ := c.GetInt64("patient_id")
  331. order_id, _ := c.GetInt64("order_id")
  332. his_patient_id, _ := c.GetInt64("his_patient_id")
  333. admin_user_id, _ := c.GetInt64("admin_user_id")
  334. trig_scen := c.GetString("trig_scen")
  335. adminUser := c.GetAdminUserInfo()
  336. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  337. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  338. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  339. record_time := c.GetString("record_time")
  340. order, _ := service.GetHisOrderByID(order_id)
  341. timeLayout := "2006-01-02"
  342. loc, _ := time.LoadLocation("Local")
  343. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  344. if err != nil {
  345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  346. return
  347. }
  348. recordDateTime := theTime.Unix()
  349. var patientPrescription models.HisPrescriptionInfo
  350. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  351. if patientPrescription.ID == 0 {
  352. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  353. }
  354. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  355. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  356. //
  357. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  358. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  359. var pp models.PublicParams
  360. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  361. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  362. pp.FixmedinsName = miConfig.OrgName
  363. pp.FixmedinsCode = miConfig.Code
  364. pp.RequestUrl = miConfig.Url
  365. pp.Cainfo = miConfig.Cainfo
  366. pp.SecretKey = miConfig.SecretKey
  367. pp.AccessKey = miConfig.AccessKey
  368. pp.OpterName = roles.UserName
  369. var config []*models.HisXtDiagnoseConfig
  370. for _, item := range diagnosis_ids {
  371. id, _ := strconv.ParseInt(item, 10, 64)
  372. diagnosisConfig, _ := service.FindDiagnoseById(id)
  373. config = append(config, &diagnosisConfig)
  374. }
  375. var pd models.PatientDtos
  376. pd.PatnID = his.PsnNo
  377. pd.PatnName = his.Name
  378. pd.Gend = his.Gend
  379. pd.Brdy = his.Brdy
  380. pd.Poolarea = his.InsuplcAdmdvs
  381. pd.CurrMdtrtID = his.Number
  382. var fed models.FsiEncounterDtos
  383. fed.MdtrtID = his.Number
  384. fed.MedinsID = miConfig.Code
  385. fed.MedinsName = miConfig.OrgName
  386. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  387. fed.MedMdtrtType = "1"
  388. fed.MedinsType = "1"
  389. fed.MedinsLv = "11"
  390. tm := time.Unix(his.RecordDate, 0)
  391. s_tm := tm.Format("2006-01-02 15:04:05")
  392. fed.AdmDate = s_tm
  393. fed.DscgDate = s_tm
  394. fed.DscgMainDiseCodg = config[0].CountryCode
  395. fed.DscgMainDiseName = config[0].CountryContentName
  396. //诊断信息
  397. var fdds []*models.FsiDiagnoseDtos
  398. for index, item := range config {
  399. if index == 0 {
  400. var fdd models.FsiDiagnoseDtos
  401. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  402. fdd.InoutDiseType = "1"
  403. fdd.MaindiseFlag = "1"
  404. fdd.DiseDate = s_tm
  405. fdd.DiasSrtNo = "1"
  406. fdd.DiseName = item.CountryContentName
  407. fdd.DiseCodg = item.CountryCode
  408. fdds = append(fdds, &fdd)
  409. } else {
  410. var fdd models.FsiDiagnoseDtos
  411. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  412. fdd.InoutDiseType = "1"
  413. fdd.MaindiseFlag = "1"
  414. fdd.DiseDate = s_tm
  415. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  416. fdd.DiseName = item.CountryContentName
  417. fdd.DiseCodg = item.CountryCode
  418. fdds = append(fdds, &fdd)
  419. }
  420. }
  421. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  422. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  423. fed.AdmDeptName = department.Name
  424. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  425. fed.DscgDeptName = department.Name
  426. fed.MedType = order.MedType
  427. //处方医嘱信息
  428. var orders []*models.FsiOrderDtos
  429. //for _, item := range prescriptions {
  430. // for _, subItem := range item.HisDoctorAdviceInfo {
  431. // var order models.FsiOrderDtos
  432. // order.RxID = strconv.FormatInt(item.ID, 10)
  433. // order.Rxno = strconv.FormatInt(item.ID, 10)
  434. // order.LongDrordFlag = "0"
  435. // order.HilistType = "1"
  436. // order.ChrgType = "1"
  437. // order.DrordBhvr = "-"
  438. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  439. // order.HosplistName = subItem.BaseDrugLib.DrugName
  440. // order.HilistLv = "1"
  441. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  442. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  443. // order.HosplistName = subItem.BaseDrugLib.DrugName
  444. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  445. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  446. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  447. // order.OwnpayAmt = ""
  448. // order.SelfpayAmt = ""
  449. // order.Spec = ""
  450. // order.SpecUnt = ""
  451. // order.DrordBegnDate = s_tm
  452. // order.DrordStopDate = ""
  453. // order.DrordDrCodg = "1"
  454. // order.DrordDeptName = department.Name
  455. // order.DrordDrCodg = "1"
  456. // order.DrordDrName = doctor_info.UserName
  457. // order.DrordDrProfttl = ""
  458. // order.CurrDrordFlag = "1"
  459. // orders = append(orders, &order)
  460. // }
  461. // for _, subItem := range item.HisPrescriptionProject {
  462. // if subItem.Type == 2 {
  463. // var order models.FsiOrderDtos
  464. // order.RxID = strconv.FormatInt(item.ID, 10)
  465. // order.Rxno = strconv.FormatInt(item.ID, 10)
  466. // order.LongDrordFlag = "0"
  467. // order.HilistType = "1"
  468. // order.ChrgType = "1"
  469. // order.DrordBhvr = "-"
  470. // order.HilistCode = subItem.HisProject.MedicalCode
  471. // order.HosplistName = subItem.HisProject.ProjectName
  472. // order.HilistLv = "1"
  473. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  474. // order.HosplistCode = subItem.HisProject.MedicalCode
  475. // order.HosplistName = subItem.HisProject.ProjectName
  476. // order.Cnt = subItem.Count
  477. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  478. //
  479. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  480. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  481. // order.OwnpayAmt = ""
  482. // order.SelfpayAmt = ""
  483. // order.Spec = ""
  484. // order.SpecUnt = ""
  485. // order.DrordBegnDate = s_tm
  486. // order.DrordStopDate = ""
  487. // order.DrordDrCodg = "1"
  488. // order.DrordDeptName = department.Name
  489. // order.DrordDrCodg = "1"
  490. // order.DrordDrName = doctor_info.UserName
  491. // order.DrordDrProfttl = ""
  492. // order.CurrDrordFlag = "1"
  493. // orders = append(orders, &order)
  494. //
  495. // }
  496. // if subItem.Type == 3 {
  497. //
  498. // var order models.FsiOrderDtos
  499. // order.RxID = strconv.FormatInt(item.ID, 10)
  500. // order.Rxno = strconv.FormatInt(item.ID, 10)
  501. // order.LongDrordFlag = "0"
  502. // order.HilistType = "1"
  503. // order.ChrgType = "1"
  504. // order.DrordBhvr = "-"
  505. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  506. // order.HosplistName = subItem.GoodInfo.GoodName
  507. // order.HilistLv = "1"
  508. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  509. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  510. // order.HosplistName = subItem.GoodInfo.GoodName
  511. // order.Cnt = subItem.Count
  512. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  513. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  514. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  515. // order.OwnpayAmt = ""
  516. // order.SelfpayAmt = ""
  517. // order.Spec = ""
  518. // order.SpecUnt = ""
  519. // order.DrordBegnDate = s_tm
  520. // order.DrordStopDate = ""
  521. // order.DrordDrCodg = "1"
  522. // order.DrordDeptName = department.Name
  523. // order.DrordDrCodg = "1"
  524. // order.DrordDrName = doctor_info.UserName
  525. // order.DrordDrProfttl = ""
  526. // order.CurrDrordFlag = "1"
  527. // orders = append(orders, &order)
  528. //
  529. // }
  530. // }
  531. //}
  532. for _, item := range prescriptions {
  533. for _, subItem := range item.HisDoctorAdviceInfo {
  534. var order models.FsiOrderDtos
  535. order.RxID = strconv.FormatInt(item.ID, 10)
  536. order.Rxno = strconv.FormatInt(item.ID, 10)
  537. order.LongDrordFlag = "0"
  538. order.HilistType = "1"
  539. order.ChrgType = "1"
  540. order.DrordBhvr = "-"
  541. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  542. order.HosplistName = subItem.BaseDrugLib.DrugName
  543. order.HilistLv = "1"
  544. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  545. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  546. order.HosplistName = subItem.BaseDrugLib.DrugName
  547. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  548. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  549. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  550. order.OwnpayAmt = ""
  551. order.SelfpayAmt = ""
  552. order.Spec = ""
  553. order.SpecUnt = ""
  554. order.DrordBegnDate = s_tm
  555. order.DrordStopDate = ""
  556. order.DrordDrCodg = "1"
  557. order.DrordDeptName = department.Name
  558. order.DrordDrCodg = "1"
  559. order.DrordDrName = doctor_info.UserName
  560. order.DrordDrProfttl = ""
  561. order.CurrDrordFlag = "1"
  562. orders = append(orders, &order)
  563. }
  564. for _, subItem := range item.HisPrescriptionProject {
  565. if subItem.Type == 2 {
  566. var order models.FsiOrderDtos
  567. order.RxID = strconv.FormatInt(item.ID, 10)
  568. order.Rxno = strconv.FormatInt(item.ID, 10)
  569. order.LongDrordFlag = "0"
  570. order.HilistType = "1"
  571. order.ChrgType = "1"
  572. order.DrordBhvr = "-"
  573. order.HilistCode = subItem.HisProject.MedicalCode
  574. order.HosplistName = subItem.HisProject.ProjectName
  575. order.HilistLv = "1"
  576. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  577. order.HosplistCode = subItem.HisProject.MedicalCode
  578. order.HosplistName = subItem.HisProject.ProjectName
  579. order.Cnt = subItem.Count
  580. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  581. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  582. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  583. order.OwnpayAmt = ""
  584. order.SelfpayAmt = ""
  585. order.Spec = ""
  586. order.SpecUnt = ""
  587. order.DrordBegnDate = s_tm
  588. order.DrordStopDate = ""
  589. order.DrordDrCodg = "1"
  590. order.DrordDeptName = department.Name
  591. order.DrordDrCodg = "1"
  592. order.DrordDrName = doctor_info.UserName
  593. order.DrordDrProfttl = ""
  594. order.CurrDrordFlag = "1"
  595. orders = append(orders, &order)
  596. }
  597. if subItem.Type == 3 {
  598. var order models.FsiOrderDtos
  599. order.RxID = strconv.FormatInt(item.ID, 10)
  600. order.Rxno = strconv.FormatInt(item.ID, 10)
  601. order.LongDrordFlag = "0"
  602. order.HilistType = "1"
  603. order.ChrgType = "1"
  604. order.DrordBhvr = "-"
  605. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  606. order.HosplistName = subItem.GoodInfo.GoodName
  607. order.HilistLv = "1"
  608. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  609. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  610. order.HosplistName = subItem.GoodInfo.GoodName
  611. order.Cnt = subItem.Count
  612. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  613. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  614. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  615. order.OwnpayAmt = ""
  616. order.SelfpayAmt = ""
  617. order.Spec = ""
  618. order.SpecUnt = ""
  619. order.DrordBegnDate = s_tm
  620. order.DrordStopDate = ""
  621. order.DrordDrCodg = "1"
  622. order.DrordDeptName = department.Name
  623. order.DrordDrCodg = "1"
  624. order.DrordDrName = doctor_info.UserName
  625. order.DrordDrProfttl = ""
  626. order.CurrDrordFlag = "1"
  627. orders = append(orders, &order)
  628. }
  629. }
  630. }
  631. //处方医嘱信息
  632. fed.MatnStas = "0"
  633. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  634. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  635. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  636. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  637. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  638. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  639. fed.SetlTotlnum = "1"
  640. fed.Insutype = his.Insutype
  641. fed.ReimFlag = "0"
  642. fed.OutSetlFlag = "0"
  643. var fopd []*models.FsiOperationDtosData
  644. data := make(map[string]interface{})
  645. data["fed"] = fed
  646. data["fdd"] = fdds
  647. data["fod"] = orders
  648. data["pd"] = pd
  649. data["pp"] = pp
  650. data["fopd"] = fopd
  651. data["trig_scen"] = trig_scen
  652. fmt.Println(data)
  653. fmt.Println(fed)
  654. fmt.Println(fdds)
  655. fmt.Println(orders)
  656. fmt.Println(pd)
  657. fmt.Println(pp)
  658. fmt.Println(fopd)
  659. client := &http.Client{}
  660. bytesData, _ := json.Marshal(data)
  661. var req *http.Request
  662. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  663. resp, _ := client.Do(req)
  664. defer resp.Body.Close()
  665. body, ioErr := ioutil.ReadAll(resp.Body)
  666. if ioErr != nil {
  667. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  669. return
  670. }
  671. var respJSON map[string]interface{}
  672. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  673. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  675. return
  676. }
  677. //手术操作集合
  678. //手术操作集合
  679. }
  680. func (c *HisApiController) Check() {
  681. psn_no := c.GetString("psn_no")
  682. in := c.GetString("in")
  683. mt := c.GetString("mt")
  684. baseParams := models.BaseParams{
  685. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  686. FixmedinsCode: "H15049901371",
  687. InsuplcAdmdvs: "150499",
  688. MdtrtareaAdmvs: "150499",
  689. OrgName: "赤峰费森血液透析中心",
  690. Doctor: "1111",
  691. }
  692. service.Gdyb2001(baseParams, psn_no, in, mt)
  693. }
  694. func (c *HisApiController) GetPsnNcdsInfo() {
  695. admin_user_id, _ := c.GetInt64("admin_user_id")
  696. patient_id, _ := c.GetInt64("patient_id")
  697. id, _ := c.GetInt64("id")
  698. adminUser := c.GetAdminUserInfo()
  699. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  700. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  701. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  702. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  703. psn_record, _ := service.GetPsnNCDSRecordById(id)
  704. //
  705. //if psn_record.ID == 0 {
  706. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  707. // return
  708. //}
  709. var res Result5301
  710. var res10265 Result5301For10265
  711. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  712. psn_info, _ := service.GetPsnByPatientId(patient_id)
  713. var api string
  714. if miConfig.MdtrtareaAdmvs == "320921" {
  715. 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 +
  716. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  717. } else {
  718. 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 +
  719. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  720. }
  721. resp, requestErr := http.Get(api)
  722. if requestErr != nil {
  723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  724. return
  725. }
  726. body, ioErr := ioutil.ReadAll(resp.Body)
  727. if ioErr != nil {
  728. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  730. return
  731. }
  732. var respJSON map[string]interface{}
  733. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  734. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  736. return
  737. }
  738. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  739. result, _ := json.Marshal(respJSON)
  740. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  741. utils.ErrorLog("解析失败:%v", err)
  742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  743. return
  744. }
  745. res.ErrMsg = res10265.ErrMsg
  746. res.Output = res10265.Output
  747. res.InfRefmsgid = res10265.InfRefmsgid
  748. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  749. res.Infcode = infocode
  750. } else {
  751. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  752. var dat map[string]interface{}
  753. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  754. fmt.Println(dat)
  755. } else {
  756. fmt.Println(err)
  757. }
  758. userJSONBytes, _ := json.Marshal(dat)
  759. if miConfig.Code == "H15049901371" {
  760. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  761. utils.ErrorLog("解析失败:%v", err)
  762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  763. return
  764. }
  765. res.InfRefmsgid = res10265.InfRefmsgid
  766. res.Output = res10265.Output
  767. res.ErrMsg = res10265.ErrMsg
  768. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  769. res.Infcode = infocode
  770. } else {
  771. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  772. utils.ErrorLog("解析失败:%v", err)
  773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  774. return
  775. }
  776. }
  777. }
  778. if res.Infcode == 0 {
  779. c.ServeSuccessJSON(map[string]interface{}{
  780. "result": res.Output.Result,
  781. })
  782. }
  783. }
  784. func (c *HisApiController) CheckInsutype() {
  785. his_patient_id, _ := c.GetInt64("his_patient_id")
  786. admin_user_id, _ := c.GetInt64("admin_user_id")
  787. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  788. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  789. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  790. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  791. var dat map[string]interface{}
  792. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  793. fmt.Println(dat)
  794. } else {
  795. fmt.Println(err)
  796. }
  797. userJSONBytes, _ := json.Marshal(dat)
  798. var res Result90100
  799. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  800. utils.ErrorLog("解析失败:%v", err)
  801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  802. return
  803. }
  804. if res.Infcode != 0 {
  805. c.ServeSuccessJSON(map[string]interface{}{
  806. "failed_code": -10,
  807. "msg": res.ErrMsg,
  808. })
  809. return
  810. } else {
  811. fmt.Println(res)
  812. }
  813. }
  814. func (c *HisApiController) CheckCardPWD() {
  815. card_pwd := c.GetString("card_pwd")
  816. his_patient_id, _ := c.GetInt64("his_patient_id")
  817. admin_user_id, _ := c.GetInt64("admin_user_id")
  818. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  819. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  820. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  821. psn, _ := service.GetPsnByPatientId(his.PatientId)
  822. bas := strings.Split(psn.CardInfo, "|")
  823. basNumber := bas[2]
  824. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  825. var dat map[string]interface{}
  826. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  827. fmt.Println(dat)
  828. } else {
  829. fmt.Println(err)
  830. }
  831. userJSONBytes, _ := json.Marshal(dat)
  832. var res Result90991
  833. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  834. utils.ErrorLog("解析失败:%v", err)
  835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  836. return
  837. }
  838. if res.Infcode != 0 {
  839. c.ServeSuccessJSON(map[string]interface{}{
  840. "failed_code": -10,
  841. "msg": res.ErrMsg,
  842. })
  843. return
  844. } else {
  845. if res.Output.Result.CheckStat == "0" {
  846. var msg string
  847. switch res.Output.Result.CardStat {
  848. case "00":
  849. msg = "未激活"
  850. break
  851. case "10":
  852. msg = "激活"
  853. break
  854. case "20":
  855. msg = "窗口挂失"
  856. break
  857. case "21":
  858. msg = "电话挂失"
  859. break
  860. case "22":
  861. msg = "单位网上申报挂失"
  862. break
  863. case "23":
  864. msg = "保健办挂失"
  865. break
  866. case "24":
  867. msg = "个人网上挂失"
  868. break
  869. case "25":
  870. msg = "网上服务大厅挂失"
  871. break
  872. case "30":
  873. msg = "注销"
  874. break
  875. case "40":
  876. msg = "回收"
  877. break
  878. case "99":
  879. msg = "制卡中(无效卡)"
  880. break
  881. }
  882. c.ServeSuccessJSON(map[string]interface{}{
  883. "failed_code": -10,
  884. "msg": msg,
  885. })
  886. return
  887. } else {
  888. c.ServeSuccessJSON(map[string]interface{}{
  889. "msg": "校验成功",
  890. })
  891. return
  892. }
  893. }
  894. }
  895. func (c *HisApiController) ReadCard() {
  896. id_card_type, _ := c.GetInt64("id_card_type")
  897. admin_user_id, _ := c.GetInt64("admin_user_id")
  898. certificates, _ := c.GetInt64("certificates")
  899. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  900. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  901. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  902. switch id_card_type {
  903. case 1:
  904. if miConfig.MdtrtareaAdmvs == "421300" {
  905. var res ResultTwo
  906. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  907. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  908. "&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)
  909. resp, requestErr := http.Get(api)
  910. if requestErr != nil {
  911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  912. return
  913. }
  914. body, ioErr := ioutil.ReadAll(resp.Body)
  915. if ioErr != nil {
  916. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  918. return
  919. }
  920. var respJSON map[string]interface{}
  921. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  922. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  924. return
  925. }
  926. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  927. result, _ := json.Marshal(respJSON)
  928. fmt.Println("log")
  929. fmt.Println(string(result))
  930. if err := json.Unmarshal([]byte(result), &res); err != nil {
  931. utils.ErrorLog("解析失败:%v", err)
  932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  933. return
  934. }
  935. if res.Infcode == 0 {
  936. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  937. if err == gorm.ErrRecordNotFound {
  938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  939. return
  940. } else if err != nil {
  941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  942. return
  943. } else {
  944. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  945. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  946. infoStr := string(Iinfos)
  947. idetinfoStr := string(Idetinfos)
  948. psn := &models.HisPsn{
  949. PsnNo: res.Output.Baseinfo.PsnNo,
  950. Age: res.Output.Baseinfo.Age,
  951. PatientId: patient.ID,
  952. Certno: res.Output.Baseinfo.Certno,
  953. Brdy: res.Output.Baseinfo.Brdy,
  954. Gend: res.Output.Baseinfo.Gend,
  955. Naty: res.Output.Baseinfo.Naty,
  956. PsnCertType: res.Output.Baseinfo.PsnCertType,
  957. PsnName: res.Output.Baseinfo.PsnName,
  958. Idetinfo: idetinfoStr,
  959. Insuinfo: infoStr,
  960. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  961. }
  962. service.CreateHisPsn(psn)
  963. c.ServeSuccessJSON(map[string]interface{}{
  964. "patient": patient,
  965. "number": res.Output.Baseinfo.Certno,
  966. })
  967. }
  968. } else {
  969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  970. return
  971. }
  972. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  973. var api string
  974. if miConfig.MdtrtareaAdmvs == "320921" {
  975. 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 +
  976. "&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
  977. fmt.Println(api)
  978. } else {
  979. 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 +
  980. "&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)
  981. }
  982. resp, requestErr := http.Get(api)
  983. if requestErr != nil {
  984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  985. return
  986. }
  987. body, ioErr := ioutil.ReadAll(resp.Body)
  988. if ioErr != nil {
  989. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  991. return
  992. }
  993. var respJSON map[string]interface{}
  994. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  995. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  997. return
  998. }
  999. var status string
  1000. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1001. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1002. //console.log()
  1003. fmt.Println("type===")
  1004. fmt.Println(card_type)
  1005. var token string
  1006. var res ResultTwo //1101结果
  1007. var res10265 ResultTwo10265 //1101结果
  1008. var card_info string //卡信息
  1009. var busi_card_info string
  1010. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1011. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1012. if status == "0" { //读卡成功
  1013. if card_type == "1" {
  1014. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1015. result, _ := json.Marshal(respJSON)
  1016. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1017. utils.ErrorLog("解析失败:%v", err)
  1018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1019. return
  1020. }
  1021. res.ErrMsg = res10265.ErrMsg
  1022. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1023. res.Infcode = infocode
  1024. res.Output = res10265.Output
  1025. res.InfRefmsgid = res10265.InfRefmsgid
  1026. } else {
  1027. //var card_info string //卡信息
  1028. //var busi_card_info string
  1029. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1030. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1031. //fmt.Println(card_info)
  1032. //fmt.Println(busi_card_info)
  1033. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1034. result, _ := json.Marshal(respJSON)
  1035. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1036. utils.ErrorLog("解析失败:%v", err)
  1037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1038. return
  1039. }
  1040. res.ErrMsg = res10265.ErrMsg
  1041. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1042. res.Infcode = infocode
  1043. res.Output = res10265.Output
  1044. res.InfRefmsgid = res10265.InfRefmsgid
  1045. }
  1046. if res.Infcode == 0 {
  1047. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1048. if err == gorm.ErrRecordNotFound {
  1049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1050. return
  1051. } else if err != nil {
  1052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1053. return
  1054. } else {
  1055. if card_type == "1" {
  1056. bas := strings.Split(card_info, "|")
  1057. basNumber := bas[2]
  1058. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1059. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1060. infoStr := string(Iinfos)
  1061. idetinfoStr := string(Idetinfos)
  1062. psn := &models.HisPsn{
  1063. PsnNo: res.Output.Baseinfo.PsnNo,
  1064. Age: res.Output.Baseinfo.Age,
  1065. PatientId: patient.ID,
  1066. Certno: res.Output.Baseinfo.Certno,
  1067. Brdy: res.Output.Baseinfo.Brdy,
  1068. Gend: res.Output.Baseinfo.Gend,
  1069. Naty: res.Output.Baseinfo.Naty,
  1070. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1071. PsnName: res.Output.Baseinfo.PsnName,
  1072. Idetinfo: idetinfoStr,
  1073. Insuinfo: infoStr,
  1074. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1075. CardInfo: card_info,
  1076. VerifyNumber: busi_card_info,
  1077. }
  1078. service.CreateHisPsn(psn)
  1079. c.ServeSuccessJSON(map[string]interface{}{
  1080. "patient": patient,
  1081. "number": basNumber,
  1082. })
  1083. } else {
  1084. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1085. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1086. infoStr := string(Iinfos)
  1087. idetinfoStr := string(Idetinfos)
  1088. psn := &models.HisPsn{
  1089. PsnNo: res.Output.Baseinfo.PsnNo,
  1090. Age: res.Output.Baseinfo.Age,
  1091. PatientId: patient.ID,
  1092. Certno: res.Output.Baseinfo.Certno,
  1093. Brdy: res.Output.Baseinfo.Brdy,
  1094. Gend: res.Output.Baseinfo.Gend,
  1095. Naty: res.Output.Baseinfo.Naty,
  1096. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1097. PsnName: res.Output.Baseinfo.PsnName,
  1098. Idetinfo: idetinfoStr,
  1099. Insuinfo: infoStr,
  1100. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1101. CardInfo: card_info,
  1102. VerifyNumber: token,
  1103. }
  1104. service.CreateHisPsn(psn)
  1105. c.ServeSuccessJSON(map[string]interface{}{
  1106. "patient": patient,
  1107. "number": token,
  1108. })
  1109. }
  1110. }
  1111. } else {
  1112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1113. return
  1114. }
  1115. } else { //读卡失败
  1116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1117. return
  1118. }
  1119. } else {
  1120. if initFlag == 0 {
  1121. c.TestGetBasBaseInit()
  1122. }
  1123. basStr := c.GetBasBaseInfo()
  1124. if len(basStr) == 0 {
  1125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1126. return
  1127. }
  1128. fmt.Println(basStr)
  1129. bas := strings.Split(basStr, "|")
  1130. basNumber := bas[1]
  1131. fmt.Println(basNumber)
  1132. card_sn := bas[3]
  1133. fmt.Println(card_sn)
  1134. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1135. var dat map[string]interface{}
  1136. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1137. fmt.Println(dat)
  1138. } else {
  1139. fmt.Println(err)
  1140. }
  1141. userJSONBytes, _ := json.Marshal(dat)
  1142. var res ResultTwo
  1143. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1144. utils.ErrorLog("解析失败:%v", err)
  1145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1146. return
  1147. }
  1148. if res.Infcode == 0 {
  1149. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1150. if err == gorm.ErrRecordNotFound {
  1151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1152. return
  1153. } else if err != nil {
  1154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1155. return
  1156. } else {
  1157. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1158. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1159. infoStr := string(Iinfos)
  1160. idetinfoStr := string(Idetinfos)
  1161. psn := &models.HisPsn{
  1162. PsnNo: res.Output.Baseinfo.PsnNo,
  1163. Age: res.Output.Baseinfo.Age,
  1164. PatientId: patient.ID,
  1165. Certno: res.Output.Baseinfo.Certno,
  1166. Brdy: res.Output.Baseinfo.Brdy,
  1167. Gend: res.Output.Baseinfo.Gend,
  1168. Naty: res.Output.Baseinfo.Naty,
  1169. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1170. PsnName: res.Output.Baseinfo.PsnName,
  1171. Idetinfo: idetinfoStr,
  1172. Insuinfo: infoStr,
  1173. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1174. CardInfo: basStr,
  1175. VerifyNumber: "",
  1176. }
  1177. service.CreateHisPsn(psn)
  1178. c.ServeSuccessJSON(map[string]interface{}{
  1179. "patient": patient,
  1180. "number": basNumber,
  1181. })
  1182. }
  1183. } else {
  1184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1185. return
  1186. }
  1187. break
  1188. }
  1189. case 2:
  1190. SFZStr := c.GetSFZBaseInfo()
  1191. id_card_str := strings.Split(SFZStr, "^")
  1192. id_card_number := id_card_str[0]
  1193. card_sn := ""
  1194. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1195. var dat map[string]interface{}
  1196. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1197. fmt.Println(dat)
  1198. } else {
  1199. fmt.Println(err)
  1200. }
  1201. userJSONBytes, _ := json.Marshal(dat)
  1202. var res ResultTwo
  1203. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1204. utils.ErrorLog("解析失败:%v", err)
  1205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1206. return
  1207. }
  1208. if res.Infcode == 0 {
  1209. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1210. if err == gorm.ErrRecordNotFound {
  1211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1212. return
  1213. } else if err != nil {
  1214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1215. return
  1216. } else {
  1217. c.ServeSuccessJSON(map[string]interface{}{
  1218. "patient": patient,
  1219. "number": id_card_number,
  1220. })
  1221. }
  1222. } else {
  1223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1224. return
  1225. }
  1226. break
  1227. case 3:
  1228. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1229. var api string
  1230. if miConfig.MdtrtareaAdmvs == "320921" {
  1231. 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 +
  1232. "&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
  1233. fmt.Println(api)
  1234. } else {
  1235. 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 +
  1236. "&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)
  1237. }
  1238. resp, requestErr := http.Get(api)
  1239. if requestErr != nil {
  1240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1241. return
  1242. }
  1243. body, ioErr := ioutil.ReadAll(resp.Body)
  1244. if ioErr != nil {
  1245. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1247. return
  1248. }
  1249. var respJSON map[string]interface{}
  1250. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1251. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1253. return
  1254. }
  1255. var status string
  1256. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1257. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1258. var token string
  1259. var res ResultTwo //1101结果
  1260. var res10265 ResultTwo10265 //1101结果
  1261. var card_info string //卡信息
  1262. var busi_card_info string
  1263. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1264. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1265. if status == "0" { //读卡成功
  1266. if card_type == "1" {
  1267. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1268. result, _ := json.Marshal(respJSON)
  1269. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1270. utils.ErrorLog("解析失败:%v", err)
  1271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1272. return
  1273. }
  1274. res.ErrMsg = res10265.ErrMsg
  1275. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1276. res.Infcode = infocode
  1277. res.Output = res10265.Output
  1278. res.InfRefmsgid = res10265.InfRefmsgid
  1279. } else {
  1280. //var card_info string //卡信息
  1281. //var busi_card_info string
  1282. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1283. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1284. //fmt.Println(card_info)
  1285. //fmt.Println(busi_card_info)
  1286. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1287. result, _ := json.Marshal(respJSON)
  1288. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1289. utils.ErrorLog("解析失败:%v", err)
  1290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1291. return
  1292. }
  1293. res.ErrMsg = res10265.ErrMsg
  1294. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1295. res.Infcode = infocode
  1296. res.Output = res10265.Output
  1297. res.InfRefmsgid = res10265.InfRefmsgid
  1298. }
  1299. if res.Infcode == 0 {
  1300. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1301. if err == gorm.ErrRecordNotFound {
  1302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1303. return
  1304. } else if err != nil {
  1305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1306. return
  1307. } else {
  1308. if card_type == "1" {
  1309. bas := strings.Split(card_info, "|")
  1310. basNumber := bas[2]
  1311. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1312. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1313. infoStr := string(Iinfos)
  1314. idetinfoStr := string(Idetinfos)
  1315. psn := &models.HisPsn{
  1316. PsnNo: res.Output.Baseinfo.PsnNo,
  1317. Age: res.Output.Baseinfo.Age,
  1318. PatientId: patient.ID,
  1319. Certno: res.Output.Baseinfo.Certno,
  1320. Brdy: res.Output.Baseinfo.Brdy,
  1321. Gend: res.Output.Baseinfo.Gend,
  1322. Naty: res.Output.Baseinfo.Naty,
  1323. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1324. PsnName: res.Output.Baseinfo.PsnName,
  1325. Idetinfo: idetinfoStr,
  1326. Insuinfo: infoStr,
  1327. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1328. CardInfo: card_info,
  1329. VerifyNumber: busi_card_info,
  1330. }
  1331. service.CreateHisPsn(psn)
  1332. c.ServeSuccessJSON(map[string]interface{}{
  1333. "patient": patient,
  1334. "number": basNumber,
  1335. })
  1336. } else {
  1337. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1338. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1339. infoStr := string(Iinfos)
  1340. idetinfoStr := string(Idetinfos)
  1341. psn := &models.HisPsn{
  1342. PsnNo: res.Output.Baseinfo.PsnNo,
  1343. Age: res.Output.Baseinfo.Age,
  1344. PatientId: patient.ID,
  1345. Certno: res.Output.Baseinfo.Certno,
  1346. Brdy: res.Output.Baseinfo.Brdy,
  1347. Gend: res.Output.Baseinfo.Gend,
  1348. Naty: res.Output.Baseinfo.Naty,
  1349. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1350. PsnName: res.Output.Baseinfo.PsnName,
  1351. Idetinfo: idetinfoStr,
  1352. Insuinfo: infoStr,
  1353. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1354. CardInfo: card_info,
  1355. VerifyNumber: token,
  1356. }
  1357. service.CreateHisPsn(psn)
  1358. c.ServeSuccessJSON(map[string]interface{}{
  1359. "patient": patient,
  1360. "number": token,
  1361. })
  1362. }
  1363. }
  1364. } else {
  1365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1366. return
  1367. }
  1368. } else { //读卡失败
  1369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1370. return
  1371. }
  1372. }
  1373. break
  1374. case 4:
  1375. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1376. var api string
  1377. if miConfig.MdtrtareaAdmvs == "320921" {
  1378. 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 +
  1379. "&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
  1380. fmt.Println(api)
  1381. } else {
  1382. 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 +
  1383. "&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)
  1384. }
  1385. resp, requestErr := http.Get(api)
  1386. if requestErr != nil {
  1387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1388. return
  1389. }
  1390. body, ioErr := ioutil.ReadAll(resp.Body)
  1391. if ioErr != nil {
  1392. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1394. return
  1395. }
  1396. var respJSON map[string]interface{}
  1397. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1398. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1400. return
  1401. }
  1402. var status string
  1403. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1404. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1405. var token string
  1406. var res ResultTwo //1101结果
  1407. var res10265 ResultTwo10265 //1101结果
  1408. if status == "0" { //读卡成功
  1409. var card_info string //卡信息
  1410. var busi_card_info string
  1411. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1412. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1413. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1414. fmt.Println(card_info)
  1415. fmt.Println(busi_card_info)
  1416. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1417. result, _ := json.Marshal(respJSON)
  1418. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1419. utils.ErrorLog("解析失败:%v", err)
  1420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1421. return
  1422. }
  1423. res.ErrMsg = res10265.ErrMsg
  1424. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1425. res.Infcode = infocode
  1426. res.Output = res10265.Output
  1427. res.InfRefmsgid = res10265.InfRefmsgid
  1428. if res.Infcode == 0 {
  1429. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1430. if err == gorm.ErrRecordNotFound {
  1431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1432. return
  1433. } else if err != nil {
  1434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1435. return
  1436. } else {
  1437. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1438. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1439. infoStr := string(Iinfos)
  1440. idetinfoStr := string(Idetinfos)
  1441. psn := &models.HisPsn{
  1442. PsnNo: res.Output.Baseinfo.PsnNo,
  1443. Age: res.Output.Baseinfo.Age,
  1444. PatientId: patient.ID,
  1445. Certno: res.Output.Baseinfo.Certno,
  1446. Brdy: res.Output.Baseinfo.Brdy,
  1447. Gend: res.Output.Baseinfo.Gend,
  1448. Naty: res.Output.Baseinfo.Naty,
  1449. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1450. PsnName: res.Output.Baseinfo.PsnName,
  1451. Idetinfo: idetinfoStr,
  1452. Insuinfo: infoStr,
  1453. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1454. CardInfo: card_info,
  1455. VerifyNumber: token,
  1456. }
  1457. service.CreateHisPsn(psn)
  1458. c.ServeSuccessJSON(map[string]interface{}{
  1459. "patient": patient,
  1460. "number": token,
  1461. })
  1462. }
  1463. } else {
  1464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1465. return
  1466. }
  1467. } else { //读卡失败
  1468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1469. return
  1470. }
  1471. }
  1472. break
  1473. }
  1474. }
  1475. var initFlag int64 = 0
  1476. func (c *HisApiController) TestGetBasBaseInit() {
  1477. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1478. Iinit := DllDef.MustFindProc("Init")
  1479. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1480. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  1481. if ret != 0 {
  1482. fmt.Println("SSCard的报错原因:", err)
  1483. fmt.Println("SSCard的运算结果为:", ret)
  1484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1485. return
  1486. }
  1487. result := int(ret)
  1488. fmt.Println("SSCard的运算结果为1:", result)
  1489. initFlag = 1
  1490. return
  1491. }
  1492. func (c *HisApiController) GetSFZBaseInfo() string {
  1493. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1494. readCard := DllDef.MustFindProc("ReadSFZ")
  1495. if readCard == nil {
  1496. fmt.Println("readcard is nil")
  1497. readCard = DllDef.MustFindProc("ReadSFZ")
  1498. }
  1499. str := make([]byte, 256)
  1500. str1 := make([]byte, 256)
  1501. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1502. fmt.Println(r)
  1503. return string(str)
  1504. }
  1505. func (c *HisApiController) GetBasBaseInfo() string {
  1506. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1507. readCard := DllDef.MustFindProc("ReadCardBas")
  1508. if readCard == nil {
  1509. fmt.Println("readcard is nil")
  1510. readCard = DllDef.MustFindProc("ReadCardBas")
  1511. }
  1512. str := make([]byte, 1024)
  1513. str1 := make([]byte, 1024)
  1514. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  1515. fmt.Println(string(str1))
  1516. fmt.Println(string(str))
  1517. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1518. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1519. if ret2 != 0 {
  1520. return ""
  1521. }
  1522. return string(str)
  1523. }
  1524. type CustomFundPay struct {
  1525. FundPayType string `json:"fund_pay_type"`
  1526. FundPayamt float64 `json:"fund_payamt"`
  1527. }
  1528. func (c *HisApiController) GetSettleList() {
  1529. order_id, _ := c.GetInt64("order_id")
  1530. admin_user_id, _ := c.GetInt64("admin_user_id")
  1531. order, _ := service.GetHisOrderByIDTwo(order_id)
  1532. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1533. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1534. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1535. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1536. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1537. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1538. if order.ID == 0 {
  1539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1540. return
  1541. }
  1542. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1543. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1544. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1545. fmt.Println(count)
  1546. var zero string
  1547. number := count + 1
  1548. if number >= 1000 {
  1549. zero = "0000" + strconv.FormatInt(number, 10)
  1550. } else if number >= 10000 {
  1551. zero = "000" + strconv.FormatInt(number, 10)
  1552. } else if number >= 100000 {
  1553. zero = "00" + strconv.FormatInt(number, 10)
  1554. } else if number >= 1000000 {
  1555. zero = "0" + strconv.FormatInt(number, 10)
  1556. } else {
  1557. zero = strconv.FormatInt(number, 10)
  1558. }
  1559. fmt.Println(zero)
  1560. struct4101 := service.Struct4101{
  1561. PsnNo: order.PsnNo,
  1562. MdtrtId: order.MdtrtId,
  1563. SetlId: order.SetlId,
  1564. PsnName: order.PsnName,
  1565. Gend: order.Gend,
  1566. Brdy: his.Brdy,
  1567. Age: his.Age,
  1568. Naty: order.Naty,
  1569. PatnCertType: "01",
  1570. Certno: order.Certno,
  1571. Prfs: "90",
  1572. ConerName: roles[0].UserName,
  1573. PatnRlts: "99",
  1574. ConerAddr: miConfig.OrgName,
  1575. ConerTel: admin.Mobile,
  1576. HiType: order.Insutype,
  1577. Insuplc: miConfig.InsuplcAdmdvs,
  1578. MaindiagFlag: "1",
  1579. BillCode: last_order.FaPiaoCode,
  1580. BillNo: zero,
  1581. BizSn: order.Number,
  1582. PsnSelfPay: order.PsnPartAmt,
  1583. PsnOwnPay: order.PsnPartAmt,
  1584. AcctPay: order.AcctPay,
  1585. PsnCashpay: order.PsnCashPay,
  1586. HiPaymtd: "1",
  1587. Hsorg: miConfig.InsuplcAdmdvs,
  1588. HsorgOpter: miConfig.InsuplcAdmdvs,
  1589. MedinsFillPsn: curRoles.UserName,
  1590. MedinsFillDept: depart.Name,
  1591. IptMedType: "2",
  1592. }
  1593. struct4101.SetlBegnDate = order.SetlTime
  1594. struct4101.SetlEndDate = order.SetlTime
  1595. time_arr := strings.Split(order.SetlTime, " ")
  1596. struct4101.AdmTime = time_arr[0]
  1597. struct4101.AdmEndTime = time_arr[0]
  1598. var rf []CustomFundPay
  1599. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1600. var tempFunPays []service.CustomStruct
  1601. for _, item := range rf {
  1602. var tempFunPay service.CustomStruct
  1603. tempFunPay.FundPayamt = item.FundPayamt
  1604. tempFunPay.FundPayType = item.FundPayType
  1605. tempFunPays = append(tempFunPays, tempFunPay)
  1606. }
  1607. struct4101.CustomStruct = tempFunPays
  1608. var tempDiaginfos []service.DiaginfoStructTwo
  1609. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1610. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1611. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  1612. var config []*models.HisXtDiagnoseConfig
  1613. for _, item := range diagnosis_ids {
  1614. id, _ := strconv.ParseInt(item, 10, 64)
  1615. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1616. config = append(config, &diagnosisConfig)
  1617. }
  1618. for index, item := range config {
  1619. if index == 0 {
  1620. var tempDiaginfo service.DiaginfoStructTwo
  1621. tempDiaginfo.DiagCode = item.CountryCode
  1622. tempDiaginfo.DiagName = item.CountryContentName
  1623. tempDiaginfo.DiagType = "1"
  1624. tempDiaginfo.MaindiagFlag = "1"
  1625. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1626. } else {
  1627. var tempDiaginfo service.DiaginfoStructTwo
  1628. tempDiaginfo.DiagCode = item.CountryCode
  1629. tempDiaginfo.DiagName = item.CountryContentName
  1630. tempDiaginfo.DiagType = "2"
  1631. tempDiaginfo.MaindiagFlag = "0"
  1632. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1633. }
  1634. }
  1635. struct4101.Diseinfo = tempDiaginfos
  1636. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1637. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1638. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1639. tempOpspdiseinfo2.OprnOprtCode = ""
  1640. tempOpspdiseinfo2.OprnOprtName = ""
  1641. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1642. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1643. var iteminfo service.IteminfoStruct
  1644. var bedCostTotal float64 = 0 //床位总费
  1645. var bedCostSelfTotal float64 = 0 //床位自费
  1646. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1647. var operationCostTotal float64 = 0 //手术费
  1648. var operationCostSelfTotal float64 = 0 //手术费
  1649. var operationCostPartSelfTotal float64 = 0 //手术费
  1650. var otherCostTotal float64 = 0 //其他费用
  1651. var otherCostSelfTotal float64 = 0 //其他费用
  1652. var otherCostPartSelfTotal float64 = 0 //其他费用
  1653. var materialCostTotal float64 = 0 //材料费
  1654. var materialCostSelfTotal float64 = 0 //材料费
  1655. var materialCostPartSelfTotal float64 = 0 //材料费
  1656. var westernMedicineCostTotal float64 = 0 //西药费
  1657. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1658. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1659. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1660. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1661. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1662. var checkCostTotal float64 = 0 //检查费
  1663. var checkCostSelfTotal float64 = 0 //检查费
  1664. var checkCostPartSelfTotal float64 = 0 //检查费
  1665. var laboratoryCostTotal float64 = 0 //化验费
  1666. var laboratoryCostSelfTotal float64 = 0 //化验费
  1667. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1668. var treatCostTotal float64 = 0 //治疗费用
  1669. var treatCostSelfTotal float64 = 0 //治疗费用
  1670. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1671. decimal.DivisionPrecision = 2
  1672. var bed_fulamt_ownpay_amt float64 = 0
  1673. var operation_fulamt_ownpay_amt float64 = 0
  1674. var other_fulamt_ownpay_amt float64 = 0
  1675. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1676. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1677. var check_fulamt_ownpay_amt float64 = 0
  1678. var material_fulamt_ownpay_amt float64 = 0
  1679. var laboratory_fulamt_ownpay_amt float64 = 0
  1680. var treat_fulamt_ownpay_amt float64 = 0
  1681. var bed_claa_sunmfee float64 = 0
  1682. var bed_clab_amt float64 = 0
  1683. var bed_other_amt float64 = 0
  1684. var operation_claa_sunmfee float64 = 0
  1685. var operation_clab_amt float64 = 0
  1686. var operation_other_amt float64 = 0
  1687. var other_claa_sunmfee float64 = 0
  1688. var other_clab_amt float64 = 0
  1689. var other_other_amt float64 = 0
  1690. var westernMedicine_claa_sunmfee float64 = 0
  1691. var westernMedicine_clab_amt float64 = 0
  1692. var westernMedicine_other_amt float64 = 0
  1693. var chineseTraditional_claa_sunmfee float64 = 0
  1694. var chineseTraditional_clab_amt float64 = 0
  1695. var chineseTraditional_other_amt float64 = 0
  1696. var check_claa_sunmfee float64 = 0
  1697. var check_clab_amt float64 = 0
  1698. var check_other_amt float64 = 0
  1699. var material_claa_sunmfee float64 = 0
  1700. var material_clab_amt float64 = 0
  1701. var material_other_amt float64 = 0
  1702. var laboratory_claa_sunmfee float64 = 0
  1703. var laboratory_clab_amt float64 = 0
  1704. var laboratory_other_amt float64 = 0
  1705. var treat_claa_sunmfee float64 = 0
  1706. var treat_clab_amt float64 = 0
  1707. var treat_other_amt float64 = 0
  1708. for _, item := range order.HisOrderInfo {
  1709. if item.MedChrgitmType == "01" { //床位费
  1710. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1711. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1712. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1713. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1714. if item.ChrgitmLv == "1" {
  1715. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1716. }
  1717. if item.ChrgitmLv == "2" {
  1718. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1719. }
  1720. if item.ChrgitmLv == "3" {
  1721. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1722. }
  1723. }
  1724. if item.MedChrgitmType == "03" { //检查费
  1725. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1726. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1727. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1728. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1729. if item.ChrgitmLv == "1" {
  1730. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1731. }
  1732. if item.ChrgitmLv == "2" {
  1733. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1734. }
  1735. if item.ChrgitmLv == "3" {
  1736. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1737. }
  1738. }
  1739. if item.MedChrgitmType == "04" { //化验费
  1740. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1741. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1742. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1743. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1744. if item.ChrgitmLv == "1" {
  1745. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1746. }
  1747. if item.ChrgitmLv == "2" {
  1748. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1749. }
  1750. if item.ChrgitmLv == "3" {
  1751. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1752. }
  1753. }
  1754. if item.MedChrgitmType == "05" { //治疗费
  1755. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1756. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1757. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1758. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1759. if item.ChrgitmLv == "1" {
  1760. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1761. }
  1762. if item.ChrgitmLv == "2" {
  1763. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1764. }
  1765. if item.ChrgitmLv == "3" {
  1766. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1767. }
  1768. }
  1769. if item.MedChrgitmType == "06" { //手术费
  1770. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1771. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1772. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1773. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1774. if item.ChrgitmLv == "1" {
  1775. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1776. }
  1777. if item.ChrgitmLv == "2" {
  1778. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1779. }
  1780. if item.ChrgitmLv == "3" {
  1781. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1782. }
  1783. }
  1784. if item.MedChrgitmType == "08" { //材料费
  1785. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1786. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1787. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1788. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1789. if item.ChrgitmLv == "1" {
  1790. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1791. }
  1792. if item.ChrgitmLv == "2" {
  1793. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1794. }
  1795. if item.ChrgitmLv == "3" {
  1796. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1797. }
  1798. }
  1799. if item.MedChrgitmType == "09" { //西药费
  1800. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1801. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1802. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1803. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1804. if item.ChrgitmLv == "1" {
  1805. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1806. }
  1807. if item.ChrgitmLv == "2" {
  1808. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1809. }
  1810. if item.ChrgitmLv == "3" {
  1811. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1812. }
  1813. }
  1814. if item.MedChrgitmType == "11" { //中成费
  1815. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1816. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1817. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1818. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1819. if item.ChrgitmLv == "1" {
  1820. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1821. }
  1822. if item.ChrgitmLv == "2" {
  1823. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1824. }
  1825. if item.ChrgitmLv == "3" {
  1826. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1827. }
  1828. }
  1829. if item.MedChrgitmType == "14" { //其他费
  1830. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1831. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1832. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1833. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1834. if item.ChrgitmLv == "1" {
  1835. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1836. }
  1837. if item.ChrgitmLv == "2" {
  1838. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1839. }
  1840. if item.ChrgitmLv == "3" {
  1841. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1842. }
  1843. }
  1844. }
  1845. var iteminfoStructs []service.IteminfoStruct
  1846. if bedCostTotal != 0 {
  1847. iteminfo.MedChrgitm = "01"
  1848. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1849. iteminfo.Amt = bedCostTotal
  1850. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1851. iteminfo.ClabAmt = bed_clab_amt
  1852. iteminfo.OthAmt = bed_other_amt
  1853. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1854. }
  1855. if checkCostTotal != 0 {
  1856. iteminfo.MedChrgitm = "03"
  1857. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1858. iteminfo.Amt = checkCostTotal
  1859. iteminfo.ClaaSumfee = check_claa_sunmfee
  1860. iteminfo.ClabAmt = check_clab_amt
  1861. iteminfo.OthAmt = check_other_amt
  1862. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1863. }
  1864. if laboratoryCostTotal != 0 {
  1865. iteminfo.MedChrgitm = "04"
  1866. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1867. iteminfo.Amt = laboratoryCostTotal
  1868. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1869. iteminfo.ClabAmt = laboratory_clab_amt
  1870. iteminfo.OthAmt = laboratory_other_amt
  1871. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1872. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1873. }
  1874. if treatCostTotal != 0 {
  1875. iteminfo.MedChrgitm = "05"
  1876. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1877. iteminfo.Amt = treatCostTotal
  1878. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1879. iteminfo.ClabAmt = treat_clab_amt
  1880. iteminfo.OthAmt = treat_other_amt
  1881. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1882. //(struct4101.IteminfoStruct, iteminfo)
  1883. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1884. }
  1885. if operationCostTotal != 0 {
  1886. iteminfo.MedChrgitm = "06"
  1887. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1888. iteminfo.Amt = operationCostTotal
  1889. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1890. iteminfo.ClabAmt = operation_clab_amt
  1891. iteminfo.OthAmt = operation_other_amt
  1892. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1893. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1894. }
  1895. if materialCostTotal != 0 {
  1896. iteminfo.MedChrgitm = "08"
  1897. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1898. iteminfo.Amt = materialCostTotal
  1899. iteminfo.ClaaSumfee = material_claa_sunmfee
  1900. iteminfo.ClabAmt = material_clab_amt
  1901. iteminfo.OthAmt = material_other_amt
  1902. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1903. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1904. }
  1905. if westernMedicineCostTotal != 0 {
  1906. iteminfo.MedChrgitm = "09"
  1907. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1908. iteminfo.Amt = westernMedicineCostTotal
  1909. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1910. iteminfo.ClabAmt = westernMedicine_clab_amt
  1911. iteminfo.OthAmt = westernMedicine_other_amt
  1912. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1913. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1914. }
  1915. if chineseTraditionalMedicineCostTotal != 0 {
  1916. iteminfo.MedChrgitm = "11"
  1917. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1918. iteminfo.Amt = westernMedicineCostTotal
  1919. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1920. iteminfo.ClabAmt = westernMedicine_clab_amt
  1921. iteminfo.OthAmt = westernMedicine_other_amt
  1922. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1923. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1924. }
  1925. if otherCostTotal != 0 {
  1926. iteminfo.MedChrgitm = "14"
  1927. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1928. iteminfo.Amt = otherCostTotal
  1929. iteminfo.ClaaSumfee = other_claa_sunmfee
  1930. iteminfo.ClabAmt = other_clab_amt
  1931. iteminfo.OthAmt = other_other_amt
  1932. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1933. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1934. }
  1935. struct4101.IteminfoStruct = iteminfoStructs
  1936. struct4101.Ntly = "中国"
  1937. struct4101.AdmCaty = "A03.06"
  1938. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  1939. fmt.Println(result)
  1940. var dat map[string]interface{}
  1941. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1942. fmt.Println(dat)
  1943. } else {
  1944. fmt.Println(err)
  1945. }
  1946. userJSONBytes, _ := json.Marshal(dat)
  1947. var res ResultSeventeen
  1948. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1949. utils.ErrorLog("解析失败:%v", err)
  1950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1951. return
  1952. }
  1953. if res.Infcode != 0 {
  1954. c.ServeSuccessJSON(map[string]interface{}{
  1955. "failed_code": -10,
  1956. "msg": res.ErrMsg,
  1957. })
  1958. return
  1959. } else {
  1960. order.FaPiaoNumber = zero
  1961. order.FaPiaoCode = last_order.FaPiaoCode
  1962. service.UpdateOrder(order)
  1963. hisFundSettleListResult := &models.HisFundSettleListResult{
  1964. Number: res.Output.SetlListId,
  1965. Status: 1,
  1966. Ctime: time.Now().Unix(),
  1967. Mtime: time.Now().Unix(),
  1968. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1969. IsUpload: 1,
  1970. OrderId: order_id,
  1971. }
  1972. service.CreateUploadRecord(hisFundSettleListResult)
  1973. c.ServeSuccessJSON(map[string]interface{}{
  1974. "msg": "上传成功",
  1975. "result": hisFundSettleListResult,
  1976. })
  1977. return
  1978. }
  1979. }
  1980. func (c *HisApiController) GetSettleListHospital() {
  1981. order_id, _ := c.GetInt64("order_id")
  1982. admin_user_id, _ := c.GetInt64("admin_user_id")
  1983. order, _ := service.GetHisOrderByIDTwo(order_id)
  1984. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1985. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1986. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1987. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1988. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1989. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1990. if order.ID == 0 {
  1991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1992. return
  1993. }
  1994. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1995. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1996. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1997. fmt.Println(count)
  1998. var zero string
  1999. number := count + 1
  2000. if number >= 1000 {
  2001. zero = "0000" + strconv.FormatInt(number, 10)
  2002. } else if number >= 10000 {
  2003. zero = "000" + strconv.FormatInt(number, 10)
  2004. } else if number >= 100000 {
  2005. zero = "00" + strconv.FormatInt(number, 10)
  2006. } else if number >= 1000000 {
  2007. zero = "0" + strconv.FormatInt(number, 10)
  2008. } else {
  2009. zero = strconv.FormatInt(number, 10)
  2010. }
  2011. fmt.Println(zero)
  2012. struct4101 := service.Struct4101{
  2013. PsnNo: order.PsnNo,
  2014. MdtrtId: order.MdtrtId,
  2015. SetlId: order.SetlId,
  2016. PsnName: order.PsnName,
  2017. Gend: order.Gend,
  2018. Brdy: his.Brdy,
  2019. Age: int64(order.Age),
  2020. Naty: order.Naty,
  2021. PatnCertType: "01",
  2022. Certno: order.Certno,
  2023. Prfs: "90",
  2024. ConerName: roles[0].UserName,
  2025. PatnRlts: "99",
  2026. ConerAddr: miConfig.OrgName,
  2027. ConerTel: admin.Mobile,
  2028. HiType: order.Insutype,
  2029. Insuplc: miConfig.InsuplcAdmdvs,
  2030. MaindiagFlag: "1",
  2031. BillCode: last_order.FaPiaoCode,
  2032. BillNo: zero,
  2033. BizSn: order.Number,
  2034. PsnSelfPay: order.PsnPartAmt,
  2035. PsnOwnPay: order.PsnPartAmt,
  2036. AcctPay: order.AcctPay,
  2037. PsnCashpay: order.PsnCashPay,
  2038. HiPaymtd: "1",
  2039. Hsorg: miConfig.InsuplcAdmdvs,
  2040. HsorgOpter: miConfig.InsuplcAdmdvs,
  2041. MedinsFillPsn: curRoles.UserName,
  2042. MedinsFillDept: depart.Name,
  2043. IptMedType: "2",
  2044. AdmTime: his.InHosptialTime,
  2045. AdmEndTime: his.OutHosptialTime,
  2046. }
  2047. struct4101.SetlBegnDate = order.SetlTime
  2048. struct4101.SetlEndDate = order.SetlTime
  2049. var rf []CustomFundPay
  2050. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2051. var tempFunPays []service.CustomStruct
  2052. for _, item := range rf {
  2053. var tempFunPay service.CustomStruct
  2054. tempFunPay.FundPayamt = item.FundPayamt
  2055. tempFunPay.FundPayType = item.FundPayType
  2056. tempFunPays = append(tempFunPays, tempFunPay)
  2057. }
  2058. struct4101.CustomStruct = tempFunPays
  2059. var tempDiaginfos []service.DiaginfoStructTwo
  2060. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2061. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2062. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2063. var config []*models.HisXtDiagnoseConfig
  2064. for _, item := range diagnosis_ids {
  2065. id, _ := strconv.ParseInt(item, 10, 64)
  2066. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2067. config = append(config, &diagnosisConfig)
  2068. }
  2069. for index, item := range config {
  2070. if index == 0 {
  2071. var tempDiaginfo service.DiaginfoStructTwo
  2072. tempDiaginfo.DiagCode = item.CountryCode
  2073. tempDiaginfo.DiagName = item.CountryContentName
  2074. tempDiaginfo.DiagType = "1"
  2075. tempDiaginfo.MaindiagFlag = "1"
  2076. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2077. } else {
  2078. var tempDiaginfo service.DiaginfoStructTwo
  2079. tempDiaginfo.DiagCode = item.CountryCode
  2080. tempDiaginfo.DiagName = item.CountryContentName
  2081. tempDiaginfo.DiagType = "2"
  2082. tempDiaginfo.MaindiagFlag = "0"
  2083. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2084. }
  2085. }
  2086. struct4101.Diseinfo = tempDiaginfos
  2087. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2088. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2089. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2090. tempOpspdiseinfo2.OprnOprtCode = ""
  2091. tempOpspdiseinfo2.OprnOprtName = ""
  2092. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2093. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2094. var iteminfo service.IteminfoStruct
  2095. var bedCostTotal float64 = 0 //床位总费
  2096. var bedCostSelfTotal float64 = 0 //床位自费
  2097. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2098. var operationCostTotal float64 = 0 //手术费
  2099. var operationCostSelfTotal float64 = 0 //手术费
  2100. var operationCostPartSelfTotal float64 = 0 //手术费
  2101. var otherCostTotal float64 = 0 //其他费用
  2102. var otherCostSelfTotal float64 = 0 //其他费用
  2103. var otherCostPartSelfTotal float64 = 0 //其他费用
  2104. var materialCostTotal float64 = 0 //材料费
  2105. var materialCostSelfTotal float64 = 0 //材料费
  2106. var materialCostPartSelfTotal float64 = 0 //材料费
  2107. var westernMedicineCostTotal float64 = 0 //西药费
  2108. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2109. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2110. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2111. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2112. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2113. var checkCostTotal float64 = 0 //检查费
  2114. var checkCostSelfTotal float64 = 0 //检查费
  2115. var checkCostPartSelfTotal float64 = 0 //检查费
  2116. var laboratoryCostTotal float64 = 0 //化验费
  2117. var laboratoryCostSelfTotal float64 = 0 //化验费
  2118. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2119. var treatCostTotal float64 = 0 //治疗费用
  2120. var treatCostSelfTotal float64 = 0 //治疗费用
  2121. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2122. decimal.DivisionPrecision = 2
  2123. var bed_fulamt_ownpay_amt float64 = 0
  2124. var operation_fulamt_ownpay_amt float64 = 0
  2125. var other_fulamt_ownpay_amt float64 = 0
  2126. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2127. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2128. var check_fulamt_ownpay_amt float64 = 0
  2129. var material_fulamt_ownpay_amt float64 = 0
  2130. var laboratory_fulamt_ownpay_amt float64 = 0
  2131. var treat_fulamt_ownpay_amt float64 = 0
  2132. var bed_claa_sunmfee float64 = 0
  2133. var bed_clab_amt float64 = 0
  2134. var bed_other_amt float64 = 0
  2135. var operation_claa_sunmfee float64 = 0
  2136. var operation_clab_amt float64 = 0
  2137. var operation_other_amt float64 = 0
  2138. var other_claa_sunmfee float64 = 0
  2139. var other_clab_amt float64 = 0
  2140. var other_other_amt float64 = 0
  2141. var westernMedicine_claa_sunmfee float64 = 0
  2142. var westernMedicine_clab_amt float64 = 0
  2143. var westernMedicine_other_amt float64 = 0
  2144. var chineseTraditional_claa_sunmfee float64 = 0
  2145. var chineseTraditional_clab_amt float64 = 0
  2146. var chineseTraditional_other_amt float64 = 0
  2147. var check_claa_sunmfee float64 = 0
  2148. var check_clab_amt float64 = 0
  2149. var check_other_amt float64 = 0
  2150. var material_claa_sunmfee float64 = 0
  2151. var material_clab_amt float64 = 0
  2152. var material_other_amt float64 = 0
  2153. var laboratory_claa_sunmfee float64 = 0
  2154. var laboratory_clab_amt float64 = 0
  2155. var laboratory_other_amt float64 = 0
  2156. var treat_claa_sunmfee float64 = 0
  2157. var treat_clab_amt float64 = 0
  2158. var treat_other_amt float64 = 0
  2159. for _, item := range order.HisOrderInfo {
  2160. if item.MedChrgitmType == "01" { //床位费
  2161. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2162. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2163. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2164. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2165. if item.ChrgitmLv == "1" {
  2166. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2167. }
  2168. if item.ChrgitmLv == "2" {
  2169. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2170. }
  2171. if item.ChrgitmLv == "3" {
  2172. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2173. }
  2174. }
  2175. if item.MedChrgitmType == "03" { //检查费
  2176. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2177. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2178. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2179. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2180. if item.ChrgitmLv == "1" {
  2181. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2182. }
  2183. if item.ChrgitmLv == "2" {
  2184. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2185. }
  2186. if item.ChrgitmLv == "3" {
  2187. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2188. }
  2189. }
  2190. if item.MedChrgitmType == "04" { //化验费
  2191. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2192. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2193. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2194. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2195. if item.ChrgitmLv == "1" {
  2196. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2197. }
  2198. if item.ChrgitmLv == "2" {
  2199. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2200. }
  2201. if item.ChrgitmLv == "3" {
  2202. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2203. }
  2204. }
  2205. if item.MedChrgitmType == "05" { //治疗费
  2206. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2207. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2208. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2209. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2210. if item.ChrgitmLv == "1" {
  2211. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2212. }
  2213. if item.ChrgitmLv == "2" {
  2214. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2215. }
  2216. if item.ChrgitmLv == "3" {
  2217. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2218. }
  2219. }
  2220. if item.MedChrgitmType == "06" { //手术费
  2221. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2222. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2223. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2224. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2225. if item.ChrgitmLv == "1" {
  2226. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2227. }
  2228. if item.ChrgitmLv == "2" {
  2229. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2230. }
  2231. if item.ChrgitmLv == "3" {
  2232. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2233. }
  2234. }
  2235. if item.MedChrgitmType == "08" { //材料费
  2236. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2237. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2238. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2239. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2240. if item.ChrgitmLv == "1" {
  2241. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2242. }
  2243. if item.ChrgitmLv == "2" {
  2244. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2245. }
  2246. if item.ChrgitmLv == "3" {
  2247. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2248. }
  2249. }
  2250. if item.MedChrgitmType == "09" { //西药费
  2251. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2252. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2253. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2254. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2255. if item.ChrgitmLv == "1" {
  2256. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2257. }
  2258. if item.ChrgitmLv == "2" {
  2259. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2260. }
  2261. if item.ChrgitmLv == "3" {
  2262. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2263. }
  2264. }
  2265. if item.MedChrgitmType == "11" { //中成费
  2266. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2267. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2268. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2269. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2270. if item.ChrgitmLv == "1" {
  2271. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2272. }
  2273. if item.ChrgitmLv == "2" {
  2274. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2275. }
  2276. if item.ChrgitmLv == "3" {
  2277. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2278. }
  2279. }
  2280. if item.MedChrgitmType == "14" { //其他费
  2281. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2282. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2283. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2284. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2285. if item.ChrgitmLv == "1" {
  2286. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2287. }
  2288. if item.ChrgitmLv == "2" {
  2289. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2290. }
  2291. if item.ChrgitmLv == "3" {
  2292. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2293. }
  2294. }
  2295. }
  2296. var iteminfoStructs []service.IteminfoStruct
  2297. if bedCostTotal != 0 {
  2298. iteminfo.MedChrgitm = "01"
  2299. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2300. iteminfo.Amt = bedCostTotal
  2301. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2302. iteminfo.ClabAmt = bed_clab_amt
  2303. iteminfo.OthAmt = bed_other_amt
  2304. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2305. }
  2306. if checkCostTotal != 0 {
  2307. iteminfo.MedChrgitm = "03"
  2308. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2309. iteminfo.Amt = checkCostTotal
  2310. iteminfo.ClaaSumfee = check_claa_sunmfee
  2311. iteminfo.ClabAmt = check_clab_amt
  2312. iteminfo.OthAmt = check_other_amt
  2313. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2314. }
  2315. if laboratoryCostTotal != 0 {
  2316. iteminfo.MedChrgitm = "04"
  2317. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2318. iteminfo.Amt = laboratoryCostTotal
  2319. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2320. iteminfo.ClabAmt = laboratory_clab_amt
  2321. iteminfo.OthAmt = laboratory_other_amt
  2322. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2323. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2324. }
  2325. if treatCostTotal != 0 {
  2326. iteminfo.MedChrgitm = "05"
  2327. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2328. iteminfo.Amt = treatCostTotal
  2329. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2330. iteminfo.ClabAmt = treat_clab_amt
  2331. iteminfo.OthAmt = treat_other_amt
  2332. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2333. //(struct4101.IteminfoStruct, iteminfo)
  2334. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2335. }
  2336. if operationCostTotal != 0 {
  2337. iteminfo.MedChrgitm = "06"
  2338. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2339. iteminfo.Amt = operationCostTotal
  2340. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2341. iteminfo.ClabAmt = operation_clab_amt
  2342. iteminfo.OthAmt = operation_other_amt
  2343. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2344. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2345. }
  2346. if materialCostTotal != 0 {
  2347. iteminfo.MedChrgitm = "08"
  2348. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2349. iteminfo.Amt = materialCostTotal
  2350. iteminfo.ClaaSumfee = material_claa_sunmfee
  2351. iteminfo.ClabAmt = material_clab_amt
  2352. iteminfo.OthAmt = material_other_amt
  2353. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2354. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2355. }
  2356. if westernMedicineCostTotal != 0 {
  2357. iteminfo.MedChrgitm = "09"
  2358. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2359. iteminfo.Amt = westernMedicineCostTotal
  2360. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2361. iteminfo.ClabAmt = westernMedicine_clab_amt
  2362. iteminfo.OthAmt = westernMedicine_other_amt
  2363. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2364. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2365. }
  2366. if chineseTraditionalMedicineCostTotal != 0 {
  2367. iteminfo.MedChrgitm = "11"
  2368. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2369. iteminfo.Amt = westernMedicineCostTotal
  2370. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2371. iteminfo.ClabAmt = westernMedicine_clab_amt
  2372. iteminfo.OthAmt = westernMedicine_other_amt
  2373. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2374. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2375. }
  2376. if otherCostTotal != 0 {
  2377. iteminfo.MedChrgitm = "14"
  2378. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2379. iteminfo.Amt = otherCostTotal
  2380. iteminfo.ClaaSumfee = other_claa_sunmfee
  2381. iteminfo.ClabAmt = other_clab_amt
  2382. iteminfo.OthAmt = other_other_amt
  2383. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2384. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2385. }
  2386. struct4101.IteminfoStruct = iteminfoStructs
  2387. struct4101.Ntly = "中国"
  2388. struct4101.AdmCaty = "A03.06"
  2389. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2390. fmt.Println(result)
  2391. var dat map[string]interface{}
  2392. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2393. fmt.Println(dat)
  2394. } else {
  2395. fmt.Println(err)
  2396. }
  2397. userJSONBytes, _ := json.Marshal(dat)
  2398. var res ResultSeventeen
  2399. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2400. utils.ErrorLog("解析失败:%v", err)
  2401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2402. return
  2403. }
  2404. if res.Infcode != 0 {
  2405. c.ServeSuccessJSON(map[string]interface{}{
  2406. "failed_code": -10,
  2407. "msg": res.ErrMsg,
  2408. })
  2409. return
  2410. } else {
  2411. order.FaPiaoNumber = zero
  2412. order.FaPiaoCode = last_order.FaPiaoCode
  2413. service.UpdateOrder(order)
  2414. hisFundSettleListResult := &models.HisFundSettleListResult{
  2415. Number: res.Output.SetlListId,
  2416. Status: 1,
  2417. Ctime: time.Now().Unix(),
  2418. Mtime: time.Now().Unix(),
  2419. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2420. IsUpload: 1,
  2421. OrderId: order_id,
  2422. }
  2423. service.CreateUploadRecord(hisFundSettleListResult)
  2424. c.ServeSuccessJSON(map[string]interface{}{
  2425. "msg": "上传成功",
  2426. "result": hisFundSettleListResult,
  2427. })
  2428. return
  2429. }
  2430. }
  2431. func (c *HisApiController) GetBatchSettleList() {
  2432. orders, _ := service.GetAllHisOrder(10106)
  2433. for _, item := range orders {
  2434. order_id := item.ID
  2435. order, _ := service.GetHisOrderByIDTwo(order_id)
  2436. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2437. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2438. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2439. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  2440. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2441. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2442. if order.ID == 0 {
  2443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2444. return
  2445. }
  2446. if his.BalanceAccountsType == 2 {
  2447. continue
  2448. }
  2449. struct4101 := service.Struct4101{
  2450. PsnNo: order.PsnNo,
  2451. MdtrtId: order.MdtrtId,
  2452. SetlId: order.SetlId,
  2453. PsnName: order.PsnName,
  2454. Gend: order.Gend,
  2455. Brdy: his.Brdy,
  2456. Age: his.Age,
  2457. Naty: order.Naty,
  2458. PatnCertType: "01",
  2459. Certno: order.Certno,
  2460. Prfs: "90",
  2461. ConerName: roles[0].UserName,
  2462. PatnRlts: "99",
  2463. ConerAddr: miConfig.OrgName,
  2464. ConerTel: admin.Mobile,
  2465. HiType: order.Insutype,
  2466. Insuplc: his.InsuplcAdmdvs,
  2467. MaindiagFlag: "1",
  2468. BillCode: order.FaPiaoCode,
  2469. BillNo: order.FaPiaoNumber,
  2470. BizSn: order.Number,
  2471. PsnSelfPay: order.PsnPartAmt,
  2472. PsnOwnPay: order.PsnPartAmt,
  2473. AcctPay: order.AcctPay,
  2474. PsnCashpay: order.PsnCashPay,
  2475. HiPaymtd: "1",
  2476. Hsorg: his.InsuplcAdmdvs,
  2477. HsorgOpter: his.InsuplcAdmdvs,
  2478. MedinsFillPsn: curRoles.UserName,
  2479. MedinsFillDept: depart.Name,
  2480. IptMedType: "2",
  2481. }
  2482. struct4101.SetlBegnDate = order.SetlTime
  2483. struct4101.SetlEndDate = order.SetlTime
  2484. //if order.SettleType == 1 {
  2485. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  2486. // dateStr := t.Format("2006-01-02")
  2487. // struct4101.SetlBegnDate = dateStr
  2488. // struct4101.SetlEndDate = dateStr
  2489. //} else {
  2490. // t := time.Unix(int64(order.SettleStartTime), 0)
  2491. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  2492. // dateStartStr := t.Format("2006-01-02")
  2493. // dateEndStr := t2.Format("2006-01-02")
  2494. // struct4101.SetlBegnDate = dateStartStr
  2495. // struct4101.SetlEndDate = dateEndStr
  2496. //}
  2497. var rf []CustomFundPay
  2498. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2499. var tempFunPays []service.CustomStruct
  2500. var tempFunPay610100 service.CustomStruct
  2501. for _, item := range rf {
  2502. if item.FundPayType == "610100" {
  2503. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  2504. tempFunPay610100.FundPayType = item.FundPayType
  2505. } else {
  2506. var tempFunPay service.CustomStruct
  2507. tempFunPay.FundPayamt = item.FundPayamt
  2508. tempFunPay.FundPayType = item.FundPayType
  2509. tempFunPays = append(tempFunPays, tempFunPay)
  2510. }
  2511. }
  2512. tempFunPays = append(tempFunPays, tempFunPay610100)
  2513. struct4101.CustomStruct = tempFunPays
  2514. var tempDiaginfos []service.DiaginfoStructTwo
  2515. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2516. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2517. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2518. var config []*models.HisXtDiagnoseConfig
  2519. for _, item := range diagnosis_ids {
  2520. id, _ := strconv.ParseInt(item, 10, 64)
  2521. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2522. config = append(config, &diagnosisConfig)
  2523. }
  2524. for index, item := range config {
  2525. if index == 0 {
  2526. var tempDiaginfo service.DiaginfoStructTwo
  2527. tempDiaginfo.DiagCode = item.CountryCode
  2528. tempDiaginfo.DiagName = item.CountryContentName
  2529. tempDiaginfo.DiagType = "1"
  2530. tempDiaginfo.MaindiagFlag = "1"
  2531. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2532. } else {
  2533. var tempDiaginfo service.DiaginfoStructTwo
  2534. tempDiaginfo.DiagCode = item.CountryCode
  2535. tempDiaginfo.DiagName = item.CountryContentName
  2536. tempDiaginfo.DiagType = "2"
  2537. tempDiaginfo.MaindiagFlag = "0"
  2538. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2539. }
  2540. }
  2541. struct4101.Diseinfo = tempDiaginfos
  2542. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2543. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2544. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2545. tempOpspdiseinfo2.OprnOprtCode = ""
  2546. tempOpspdiseinfo2.OprnOprtName = ""
  2547. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2548. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2549. var iteminfo service.IteminfoStruct
  2550. var bedCostTotal float64 = 0 //床位总费
  2551. var bedCostSelfTotal float64 = 0 //床位自费
  2552. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2553. var examineCostTotal float64 = 0 //诊查总费
  2554. var examineCostSelfTotal float64 = 0 //诊查自费
  2555. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  2556. var nursingCostTotal float64 = 0 //护理总费
  2557. var nursingCostSelfTotal float64 = 0 //护理自费
  2558. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  2559. var chineseMedicineCostTotal float64 = 0 //中成药
  2560. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  2561. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  2562. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  2563. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  2564. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  2565. var registerCostTotal float64 = 0 //一般诊疗费
  2566. var registerCostSelfTotal float64 = 0 //一般诊疗费
  2567. var registerPartSelfTotal float64 = 0 //一般诊疗费
  2568. var operationCostTotal float64 = 0 //手术费
  2569. var operationCostSelfTotal float64 = 0 //手术费
  2570. var operationCostPartSelfTotal float64 = 0 //手术费
  2571. var otherCostTotal float64 = 0 //其他费用
  2572. var otherCostSelfTotal float64 = 0 //其他费用
  2573. var otherCostPartSelfTotal float64 = 0 //其他费用
  2574. var materialCostTotal float64 = 0 //材料费
  2575. var materialCostSelfTotal float64 = 0 //材料费
  2576. var materialCostPartSelfTotal float64 = 0 //材料费
  2577. var westernMedicineCostTotal float64 = 0 //西药费
  2578. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2579. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2580. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2581. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2582. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2583. var checkCostTotal float64 = 0 //检查费
  2584. var checkCostSelfTotal float64 = 0 //检查费
  2585. var checkCostPartSelfTotal float64 = 0 //检查费
  2586. var laboratoryCostTotal float64 = 0 //化验费
  2587. var laboratoryCostSelfTotal float64 = 0 //化验费
  2588. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2589. var treatCostTotal float64 = 0 //治疗费用
  2590. var treatCostSelfTotal float64 = 0 //治疗费用
  2591. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2592. decimal.DivisionPrecision = 2
  2593. var bed_fulamt_ownpay_amt float64 = 0
  2594. var examine_fulamt_ownpay_amt float64 = 0
  2595. var nursing_fulamt_ownpay_amt float64 = 0
  2596. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  2597. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  2598. var register_fulamt_ownpay_amt float64 = 0
  2599. var operation_fulamt_ownpay_amt float64 = 0
  2600. var other_fulamt_ownpay_amt float64 = 0
  2601. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2602. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2603. var check_fulamt_ownpay_amt float64 = 0
  2604. var material_fulamt_ownpay_amt float64 = 0
  2605. var laboratory_fulamt_ownpay_amt float64 = 0
  2606. var treat_fulamt_ownpay_amt float64 = 0
  2607. var bed_claa_sunmfee float64 = 0
  2608. var bed_clab_amt float64 = 0
  2609. var bed_other_amt float64 = 0
  2610. var examine_claa_sunmfee float64 = 0
  2611. var examine_clab_amt float64 = 0
  2612. var examine_other_amt float64 = 0
  2613. var nursing_claa_sunmfee float64 = 0
  2614. var nursing_clab_amt float64 = 0
  2615. var nursing_other_amt float64 = 0
  2616. var chinese_medicine_claa_sunmfee float64 = 0
  2617. var chinese_medicine_clab_amt float64 = 0
  2618. var chinese_medicine_other_amt float64 = 0
  2619. var commonly_treatment_claa_sunmfee float64 = 0
  2620. var commonly_treatment_clab_amt float64 = 0
  2621. var commonly_treatment_other_amt float64 = 0
  2622. var operation_claa_sunmfee float64 = 0
  2623. var operation_clab_amt float64 = 0
  2624. var operation_other_amt float64 = 0
  2625. var other_claa_sunmfee float64 = 0
  2626. var other_clab_amt float64 = 0
  2627. var other_other_amt float64 = 0
  2628. var westernMedicine_claa_sunmfee float64 = 0
  2629. var westernMedicine_clab_amt float64 = 0
  2630. var westernMedicine_other_amt float64 = 0
  2631. var chineseTraditional_claa_sunmfee float64 = 0
  2632. var chineseTraditional_clab_amt float64 = 0
  2633. var chineseTraditional_other_amt float64 = 0
  2634. var check_claa_sunmfee float64 = 0
  2635. var check_clab_amt float64 = 0
  2636. var check_other_amt float64 = 0
  2637. var material_claa_sunmfee float64 = 0
  2638. var material_clab_amt float64 = 0
  2639. var material_other_amt float64 = 0
  2640. var laboratory_claa_sunmfee float64 = 0
  2641. var laboratory_clab_amt float64 = 0
  2642. var laboratory_other_amt float64 = 0
  2643. var treat_claa_sunmfee float64 = 0
  2644. var treat_clab_amt float64 = 0
  2645. var treat_other_amt float64 = 0
  2646. var register_claa_sunmfee float64 = 0
  2647. var register_clab_amt float64 = 0
  2648. var register_other_amt float64 = 0
  2649. for _, item := range order.HisOrderInfo {
  2650. if item.MedChrgitmType == "01" { //床位费
  2651. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2652. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2653. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2654. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2655. if item.ChrgitmLv == "1" {
  2656. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2657. }
  2658. if item.ChrgitmLv == "2" {
  2659. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2660. }
  2661. if item.ChrgitmLv == "3" {
  2662. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2663. }
  2664. }
  2665. if item.MedChrgitmType == "02" { //诊查
  2666. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2667. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2668. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2669. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2670. if item.ChrgitmLv == "1" {
  2671. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2672. }
  2673. if item.ChrgitmLv == "2" {
  2674. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2675. }
  2676. if item.ChrgitmLv == "3" {
  2677. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2678. }
  2679. }
  2680. if item.MedChrgitmType == "03" { //检查费
  2681. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2682. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2683. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2684. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2685. if item.ChrgitmLv == "1" {
  2686. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2687. }
  2688. if item.ChrgitmLv == "2" {
  2689. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2690. }
  2691. if item.ChrgitmLv == "3" {
  2692. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2693. }
  2694. }
  2695. if item.MedChrgitmType == "04" { //化验费
  2696. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2697. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2698. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2699. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2700. if item.ChrgitmLv == "1" {
  2701. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2702. }
  2703. if item.ChrgitmLv == "2" {
  2704. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2705. }
  2706. if item.ChrgitmLv == "3" {
  2707. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2708. }
  2709. }
  2710. if item.MedChrgitmType == "05" { //治疗费
  2711. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2712. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2713. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2714. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2715. if item.ChrgitmLv == "1" {
  2716. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2717. }
  2718. if item.ChrgitmLv == "2" {
  2719. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2720. }
  2721. if item.ChrgitmLv == "3" {
  2722. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2723. }
  2724. }
  2725. if item.MedChrgitmType == "06" { //手术费
  2726. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2727. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2728. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2729. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2730. if item.ChrgitmLv == "1" {
  2731. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2732. }
  2733. if item.ChrgitmLv == "2" {
  2734. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2735. }
  2736. if item.ChrgitmLv == "3" {
  2737. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2738. }
  2739. }
  2740. if item.MedChrgitmType == "07" { //手术费
  2741. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2742. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2743. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2744. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2745. if item.ChrgitmLv == "1" {
  2746. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2747. }
  2748. if item.ChrgitmLv == "2" {
  2749. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2750. }
  2751. if item.ChrgitmLv == "3" {
  2752. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2753. }
  2754. }
  2755. if item.MedChrgitmType == "08" { //材料费
  2756. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2757. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2758. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2759. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2760. if item.ChrgitmLv == "1" {
  2761. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2762. }
  2763. if item.ChrgitmLv == "2" {
  2764. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2765. }
  2766. if item.ChrgitmLv == "3" {
  2767. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2768. }
  2769. }
  2770. if item.MedChrgitmType == "09" { //西药费
  2771. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2772. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2773. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2774. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2775. if item.ChrgitmLv == "1" {
  2776. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2777. }
  2778. if item.ChrgitmLv == "2" {
  2779. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2780. }
  2781. if item.ChrgitmLv == "3" {
  2782. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2783. }
  2784. }
  2785. if item.MedChrgitmType == "10" { //中药饮片
  2786. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2787. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2788. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2789. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2790. if item.ChrgitmLv == "1" {
  2791. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2792. }
  2793. if item.ChrgitmLv == "2" {
  2794. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2795. }
  2796. if item.ChrgitmLv == "3" {
  2797. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2798. }
  2799. }
  2800. if item.MedChrgitmType == "11" { //中成费
  2801. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2802. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2803. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2804. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2805. if item.ChrgitmLv == "1" {
  2806. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2807. }
  2808. if item.ChrgitmLv == "2" {
  2809. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2810. }
  2811. if item.ChrgitmLv == "3" {
  2812. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2813. }
  2814. }
  2815. if item.MedChrgitmType == "12" { //中成费
  2816. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2817. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2818. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2819. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2820. if item.ChrgitmLv == "1" {
  2821. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2822. }
  2823. if item.ChrgitmLv == "2" {
  2824. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2825. }
  2826. if item.ChrgitmLv == "3" {
  2827. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2828. }
  2829. }
  2830. if item.MedChrgitmType == "13" { //中成费
  2831. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2832. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2833. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2834. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2835. if item.ChrgitmLv == "1" {
  2836. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2837. }
  2838. if item.ChrgitmLv == "2" {
  2839. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2840. }
  2841. if item.ChrgitmLv == "3" {
  2842. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2843. }
  2844. }
  2845. if item.MedChrgitmType == "14" { //其他费
  2846. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2847. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2848. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2849. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2850. if item.ChrgitmLv == "1" {
  2851. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2852. }
  2853. if item.ChrgitmLv == "2" {
  2854. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2855. }
  2856. if item.ChrgitmLv == "3" {
  2857. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2858. }
  2859. }
  2860. }
  2861. var iteminfoStructs []service.IteminfoStruct
  2862. if bedCostTotal != 0 {
  2863. iteminfo.MedChrgitm = "01"
  2864. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2865. iteminfo.Amt = bedCostTotal
  2866. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2867. iteminfo.ClabAmt = bed_clab_amt
  2868. iteminfo.OthAmt = bed_other_amt
  2869. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2870. }
  2871. if examineCostTotal != 0 {
  2872. iteminfo.MedChrgitm = "02"
  2873. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  2874. iteminfo.Amt = examineCostTotal
  2875. iteminfo.ClaaSumfee = examine_claa_sunmfee
  2876. iteminfo.ClabAmt = examine_clab_amt
  2877. iteminfo.OthAmt = examine_other_amt
  2878. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2879. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2880. }
  2881. if checkCostTotal != 0 {
  2882. iteminfo.MedChrgitm = "03"
  2883. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2884. iteminfo.Amt = checkCostTotal
  2885. iteminfo.ClaaSumfee = check_claa_sunmfee
  2886. iteminfo.ClabAmt = check_clab_amt
  2887. iteminfo.OthAmt = check_other_amt
  2888. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2889. }
  2890. if laboratoryCostTotal != 0 {
  2891. iteminfo.MedChrgitm = "04"
  2892. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2893. iteminfo.Amt = laboratoryCostTotal
  2894. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2895. iteminfo.ClabAmt = laboratory_clab_amt
  2896. iteminfo.OthAmt = laboratory_other_amt
  2897. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2898. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2899. }
  2900. if treatCostTotal != 0 {
  2901. iteminfo.MedChrgitm = "05"
  2902. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2903. iteminfo.Amt = treatCostTotal
  2904. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2905. iteminfo.ClabAmt = treat_clab_amt
  2906. iteminfo.OthAmt = treat_other_amt
  2907. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2908. //(struct4101.IteminfoStruct, iteminfo)
  2909. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2910. }
  2911. if operationCostTotal != 0 {
  2912. iteminfo.MedChrgitm = "06"
  2913. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2914. iteminfo.Amt = operationCostTotal
  2915. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2916. iteminfo.ClabAmt = operation_clab_amt
  2917. iteminfo.OthAmt = operation_other_amt
  2918. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2919. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2920. }
  2921. if nursingCostTotal != 0 {
  2922. iteminfo.MedChrgitm = "07"
  2923. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  2924. iteminfo.Amt = nursingCostTotal
  2925. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  2926. iteminfo.ClabAmt = nursing_clab_amt
  2927. iteminfo.OthAmt = nursing_other_amt
  2928. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2929. }
  2930. if materialCostTotal != 0 {
  2931. iteminfo.MedChrgitm = "08"
  2932. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2933. iteminfo.Amt = materialCostTotal
  2934. iteminfo.ClaaSumfee = material_claa_sunmfee
  2935. iteminfo.ClabAmt = material_clab_amt
  2936. iteminfo.OthAmt = material_other_amt
  2937. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2938. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2939. }
  2940. if westernMedicineCostTotal != 0 {
  2941. iteminfo.MedChrgitm = "09"
  2942. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2943. iteminfo.Amt = westernMedicineCostTotal
  2944. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2945. iteminfo.ClabAmt = westernMedicine_clab_amt
  2946. iteminfo.OthAmt = westernMedicine_other_amt
  2947. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2948. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2949. }
  2950. if chineseMedicineCostTotal != 0 {
  2951. iteminfo.MedChrgitm = "10"
  2952. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  2953. iteminfo.Amt = chineseMedicineCostTotal
  2954. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  2955. iteminfo.ClabAmt = chinese_medicine_clab_amt
  2956. iteminfo.OthAmt = chinese_medicine_other_amt
  2957. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2958. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2959. }
  2960. if chineseTraditionalMedicineCostTotal != 0 {
  2961. iteminfo.MedChrgitm = "11"
  2962. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2963. iteminfo.Amt = westernMedicineCostTotal
  2964. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2965. iteminfo.ClabAmt = westernMedicine_clab_amt
  2966. iteminfo.OthAmt = westernMedicine_other_amt
  2967. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2968. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2969. }
  2970. if commonlyTreatmentCostTotal != 0 {
  2971. iteminfo.MedChrgitm = "12"
  2972. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  2973. iteminfo.Amt = commonlyTreatmentCostTotal
  2974. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  2975. iteminfo.ClabAmt = commonly_treatment_clab_amt
  2976. iteminfo.OthAmt = commonly_treatment_other_amt
  2977. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2978. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2979. }
  2980. if registerCostTotal != 0 {
  2981. iteminfo.MedChrgitm = "13"
  2982. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  2983. iteminfo.Amt = registerCostTotal
  2984. iteminfo.ClaaSumfee = register_claa_sunmfee
  2985. iteminfo.ClabAmt = register_clab_amt
  2986. iteminfo.OthAmt = register_other_amt
  2987. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2988. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2989. }
  2990. if otherCostTotal != 0 {
  2991. iteminfo.MedChrgitm = "14"
  2992. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2993. iteminfo.Amt = otherCostTotal
  2994. iteminfo.ClaaSumfee = other_claa_sunmfee
  2995. iteminfo.ClabAmt = other_clab_amt
  2996. iteminfo.OthAmt = other_other_amt
  2997. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2998. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2999. }
  3000. struct4101.IteminfoStruct = iteminfoStructs
  3001. struct4101.Ntly = "中国"
  3002. struct4101.AdmCaty = "A03.06"
  3003. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  3004. fmt.Println(result)
  3005. var dat map[string]interface{}
  3006. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3007. fmt.Println(dat)
  3008. } else {
  3009. fmt.Println(err)
  3010. }
  3011. userJSONBytes, _ := json.Marshal(dat)
  3012. var res ResultSeventeen
  3013. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3014. utils.ErrorLog("解析失败:%v", err)
  3015. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3016. adminUser := c.GetAdminUserInfo()
  3017. errlog := &models.HisOrderError{
  3018. UserOrgId: adminUser.CurrentOrgId,
  3019. Ctime: time.Now().Unix(),
  3020. Mtime: time.Now().Unix(),
  3021. ErrMsg: res.ErrMsg + "解析失败",
  3022. Status: 1,
  3023. PatientId: order_id,
  3024. Stage: 10106,
  3025. }
  3026. service.CreateErrMsgLog(errlog)
  3027. continue
  3028. }
  3029. if res.Infcode != 0 {
  3030. adminUser := c.GetAdminUserInfo()
  3031. errlog := &models.HisOrderError{
  3032. UserOrgId: adminUser.CurrentOrgId,
  3033. Ctime: time.Now().Unix(),
  3034. Mtime: time.Now().Unix(),
  3035. ErrMsg: res.ErrMsg,
  3036. Status: 1,
  3037. PatientId: order_id,
  3038. Stage: 10106,
  3039. }
  3040. service.CreateErrMsgLog(errlog)
  3041. continue
  3042. } else {
  3043. hisFundSettleListResult := &models.HisFundSettleListResult{
  3044. Number: res.Output.SetlListId,
  3045. Status: 1,
  3046. Ctime: time.Now().Unix(),
  3047. Mtime: time.Now().Unix(),
  3048. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3049. IsUpload: 1,
  3050. OrderId: order_id,
  3051. }
  3052. service.CreateUploadRecord(hisFundSettleListResult)
  3053. continue
  3054. }
  3055. }
  3056. }
  3057. func (c *HisApiController) GetOrgInfo() {
  3058. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  3059. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  3060. }
  3061. func (c *HisApiController) GetHisPatientInfo() {
  3062. medical_insurance_card := c.GetString("medical_insurance_card")
  3063. id_card_type, _ := c.GetInt64("id_card_type")
  3064. id_card := c.GetString("id_card")
  3065. adminInfo := c.GetAdminUserInfo()
  3066. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3067. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3068. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  3069. IdCardNo := ""
  3070. if id_card_type == 1 {
  3071. IdCardNo = medical_insurance_card
  3072. } else if id_card_type == 2 {
  3073. IdCardNo = id_card
  3074. }
  3075. if config.IsOpen == 1 {
  3076. 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
  3077. resp, requestErr := http.Get(api)
  3078. if requestErr != nil {
  3079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3080. return
  3081. }
  3082. defer resp.Body.Close()
  3083. body, ioErr := ioutil.ReadAll(resp.Body)
  3084. if ioErr != nil {
  3085. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3087. return
  3088. }
  3089. var respJSON map[string]interface{}
  3090. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3091. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3093. return
  3094. }
  3095. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3096. userJSONBytes, _ := json.Marshal(userJSON)
  3097. var res ResultTwo
  3098. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3099. utils.ErrorLog("解析失败:%v", err)
  3100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3101. return
  3102. }
  3103. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3104. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3105. infoStr := string(Iinfos)
  3106. idetinfoStr := string(Idetinfos)
  3107. if res.Infcode == 0 {
  3108. his := models.VMHisPatient{
  3109. Status: 1,
  3110. Ctime: time.Now().Unix(),
  3111. Mtime: time.Now().Unix(),
  3112. PsnNo: res.Output.Baseinfo.PsnNo,
  3113. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3114. Certno: res.Output.Baseinfo.Certno,
  3115. PsnName: res.Output.Baseinfo.PsnName,
  3116. Gend: res.Output.Baseinfo.Gend,
  3117. Naty: res.Output.Baseinfo.Naty,
  3118. Brdy: res.Output.Baseinfo.Brdy,
  3119. Age: res.Output.Baseinfo.Age,
  3120. Iinfo: infoStr,
  3121. Idetinfo: idetinfoStr,
  3122. UserOrgId: adminInfo.CurrentOrgId,
  3123. IsReturn: 1,
  3124. IdCardType: id_card_type,
  3125. }
  3126. c.ServeSuccessJSON(map[string]interface{}{
  3127. "info": his,
  3128. })
  3129. } else {
  3130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3131. return
  3132. }
  3133. }
  3134. }
  3135. //func GetBasBaseInfo() (jsonStr string, err error) {
  3136. //
  3137. // handle := syscall.NewLazyDLL("SSCard.dll")
  3138. // add := handle.NewProc("ReadCardBas")
  3139. // str := make([]byte, 1024)
  3140. // str1 := make([]byte, 1024)
  3141. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3142. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3143. //
  3144. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3145. //
  3146. // fmt.Println("> Add(4,5)的结果为:", ret)
  3147. // handle.Release()
  3148. //
  3149. // return "", nil
  3150. //
  3151. //}
  3152. //func GetQRBaseInfo() (jsonStr string, err error) {
  3153. // handle := syscall.LoadDLL("SSCard.dll")
  3154. // ReadCardBas := handle.FindProc("GetQRBase")
  3155. //
  3156. // str := make([]byte, 256)
  3157. // str1 := make([]byte, 256)
  3158. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3159. //
  3160. // fmt.Println(string(str))
  3161. // fmt.Println(r)
  3162. // return string(str), nil
  3163. //}
  3164. //func CardInit() int {
  3165. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  3166. // add := DllTestDef.MustFindProc("Init")
  3167. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3168. // if err != nil {
  3169. // fmt.Println("SSCard的运算结果为:", ret)
  3170. // }
  3171. // result := int(ret)
  3172. // return result
  3173. //}
  3174. //func CardInit() int {
  3175. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3176. // if err != nil {
  3177. // fmt.Println("SSCard的运算结果为:", ret)
  3178. // }
  3179. // fmt.Println(err)
  3180. // result := int(ret)
  3181. // return result
  3182. //}
  3183. func IntPtr(n int) uintptr {
  3184. return uintptr(n)
  3185. }
  3186. func StrPtr(s string) uintptr {
  3187. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3188. }
  3189. type Result2001 struct {
  3190. Cainfo interface{} `json:"cainfo"`
  3191. ErrMsg string `json:"err_msg"`
  3192. InfRefmsgid string `json:"inf_refmsgid"`
  3193. Infcode int64 `json:"infcode"`
  3194. Output struct {
  3195. Trtinfo struct {
  3196. PsnNo string `json:"psn_no"`
  3197. TrtChkType string `json:"trt_chk_type"`
  3198. FundPayType string `json:"fund_pay_type"`
  3199. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3200. Begndate string `json:"begndate"`
  3201. Enddate string `json:"enddate"`
  3202. TrtChkRslt string `json:"trt_chk_rslt"`
  3203. } `json:"trtinfo"`
  3204. } `json:"output"`
  3205. RefmsgTime string `json:"refmsg_time"`
  3206. RespondTime string `json:"respond_time"`
  3207. Signtype interface{} `json:"signtype"`
  3208. WarnMsg interface{} `json:"warn_msg"`
  3209. }
  3210. type Result2001Org10265 struct {
  3211. Cainfo interface{} `json:"cainfo"`
  3212. ErrMsg string `json:"err_msg"`
  3213. InfRefmsgid string `json:"inf_refmsgid"`
  3214. Infcode string `json:"infcode"`
  3215. Output struct {
  3216. Trtinfo struct {
  3217. PsnNo string `json:"psn_no"`
  3218. TrtChkType string `json:"trt_chk_type"`
  3219. FundPayType string `json:"fund_pay_type"`
  3220. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3221. Begndate string `json:"begndate"`
  3222. Enddate string `json:"enddate"`
  3223. TrtChkRslt string `json:"trt_chk_rslt"`
  3224. } `json:"trtinfo"`
  3225. } `json:"output"`
  3226. RefmsgTime string `json:"refmsg_time"`
  3227. RespondTime string `json:"respond_time"`
  3228. Signtype interface{} `json:"signtype"`
  3229. WarnMsg interface{} `json:"warn_msg"`
  3230. }
  3231. type ResultTwo struct {
  3232. ErrMsg string `json:"err_msg"`
  3233. InfRefmsgid string `json:"inf_refmsgid"`
  3234. Infcode int64 `json:"infcode"`
  3235. Output struct {
  3236. Baseinfo struct {
  3237. Age float64 `json:"age"`
  3238. Brdy string `json:"brdy"`
  3239. Certno string `json:"certno"`
  3240. Gend string `json:"gend"`
  3241. Naty string `json:"naty"`
  3242. PsnCertType string `json:"psn_cert_type"`
  3243. PsnName string `json:"psn_name"`
  3244. PsnNo string `json:"psn_no"`
  3245. } `json:"baseinfo"`
  3246. Idetinfo []interface{} `json:"idetinfo"`
  3247. Iinfo []struct {
  3248. Balc float64 `json:"balc"`
  3249. CvlservFlag string `json:"cvlserv_flag"`
  3250. EmpName string `json:"emp_name"`
  3251. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3252. Insutype string `json:"insutype"`
  3253. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3254. PausInsuDate string `json:"paus_insu_date"`
  3255. PsnInsuDate string `json:"psn_insu_date"`
  3256. PsnInsuStas string `json:"psn_insu_stas"`
  3257. PsnType string `json:"psn_type"`
  3258. } `json:"insuinfo"`
  3259. } `json:"output"`
  3260. RefmsgTime string `json:"refmsg_time"`
  3261. RespondTime string `json:"respond_time"`
  3262. Signtype interface{} `json:"signtype"`
  3263. WarnInfo interface{} `json:"warn_info"`
  3264. }
  3265. type ResultTwo10265 struct {
  3266. ErrMsg string `json:"err_msg"`
  3267. InfRefmsgid string `json:"inf_refmsgid"`
  3268. Infcode string `json:"infcode"`
  3269. Output struct {
  3270. Baseinfo struct {
  3271. Age float64 `json:"age"`
  3272. Brdy string `json:"brdy"`
  3273. Certno string `json:"certno"`
  3274. Gend string `json:"gend"`
  3275. Naty string `json:"naty"`
  3276. PsnCertType string `json:"psn_cert_type"`
  3277. PsnName string `json:"psn_name"`
  3278. PsnNo string `json:"psn_no"`
  3279. } `json:"baseinfo"`
  3280. Idetinfo []interface{} `json:"idetinfo"`
  3281. Iinfo []struct {
  3282. Balc float64 `json:"balc"`
  3283. CvlservFlag string `json:"cvlserv_flag"`
  3284. EmpName string `json:"emp_name"`
  3285. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3286. Insutype string `json:"insutype"`
  3287. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3288. PausInsuDate string `json:"paus_insu_date"`
  3289. PsnInsuDate string `json:"psn_insu_date"`
  3290. PsnInsuStas string `json:"psn_insu_stas"`
  3291. PsnType string `json:"psn_type"`
  3292. } `json:"insuinfo"`
  3293. } `json:"output"`
  3294. RefmsgTime string `json:"refmsg_time"`
  3295. RespondTime string `json:"respond_time"`
  3296. Signtype interface{} `json:"signtype"`
  3297. WarnInfo interface{} `json:"warn_info"`
  3298. }
  3299. type ResultThree struct {
  3300. Cainfo interface{} `json:"cainfo"`
  3301. ErrMsg string `json:"err_msg"`
  3302. InfRefmsgid string `json:"inf_refmsgid"`
  3303. Infcode int64 `json:"infcode"`
  3304. Output struct {
  3305. Data struct {
  3306. IptOtpNo string `json:"ipt_otp_no"`
  3307. MdtrtID string `json:"mdtrt_id"`
  3308. PsnNo string `json:"psn_no"`
  3309. } `json:"data"`
  3310. } `json:"output"`
  3311. RefmsgTime string `json:"refmsg_time"`
  3312. RespondTime string `json:"respond_time"`
  3313. Signtype interface{} `json:"signtype"`
  3314. WarnMsg interface{} `json:"warn_msg"`
  3315. }
  3316. type ResultThree10265 struct {
  3317. Cainfo interface{} `json:"cainfo"`
  3318. ErrMsg string `json:"err_msg"`
  3319. InfRefmsgid string `json:"inf_refmsgid"`
  3320. Infcode string `json:"infcode"`
  3321. Output struct {
  3322. Data struct {
  3323. IptOtpNo string `json:"ipt_otp_no"`
  3324. MdtrtID string `json:"mdtrt_id"`
  3325. PsnNo string `json:"psn_no"`
  3326. } `json:"data"`
  3327. } `json:"output"`
  3328. RefmsgTime string `json:"refmsg_time"`
  3329. RespondTime string `json:"respond_time"`
  3330. Signtype interface{} `json:"signtype"`
  3331. WarnMsg interface{} `json:"warn_msg"`
  3332. }
  3333. type ResultFour struct {
  3334. Cainfo string `json:"cainfo"`
  3335. ErrMsg string `json:"err_msg"`
  3336. InfRefmsgid string `json:"inf_refmsgid"`
  3337. Infcode int64 `json:"infcode"`
  3338. Output struct {
  3339. Result []struct {
  3340. BasMednFlag string `json:"bas_medn_flag"`
  3341. ChldMedcFlag string `json:"chld_medc_flag"`
  3342. ChrgitmLv string `json:"chrgitm_lv"`
  3343. Cnt float64 `json:"cnt"`
  3344. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3345. DrtReimFlag string `json:"drt_reim_flag"`
  3346. FeedetlSn string `json:"feedetl_sn"`
  3347. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3348. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3349. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3350. ListSpItemFlag string `json:"list_sp_item_flag"`
  3351. LmtUsedFlag string `json:"lmt_used_flag"`
  3352. MedChrgitmType string `json:"med_chrgitm_type"`
  3353. Memo string `json:"memo"`
  3354. OverlmtAmt float64 `json:"overlmt_amt"`
  3355. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3356. Pric float64 `json:"pric"`
  3357. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3358. SelfpayProp float64 `json:"selfpay_prop"`
  3359. } `json:"result"`
  3360. } `json:"output"`
  3361. RefmsgTime string `json:"refmsg_time"`
  3362. RespondTime string `json:"respond_time"`
  3363. Signtype string `json:"signtype"`
  3364. WarnMsg string `json:"warn_msg"`
  3365. }
  3366. type ResultFour10265 struct {
  3367. Cainfo string `json:"cainfo"`
  3368. ErrMsg string `json:"err_msg"`
  3369. InfRefmsgid string `json:"inf_refmsgid"`
  3370. Infcode string `json:"infcode"`
  3371. Output struct {
  3372. Result []struct {
  3373. BasMednFlag string `json:"bas_medn_flag"`
  3374. ChldMedcFlag string `json:"chld_medc_flag"`
  3375. ChrgitmLv string `json:"chrgitm_lv"`
  3376. Cnt float64 `json:"cnt"`
  3377. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3378. DrtReimFlag string `json:"drt_reim_flag"`
  3379. FeedetlSn string `json:"feedetl_sn"`
  3380. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3381. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3382. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3383. ListSpItemFlag string `json:"list_sp_item_flag"`
  3384. LmtUsedFlag string `json:"lmt_used_flag"`
  3385. MedChrgitmType string `json:"med_chrgitm_type"`
  3386. Memo string `json:"memo"`
  3387. OverlmtAmt float64 `json:"overlmt_amt"`
  3388. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3389. Pric float64 `json:"pric"`
  3390. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3391. SelfpayProp float64 `json:"selfpay_prop"`
  3392. } `json:"result"`
  3393. } `json:"output"`
  3394. RefmsgTime string `json:"refmsg_time"`
  3395. RespondTime string `json:"respond_time"`
  3396. Signtype string `json:"signtype"`
  3397. WarnMsg string `json:"warn_msg"`
  3398. }
  3399. type ResultFive struct {
  3400. Balc float64 `json:"balc"`
  3401. CvlservFlag string `json:"cvlserv_flag"`
  3402. EmpName string `json:"emp_name"`
  3403. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3404. Insutype string `json:"insutype"`
  3405. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3406. PausInsuDate string `json:"paus_insu_date"`
  3407. PsnInsuDate string `json:"psn_insu_date"`
  3408. PsnInsuStas string `json:"psn_insu_stas"`
  3409. PsnType string `json:"psn_type"`
  3410. }
  3411. type ResultSix struct {
  3412. Cainfo interface{} `json:"cainfo"`
  3413. ErrMsg string `json:"err_msg"`
  3414. InfRefmsgid string `json:"inf_refmsgid"`
  3415. Infcode int64 `json:"infcode"`
  3416. Output struct {
  3417. } `json:"output"`
  3418. RefmsgTime string `json:"refmsg_time"`
  3419. RespondTime string `json:"respond_time"`
  3420. Signtype interface{} `json:"signtype"`
  3421. WarnMsg interface{} `json:"warn_msg"`
  3422. }
  3423. type ResultSix10265 struct {
  3424. Cainfo interface{} `json:"cainfo"`
  3425. ErrMsg string `json:"err_msg"`
  3426. InfRefmsgid string `json:"inf_refmsgid"`
  3427. Infcode string `json:"infcode"`
  3428. Output struct {
  3429. } `json:"output"`
  3430. RefmsgTime string `json:"refmsg_time"`
  3431. RespondTime string `json:"respond_time"`
  3432. Signtype interface{} `json:"signtype"`
  3433. WarnMsg interface{} `json:"warn_msg"`
  3434. }
  3435. type ResultSeven struct {
  3436. Cainfo string `json:"cainfo"`
  3437. ErrMsg string `json:"err_msg"`
  3438. InfRefmsgid string `json:"inf_refmsgid"`
  3439. Infcode int64 `json:"infcode"`
  3440. Output struct {
  3441. Setldetail []interface{} `json:"setldetail"`
  3442. Setlinfo struct {
  3443. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3444. AcctPay float64 `json:"acct_pay"`
  3445. ActPayDedc float64 `json:"act_pay_dedc"`
  3446. Age float64 `json:"age"`
  3447. Balc float64 `json:"balc"`
  3448. Brdy string `json:"brdy"`
  3449. Certno string `json:"certno"`
  3450. ClrOptins string `json:"clr_optins"`
  3451. ClrType string `json:"clr_type"`
  3452. ClrWay string `json:"clr_way"`
  3453. CvlservFlag string `json:"cvlserv_flag"`
  3454. CvlservPay float64 `json:"cvlserv_pay"`
  3455. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3456. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3457. Gend string `json:"gend"`
  3458. HifesPay float64 `json:"hifes_pay"`
  3459. HifmiPay float64 `json:"hifmi_pay"`
  3460. HifpPay float64 `json:"hifp_pay"`
  3461. HospPartAmt float64 `json:"hosp_part_amt"`
  3462. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3463. Insutype string `json:"insutype"`
  3464. MafPay float64 `json:"maf_pay"`
  3465. MdtrtCertType string `json:"mdtrt_cert_type"`
  3466. HifobPay float64 `json:"hifob_pay"`
  3467. MdtrtID string `json:"mdtrt_id"`
  3468. MedType string `json:"med_type"`
  3469. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3470. MedinsSetlID string `json:"medins_setl_id"`
  3471. Naty string `json:"naty"`
  3472. OthPay float64 `json:"oth_pay"`
  3473. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3474. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3475. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3476. PsnCashPay float64 `json:"psn_cash_pay"`
  3477. PsnCertType string `json:"psn_cert_type"`
  3478. PsnName string `json:"psn_name"`
  3479. PsnNo string `json:"psn_no"`
  3480. PsnPartAmt float64 `json:"psn_part_amt"`
  3481. PsnType string `json:"psn_type"`
  3482. SetlID string `json:"setl_id"`
  3483. SetlTime string `json:"setl_time"`
  3484. } `json:"setlinfo"`
  3485. } `json:"output"`
  3486. RefmsgTime string `json:"refmsg_time"`
  3487. RespondTime string `json:"respond_time"`
  3488. Signtype interface{} `json:"signtype"`
  3489. WarnMsg interface{} `json:"warn_msg"`
  3490. }
  3491. type ResultSeven10265 struct {
  3492. Cainfo string `json:"cainfo"`
  3493. ErrMsg string `json:"err_msg"`
  3494. InfRefmsgid string `json:"inf_refmsgid"`
  3495. Infcode string `json:"infcode"`
  3496. Output struct {
  3497. Setldetail []interface{} `json:"setldetail"`
  3498. Setlinfo struct {
  3499. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3500. AcctPay float64 `json:"acct_pay"`
  3501. ActPayDedc float64 `json:"act_pay_dedc"`
  3502. Age float64 `json:"age"`
  3503. Balc float64 `json:"balc"`
  3504. Brdy string `json:"brdy"`
  3505. Certno string `json:"certno"`
  3506. ClrOptins string `json:"clr_optins"`
  3507. ClrType string `json:"clr_type"`
  3508. ClrWay string `json:"clr_way"`
  3509. CvlservFlag string `json:"cvlserv_flag"`
  3510. CvlservPay float64 `json:"cvlserv_pay"`
  3511. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3512. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3513. Gend string `json:"gend"`
  3514. HifesPay float64 `json:"hifes_pay"`
  3515. HifmiPay float64 `json:"hifmi_pay"`
  3516. HifpPay float64 `json:"hifp_pay"`
  3517. HospPartAmt float64 `json:"hosp_part_amt"`
  3518. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3519. Insutype string `json:"insutype"`
  3520. MafPay float64 `json:"maf_pay"`
  3521. MdtrtCertType string `json:"mdtrt_cert_type"`
  3522. HifobPay float64 `json:"hifob_pay"`
  3523. MdtrtID string `json:"mdtrt_id"`
  3524. MedType string `json:"med_type"`
  3525. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3526. MedinsSetlID string `json:"medins_setl_id"`
  3527. Naty string `json:"naty"`
  3528. OthPay float64 `json:"oth_pay"`
  3529. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3530. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3531. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3532. PsnCashPay float64 `json:"psn_cash_pay"`
  3533. PsnCertType string `json:"psn_cert_type"`
  3534. PsnName string `json:"psn_name"`
  3535. PsnNo string `json:"psn_no"`
  3536. PsnPartAmt float64 `json:"psn_part_amt"`
  3537. PsnType string `json:"psn_type"`
  3538. SetlID string `json:"setl_id"`
  3539. SetlTime string `json:"setl_time"`
  3540. } `json:"setlinfo"`
  3541. } `json:"output"`
  3542. RefmsgTime string `json:"refmsg_time"`
  3543. RespondTime string `json:"respond_time"`
  3544. Signtype interface{} `json:"signtype"`
  3545. WarnMsg interface{} `json:"warn_msg"`
  3546. }
  3547. type ResultEight struct {
  3548. Cainfo string `json:"cainfo"`
  3549. ErrMsg string `json:"err_msg"`
  3550. InfRefmsgid string `json:"inf_refmsgid"`
  3551. Infcode int64 `json:"infcode"`
  3552. Output struct {
  3553. Stmtinfo struct {
  3554. SetlOptins string `json:"setl_optins"`
  3555. StmtRslt string `json:"stmt_rslt"`
  3556. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3557. } `json:"stmtinfo"`
  3558. } `json:"output"`
  3559. RefmsgTime string `json:"refmsg_time"`
  3560. RespondTime string `json:"respond_time"`
  3561. Signtype interface{} `json:"signtype"`
  3562. WarnMsg interface{} `json:"warn_msg"`
  3563. }
  3564. type ResultEightFor10188 struct {
  3565. Cainfo string `json:"cainfo"`
  3566. ErrMsg string `json:"err_msg"`
  3567. InfRefmsgid string `json:"inf_refmsgid"`
  3568. Infcode string `json:"infcode"`
  3569. Output struct {
  3570. Stmtinfo struct {
  3571. SetlOptins string `json:"setl_optins"`
  3572. StmtRslt string `json:"stmt_rslt"`
  3573. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3574. } `json:"stmtinfo"`
  3575. } `json:"output"`
  3576. RefmsgTime string `json:"refmsg_time"`
  3577. RespondTime string `json:"respond_time"`
  3578. Signtype interface{} `json:"signtype"`
  3579. WarnMsg interface{} `json:"warn_msg"`
  3580. }
  3581. type ResultNine struct {
  3582. Cainfo string `json:"cainfo"`
  3583. ErrMsg string `json:"err_msg"`
  3584. InfRefmsgid string `json:"inf_refmsgid"`
  3585. Infcode int64 `json:"infcode"`
  3586. Output struct {
  3587. FileQuryNo string `json:"file_qury_no"`
  3588. } `json:"output"`
  3589. RefmsgTime string `json:"refmsg_time"`
  3590. RespondTime string `json:"respond_time"`
  3591. Signtype interface{} `json:"signtype"`
  3592. WarnMsg interface{} `json:"warn_msg"`
  3593. }
  3594. type ResultTen struct {
  3595. Cainfo string `json:"cainfo"`
  3596. ErrMsg string `json:"err_msg"`
  3597. InfRefmsgid string `json:"inf_refmsgid"`
  3598. Infcode int64 `json:"infcode"`
  3599. Output struct {
  3600. DldEndtime string `json:"dld_endtime"`
  3601. FileQuryNo string `json:"file_qury_no"`
  3602. Filename string `json:"filename"`
  3603. } `json:"output"`
  3604. RefmsgTime string `json:"refmsg_time"`
  3605. RespondTime string `json:"respond_time"`
  3606. Signtype interface{} `json:"signtype"`
  3607. WarnMsg interface{} `json:"warn_msg"`
  3608. }
  3609. //type Autogenerated struct {
  3610. // Output struct {
  3611. // Setlinfo struct {
  3612. // SetlTime string `json:"setl_time"`
  3613. // CvlservPay float64 `json:"cvlserv_pay"`
  3614. // Year string `json:"year"`
  3615. // MedType string `json:"med_type"`
  3616. // PsnPay float64 `json:"psn_pay"`
  3617. // OpterID string `json:"opter_id"`
  3618. // Begndate string `json:"begndate"`
  3619. // FlxempeFlag string `json:"flxempe_flag"`
  3620. // HifmiPay float64 `json:"hifmi_pay"`
  3621. // PsnNo string `json:"psn_no"`
  3622. // ActPayDedc float64 `json:"act_pay_dedc"`
  3623. // MedinsSetlID interface{} `json:"medins_setl_id"`
  3624. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3625. // ClrWay string `json:"clr_way"`
  3626. // OthPay float64 `json:"oth_pay"`
  3627. // Gend string `json:"gend"`
  3628. // MdtrtID string `json:"mdtrt_id"`
  3629. // AcctPay float64 `json:"acct_pay"`
  3630. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  3631. // Insutype string `json:"insutype"`
  3632. // Invono interface{} `json:"invono"`
  3633. // Enddate string `json:"enddate"`
  3634. // CashPayamt float64 `json:"cash_payamt"`
  3635. // PsnType string `json:"psn_type"`
  3636. // FixmedinsName string `json:"fixmedins_name"`
  3637. // HifpPay float64 `json:"hifp_pay"`
  3638. // NewFlag interface{} `json:"new_flag"`
  3639. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3640. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  3641. // PayLoc string `json:"pay_loc"`
  3642. // ClrType string `json:"clr_type"`
  3643. // RefdSetlFlag string `json:"refd_setl_flag"`
  3644. // CvlservFlag string `json:"cvlserv_flag"`
  3645. // EmpName string `json:"emp_name"`
  3646. // Brdy string `json:"brdy"`
  3647. // Naty string `json:"naty"`
  3648. // Certno string `json:"certno"`
  3649. // DiseCode string `json:"dise_code"`
  3650. // FixmedinsCode string `json:"fixmedins_code"`
  3651. // DedcHospLv string `json:"dedc_hosp_lv"`
  3652. // OpterName string `json:"opter_name"`
  3653. // Balc float64 `json:"balc"`
  3654. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3655. // PsnCertType string `json:"psn_cert_type"`
  3656. // HifobPay float64 `json:"hifob_pay"`
  3657. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  3658. // HifesPay float64 `json:"hifes_pay"`
  3659. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3660. // OptTime string `json:"opt_time"`
  3661. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3662. // SetlID string `json:"setl_id"`
  3663. // MafPay float64 `json:"maf_pay"`
  3664. // PsnName string `json:"psn_name"`
  3665. // InsuOptins interface{} `json:"insu_optins"`
  3666. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3667. // ClrOptins string `json:"clr_optins"`
  3668. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3669. // DiseName string `json:"dise_name"`
  3670. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3671. // Age float64 `json:"age"`
  3672. // DtrtCertType string `json:"dtrt_cert_type"`
  3673. // HospLv string `json:"hosp_lv"`
  3674. // } `json:"setlinfo"`
  3675. // Setldetail []struct {
  3676. // FundPayType string `json:"fund_pay_type"`
  3677. // FundPayamt float64 `json:"fund_payamt"`
  3678. // SetlProcInfo interface{} `json:"setl_proc_info"`
  3679. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  3680. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  3681. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  3682. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3683. // } `json:"setldetail"`
  3684. // } `json:"output"`
  3685. // Infcode int `json:"infcode"`
  3686. // WarnMsg interface{} `json:"warn_msg"`
  3687. // Cainfo interface{} `json:"cainfo"`
  3688. // ErrMsg interface{} `json:"err_msg"`
  3689. // RefmsgTime string `json:"refmsg_time"`
  3690. // Signtype interface{} `json:"signtype"`
  3691. // RespondTime string `json:"respond_time"`
  3692. // InfRefmsgid string `json:"inf_refmsgid"`
  3693. //}
  3694. type ResultEleven struct {
  3695. Cainfo string `json:"cainfo"`
  3696. ErrMsg string `json:"err_msg"`
  3697. InfRefmsgid string `json:"inf_refmsgid"`
  3698. Infcode int64 `json:"infcode"`
  3699. Output struct {
  3700. Setlinfo struct {
  3701. SetlTime string `json:"setl_time"`
  3702. CvlservPay float64 `json:"cvlserv_pay"`
  3703. Year string `json:"year"`
  3704. MedType string `json:"med_type"`
  3705. PsnPay float64 `json:"psn_pay"`
  3706. OpterID string `json:"opter_id"`
  3707. Begndate string `json:"begndate"`
  3708. FlxempeFlag string `json:"flxempe_flag"`
  3709. HifmiPay float64 `json:"hifmi_pay"`
  3710. PsnNo string `json:"psn_no"`
  3711. ActPayDedc float64 `json:"act_pay_dedc"`
  3712. MedinsSetlID interface{} `json:"medins_setl_id"`
  3713. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3714. ClrWay string `json:"clr_way"`
  3715. OthPay float64 `json:"oth_pay"`
  3716. Gend string `json:"gend"`
  3717. MdtrtID string `json:"mdtrt_id"`
  3718. AcctPay float64 `json:"acct_pay"`
  3719. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3720. Insutype string `json:"insutype"`
  3721. Invono interface{} `json:"invono"`
  3722. Enddate string `json:"enddate"`
  3723. CashPayamt float64 `json:"cash_payamt"`
  3724. PsnType string `json:"psn_type"`
  3725. FixmedinsName string `json:"fixmedins_name"`
  3726. HifpPay float64 `json:"hifp_pay"`
  3727. NewFlag interface{} `json:"new_flag"`
  3728. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3729. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3730. PayLoc string `json:"pay_loc"`
  3731. ClrType string `json:"clr_type"`
  3732. RefdSetlFlag string `json:"refd_setl_flag"`
  3733. CvlservFlag string `json:"cvlserv_flag"`
  3734. EmpName string `json:"emp_name"`
  3735. Brdy string `json:"brdy"`
  3736. Naty string `json:"naty"`
  3737. Certno string `json:"certno"`
  3738. DiseCode string `json:"dise_code"`
  3739. FixmedinsCode string `json:"fixmedins_code"`
  3740. DedcHospLv string `json:"dedc_hosp_lv"`
  3741. OpterName string `json:"opter_name"`
  3742. Balc float64 `json:"balc"`
  3743. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3744. PsnCertType string `json:"psn_cert_type"`
  3745. HifobPay float64 `json:"hifob_pay"`
  3746. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3747. HifesPay float64 `json:"hifes_pay"`
  3748. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3749. OptTime string `json:"opt_time"`
  3750. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3751. SetlID string `json:"setl_id"`
  3752. MafPay float64 `json:"maf_pay"`
  3753. PsnName string `json:"psn_name"`
  3754. InsuOptins interface{} `json:"insu_optins"`
  3755. PrefFundPay interface{} `json:"pref_fund_pay"`
  3756. ClrOptins string `json:"clr_optins"`
  3757. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3758. DiseName string `json:"dise_name"`
  3759. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3760. Age float64 `json:"age"`
  3761. DtrtCertType string `json:"dtrt_cert_type"`
  3762. HospLv string `json:"hosp_lv"`
  3763. } `json:"setlinfo"`
  3764. } `json:"output"`
  3765. RefmsgTime string `json:"refmsg_time"`
  3766. RespondTime string `json:"respond_time"`
  3767. Signtype interface{} `json:"signtype"`
  3768. WarnMsg interface{} `json:"warn_msg"`
  3769. }
  3770. type ResultEleven10265 struct {
  3771. Cainfo string `json:"cainfo"`
  3772. ErrMsg string `json:"err_msg"`
  3773. InfRefmsgid string `json:"inf_refmsgid"`
  3774. Infcode string `json:"infcode"`
  3775. Output struct {
  3776. Setlinfo struct {
  3777. SetlTime string `json:"setl_time"`
  3778. CvlservPay float64 `json:"cvlserv_pay"`
  3779. Year string `json:"year"`
  3780. MedType string `json:"med_type"`
  3781. PsnPay float64 `json:"psn_pay"`
  3782. OpterID string `json:"opter_id"`
  3783. Begndate string `json:"begndate"`
  3784. FlxempeFlag string `json:"flxempe_flag"`
  3785. HifmiPay float64 `json:"hifmi_pay"`
  3786. PsnNo string `json:"psn_no"`
  3787. ActPayDedc float64 `json:"act_pay_dedc"`
  3788. MedinsSetlID interface{} `json:"medins_setl_id"`
  3789. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3790. ClrWay string `json:"clr_way"`
  3791. OthPay float64 `json:"oth_pay"`
  3792. Gend string `json:"gend"`
  3793. MdtrtID string `json:"mdtrt_id"`
  3794. AcctPay float64 `json:"acct_pay"`
  3795. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3796. Insutype string `json:"insutype"`
  3797. Invono interface{} `json:"invono"`
  3798. Enddate string `json:"enddate"`
  3799. CashPayamt float64 `json:"cash_payamt"`
  3800. PsnType string `json:"psn_type"`
  3801. FixmedinsName string `json:"fixmedins_name"`
  3802. HifpPay float64 `json:"hifp_pay"`
  3803. NewFlag interface{} `json:"new_flag"`
  3804. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3805. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3806. PayLoc string `json:"pay_loc"`
  3807. ClrType string `json:"clr_type"`
  3808. RefdSetlFlag string `json:"refd_setl_flag"`
  3809. CvlservFlag string `json:"cvlserv_flag"`
  3810. EmpName string `json:"emp_name"`
  3811. Brdy string `json:"brdy"`
  3812. Naty string `json:"naty"`
  3813. Certno string `json:"certno"`
  3814. DiseCode string `json:"dise_code"`
  3815. FixmedinsCode string `json:"fixmedins_code"`
  3816. DedcHospLv string `json:"dedc_hosp_lv"`
  3817. OpterName string `json:"opter_name"`
  3818. Balc float64 `json:"balc"`
  3819. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3820. PsnCertType string `json:"psn_cert_type"`
  3821. HifobPay float64 `json:"hifob_pay"`
  3822. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3823. HifesPay float64 `json:"hifes_pay"`
  3824. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3825. OptTime string `json:"opt_time"`
  3826. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3827. SetlID string `json:"setl_id"`
  3828. MafPay float64 `json:"maf_pay"`
  3829. PsnName string `json:"psn_name"`
  3830. InsuOptins interface{} `json:"insu_optins"`
  3831. PrefFundPay interface{} `json:"pref_fund_pay"`
  3832. ClrOptins string `json:"clr_optins"`
  3833. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3834. DiseName string `json:"dise_name"`
  3835. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3836. Age float64 `json:"age"`
  3837. DtrtCertType string `json:"dtrt_cert_type"`
  3838. HospLv string `json:"hosp_lv"`
  3839. } `json:"setlinfo"`
  3840. } `json:"output"`
  3841. RefmsgTime string `json:"refmsg_time"`
  3842. RespondTime string `json:"respond_time"`
  3843. Signtype interface{} `json:"signtype"`
  3844. WarnMsg interface{} `json:"warn_msg"`
  3845. }
  3846. type ResultTwelve struct {
  3847. Cainfo string `json:"cainfo"`
  3848. ErrMsg string `json:"err_msg"`
  3849. InfRefmsgid string `json:"inf_refmsgid"`
  3850. Infcode int64 `json:"infcode"`
  3851. Output struct {
  3852. MdtrtId string `json:"mdtrt_id"`
  3853. ChrgBchno string `json:"chrg_bchno"`
  3854. PsnNo string `json:"psn_no"`
  3855. } `json:"output"`
  3856. RefmsgTime string `json:"refmsg_time"`
  3857. RespondTime string `json:"respond_time"`
  3858. Signtype interface{} `json:"signtype"`
  3859. WarnMsg interface{} `json:"warn_msg"`
  3860. }
  3861. type ResultThirteen struct {
  3862. ErrMsg string `json:"err_msg"`
  3863. InfRefmsgid string `json:"inf_refmsgid"`
  3864. Infcode int64 `json:"infcode"`
  3865. Output struct {
  3866. Result struct {
  3867. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3868. } `json:"result"`
  3869. } `json:"output"`
  3870. RefmsgTime string `json:"refmsg_time"`
  3871. RespondTime string `json:"respond_time"`
  3872. Signtype interface{} `json:"signtype"`
  3873. WarnInfo interface{} `json:"warn_info"`
  3874. }
  3875. type ResultThirteen10265 struct {
  3876. ErrMsg string `json:"err_msg"`
  3877. InfRefmsgid string `json:"inf_refmsgid"`
  3878. Infcode string `json:"infcode"`
  3879. Output struct {
  3880. Result struct {
  3881. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3882. } `json:"result"`
  3883. } `json:"output"`
  3884. RefmsgTime string `json:"refmsg_time"`
  3885. RespondTime string `json:"respond_time"`
  3886. Signtype interface{} `json:"signtype"`
  3887. WarnInfo interface{} `json:"warn_info"`
  3888. }
  3889. type ResultFourteen struct {
  3890. ErrMsg string `json:"err_msg"`
  3891. InfRefmsgid string `json:"inf_refmsgid"`
  3892. Infcode int64 `json:"infcode"`
  3893. Output struct {
  3894. } `json:"output"`
  3895. RefmsgTime string `json:"refmsg_time"`
  3896. RespondTime string `json:"respond_time"`
  3897. Signtype interface{} `json:"signtype"`
  3898. WarnInfo interface{} `json:"warn_info"`
  3899. }
  3900. type ResultFourteen10265 struct {
  3901. ErrMsg string `json:"err_msg"`
  3902. InfRefmsgid string `json:"inf_refmsgid"`
  3903. Infcode string `json:"infcode"`
  3904. Output struct {
  3905. } `json:"output"`
  3906. RefmsgTime string `json:"refmsg_time"`
  3907. RespondTime string `json:"respond_time"`
  3908. Signtype interface{} `json:"signtype"`
  3909. WarnInfo interface{} `json:"warn_info"`
  3910. }
  3911. type ResultSixteen struct {
  3912. Cainfo string `json:"cainfo"`
  3913. ErrMsg string `json:"err_msg"`
  3914. InfRefmsgid string `json:"inf_refmsgid"`
  3915. Infcode int64 `json:"infcode"`
  3916. Output struct {
  3917. Setldetail []interface{} `json:"setldetail"`
  3918. Setlinfo struct {
  3919. MdtrtID string `json:"mdtrt_id"`
  3920. SetlID string `json:"setl_id"`
  3921. ClrOptins string `json:"clr_optins"`
  3922. SetlTime string `json:"setl_time"`
  3923. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3924. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3925. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3926. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3927. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3928. ActPayDedc float64 `json:"act_pay_dedc"`
  3929. HifpPay float64 `json:"hifp_pay"`
  3930. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3931. Lfpay float64 `json:"selfpay"`
  3932. CvlservPay float64 `json:"cvlserv_pay"`
  3933. HifesPay float64 `json:"hifes_pay"`
  3934. HifmiPay float64 `json:"hifmi_pay"`
  3935. HifobPay float64 `json:"hifob_pay"`
  3936. MafPay float64 `json:"maf_pay"`
  3937. OthPay float64 `json:"oth_pay"`
  3938. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3939. PsnPartAmt float64 `json:"psn_part_amt"`
  3940. AcctPay float64 `json:"acct_pay"`
  3941. Balc float64 `json:"balc"`
  3942. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3943. HospPartAmt float64 `json:"hosp_part_amt"`
  3944. MedinsSetlID string `json:"medins_setl_id"`
  3945. PdnCashPay string `json:"pdn_cash_pay"`
  3946. } `json:"setlinfo"`
  3947. } `json:"output"`
  3948. RefmsgTime string `json:"refmsg_time"`
  3949. RespondTime string `json:"respond_time"`
  3950. Signtype interface{} `json:"signtype"`
  3951. WarnMsg interface{} `json:"warn_msg"`
  3952. }
  3953. type ResultSixteen10265 struct {
  3954. Cainfo string `json:"cainfo"`
  3955. ErrMsg string `json:"err_msg"`
  3956. InfRefmsgid string `json:"inf_refmsgid"`
  3957. Infcode string `json:"infcode"`
  3958. Output struct {
  3959. Setldetail []interface{} `json:"setldetail"`
  3960. Setlinfo struct {
  3961. MdtrtID string `json:"mdtrt_id"`
  3962. SetlID string `json:"setl_id"`
  3963. ClrOptins string `json:"clr_optins"`
  3964. SetlTime string `json:"setl_time"`
  3965. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3966. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3967. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3968. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3969. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3970. ActPayDedc float64 `json:"act_pay_dedc"`
  3971. HifpPay float64 `json:"hifp_pay"`
  3972. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3973. Lfpay float64 `json:"selfpay"`
  3974. CvlservPay float64 `json:"cvlserv_pay"`
  3975. HifesPay float64 `json:"hifes_pay"`
  3976. HifmiPay float64 `json:"hifmi_pay"`
  3977. HifobPay float64 `json:"hifob_pay"`
  3978. MafPay float64 `json:"maf_pay"`
  3979. OthPay float64 `json:"oth_pay"`
  3980. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3981. PsnPartAmt float64 `json:"psn_part_amt"`
  3982. AcctPay float64 `json:"acct_pay"`
  3983. Balc float64 `json:"balc"`
  3984. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3985. HospPartAmt float64 `json:"hosp_part_amt"`
  3986. MedinsSetlID string `json:"medins_setl_id"`
  3987. PdnCashPay string `json:"pdn_cash_pay"`
  3988. } `json:"setlinfo"`
  3989. } `json:"output"`
  3990. RefmsgTime string `json:"refmsg_time"`
  3991. RespondTime string `json:"respond_time"`
  3992. Signtype interface{} `json:"signtype"`
  3993. WarnMsg interface{} `json:"warn_msg"`
  3994. }
  3995. type ResultSeventeen struct {
  3996. ErrMsg string `json:"err_msg"`
  3997. InfRefmsgid string `json:"inf_refmsgid"`
  3998. Infcode int64 `json:"infcode"`
  3999. Output struct {
  4000. SetlListId string `json:"setl_list_id"`
  4001. } `json:"output"`
  4002. RefmsgTime string `json:"refmsg_time"`
  4003. RespondTime string `json:"respond_time"`
  4004. Signtype string `json:"signtype"`
  4005. WarnInfo string `json:"warn_info"`
  4006. }
  4007. type Result90991 struct {
  4008. ErrMsg string `json:"err_msg"`
  4009. InfRefmsgid string `json:"inf_refmsgid"`
  4010. Infcode int64 `json:"infcode"`
  4011. Output struct {
  4012. Result struct {
  4013. PsnNo string `json:"psn_no"`
  4014. CardStat string `json:"card_stat"`
  4015. Certno string `json:"certno"`
  4016. PsnName string `json:"psn_name"`
  4017. CheckStat string `json:"check_stat"`
  4018. } `json:"result"`
  4019. } `json:"output"`
  4020. RefmsgTime string `json:"refmsg_time"`
  4021. RespondTime string `json:"respond_time"`
  4022. Signtype interface{} `json:"signtype"`
  4023. WarnInfo interface{} `json:"warn_info"`
  4024. }
  4025. type Result90100 struct {
  4026. ErrMsg string `json:"err_msg"`
  4027. InfRefmsgid string `json:"inf_refmsgid"`
  4028. Infcode int64 `json:"infcode"`
  4029. Output struct {
  4030. PoolareaNo string `json:"poolarea_no"`
  4031. PoolareaNoName string `json:"poolarea_no_name"`
  4032. Insutype string `json:"insutype"`
  4033. InsutypeName string `json:"insutype_name"`
  4034. ClctType string `json:"clct_type"`
  4035. ClctTypeName string `json:"clct_type_name"`
  4036. ClctFlag string `json:"clct_flag"`
  4037. ClctFlagName string `json:"clct_flag_name"`
  4038. AccrymBegn string `json:"accrym_begn"`
  4039. AccrymEnd string `json:"accrym_end"`
  4040. ClctTime string `json:"clct_time"`
  4041. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  4042. } `json:"output"`
  4043. RefmsgTime string `json:"refmsg_time"`
  4044. RespondTime string `json:"respond_time"`
  4045. Signtype interface{} `json:"signtype"`
  4046. WarnInfo interface{} `json:"warn_info"`
  4047. }
  4048. type Custom struct {
  4049. DetItemFeeSumamt string
  4050. Cut string
  4051. FeedetlSn string
  4052. Price string
  4053. MedListCodg string
  4054. Type int64
  4055. AdviceId int64
  4056. ProjectId int64
  4057. ItemId int64
  4058. }
  4059. type Result5301 struct {
  4060. ErrMsg string `json:"err_msg"`
  4061. InfRefmsgid string `json:"inf_refmsgid"`
  4062. Infcode int64 `json:"infcode"`
  4063. Output struct {
  4064. Result []struct {
  4065. OpspDiseCode string `json:"opsp_dise_code"`
  4066. OpspDiseName string `json:"opsp_dise_name"`
  4067. Begndate string `json:"begndate"`
  4068. Enddate string `json:"enddate"`
  4069. } `json:"feedetail"`
  4070. } `json:"output"`
  4071. RefmsgTime string `json:"refmsg_time"`
  4072. RespondTime string `json:"respond_time"`
  4073. Signtype interface{} `json:"signtype"`
  4074. WarnInfo interface{} `json:"warn_info"`
  4075. }
  4076. type Result5301For10265 struct {
  4077. ErrMsg string `json:"err_msg"`
  4078. InfRefmsgid string `json:"inf_refmsgid"`
  4079. Infcode string `json:"infcode"`
  4080. Output struct {
  4081. Result []struct {
  4082. OpspDiseCode string `json:"opsp_dise_code"`
  4083. OpspDiseName string `json:"opsp_dise_name"`
  4084. Begndate string `json:"begndate"`
  4085. Enddate string `json:"enddate"`
  4086. } `json:"feedetail"`
  4087. } `json:"output"`
  4088. RefmsgTime string `json:"refmsg_time"`
  4089. RespondTime string `json:"respond_time"`
  4090. Signtype interface{} `json:"signtype"`
  4091. WarnInfo interface{} `json:"warn_info"`
  4092. }
  4093. //获取个人信息----挂号-----上传就诊信息
  4094. func (c *HisApiController) GetRegisterInfo() {
  4095. id, _ := c.GetInt64("id")
  4096. record_time := c.GetString("record_time")
  4097. settlementValue, _ := c.GetInt64("settlement_value")
  4098. medical_insurance_card := c.GetString("medical_insurance_card")
  4099. name := c.GetString("name")
  4100. id_card_type, _ := c.GetInt64("id_card_type")
  4101. certificates, _ := c.GetInt64("certificates")
  4102. medical_care, _ := c.GetInt64("medical_care")
  4103. birthday := c.GetString("birthday")
  4104. id_card := c.GetString("id_card")
  4105. register_type, _ := c.GetInt64("register")
  4106. doctor, _ := c.GetInt64("doctor")
  4107. department, _ := c.GetInt64("department")
  4108. gender, _ := c.GetInt64("sex")
  4109. registration_fee, _ := c.GetFloat("registration_fee")
  4110. medical_expenses, _ := c.GetFloat("medical_expenses")
  4111. social_type, _ := c.GetInt64("social_type")
  4112. med_type := c.GetString("social_type")
  4113. admin_user_id, _ := c.GetInt64("admin_user_id")
  4114. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4115. timeLayout := "2006-01-02"
  4116. loc, _ := time.LoadLocation("Local")
  4117. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4118. birthUnix := birthdays.Unix()
  4119. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4120. if err != nil {
  4121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4122. return
  4123. }
  4124. recordDateTime := theTime.Unix()
  4125. adminInfo := c.GetAdminUserInfo()
  4126. var patient service.Patients
  4127. if id == 0 {
  4128. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4129. } else {
  4130. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4131. }
  4132. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4133. if patientPrescription.ID == 0 {
  4134. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4135. }
  4136. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4137. if patient.ID == 0 {
  4138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4139. return
  4140. }
  4141. if len(patient.IdCardNo) == 0 {
  4142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4143. return
  4144. }
  4145. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4146. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4147. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4148. //就诊结算未完成,不能进行二次挂号
  4149. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4150. if len(his) >= 1 {
  4151. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  4152. if len(his) >= 1 && order.ID == 0 {
  4153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  4154. return
  4155. }
  4156. }
  4157. //var register_log string
  4158. if config.IsOpen == 1 {
  4159. var res ResultTwo
  4160. var res10265 ResultTwo10265
  4161. var PsnNo string
  4162. var PsnCertType string
  4163. var Certno string
  4164. var PsnName string
  4165. var Gend string
  4166. var Naty string
  4167. var Brdy string
  4168. var Age float64
  4169. var infoStr string
  4170. var idetinfoStr string
  4171. var infocode int64
  4172. var verify_number string
  4173. fmt.Println(verify_number)
  4174. if miConfig.MdtrtareaAdmvs == "421300" {
  4175. psn_info, _ := service.GetPsnByPatientId(id)
  4176. PsnNo = psn_info.PsnNo
  4177. PsnCertType = psn_info.PsnCertType
  4178. Certno = psn_info.Certno
  4179. PsnName = psn_info.PsnName
  4180. Gend = psn_info.Gend
  4181. Naty = psn_info.Naty
  4182. Brdy = psn_info.Brdy
  4183. Age = psn_info.Age
  4184. infoStr = psn_info.Insuinfo
  4185. idetinfoStr = psn_info.Idetinfo
  4186. infocode = 0
  4187. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4188. psn_info, _ := service.GetPsnByPatientId(id)
  4189. PsnNo = psn_info.PsnNo
  4190. PsnCertType = psn_info.PsnCertType
  4191. Certno = psn_info.Certno
  4192. PsnName = psn_info.PsnName
  4193. Gend = psn_info.Gend
  4194. Naty = psn_info.Naty
  4195. Brdy = psn_info.Brdy
  4196. Age = psn_info.Age
  4197. infoStr = psn_info.Insuinfo
  4198. idetinfoStr = psn_info.Idetinfo
  4199. infocode = 0
  4200. verify_number = psn_info.VerifyNumber
  4201. } else {
  4202. var result string
  4203. var requestLog string
  4204. if miConfig.UserOrgId == 10138 {
  4205. 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)
  4206. } else {
  4207. 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)
  4208. }
  4209. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4210. if miConfig.Code == "H15049901371" {
  4211. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4212. utils.ErrorLog("解析失败:%v", err)
  4213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4214. return
  4215. }
  4216. res.ErrMsg = res10265.ErrMsg
  4217. res.Output = res10265.Output
  4218. res.InfRefmsgid = res10265.InfRefmsgid
  4219. } else {
  4220. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4221. utils.ErrorLog("解析失败:%v", err)
  4222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4223. return
  4224. }
  4225. }
  4226. PsnNo = res.Output.Baseinfo.PsnNo
  4227. PsnCertType = res.Output.Baseinfo.PsnCertType
  4228. Certno = res.Output.Baseinfo.Certno
  4229. PsnName = res.Output.Baseinfo.PsnName
  4230. Gend = res.Output.Baseinfo.Gend
  4231. Naty = res.Output.Baseinfo.Naty
  4232. Brdy = res.Output.Baseinfo.Brdy
  4233. Age = res.Output.Baseinfo.Age
  4234. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4235. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4236. infoStr = string(Iinfos)
  4237. idetinfoStr = string(Idetinfos)
  4238. if miConfig.Code == "H15049901371" {
  4239. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  4240. } else {
  4241. infocode = res.Infcode
  4242. }
  4243. }
  4244. if infocode == 0 {
  4245. his := models.VMHisPatient{
  4246. Name: name,
  4247. Gender: gender,
  4248. Birthday: birthUnix,
  4249. MedicalTreatmentType: medical_care,
  4250. IdType: certificates,
  4251. IdCardNo: id_card,
  4252. BalanceAccountsType: settlementValue,
  4253. SocialType: social_type,
  4254. MedicalInsuranceNumber: medical_insurance_card,
  4255. RegisterType: register_type,
  4256. RegisterCost: registration_fee,
  4257. TreatmentCost: medical_expenses,
  4258. Status: 1,
  4259. Ctime: time.Now().Unix(),
  4260. Mtime: time.Now().Unix(),
  4261. PsnNo: PsnNo,
  4262. PsnCertType: PsnCertType,
  4263. Certno: Certno,
  4264. PsnName: PsnName,
  4265. Gend: Gend,
  4266. Naty: Naty,
  4267. Brdy: Brdy,
  4268. Age: Age,
  4269. Iinfo: infoStr,
  4270. Idetinfo: idetinfoStr,
  4271. PatientId: patient.ID,
  4272. RecordDate: theTime.Unix(),
  4273. UserOrgId: adminInfo.CurrentOrgId,
  4274. AdminUserId: admin_user_id,
  4275. IsReturn: 1,
  4276. IdCardType: id_card_type,
  4277. Doctor: doctor,
  4278. Departments: department,
  4279. }
  4280. timestamp := time.Now().Unix()
  4281. tempTime := time.Unix(timestamp, 0)
  4282. timeFormat := tempTime.Format("20060102150405")
  4283. chrgBchno := rand.Intn(100000) + 10000
  4284. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4285. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  4286. department, _ := service.GetDepartMentDetail(department)
  4287. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  4288. IdCardNo := ""
  4289. if id_card_type == 1 {
  4290. // IdCardNo = medical_insurance_card
  4291. IdCardNo = patient.IdCardNo
  4292. } else {
  4293. IdCardNo = patient.IdCardNo
  4294. }
  4295. var rf []*ResultFive
  4296. json.Unmarshal([]byte(his.Iinfo), &rf)
  4297. var insutypes []*ResultFive
  4298. var insutype string
  4299. var insuplc_admdvs_temp string
  4300. var is390 int = 0
  4301. var is310 int = 0
  4302. for _, item := range rf {
  4303. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4304. insutypes = append(insutypes, item)
  4305. }
  4306. }
  4307. if len(insutypes) == 1 {
  4308. insutype = insutypes[0].Insutype
  4309. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4310. } else {
  4311. for _, i := range insutypes {
  4312. if i.Insutype == "390" {
  4313. is390 = 1
  4314. }
  4315. if i.Insutype == "310" {
  4316. is310 = 1
  4317. }
  4318. }
  4319. }
  4320. if is390 == 1 {
  4321. insutype = "390"
  4322. }
  4323. if is310 == 1 {
  4324. insutype = "310"
  4325. }
  4326. if len(insutypes) == 0 {
  4327. insutype = "310"
  4328. }
  4329. if len(insutypes) == 2 {
  4330. insutype = med_type
  4331. }
  4332. if len(med_type) > 0 {
  4333. insutype = med_type
  4334. }
  4335. //for _, item := range rf {
  4336. // if item.Insutype == insutype {
  4337. // insuplc_admdvs = item.InsuplcAdmdvs
  4338. // }
  4339. //}
  4340. var infocode int64
  4341. var resThree ResultThree
  4342. var resThree10265 ResultThree10265
  4343. if len(insuplc_admdvs) == 0 {
  4344. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  4345. } else {
  4346. insuplc_admdvs_temp = insuplc_admdvs
  4347. }
  4348. if miConfig.MdtrtareaAdmvs == "421300" {
  4349. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  4350. "&org_name=" + miConfig.OrgName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4351. "&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
  4352. resp, requestErr := http.Get(api)
  4353. if requestErr != nil {
  4354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4355. return
  4356. }
  4357. body, ioErr := ioutil.ReadAll(resp.Body)
  4358. if ioErr != nil {
  4359. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4361. return
  4362. }
  4363. var respJSON map[string]interface{}
  4364. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4365. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4367. return
  4368. }
  4369. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4370. result, _ := json.Marshal(respJSON)
  4371. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4372. utils.ErrorLog("解析失败:%v", err)
  4373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4374. return
  4375. }
  4376. infocode = resThree.Infcode
  4377. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4378. psn_info, _ := service.GetPsnByPatientId(id)
  4379. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4380. var cert_no string
  4381. if id_card_type == 3 {
  4382. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  4383. cert_no = IdCardNo
  4384. } else {
  4385. bas := strings.Split(psn_info.CardInfo, "|")
  4386. cert_no = bas[2]
  4387. }
  4388. var api string
  4389. if miConfig.MdtrtareaAdmvs == "320921" {
  4390. api = "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4391. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4392. "&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
  4393. } else {
  4394. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4395. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4396. "&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
  4397. }
  4398. resp, requestErr := http.Get(api)
  4399. if requestErr != nil {
  4400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4401. return
  4402. }
  4403. body, ioErr := ioutil.ReadAll(resp.Body)
  4404. if ioErr != nil {
  4405. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4407. return
  4408. }
  4409. var respJSON map[string]interface{}
  4410. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4411. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4413. return
  4414. }
  4415. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4416. result, _ := json.Marshal(respJSON)
  4417. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4418. utils.ErrorLog("解析失败:%v", err)
  4419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4420. return
  4421. }
  4422. resThree.ErrMsg = resThree10265.ErrMsg
  4423. resThree.Output = resThree10265.Output
  4424. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4425. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4426. } else {
  4427. 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)
  4428. saveLog(result, requestLog, "2201A", "挂号")
  4429. if miConfig.Code == "H15049901371" {
  4430. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4431. utils.ErrorLog("解析失败:%v", err)
  4432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4433. return
  4434. }
  4435. resThree.ErrMsg = resThree10265.ErrMsg
  4436. resThree.Output = resThree10265.Output
  4437. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4438. } else {
  4439. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4440. utils.ErrorLog("解析失败:%v", err)
  4441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4442. return
  4443. }
  4444. }
  4445. if miConfig.Code == "H15049901371" {
  4446. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4447. } else {
  4448. infocode = resThree.Infcode
  4449. }
  4450. }
  4451. if infocode != 0 {
  4452. adminUser := c.GetAdminUserInfo()
  4453. errlog := &models.HisOrderError{
  4454. UserOrgId: adminUser.CurrentOrgId,
  4455. Ctime: time.Now().Unix(),
  4456. Mtime: time.Now().Unix(),
  4457. ErrMsg: resThree.ErrMsg,
  4458. Status: 1,
  4459. PatientId: id,
  4460. RecordTime: recordDateTime,
  4461. Stage: 2,
  4462. }
  4463. service.CreateErrMsgLog(errlog)
  4464. c.ServeSuccessJSON(map[string]interface{}{
  4465. "failed_code": -10,
  4466. "msg": resThree.ErrMsg,
  4467. })
  4468. return
  4469. }
  4470. his.Number = resThree.Output.Data.MdtrtID
  4471. his.PsnNo = resThree.Output.Data.PsnNo
  4472. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  4473. his.IdCardNo = patient.IdCardNo
  4474. his.PhoneNumber = patient.Phone
  4475. his.UserOrgId = adminInfo.CurrentOrgId
  4476. his.Insutype = insutype
  4477. his.Ctime = time.Now().Unix()
  4478. his.Mtime = time.Now().Unix()
  4479. his.InsuplcAdmdvs = insuplc_admdvs_temp
  4480. his.Status = 1
  4481. service.UpdateHisPatientStatus(&his)
  4482. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  4483. c.ServeSuccessJSON(map[string]interface{}{
  4484. "his_info": his,
  4485. })
  4486. } else {
  4487. adminUser := c.GetAdminUserInfo()
  4488. errlog := &models.HisOrderError{
  4489. UserOrgId: adminUser.CurrentOrgId,
  4490. Ctime: time.Now().Unix(),
  4491. Mtime: time.Now().Unix(),
  4492. ErrMsg: res.ErrMsg,
  4493. Status: 1,
  4494. PatientId: id,
  4495. RecordTime: recordDateTime,
  4496. Stage: 1,
  4497. }
  4498. service.CreateErrMsgLog(errlog)
  4499. c.ServeSuccessJSON(map[string]interface{}{
  4500. "failed_code": -10,
  4501. "msg": res.ErrMsg,
  4502. })
  4503. return
  4504. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  4505. }
  4506. }
  4507. }
  4508. //上传明细----预结算----确认订单
  4509. func (c *HisApiController) GetUploadInfo() {
  4510. id, _ := c.GetInt64("id")
  4511. record_time := c.GetString("record_time")
  4512. his_patient_id, _ := c.GetInt64("his_patient_id")
  4513. order_id, _ := c.GetInt64("order_id")
  4514. pay_way, _ := c.GetInt64("pay_way")
  4515. pay_price, _ := c.GetFloat("pay_price")
  4516. pay_card_no := c.GetString("pay_card_no")
  4517. discount_price, _ := c.GetFloat("discount_price")
  4518. preferential_price, _ := c.GetFloat("preferential_price")
  4519. reality_price, _ := c.GetFloat("reality_price")
  4520. found_price, _ := c.GetFloat("found_price")
  4521. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  4522. private_price, _ := c.GetFloat("private_price")
  4523. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4524. admin_user_id, _ := c.GetInt64("admin_user_id")
  4525. fapiao_code := c.GetString("fapiao_code")
  4526. fapiao_number := c.GetString("fapiao_number")
  4527. diagnosis_id := c.GetString("diagnosis")
  4528. sick_type, _ := c.GetInt64("sick_type")
  4529. reg_type, _ := c.GetInt64("p_type")
  4530. begin_time := c.GetString("begin_time")
  4531. id_str := c.GetString("ids")
  4532. ids_arr := strings.Split(id_str, ",")
  4533. timeLayout := "2006-01-02"
  4534. loc, _ := time.LoadLocation("Local")
  4535. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4536. if err != nil {
  4537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4538. return
  4539. }
  4540. recordDateTime := theTime.Unix()
  4541. adminUser := c.GetAdminUserInfo()
  4542. var tempOrder models.HisOrder
  4543. tempOrder, _ = service.GetHisOrderByID(order_id)
  4544. var prescriptions []*models.HisPrescription
  4545. var start_time int64
  4546. var end_time int64
  4547. //if adminUser.CurrentOrgId == 10106{
  4548. // if len(fapiao_code) == 0{
  4549. // fapiao_code = "144072080589"
  4550. // }
  4551. // if len(fapiao_number) == 0{
  4552. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  4553. // if order.ID == 0{
  4554. // fapiao_number = "00001520"
  4555. // }else{
  4556. // //fapiao_code = "00001520"
  4557. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  4558. // var zero string
  4559. // if fpNumber >= 1000{
  4560. // zero = "0000" + strconv.Itoa(fpNumber)
  4561. // }else if fpNumber >= 10000{
  4562. // zero = "000" + strconv.Itoa(fpNumber)
  4563. // } else if fpNumber >= 100000{
  4564. // zero = "00" + strconv.Itoa(fpNumber)
  4565. // } else if fpNumber >= 1000000{
  4566. // zero = "0" + strconv.Itoa(fpNumber)
  4567. // }else {
  4568. // zero = strconv.Itoa(fpNumber)
  4569. // }
  4570. // fapiao_number = zero
  4571. // }
  4572. // }
  4573. //}
  4574. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4575. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4576. var patientPrescription models.HisPrescriptionInfo
  4577. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4578. if patientPrescription.ID == 0 {
  4579. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4580. }
  4581. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4582. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4583. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4584. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4585. var config []*models.HisXtDiagnoseConfig
  4586. for _, item := range diagnosis_ids {
  4587. id, _ := strconv.ParseInt(item, 10, 64)
  4588. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4589. config = append(config, &diagnosisConfig)
  4590. }
  4591. sickConfig, _ := service.FindSickById(sick_type)
  4592. //if tempOrder.ID == 0 {
  4593. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  4594. //}
  4595. if tempOrder.ID == 0 {
  4596. var result string
  4597. var requestLog string
  4598. var res2 ResultSix
  4599. var ressix10265 ResultSix10265
  4600. if miConfig.MdtrtareaAdmvs == "421300" {
  4601. data := make(map[string]interface{})
  4602. client := &http.Client{}
  4603. data["psn_no"] = his.PsnNo
  4604. data["mdtrt_id"] = his.Number
  4605. data["doctor"] = roles.UserName
  4606. data["department"] = department.Name
  4607. data["org_name"] = miConfig.OrgName
  4608. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4609. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4610. data["fixmedins_code"] = miConfig.Code
  4611. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4612. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4613. data["secret_key"] = miConfig.SecretKey
  4614. data["sick_code"] = sickConfig.CountryCode
  4615. data["sick_name"] = sickConfig.ClassName
  4616. data["dept"] = strconv.FormatInt(department.ID, 10)
  4617. data["config"] = config
  4618. data["begin_time"] = begin_time
  4619. bytesData, _ := json.Marshal(data)
  4620. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  4621. resp, _ := client.Do(req)
  4622. defer resp.Body.Close()
  4623. body, ioErr := ioutil.ReadAll(resp.Body)
  4624. if ioErr != nil {
  4625. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4627. return
  4628. }
  4629. var respJSON map[string]interface{}
  4630. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4631. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4633. return
  4634. }
  4635. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4636. userJSONBytes, _ := json.Marshal(respJSON)
  4637. fmt.Println("log")
  4638. fmt.Println(string(userJSONBytes))
  4639. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4640. utils.ErrorLog("解析失败:%v", err)
  4641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4642. return
  4643. }
  4644. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4645. //江苏地区国家医保医疗类别
  4646. //职工透析:医疗类别选特殊情况门诊9933
  4647. //居民血透门慢: 医疗类别选门诊慢病1402
  4648. //var med_type string
  4649. //if his.Insutype == "310" {
  4650. // if reg_type == 14 {
  4651. // med_type = "9933"
  4652. // } else if reg_type == 11 {
  4653. // med_type = "11"
  4654. //
  4655. // }
  4656. //} else if his.Insutype == "390" {
  4657. // if reg_type == 14 {
  4658. // med_type = "1402"
  4659. // } else if reg_type == 11 {
  4660. // med_type = "11"
  4661. // }
  4662. //}
  4663. data := make(map[string]interface{})
  4664. client := &http.Client{}
  4665. data["psn_no"] = his.PsnNo
  4666. data["mdtrt_id"] = his.Number
  4667. data["doctor"] = roles.UserName
  4668. data["department"] = department.Name
  4669. data["org_name"] = miConfig.OrgName
  4670. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4671. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4672. data["fixmedins_code"] = miConfig.Code
  4673. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4674. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4675. data["secret_key"] = miConfig.SecretKey
  4676. data["sick_code"] = sickConfig.CountryCode
  4677. data["sick_name"] = sickConfig.ClassName
  4678. data["url"] = miConfig.Url
  4679. data["ak"] = miConfig.AccessKey
  4680. data["begin_time"] = begin_time
  4681. data["cainfo"] = miConfig.Cainfo
  4682. data["dept"] = strconv.FormatInt(department.ID, 10)
  4683. data["config"] = config
  4684. bytesData, _ := json.Marshal(data)
  4685. var req *http.Request
  4686. if miConfig.MdtrtareaAdmvs == "320921" {
  4687. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4688. //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 +
  4689. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  4690. } else {
  4691. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4692. }
  4693. resp, _ := client.Do(req)
  4694. defer resp.Body.Close()
  4695. body, ioErr := ioutil.ReadAll(resp.Body)
  4696. if ioErr != nil {
  4697. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4699. return
  4700. }
  4701. var respJSON map[string]interface{}
  4702. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4703. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4705. return
  4706. }
  4707. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4708. userJSONBytes, _ := json.Marshal(respJSON)
  4709. fmt.Println("log")
  4710. fmt.Println(string(userJSONBytes))
  4711. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  4712. utils.ErrorLog("解析失败:%v", err)
  4713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4714. return
  4715. }
  4716. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4717. res2.Output = ressix10265.Output
  4718. res2.ErrMsg = ressix10265.ErrMsg
  4719. res2.Cainfo = ressix10265.Cainfo
  4720. res2.WarnMsg = ressix10265.WarnMsg
  4721. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4722. res2.Infcode = infocode
  4723. } else {
  4724. if miConfig.MdtrtareaAdmvs == "440781" { //
  4725. 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)
  4726. } else {
  4727. if miConfig.Code == "H15049901371" {
  4728. //赤峰地区国家医保医疗类别
  4729. //职工透析:医疗类别选特殊情况门诊990502
  4730. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4731. var med_type string
  4732. if his.Insutype == "390" {
  4733. if reg_type == 14 {
  4734. med_type = "9933"
  4735. } else if reg_type == 11 {
  4736. med_type = "11"
  4737. }
  4738. } else if his.Insutype == "310" {
  4739. if reg_type == 14 {
  4740. med_type = "990502"
  4741. } else if reg_type == 11 {
  4742. med_type = "11"
  4743. }
  4744. }
  4745. 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)
  4746. } else {
  4747. 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)
  4748. }
  4749. }
  4750. saveLog(result, requestLog, "2203", "上传就诊信息")
  4751. var respJSON2 map[string]interface{}
  4752. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4753. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4755. return
  4756. }
  4757. userJSONBytes2, _ := json.Marshal(respJSON2)
  4758. if miConfig.Code == "H15049901371" {
  4759. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  4760. utils.ErrorLog("解析失败:%v", err)
  4761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4762. return
  4763. }
  4764. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4765. res2.Output = ressix10265.Output
  4766. res2.ErrMsg = ressix10265.ErrMsg
  4767. res2.Cainfo = ressix10265.Cainfo
  4768. res2.WarnMsg = ressix10265.WarnMsg
  4769. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4770. res2.Infcode = infocode
  4771. } else {
  4772. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4773. utils.ErrorLog("解析失败:%v", err)
  4774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4775. return
  4776. }
  4777. }
  4778. }
  4779. if res2.Infcode != 0 {
  4780. adminUser := c.GetAdminUserInfo()
  4781. errlog := &models.HisOrderError{
  4782. UserOrgId: adminUser.CurrentOrgId,
  4783. Ctime: time.Now().Unix(),
  4784. Mtime: time.Now().Unix(),
  4785. ErrMsg: res2.ErrMsg,
  4786. Status: 1,
  4787. PatientId: id,
  4788. RecordTime: recordDateTime,
  4789. Stage: 3,
  4790. }
  4791. service.CreateErrMsgLog(errlog)
  4792. c.ServeSuccessJSON(map[string]interface{}{
  4793. "failed_code": -10,
  4794. "msg": res2.ErrMsg,
  4795. })
  4796. return
  4797. } else {
  4798. his.Diagnosis = diagnosis_id
  4799. his.SickType = sickConfig.ID
  4800. //var p_type int64
  4801. //if reg_type == 1111 || reg_type == 1112 {
  4802. // p_type = 11
  4803. //
  4804. //}
  4805. his.PType = fmt.Sprintf("%d", reg_type)
  4806. service.UpdateHisPatientThree(&his)
  4807. data := make(map[string]interface{})
  4808. if settle_accounts_type == 1 { //日结
  4809. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  4810. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  4811. } else {
  4812. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  4813. }
  4814. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  4815. data["pre"] = prescriptions
  4816. } else { //月结
  4817. start_time_str := c.GetString("start_time")
  4818. end_time_str := c.GetString("end_time")
  4819. timeLayout := "2006-01-02"
  4820. loc, _ := time.LoadLocation("Local")
  4821. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4822. if err != nil {
  4823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4824. return
  4825. }
  4826. recordStartTime := theStartTime.Unix()
  4827. start_time = recordStartTime
  4828. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4829. if err != nil {
  4830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4831. return
  4832. }
  4833. recordEndTime := theEndTime.Unix()
  4834. end_time = recordEndTime
  4835. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  4836. data["pre"] = prescriptions
  4837. }
  4838. timestamp := time.Now().Unix()
  4839. tempTime := time.Unix(timestamp, 0)
  4840. timeFormat := tempTime.Format("20060102150405")
  4841. chrgBchno := rand.Intn(100000) + 10000
  4842. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4843. strconv.FormatInt(his.PatientId, 10)
  4844. client := &http.Client{}
  4845. data["psn_no"] = his.PsnNo
  4846. data["mdtrt_id"] = his.Number
  4847. data["chrg_bchno"] = chrg_bchno
  4848. data["org_name"] = miConfig.OrgName
  4849. data["doctor"] = roles.UserName
  4850. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4851. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4852. data["fixmedins_code"] = miConfig.Code
  4853. //if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  4854. // data["dept_code"] = "15"
  4855. //} else {
  4856. data["dept_code"] = department.Number
  4857. //}
  4858. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4859. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4860. data["secret_key"] = miConfig.SecretKey
  4861. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  4862. data["url"] = miConfig.Url
  4863. data["ak"] = miConfig.AccessKey
  4864. data["new_doctor_name"] = patientPrescription.Doctor
  4865. data["diag_code"] = sickConfig.CountryCode
  4866. data["cainfo"] = miConfig.Cainfo
  4867. var ids []int64
  4868. for _, item := range prescriptions {
  4869. ids = append(ids, item.ID)
  4870. }
  4871. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4872. if config.IsOpen == 1 { //对接了医保,走医保流程
  4873. var res ResultFour
  4874. var resFour10265 ResultFour10265
  4875. if miConfig.MdtrtareaAdmvs == "421300" {
  4876. bytesData, _ := json.Marshal(data)
  4877. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  4878. resp, _ := client.Do(req)
  4879. defer resp.Body.Close()
  4880. body, ioErr := ioutil.ReadAll(resp.Body)
  4881. if ioErr != nil {
  4882. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4884. return
  4885. }
  4886. var respJSON map[string]interface{}
  4887. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4888. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4890. return
  4891. }
  4892. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4893. userJSONBytes, _ := json.Marshal(respJSON)
  4894. fmt.Println("log")
  4895. fmt.Println(string(userJSONBytes))
  4896. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4897. utils.ErrorLog("解析失败:%v", err)
  4898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4899. return
  4900. }
  4901. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4902. bytesData, _ := json.Marshal(data)
  4903. var req *http.Request
  4904. if miConfig.MdtrtareaAdmvs == "320921" {
  4905. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4906. } else {
  4907. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4908. }
  4909. resp, _ := client.Do(req)
  4910. defer resp.Body.Close()
  4911. body, ioErr := ioutil.ReadAll(resp.Body)
  4912. if ioErr != nil {
  4913. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4915. return
  4916. }
  4917. var respJSON map[string]interface{}
  4918. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4919. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4921. return
  4922. }
  4923. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4924. userJSONBytes, _ := json.Marshal(respJSON)
  4925. fmt.Println("log")
  4926. fmt.Println(string(userJSONBytes))
  4927. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4928. utils.ErrorLog("解析失败:%v", err)
  4929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4930. return
  4931. }
  4932. res.InfRefmsgid = resFour10265.InfRefmsgid
  4933. res.Output = resFour10265.Output
  4934. res.ErrMsg = resFour10265.ErrMsg
  4935. res.Cainfo = resFour10265.Cainfo
  4936. res.WarnMsg = resFour10265.WarnMsg
  4937. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4938. res.Infcode = infocode
  4939. } else {
  4940. if miConfig.Code == "H15049901371" {
  4941. 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)
  4942. var dat map[string]interface{}
  4943. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4944. fmt.Println(dat)
  4945. } else {
  4946. fmt.Println(err)
  4947. }
  4948. saveLog(result, request_log, "2204", "上传费用明细")
  4949. userJSONBytes, _ := json.Marshal(dat)
  4950. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4951. utils.ErrorLog("解析失败:%v", err)
  4952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4953. return
  4954. }
  4955. res.InfRefmsgid = resFour10265.InfRefmsgid
  4956. res.Output = resFour10265.Output
  4957. res.ErrMsg = resFour10265.ErrMsg
  4958. res.Cainfo = resFour10265.Cainfo
  4959. res.WarnMsg = resFour10265.WarnMsg
  4960. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4961. res.Infcode = infocode
  4962. } else {
  4963. 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)
  4964. var dat map[string]interface{}
  4965. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4966. fmt.Println(dat)
  4967. } else {
  4968. fmt.Println(err)
  4969. }
  4970. saveLog(result, request_log, "2204", "上传费用明细")
  4971. userJSONBytes, _ := json.Marshal(dat)
  4972. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4973. utils.ErrorLog("解析失败:%v", err)
  4974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4975. return
  4976. }
  4977. }
  4978. }
  4979. if res.Infcode == 0 {
  4980. order := &models.HisOrder{
  4981. UserOrgId: adminUser.CurrentOrgId,
  4982. HisPatientId: his.ID,
  4983. PatientId: his.PatientId,
  4984. SettleAccountsDate: recordDateTime,
  4985. MdtrtId: his.Number,
  4986. PsnNo: his.PsnNo,
  4987. MedType: strconv.FormatInt(reg_type, 10),
  4988. Ctime: time.Now().Unix(),
  4989. Mtime: time.Now().Unix(),
  4990. Status: 1,
  4991. Number: chrg_bchno,
  4992. Infcode: res.Infcode,
  4993. WarnMsg: res.WarnMsg,
  4994. Cainfo: res.Cainfo,
  4995. ErrMsg: res.ErrMsg,
  4996. RespondTime: res.RefmsgTime,
  4997. InfRefmsgid: res.InfRefmsgid,
  4998. OrderStatus: 1,
  4999. PayWay: pay_way,
  5000. PayPrice: pay_price,
  5001. PayCardNo: pay_card_no,
  5002. DiscountPrice: discount_price,
  5003. PreferentialPrice: preferential_price,
  5004. RealityPrice: reality_price,
  5005. FoundPrice: found_price,
  5006. MedicalInsurancePrice: medical_insurance_price,
  5007. PrivatePrice: private_price,
  5008. IsMedicineInsurance: 1,
  5009. SettleType: settle_accounts_type,
  5010. SettleStartTime: start_time,
  5011. SettleEndTime: end_time,
  5012. Creator: roles.AdminUserId,
  5013. Modify: roles.AdminUserId,
  5014. FaPiaoNumber: fapiao_number,
  5015. FaPiaoCode: fapiao_code,
  5016. PType: 2,
  5017. Diagnosis: diagnosis_id,
  5018. }
  5019. err = service.CreateOrder(order)
  5020. if err != nil {
  5021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5022. return
  5023. }
  5024. for _, item := range res.Output.Result {
  5025. temp := strings.Split(item.FeedetlSn, "-")
  5026. var advice_id int64 = 0
  5027. var project_id int64 = 0
  5028. var types int64 = 0
  5029. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5030. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5031. if temp[1] == "1" {
  5032. advice_id = id
  5033. project_id = 0
  5034. } else if temp[1] == "2" {
  5035. advice_id = 0
  5036. project_id = id
  5037. }
  5038. info := &models.HisOrderInfo{
  5039. OrderNumber: order.Number,
  5040. FeedetlSn: item.FeedetlSn,
  5041. UploadDate: time.Now().Unix(),
  5042. AdviceId: advice_id,
  5043. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5044. Cnt: item.Cnt,
  5045. Pric: float64(item.Pric),
  5046. PatientId: his.PatientId,
  5047. PricUplmtAmt: item.PricUplmtAmt,
  5048. SelfpayProp: item.SelfpayProp,
  5049. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5050. OverlmtAmt: item.OverlmtAmt,
  5051. PreselfpayAmt: item.PreselfpayAmt,
  5052. BasMednFlag: item.BasMednFlag,
  5053. MedChrgitmType: item.MedChrgitmType,
  5054. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5055. Status: 1,
  5056. Memo: item.Memo,
  5057. Mtime: time.Now().Unix(),
  5058. InscpScpAmt: item.InscpScpAmt,
  5059. DrtReimFlag: item.DrtReimFlag,
  5060. Ctime: time.Now().Unix(),
  5061. ListSpItemFlag: item.ListSpItemFlag,
  5062. ChldMedcFlag: item.ChldMedcFlag,
  5063. LmtUsedFlag: item.LmtUsedFlag,
  5064. ChrgitmLv: item.ChrgitmLv,
  5065. UserOrgId: adminUser.CurrentOrgId,
  5066. HisPatientId: his.ID,
  5067. OrderId: order.ID,
  5068. ProjectId: project_id,
  5069. Type: types,
  5070. }
  5071. service.CreateOrderInfo(info)
  5072. }
  5073. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5074. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5075. var total float64
  5076. for _, item := range prescriptions {
  5077. if item.Type == 1 { //药品
  5078. for _, subItem := range item.HisDoctorAdviceInfo {
  5079. total = total + (subItem.Price * subItem.PrescribingNumber)
  5080. }
  5081. }
  5082. if item.Type == 2 { //项目
  5083. for _, subItem := range item.HisPrescriptionProject {
  5084. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5085. total = total + (subItem.Price * cnt)
  5086. }
  5087. }
  5088. }
  5089. for _, item := range prescriptions {
  5090. for _, subItem := range item.HisAdditionalCharge {
  5091. total = total + (subItem.Price * float64(subItem.Count))
  5092. }
  5093. }
  5094. var allTotal string
  5095. if adminUser.CurrentOrgId == 9919 {
  5096. allTotal = fmt.Sprintf("%.4f", total)
  5097. } else {
  5098. allTotal = fmt.Sprintf("%.4f", total)
  5099. }
  5100. if res.Infcode == 0 {
  5101. var rf []*ResultFive
  5102. json.Unmarshal([]byte(his.Iinfo), &rf)
  5103. chrg_bchno := chrg_bchno
  5104. cert_no := his.Certno
  5105. var insutypes []string
  5106. var insutype string
  5107. var is390 int = 0
  5108. var is310 int = 0
  5109. for _, item := range rf {
  5110. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5111. insutypes = append(insutypes, item.Insutype)
  5112. }
  5113. }
  5114. if len(insutypes) == 1 {
  5115. insutype = insutypes[0]
  5116. } else {
  5117. for _, i := range insutypes {
  5118. if i == "390" {
  5119. is390 = 1
  5120. }
  5121. if i == "310" {
  5122. is310 = 1
  5123. }
  5124. }
  5125. }
  5126. if is390 == 1 {
  5127. insutype = "390"
  5128. }
  5129. if is310 == 1 {
  5130. insutype = "310"
  5131. }
  5132. if len(insutypes) == 0 {
  5133. insutype = "310"
  5134. }
  5135. if len(insutypes) == 2 {
  5136. insutype = strconv.FormatInt(his.SocialType, 10)
  5137. }
  5138. insutype = strconv.FormatInt(his.SocialType, 10)
  5139. //insutype = "390"
  5140. if his.IdCardType == 1 {
  5141. // cert_no = his.MedicalInsuranceNumber
  5142. cert_no = his.Certno
  5143. } else {
  5144. cert_no = his.Certno
  5145. }
  5146. var res ResultSeven
  5147. var resSeven10265 ResultSeven10265
  5148. var src_resquest string
  5149. var result2 string
  5150. var acct_used_flag string
  5151. fmt.Println("pay_way")
  5152. fmt.Println(pay_way)
  5153. fmt.Println("pay_way")
  5154. if pay_way == 4 {
  5155. acct_used_flag = "1"
  5156. } else {
  5157. acct_used_flag = "0"
  5158. }
  5159. if miConfig.MdtrtareaAdmvs == "421300" {
  5160. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5161. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5162. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5163. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5164. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5165. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5166. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5167. resp, requestErr := http.Get(api)
  5168. if requestErr != nil {
  5169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5170. return
  5171. }
  5172. body, ioErr := ioutil.ReadAll(resp.Body)
  5173. if ioErr != nil {
  5174. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5176. return
  5177. }
  5178. var respJSON map[string]interface{}
  5179. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5180. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5182. return
  5183. }
  5184. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5185. result, _ := json.Marshal(respJSON)
  5186. if miConfig.Code == "H15049901371" {
  5187. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5188. utils.ErrorLog("解析失败:%v", err)
  5189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5190. return
  5191. }
  5192. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5193. res.Output = resSeven10265.Output
  5194. res.ErrMsg = resSeven10265.ErrMsg
  5195. res.Cainfo = resSeven10265.Cainfo
  5196. res.WarnMsg = resSeven10265.WarnMsg
  5197. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5198. res.Infcode = infocode
  5199. } else {
  5200. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5201. utils.ErrorLog("解析失败:%v", err)
  5202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5203. return
  5204. }
  5205. }
  5206. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5207. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5208. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5209. //psn_info, _ := service.GetPsnByPatientId(id)
  5210. bas := strings.Split(psn_info.CardInfo, "|")
  5211. if his.IdCardType == 1 {
  5212. cert_no = bas[2]
  5213. } else if his.IdCardType == 3 {
  5214. cert_no = his.Certno
  5215. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  5216. } else {
  5217. cert_no = bas[1]
  5218. }
  5219. //江苏地区国家医保医疗类别
  5220. //职工透析:医疗类别选特殊情况门诊9933
  5221. //居民血透门慢: 医疗类别选门诊慢病1402
  5222. //var med_type string
  5223. //if his.Insutype == "310" {
  5224. // if reg_type == 14 {
  5225. // med_type = "9933"
  5226. // } else if reg_type == 11 {
  5227. // med_type = "11"
  5228. //
  5229. // }
  5230. //} else if his.Insutype == "390" {
  5231. // if reg_type == 14 {
  5232. // med_type = "1402"
  5233. // } else if reg_type == 11 {
  5234. // med_type = "11"
  5235. // }
  5236. //}
  5237. //psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5238. var api string
  5239. if miConfig.MdtrtareaAdmvs == "320921" {
  5240. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5241. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5242. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5243. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5244. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5245. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5246. "&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
  5247. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5248. } else {
  5249. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5250. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5251. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5252. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5253. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5254. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5255. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5256. "&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
  5257. }
  5258. resp, requestErr := http.Get(api)
  5259. if requestErr != nil {
  5260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5261. return
  5262. }
  5263. body, ioErr := ioutil.ReadAll(resp.Body)
  5264. if ioErr != nil {
  5265. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5267. return
  5268. }
  5269. var respJSON map[string]interface{}
  5270. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5271. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5273. return
  5274. }
  5275. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5276. result, _ := json.Marshal(respJSON)
  5277. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5278. utils.ErrorLog("解析失败:%v", err)
  5279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5280. return
  5281. }
  5282. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5283. res.Output = resSeven10265.Output
  5284. res.ErrMsg = resSeven10265.ErrMsg
  5285. res.Cainfo = resSeven10265.Cainfo
  5286. res.WarnMsg = resSeven10265.WarnMsg
  5287. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5288. res.Infcode = infocode
  5289. } else {
  5290. if miConfig.Code == "H15049901371" {
  5291. //赤峰地区国家医保医疗类别
  5292. //职工透析:医疗类别选特殊情况门诊990502
  5293. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5294. var med_type string
  5295. if his.Insutype == "390" {
  5296. if reg_type == 14 {
  5297. med_type = "9933"
  5298. } else if reg_type == 11 {
  5299. med_type = "11"
  5300. }
  5301. } else if his.Insutype == "310" {
  5302. if reg_type == 14 {
  5303. med_type = "990502"
  5304. } else if reg_type == 11 {
  5305. med_type = "11"
  5306. }
  5307. }
  5308. 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)
  5309. } else {
  5310. 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)
  5311. }
  5312. //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)
  5313. var dat map[string]interface{}
  5314. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5315. fmt.Println(dat)
  5316. } else {
  5317. fmt.Println(err)
  5318. }
  5319. saveLog(result2, src_resquest, "2207", "结算")
  5320. userJSONBytes, _ := json.Marshal(dat)
  5321. if miConfig.Code == "H15049901371" {
  5322. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5323. utils.ErrorLog("解析失败:%v", err)
  5324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5325. return
  5326. }
  5327. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5328. res.Output = resSeven10265.Output
  5329. res.ErrMsg = resSeven10265.ErrMsg
  5330. res.Cainfo = resSeven10265.Cainfo
  5331. res.WarnMsg = resSeven10265.WarnMsg
  5332. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5333. res.Infcode = infocode
  5334. } else {
  5335. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5336. utils.ErrorLog("解析失败:%v", err)
  5337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5338. return
  5339. }
  5340. }
  5341. }
  5342. if res.Infcode != 0 {
  5343. errlog := &models.HisOrderError{
  5344. UserOrgId: adminUser.CurrentOrgId,
  5345. Ctime: time.Now().Unix(),
  5346. Mtime: time.Now().Unix(),
  5347. Number: chrg_bchno,
  5348. ErrMsg: res.ErrMsg,
  5349. Status: 1,
  5350. PatientId: id,
  5351. RecordTime: recordDateTime,
  5352. Stage: 6,
  5353. }
  5354. service.CreateErrMsgLog(errlog)
  5355. c.ServeSuccessJSON(map[string]interface{}{
  5356. "failed_code": -10,
  5357. "msg": res.ErrMsg,
  5358. })
  5359. return
  5360. } else {
  5361. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5362. order.OrderStatus = 2
  5363. order.Status = 1
  5364. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5365. order.SetlId = res.Output.Setlinfo.SetlID
  5366. order.PsnNo = res.Output.Setlinfo.PsnNo
  5367. order.PsnName = res.Output.Setlinfo.PsnName
  5368. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5369. order.Certno = res.Output.Setlinfo.Certno
  5370. order.Gend = res.Output.Setlinfo.Gend
  5371. order.Naty = res.Output.Setlinfo.Naty
  5372. order.Age = res.Output.Setlinfo.Age
  5373. order.Insutype = res.Output.Setlinfo.Insutype
  5374. order.PsnType = res.Output.Setlinfo.PsnType
  5375. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5376. order.SetlTime = res.Output.Setlinfo.SetlTime
  5377. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5378. if res.Output.Setlinfo.MedType == "140101" {
  5379. order.MedType = "14"
  5380. } else {
  5381. order.MedType = res.Output.Setlinfo.MedType
  5382. }
  5383. if reg_type == 1112 {
  5384. order.MedType = "1112"
  5385. }
  5386. if reg_type == 1111 {
  5387. order.MedType = "1111"
  5388. }
  5389. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5390. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5391. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5392. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5393. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5394. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5395. order.HifpPay = res.Output.Setlinfo.HifpPay
  5396. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5397. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5398. order.HifesPay = res.Output.Setlinfo.HifesPay
  5399. order.HifobPay = res.Output.Setlinfo.HifobPay
  5400. order.MafPay = res.Output.Setlinfo.MafPay
  5401. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5402. order.OthPay = res.Output.Setlinfo.OthPay
  5403. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5404. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5405. order.AcctPay = res.Output.Setlinfo.AcctPay
  5406. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5407. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5408. order.Balc = res.Output.Setlinfo.Balc
  5409. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5410. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5411. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5412. order.ClrType = res.Output.Setlinfo.ClrType
  5413. order.ClrWay = res.Output.Setlinfo.ClrWay
  5414. order.Creator = order.Creator
  5415. order.Modify = roles.AdminUserId
  5416. order.RequestLog = src_resquest
  5417. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5418. detailStr := string(setlDetail)
  5419. order.SetlDetail = detailStr
  5420. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5421. err = service.UpDateOrder(order)
  5422. if err == nil {
  5423. c.ServeSuccessJSON(map[string]interface{}{
  5424. "msg": "结算成功",
  5425. })
  5426. } else {
  5427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5428. return
  5429. }
  5430. }
  5431. } else {
  5432. adminUser := c.GetAdminUserInfo()
  5433. errlog := &models.HisOrderError{
  5434. UserOrgId: adminUser.CurrentOrgId,
  5435. Ctime: time.Now().Unix(),
  5436. Mtime: time.Now().Unix(),
  5437. ErrMsg: res.ErrMsg,
  5438. Status: 1,
  5439. PatientId: id,
  5440. RecordTime: recordDateTime,
  5441. Stage: 4,
  5442. }
  5443. service.CreateErrMsgLog(errlog)
  5444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5445. return
  5446. }
  5447. } else {
  5448. adminUser := c.GetAdminUserInfo()
  5449. errlog := &models.HisOrderError{
  5450. UserOrgId: adminUser.CurrentOrgId,
  5451. Ctime: time.Now().Unix(),
  5452. Mtime: time.Now().Unix(),
  5453. ErrMsg: res.ErrMsg,
  5454. Status: 1,
  5455. PatientId: id,
  5456. RecordTime: recordDateTime,
  5457. Stage: 4,
  5458. }
  5459. service.CreateErrMsgLog(errlog)
  5460. c.ServeSuccessJSON(map[string]interface{}{
  5461. "failed_code": -10,
  5462. "msg": res.ErrMsg,
  5463. })
  5464. return
  5465. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5466. //return
  5467. }
  5468. }
  5469. }
  5470. } else if tempOrder.ID > 0 {
  5471. if tempOrder.IsPre == 1 {
  5472. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  5473. var rf []*ResultFive
  5474. json.Unmarshal([]byte(his.Iinfo), &rf)
  5475. chrg_bchno := tempOrder.Number
  5476. cert_no := his.Certno
  5477. var insutypes []string
  5478. var insutype string
  5479. var is390 int = 0
  5480. var is310 int = 0
  5481. for _, item := range rf {
  5482. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5483. insutypes = append(insutypes, item.Insutype)
  5484. }
  5485. }
  5486. if len(insutypes) == 1 {
  5487. insutype = insutypes[0]
  5488. } else {
  5489. for _, i := range insutypes {
  5490. if i == "390" {
  5491. is390 = 1
  5492. }
  5493. if i == "310" {
  5494. is310 = 1
  5495. }
  5496. }
  5497. }
  5498. if is390 == 1 {
  5499. insutype = "390"
  5500. }
  5501. if is310 == 1 {
  5502. insutype = "310"
  5503. }
  5504. if len(insutypes) == 0 {
  5505. insutype = "310"
  5506. }
  5507. if len(insutypes) == 2 {
  5508. insutype = strconv.FormatInt(his.SocialType, 64)
  5509. }
  5510. //insutype = "390"
  5511. if his.IdCardType == 1 {
  5512. // cert_no = his.MedicalInsuranceNumber
  5513. cert_no = his.Certno
  5514. } else {
  5515. cert_no = his.Certno
  5516. }
  5517. var res ResultSeven
  5518. var resSeven10265 ResultSeven10265
  5519. var src_resquest string
  5520. var result2 string
  5521. var acct_used_flag string
  5522. fmt.Println("pay_way")
  5523. fmt.Println(pay_way)
  5524. fmt.Println("pay_way")
  5525. if pay_way == 4 {
  5526. acct_used_flag = "1"
  5527. } else {
  5528. acct_used_flag = "0"
  5529. }
  5530. if miConfig.MdtrtareaAdmvs == "421300" {
  5531. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5532. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5533. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5534. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5535. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5536. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5537. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5538. resp, requestErr := http.Get(api)
  5539. if requestErr != nil {
  5540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5541. return
  5542. }
  5543. body, ioErr := ioutil.ReadAll(resp.Body)
  5544. if ioErr != nil {
  5545. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5547. return
  5548. }
  5549. var respJSON map[string]interface{}
  5550. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5551. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5553. return
  5554. }
  5555. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5556. result, _ := json.Marshal(respJSON)
  5557. fmt.Println("log")
  5558. fmt.Println(string(result))
  5559. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5560. utils.ErrorLog("解析失败:%v", err)
  5561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5562. return
  5563. }
  5564. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5565. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5566. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5567. //psn_info, _ := service.GetPsnByPatientId(id)
  5568. bas := strings.Split(psn_info.CardInfo, "|")
  5569. if his.IdCardType == 1 {
  5570. cert_no = bas[2]
  5571. } else {
  5572. cert_no = bas[1]
  5573. }
  5574. //江苏地区国家医保医疗类别
  5575. //职工透析:医疗类别选特殊情况门诊9933
  5576. //居民血透门慢: 医疗类别选门诊慢病1402
  5577. //var med_type string
  5578. //if his.Insutype == "310" {
  5579. // if reg_type == 14 {
  5580. // med_type = "9933"
  5581. // } else if reg_type == 11 {
  5582. // med_type = "11"
  5583. //
  5584. // }
  5585. //} else if his.Insutype == "390" {
  5586. // if reg_type == 14 {
  5587. // med_type = "1402"
  5588. // } else if reg_type == 11 {
  5589. // med_type = "11"
  5590. // }
  5591. //}
  5592. var api string
  5593. if miConfig.MdtrtareaAdmvs == "320921" {
  5594. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5595. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5596. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5597. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5598. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5599. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5600. "&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
  5601. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5602. } else {
  5603. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5604. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5605. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5606. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5607. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5608. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5609. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5610. "&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
  5611. }
  5612. resp, requestErr := http.Get(api)
  5613. if requestErr != nil {
  5614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5615. return
  5616. }
  5617. body, ioErr := ioutil.ReadAll(resp.Body)
  5618. if ioErr != nil {
  5619. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5621. return
  5622. }
  5623. var respJSON map[string]interface{}
  5624. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5625. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5627. return
  5628. }
  5629. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5630. result, _ := json.Marshal(respJSON)
  5631. fmt.Println("log")
  5632. fmt.Println(string(result))
  5633. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5634. utils.ErrorLog("解析失败:%v", err)
  5635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5636. return
  5637. }
  5638. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5639. res.Output = resSeven10265.Output
  5640. res.ErrMsg = resSeven10265.ErrMsg
  5641. res.Cainfo = resSeven10265.Cainfo
  5642. res.WarnMsg = resSeven10265.WarnMsg
  5643. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5644. res.Infcode = infocode
  5645. } else {
  5646. var src_resquest string
  5647. if miConfig.Code == "H15049901371" {
  5648. //赤峰地区国家医保医疗类别
  5649. //职工透析:医疗类别选特殊情况门诊990502
  5650. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5651. var med_type string
  5652. if his.Insutype == "390" {
  5653. if reg_type == 14 {
  5654. med_type = "9933"
  5655. } else if reg_type == 11 {
  5656. med_type = "11"
  5657. }
  5658. } else if his.Insutype == "310" {
  5659. if reg_type == 14 {
  5660. med_type = "990502"
  5661. } else if reg_type == 11 {
  5662. med_type = "11"
  5663. }
  5664. }
  5665. 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)
  5666. } else {
  5667. 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)
  5668. }
  5669. var dat map[string]interface{}
  5670. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5671. fmt.Println(dat)
  5672. } else {
  5673. fmt.Println(err)
  5674. }
  5675. saveLog(result2, src_resquest, "2207", "结算")
  5676. userJSONBytes, _ := json.Marshal(dat)
  5677. if miConfig.Code == "H15049901371" {
  5678. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5679. utils.ErrorLog("解析失败:%v", err)
  5680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5681. return
  5682. }
  5683. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5684. res.Output = resSeven10265.Output
  5685. res.ErrMsg = resSeven10265.ErrMsg
  5686. res.Cainfo = resSeven10265.Cainfo
  5687. res.WarnMsg = resSeven10265.WarnMsg
  5688. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5689. res.Infcode = infocode
  5690. } else {
  5691. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5692. utils.ErrorLog("解析失败:%v", err)
  5693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5694. return
  5695. }
  5696. }
  5697. }
  5698. if res.Infcode != 0 {
  5699. errlog := &models.HisOrderError{
  5700. UserOrgId: adminUser.CurrentOrgId,
  5701. Ctime: time.Now().Unix(),
  5702. Mtime: time.Now().Unix(),
  5703. Number: chrg_bchno,
  5704. ErrMsg: res.ErrMsg,
  5705. Status: 1,
  5706. PatientId: id,
  5707. RecordTime: recordDateTime,
  5708. Stage: 6,
  5709. }
  5710. service.CreateErrMsgLog(errlog)
  5711. c.ServeSuccessJSON(map[string]interface{}{
  5712. "failed_code": -10,
  5713. "msg": res.ErrMsg,
  5714. })
  5715. return
  5716. } else {
  5717. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5718. order.OrderStatus = 2
  5719. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5720. order.SetlId = res.Output.Setlinfo.SetlID
  5721. order.PsnNo = res.Output.Setlinfo.PsnNo
  5722. order.PsnName = res.Output.Setlinfo.PsnName
  5723. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5724. order.Certno = res.Output.Setlinfo.Certno
  5725. order.Gend = res.Output.Setlinfo.Gend
  5726. order.Naty = res.Output.Setlinfo.Naty
  5727. order.Age = res.Output.Setlinfo.Age
  5728. order.Insutype = res.Output.Setlinfo.Insutype
  5729. order.PsnType = res.Output.Setlinfo.PsnType
  5730. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5731. order.SetlTime = res.Output.Setlinfo.SetlTime
  5732. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5733. //order.MedType = res.Output.Setlinfo.MedType
  5734. if reg_type == 1112 {
  5735. order.MedType = "1112"
  5736. }
  5737. if reg_type == 1111 {
  5738. order.MedType = "1111"
  5739. }
  5740. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5741. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5742. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5743. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5744. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5745. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5746. order.HifpPay = res.Output.Setlinfo.HifpPay
  5747. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5748. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5749. order.HifesPay = res.Output.Setlinfo.HifesPay
  5750. order.HifobPay = res.Output.Setlinfo.HifobPay
  5751. order.MafPay = res.Output.Setlinfo.MafPay
  5752. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5753. order.OthPay = res.Output.Setlinfo.OthPay
  5754. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5755. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5756. order.AcctPay = res.Output.Setlinfo.AcctPay
  5757. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5758. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5759. order.Balc = res.Output.Setlinfo.Balc
  5760. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5761. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5762. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5763. order.ClrWay = res.Output.Setlinfo.ClrWay
  5764. order.Creator = order.Creator
  5765. order.Modify = roles.AdminUserId
  5766. order.RequestLog = src_resquest
  5767. order.Diagnosis = diagnosis_id
  5768. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5769. detailStr := string(setlDetail)
  5770. order.SetlDetail = detailStr
  5771. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5772. err = service.UpDateOrder(order)
  5773. if err == nil {
  5774. c.ServeSuccessJSON(map[string]interface{}{
  5775. "msg": "结算成功",
  5776. })
  5777. } else {
  5778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5779. return
  5780. }
  5781. }
  5782. }
  5783. }
  5784. }
  5785. //func (c *HisApiController) GetPreUploadInfo() {
  5786. // id, _ := c.GetInt64("id")
  5787. // record_time := c.GetString("record_time")
  5788. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5789. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5790. //
  5791. // timeLayout := "2006-01-02"
  5792. // loc, _ := time.LoadLocation("Local")
  5793. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5794. // if err != nil {
  5795. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5796. // return
  5797. // }
  5798. // recordDateTime := theTime.Unix()
  5799. // adminUser := c.GetAdminUserInfo()
  5800. //
  5801. // var prescriptions []*models.HisPrescription
  5802. //
  5803. // var start_time int64
  5804. // var end_time int64
  5805. //
  5806. // data := make(map[string]interface{})
  5807. // if settle_accounts_type == 1 { //日结
  5808. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  5809. // data["pre"] = prescriptions
  5810. //
  5811. // } else { //月结
  5812. // start_time_str := c.GetString("start_time")
  5813. // end_time_str := c.GetString("end_time")
  5814. // timeLayout := "2006-01-02"
  5815. // loc, _ := time.LoadLocation("Local")
  5816. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5817. // if err != nil {
  5818. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5819. // return
  5820. // }
  5821. // recordStartTime := theStartTime.Unix()
  5822. // start_time = recordStartTime
  5823. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5824. // if err != nil {
  5825. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5826. // return
  5827. // }
  5828. // recordEndTime := theEndTime.Unix()
  5829. // end_time = recordEndTime
  5830. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  5831. // data["pre"] = prescriptions
  5832. //
  5833. // }
  5834. //
  5835. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5836. //
  5837. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5838. // timestamp := time.Now().Unix()
  5839. // tempTime := time.Unix(timestamp, 0)
  5840. // timeFormat := tempTime.Format("20060102150405")
  5841. // chrgBchno := rand.Intn(100000) + 10000
  5842. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5843. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5844. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5845. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5846. // strconv.FormatInt(his.PatientId, 10)
  5847. // client := &http.Client{}
  5848. // data["psn_no"] = his.PsnNo
  5849. // data["mdtrt_id"] = his.Number
  5850. // data["chrg_bchno"] = chrg_bchno
  5851. // data["org_name"] = miConfig.OrgName
  5852. // data["doctor"] = roles.UserName
  5853. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5854. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5855. // data["fixmedins_code"] = miConfig.Code
  5856. // data["dept_code"] = department.Number
  5857. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5858. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5859. // data["secret_key"] = miConfig.SecretKey
  5860. // var ids []int64
  5861. //
  5862. // for _, item := range prescriptions {
  5863. // ids = append(ids, item.ID)
  5864. // }
  5865. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5866. // if config.IsOpen == 1 { //对接了医保,走医保流程
  5867. // bytesData, _ := json.Marshal(data)
  5868. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  5869. // resp, _ := client.Do(req)
  5870. // defer resp.Body.Close()
  5871. // body, ioErr := ioutil.ReadAll(resp.Body)
  5872. // if ioErr != nil {
  5873. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5874. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5875. // return
  5876. // }
  5877. // var respJSON map[string]interface{}
  5878. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5879. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5880. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5881. // return
  5882. // }
  5883. //
  5884. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5885. // userJSONBytes, _ := json.Marshal(respJSON)
  5886. // var res ResultFour
  5887. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5888. // utils.ErrorLog("解析失败:%v", err)
  5889. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5890. // return
  5891. // }
  5892. //
  5893. // if res.Infcode == 0 {
  5894. // order := &models.HisOrder{
  5895. // UserOrgId: adminUser.CurrentOrgId,
  5896. // HisPatientId: his.ID,
  5897. // PatientId: his.PatientId,
  5898. // SettleAccountsDate: recordDateTime,
  5899. // Ctime: time.Now().Unix(),
  5900. // Mtime: time.Now().Unix(),
  5901. // Status: 1,
  5902. // Number: chrg_bchno,
  5903. // Infcode: res.Infcode,
  5904. // WarnMsg: res.WarnMsg,
  5905. // Cainfo: res.Cainfo,
  5906. // ErrMsg: res.ErrMsg,
  5907. // RespondTime: res.RefmsgTime,
  5908. // InfRefmsgid: res.InfRefmsgid,
  5909. // OrderStatus: 1,
  5910. // IsMedicineInsurance: 1,
  5911. // SettleType: settle_accounts_type,
  5912. // SettleStartTime: start_time,
  5913. // SettleEndTime: end_time,
  5914. // Creator: roles.ID,
  5915. // Modify: roles.ID,
  5916. // PType: 2,
  5917. // }
  5918. // err = service.CreateOrder(order)
  5919. // if err != nil {
  5920. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5921. // return
  5922. // }
  5923. //
  5924. // for _, item := range res.Output.Result {
  5925. // temp := strings.Split(item.FeedetlSn, "-")
  5926. // var advice_id int64 = 0
  5927. // var project_id int64 = 0
  5928. // var types int64 = 0
  5929. //
  5930. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  5931. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  5932. //
  5933. // if temp[1] == "1" {
  5934. // advice_id = id
  5935. // project_id = 0
  5936. // } else if temp[1] == "2" {
  5937. // advice_id = 0
  5938. // project_id = id
  5939. // }
  5940. //
  5941. // info := &models.HisOrderInfo{
  5942. // OrderNumber: order.Number,
  5943. // FeedetlSn: item.FeedetlSn,
  5944. // UploadDate: time.Now().Unix(),
  5945. // AdviceId: advice_id,
  5946. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  5947. // Cnt: item.Cnt,
  5948. // Pric: float64(item.Pric),
  5949. // PatientId: his.PatientId,
  5950. // PricUplmtAmt: item.PricUplmtAmt,
  5951. // SelfpayProp: item.SelfpayProp,
  5952. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5953. // OverlmtAmt: item.OverlmtAmt,
  5954. // PreselfpayAmt: item.PreselfpayAmt,
  5955. // BasMednFlag: item.BasMednFlag,
  5956. // MedChrgitmType: item.MedChrgitmType,
  5957. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  5958. // Status: 1,
  5959. // Memo: item.Memo,
  5960. // Mtime: time.Now().Unix(),
  5961. // InscpScpAmt: item.InscpScpAmt,
  5962. // DrtReimFlag: item.DrtReimFlag,
  5963. // Ctime: time.Now().Unix(),
  5964. // ListSpItemFlag: item.ListSpItemFlag,
  5965. // ChldMedcFlag: item.ChldMedcFlag,
  5966. // LmtUsedFlag: item.LmtUsedFlag,
  5967. // ChrgitmLv: item.ChrgitmLv,
  5968. // UserOrgId: adminUser.CurrentOrgId,
  5969. // HisPatientId: his.ID,
  5970. // OrderId: order.ID,
  5971. // ProjectId: project_id,
  5972. // Type: types,
  5973. // }
  5974. // service.CreateOrderInfo(info)
  5975. //
  5976. // }
  5977. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5978. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  5979. //
  5980. // var total float64
  5981. // for _, item := range prescriptions {
  5982. // if item.Type == 1 { //药品
  5983. // for _, subItem := range item.HisDoctorAdviceInfo {
  5984. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5985. // }
  5986. // }
  5987. // if item.Type == 2 { //项目
  5988. // for _, subItem := range item.HisPrescriptionProject {
  5989. // total = total + (subItem.Price * float64(subItem.Count))
  5990. // }
  5991. // }
  5992. // }
  5993. //
  5994. // for _, item := range prescriptions {
  5995. // for _, subItem := range item.HisAdditionalCharge {
  5996. // total = total + (subItem.Price * float64(subItem.Count))
  5997. // }
  5998. // }
  5999. //
  6000. // allTotal := fmt.Sprintf("%.2f", total)
  6001. // if res.Infcode == 0 {
  6002. // var rf []*ResultFive
  6003. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6004. // psn_no := his.PsnNo
  6005. // mdtrt_id := his.Number
  6006. // chrg_bchno := chrg_bchno
  6007. // cert_no := his.Certno
  6008. // insutype := rf[0].Insutype
  6009. //
  6010. // if his.IdCardType == 1 {
  6011. // cert_no = his.MedicalInsuranceNumber
  6012. //
  6013. // } else {
  6014. //
  6015. // cert_no = his.Certno
  6016. //
  6017. // }
  6018. //
  6019. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  6020. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  6021. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  6022. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  6023. // resp, requestErr := http.Get(api)
  6024. // if requestErr != nil {
  6025. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6026. // return
  6027. // }
  6028. // defer resp.Body.Close()
  6029. // body, ioErr := ioutil.ReadAll(resp.Body)
  6030. // if ioErr != nil {
  6031. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6032. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6033. // return
  6034. // }
  6035. // var respJSON map[string]interface{}
  6036. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6037. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6038. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6039. // return
  6040. // }
  6041. // fmt.Println(respJSON)
  6042. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6043. // userJSONBytes, _ := json.Marshal(respJSON)
  6044. // var res ResultSeven
  6045. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6046. // utils.ErrorLog("解析失败:%v", err)
  6047. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6048. // return
  6049. // }
  6050. // if res.Infcode != 0 {
  6051. // errlog := &models.HisOrderError{
  6052. // UserOrgId: adminUser.CurrentOrgId,
  6053. // Ctime: time.Now().Unix(),
  6054. // Mtime: time.Now().Unix(),
  6055. // Number: chrg_bchno,
  6056. // ErrMsg: res.ErrMsg,
  6057. // Status: 1,
  6058. // PatientId: id,
  6059. // RecordTime: recordDateTime,
  6060. // Stage: 7,
  6061. // }
  6062. // service.CreateErrMsgLog(errlog)
  6063. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6064. // return
  6065. // } else {
  6066. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6067. // order.OrderStatus = 1
  6068. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6069. // order.SetlId = res.Output.Setlinfo.SetlID
  6070. // order.PsnNo = res.Output.Setlinfo.PsnNo
  6071. // order.PsnName = res.Output.Setlinfo.PsnName
  6072. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6073. // order.Certno = res.Output.Setlinfo.Certno
  6074. // order.Gend = res.Output.Setlinfo.Gend
  6075. // order.Naty = res.Output.Setlinfo.Naty
  6076. // order.Age = res.Output.Setlinfo.Age
  6077. // order.Insutype = res.Output.Setlinfo.Insutype
  6078. // order.PsnType = res.Output.Setlinfo.PsnType
  6079. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6080. // order.SetlTime = res.Output.Setlinfo.SetlTime
  6081. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6082. // order.MedType = res.Output.Setlinfo.MedType
  6083. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6084. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6085. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6086. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6087. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6088. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6089. // order.HifpPay = res.Output.Setlinfo.HifpPay
  6090. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6091. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6092. // order.HifesPay = res.Output.Setlinfo.HifesPay
  6093. // order.HifobPay = res.Output.Setlinfo.HifobPay
  6094. // order.MafPay = res.Output.Setlinfo.MafPay
  6095. // order.OthPay = res.Output.Setlinfo.OthPay
  6096. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6097. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6098. // order.AcctPay = res.Output.Setlinfo.AcctPay
  6099. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6100. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6101. // order.Balc = res.Output.Setlinfo.Balc
  6102. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6103. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6104. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6105. // order.ClrWay = res.Output.Setlinfo.ClrWay
  6106. // order.Creator = order.Creator
  6107. // order.Modify = roles.ID
  6108. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6109. // detailStr := string(setlDetail)
  6110. // order.SetlDetail = detailStr
  6111. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6112. // err = service.UpDateOrder(order)
  6113. // if err == nil {
  6114. // c.ServeSuccessJSON(map[string]interface{}{
  6115. // "msg": "预结算成功",
  6116. // })
  6117. // } else {
  6118. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6119. // return
  6120. // }
  6121. // }
  6122. // } else {
  6123. // adminUser := c.GetAdminUserInfo()
  6124. // errlog := &models.HisOrderError{
  6125. // UserOrgId: adminUser.CurrentOrgId,
  6126. // Ctime: time.Now().Unix(),
  6127. // Mtime: time.Now().Unix(),
  6128. // ErrMsg: res.ErrMsg,
  6129. // Status: 1,
  6130. // PatientId: id,
  6131. // RecordTime: recordDateTime,
  6132. // Stage: 4,
  6133. // }
  6134. // service.CreateErrMsgLog(errlog)
  6135. //
  6136. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6137. // return
  6138. // }
  6139. // } else {
  6140. // adminUser := c.GetAdminUserInfo()
  6141. // errlog := &models.HisOrderError{
  6142. // UserOrgId: adminUser.CurrentOrgId,
  6143. // Ctime: time.Now().Unix(),
  6144. // Mtime: time.Now().Unix(),
  6145. // ErrMsg: res.ErrMsg,
  6146. // Status: 1,
  6147. // PatientId: id,
  6148. // RecordTime: recordDateTime,
  6149. // Stage: 4,
  6150. // }
  6151. // service.CreateErrMsgLog(errlog)
  6152. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6153. // return
  6154. // }
  6155. //
  6156. // } else {
  6157. // var total float64
  6158. // for _, item := range prescriptions {
  6159. // if item.Type == 1 { //药品
  6160. // for _, subItem := range item.HisDoctorAdviceInfo {
  6161. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6162. // }
  6163. // }
  6164. // if item.Type == 2 { //项目
  6165. // for _, subItem := range item.HisPrescriptionProject {
  6166. // total = total + (subItem.Price * float64(subItem.Count))
  6167. // }
  6168. // }
  6169. //
  6170. // for _, subItem := range item.HisAdditionalCharge {
  6171. // total = total + (subItem.Price * float64(subItem.Count))
  6172. // }
  6173. // }
  6174. //
  6175. // allTotal := fmt.Sprintf("%.2f", total)
  6176. // totals, _ := strconv.ParseFloat(allTotal, 64)
  6177. // order := &models.HisOrder{
  6178. // UserOrgId: adminUser.CurrentOrgId,
  6179. // HisPatientId: his.ID,
  6180. // PatientId: id,
  6181. // SettleAccountsDate: recordDateTime,
  6182. // Ctime: time.Now().Unix(),
  6183. // Mtime: time.Now().Unix(),
  6184. // Status: 1,
  6185. // OrderStatus: 2,
  6186. // Number: chrg_bchno,
  6187. // MedfeeSumamt: totals,
  6188. // }
  6189. // err = service.CreateOrder(order)
  6190. // if err != nil {
  6191. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6192. // return
  6193. // }
  6194. //
  6195. // var customs []*Custom
  6196. // for _, item := range prescriptions {
  6197. //
  6198. // if item.Type == 1 { //药品
  6199. // for _, subItem := range item.HisDoctorAdviceInfo {
  6200. // cus := &Custom{
  6201. // AdviceId: subItem.ID,
  6202. // ProjectId: 0,
  6203. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  6204. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  6205. // FeedetlSn: subItem.FeedetlSn,
  6206. // Price: fmt.Sprintf("%.2f", subItem.Price),
  6207. // MedListCodg: subItem.MedListCodg,
  6208. // Type: 1,
  6209. // }
  6210. // customs = append(customs, cus)
  6211. // }
  6212. // }
  6213. //
  6214. // if item.Type == 2 { //项目
  6215. // for _, subItem := range item.HisPrescriptionProject {
  6216. //
  6217. // cus := &Custom{
  6218. // AdviceId: 0,
  6219. // ProjectId: subItem.ID,
  6220. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  6221. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  6222. // FeedetlSn: subItem.FeedetlSn,
  6223. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  6224. // MedListCodg: subItem.MedListCodg,
  6225. // Type: 2,
  6226. // }
  6227. //
  6228. // customs = append(customs, cus)
  6229. // }
  6230. // }
  6231. //
  6232. // for _, item := range item.HisAdditionalCharge {
  6233. // cus := &Custom{
  6234. // ItemId: item.ID,
  6235. // AdviceId: 0,
  6236. // ProjectId: 0,
  6237. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  6238. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  6239. // FeedetlSn: item.FeedetlSn,
  6240. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  6241. // MedListCodg: item.XtHisAddtionConfig.Code,
  6242. // Type: 3,
  6243. // }
  6244. //
  6245. // customs = append(customs, cus)
  6246. // }
  6247. //
  6248. // }
  6249. //
  6250. // for _, item := range customs {
  6251. // var advice_id int64 = 0
  6252. // var project_id int64 = 0
  6253. // var item_id int64 = 0
  6254. //
  6255. // var types int64 = 0
  6256. //
  6257. // if item.Type == 1 {
  6258. // advice_id = item.AdviceId
  6259. // project_id = 0
  6260. // item_id = 0
  6261. // } else if item.Type == 2 {
  6262. // advice_id = 0
  6263. // item_id = 0
  6264. //
  6265. // project_id = item.ProjectId
  6266. // } else if item.Type == 3 {
  6267. // advice_id = 0
  6268. // item_id = item.ItemId
  6269. // project_id = 0
  6270. // }
  6271. //
  6272. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  6273. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  6274. // pric, _ := strconv.ParseFloat(item.Price, 32)
  6275. //
  6276. // info := &models.HisOrderInfo{
  6277. // OrderNumber: order.Number,
  6278. // UploadDate: time.Now().Unix(),
  6279. // AdviceId: advice_id,
  6280. // DetItemFeeSumamt: detItemFeeSumamt,
  6281. // Cnt: cut,
  6282. // Pric: pric,
  6283. // PatientId: id,
  6284. // Status: 1,
  6285. // Mtime: time.Now().Unix(),
  6286. // Ctime: time.Now().Unix(),
  6287. // UserOrgId: adminUser.CurrentOrgId,
  6288. // HisPatientId: his.ID,
  6289. // OrderId: order.ID,
  6290. // ProjectId: project_id,
  6291. // Type: types,
  6292. // ItemId: item_id,
  6293. // }
  6294. // service.CreateOrderInfo(info)
  6295. // }
  6296. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6297. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6298. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  6299. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6300. // if err == nil {
  6301. // c.ServeSuccessJSON(map[string]interface{}{
  6302. // "msg": "结算成功",
  6303. // })
  6304. // } else {
  6305. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6306. // return
  6307. // }
  6308. // }
  6309. //}
  6310. //上传明细-预结算-
  6311. func (c *HisApiController) GetPreUploadInfo() {
  6312. id, _ := c.GetInt64("id")
  6313. record_time := c.GetString("record_time")
  6314. his_patient_id, _ := c.GetInt64("his_patient_id")
  6315. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6316. admin_user_id, _ := c.GetInt64("admin_user_id")
  6317. diagnosis_id := c.GetString("diagnosis")
  6318. sick_type, _ := c.GetInt64("sick_type")
  6319. reg_type, _ := c.GetInt64("p_type")
  6320. begin_time := c.GetString("begin_time")
  6321. id_str := c.GetString("ids")
  6322. ids_arr := strings.Split(id_str, ",")
  6323. timeLayout := "2006-01-02"
  6324. loc, _ := time.LoadLocation("Local")
  6325. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6326. if err != nil {
  6327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6328. return
  6329. }
  6330. recordDateTime := theTime.Unix()
  6331. adminUser := c.GetAdminUserInfo()
  6332. diagnosis_ids := strings.Split(diagnosis_id, ",")
  6333. var config []*models.HisXtDiagnoseConfig
  6334. for _, item := range diagnosis_ids {
  6335. id, _ := strconv.ParseInt(item, 10, 64)
  6336. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6337. config = append(config, &diagnosisConfig)
  6338. }
  6339. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  6340. sickConfig, _ := service.FindSickById(sick_type)
  6341. var prescriptions []*models.HisPrescription
  6342. var start_time int64
  6343. var end_time int64
  6344. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6345. fmt.Println(his_patient_id)
  6346. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6347. timestamp := time.Now().Unix()
  6348. tempTime := time.Unix(timestamp, 0)
  6349. timeFormat := tempTime.Format("20060102150405")
  6350. chrgBchno := rand.Intn(100000) + 10000
  6351. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6352. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6353. var patientPrescription models.HisPrescriptionInfo
  6354. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6355. if patientPrescription.ID == 0 {
  6356. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6357. }
  6358. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6359. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6360. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6361. strconv.FormatInt(his.PatientId, 10)
  6362. var res2 ResultSix
  6363. var resSix10265 ResultSix10265
  6364. var time_stamp string
  6365. if miConfig.MdtrtareaAdmvs == "421300" {
  6366. data := make(map[string]interface{})
  6367. client := &http.Client{}
  6368. data["psn_no"] = his.PsnNo
  6369. data["mdtrt_id"] = his.Number
  6370. data["doctor"] = roles.UserName
  6371. data["department"] = department.Name
  6372. data["org_name"] = miConfig.OrgName
  6373. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6374. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6375. data["fixmedins_code"] = miConfig.Code
  6376. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6377. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6378. data["secret_key"] = miConfig.SecretKey
  6379. data["sick_code"] = sickConfig.CountryCode
  6380. data["sick_name"] = sickConfig.ClassName
  6381. data["begin_time"] = begin_time
  6382. data["dept"] = strconv.FormatInt(department.ID, 10)
  6383. data["config"] = config
  6384. fmt.Println(data)
  6385. bytesData, _ := json.Marshal(data)
  6386. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  6387. resp, _ := client.Do(req)
  6388. defer resp.Body.Close()
  6389. body, ioErr := ioutil.ReadAll(resp.Body)
  6390. if ioErr != nil {
  6391. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6393. return
  6394. }
  6395. var respJSON map[string]interface{}
  6396. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6397. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6399. return
  6400. }
  6401. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6402. userJSONBytes, _ := json.Marshal(respJSON)
  6403. fmt.Println("log")
  6404. fmt.Println(string(userJSONBytes))
  6405. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6406. utils.ErrorLog("解析失败:%v", err)
  6407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6408. return
  6409. }
  6410. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6411. //江苏地区国家医保医疗类别
  6412. //职工透析:医疗类别选特殊情况门诊9933
  6413. //居民血透门慢: 医疗类别选门诊慢病1402
  6414. //var med_type string
  6415. //if his.Insutype == "310" {
  6416. // if reg_type == 14 {
  6417. // med_type = "9933"
  6418. // } else if reg_type == 11 {
  6419. // med_type = "11"
  6420. //
  6421. // }
  6422. //} else if his.Insutype == "390" {
  6423. // if reg_type == 14 {
  6424. // med_type = "1402"
  6425. // } else if reg_type == 11 {
  6426. // med_type = "11"
  6427. // }
  6428. //}
  6429. data := make(map[string]interface{})
  6430. client := &http.Client{}
  6431. data["psn_no"] = his.PsnNo
  6432. data["mdtrt_id"] = his.Number
  6433. data["doctor"] = roles.UserName
  6434. data["department"] = department.Name
  6435. data["org_name"] = miConfig.OrgName
  6436. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6437. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6438. data["fixmedins_code"] = miConfig.Code
  6439. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6440. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6441. data["secret_key"] = miConfig.SecretKey
  6442. data["sick_code"] = sickConfig.CountryCode
  6443. data["sick_name"] = sickConfig.ClassName
  6444. data["begin_time"] = begin_time
  6445. data["dept"] = strconv.FormatInt(department.ID, 10)
  6446. data["config"] = config
  6447. data["url"] = miConfig.Url
  6448. data["ak"] = miConfig.AccessKey
  6449. data["cainfo"] = miConfig.Cainfo
  6450. bytesData, _ := json.Marshal(data)
  6451. var req *http.Request
  6452. if miConfig.MdtrtareaAdmvs == "320921" {
  6453. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6454. //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 +
  6455. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  6456. } else {
  6457. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6458. }
  6459. resp, _ := client.Do(req)
  6460. defer resp.Body.Close()
  6461. body, ioErr := ioutil.ReadAll(resp.Body)
  6462. if ioErr != nil {
  6463. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6465. return
  6466. }
  6467. var respJSON map[string]interface{}
  6468. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6469. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6471. return
  6472. }
  6473. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  6474. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  6475. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  6476. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6477. userJSONBytes, _ := json.Marshal(respJSON)
  6478. fmt.Println("log")
  6479. fmt.Println(string(userJSONBytes))
  6480. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6481. utils.ErrorLog("解析失败:%v", err)
  6482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6483. return
  6484. }
  6485. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6486. res2.Output = resSix10265.Output
  6487. res2.ErrMsg = resSix10265.ErrMsg
  6488. res2.Cainfo = resSix10265.Cainfo
  6489. res2.WarnMsg = resSix10265.WarnMsg
  6490. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6491. res2.Infcode = infocode
  6492. } else {
  6493. var result string
  6494. var requestLog string
  6495. if miConfig.MdtrtareaAdmvs == "440781" { //
  6496. 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)
  6497. } else {
  6498. if miConfig.Code == "H15049901371" {
  6499. //赤峰地区国家医保医疗类别
  6500. //职工透析:医疗类别选特殊情况门诊990502
  6501. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6502. var med_type string
  6503. if his.Insutype == "390" {
  6504. if reg_type == 14 {
  6505. med_type = "9933"
  6506. } else if reg_type == 11 {
  6507. med_type = "11"
  6508. }
  6509. } else if his.Insutype == "310" {
  6510. if reg_type == 14 {
  6511. med_type = "990502"
  6512. } else if reg_type == 11 {
  6513. med_type = "11"
  6514. }
  6515. }
  6516. 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)
  6517. } else {
  6518. 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)
  6519. }
  6520. saveLog(result, requestLog, "2203", "上传就诊信息")
  6521. var respJSON2 map[string]interface{}
  6522. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6523. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6525. return
  6526. }
  6527. userJSONBytes2, _ := json.Marshal(respJSON2)
  6528. if miConfig.Code == "H15049901371" {
  6529. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  6530. utils.ErrorLog("解析失败:%v", err)
  6531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6532. return
  6533. }
  6534. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6535. res2.Output = resSix10265.Output
  6536. res2.ErrMsg = resSix10265.ErrMsg
  6537. res2.Cainfo = resSix10265.Cainfo
  6538. res2.WarnMsg = resSix10265.WarnMsg
  6539. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6540. res2.Infcode = infocode
  6541. } else {
  6542. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  6543. utils.ErrorLog("解析失败:%v", err)
  6544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6545. return
  6546. }
  6547. }
  6548. }
  6549. }
  6550. if res2.Infcode != 0 {
  6551. adminUser := c.GetAdminUserInfo()
  6552. errlog := &models.HisOrderError{
  6553. UserOrgId: adminUser.CurrentOrgId,
  6554. Ctime: time.Now().Unix(),
  6555. Mtime: time.Now().Unix(),
  6556. ErrMsg: res2.ErrMsg,
  6557. Status: 1,
  6558. PatientId: id,
  6559. RecordTime: recordDateTime,
  6560. Stage: 3,
  6561. }
  6562. service.CreateErrMsgLog(errlog)
  6563. c.ServeSuccessJSON(map[string]interface{}{
  6564. "failed_code": -10,
  6565. "msg": res2.ErrMsg,
  6566. })
  6567. return
  6568. } else {
  6569. his.Diagnosis = diagnosis_id
  6570. his.SickType = sickConfig.ID
  6571. his.PType = fmt.Sprintf("%d", reg_type)
  6572. service.UpdateHisPatientThree(&his)
  6573. data := make(map[string]interface{})
  6574. if settle_accounts_type == 1 { //日结
  6575. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  6576. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  6577. } else {
  6578. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  6579. }
  6580. data["pre"] = prescriptions
  6581. } else { //月结
  6582. start_time_str := c.GetString("start_time")
  6583. end_time_str := c.GetString("end_time")
  6584. timeLayout := "2006-01-02"
  6585. loc, _ := time.LoadLocation("Local")
  6586. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6587. if err != nil {
  6588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6589. return
  6590. }
  6591. recordStartTime := theStartTime.Unix()
  6592. start_time = recordStartTime
  6593. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6594. if err != nil {
  6595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6596. return
  6597. }
  6598. recordEndTime := theEndTime.Unix()
  6599. end_time = recordEndTime
  6600. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  6601. data["pre"] = prescriptions
  6602. }
  6603. client := &http.Client{}
  6604. data["psn_no"] = his.PsnNo
  6605. data["mdtrt_id"] = his.Number
  6606. data["chrg_bchno"] = chrg_bchno
  6607. data["org_name"] = miConfig.OrgName
  6608. data["doctor"] = roles.UserName
  6609. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6610. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6611. data["fixmedins_code"] = miConfig.Code
  6612. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  6613. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  6614. data["dept_code"] = "15"
  6615. } else {
  6616. data["dept_code"] = department.Number
  6617. }
  6618. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6619. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6620. data["secret_key"] = miConfig.SecretKey
  6621. data["url"] = miConfig.Url
  6622. data["ak"] = miConfig.AccessKey
  6623. data["new_doctor_name"] = patientPrescription.Doctor
  6624. data["diag_code"] = sickConfig.CountryCode
  6625. data["time_stamp"] = time_stamp
  6626. data["cainfo"] = miConfig.Cainfo
  6627. var ids []int64
  6628. for _, item := range prescriptions {
  6629. ids = append(ids, item.ID)
  6630. }
  6631. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6632. if config.IsOpen == 1 { //对接了医保,走医保流程
  6633. var res ResultFour
  6634. var resFour10265 ResultFour10265
  6635. if miConfig.MdtrtareaAdmvs == "421300" {
  6636. bytesData, _ := json.Marshal(data)
  6637. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  6638. resp, _ := client.Do(req)
  6639. defer resp.Body.Close()
  6640. body, ioErr := ioutil.ReadAll(resp.Body)
  6641. if ioErr != nil {
  6642. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6644. return
  6645. }
  6646. var respJSON map[string]interface{}
  6647. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6648. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6650. return
  6651. }
  6652. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6653. userJSONBytes, _ := json.Marshal(respJSON)
  6654. fmt.Println("log")
  6655. fmt.Println(string(userJSONBytes))
  6656. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6657. utils.ErrorLog("解析失败:%v", err)
  6658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6659. return
  6660. }
  6661. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6662. bytesData, _ := json.Marshal(data)
  6663. var req *http.Request
  6664. if miConfig.MdtrtareaAdmvs == "320921" {
  6665. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6666. } else {
  6667. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6668. }
  6669. resp, _ := client.Do(req)
  6670. defer resp.Body.Close()
  6671. body, ioErr := ioutil.ReadAll(resp.Body)
  6672. if ioErr != nil {
  6673. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6675. return
  6676. }
  6677. var respJSON map[string]interface{}
  6678. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6679. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6681. return
  6682. }
  6683. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6684. userJSONBytes, _ := json.Marshal(respJSON)
  6685. fmt.Println("log")
  6686. fmt.Println(string(userJSONBytes))
  6687. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6688. utils.ErrorLog("解析失败:%v", err)
  6689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6690. return
  6691. }
  6692. res.InfRefmsgid = resFour10265.InfRefmsgid
  6693. res.Output = resFour10265.Output
  6694. res.ErrMsg = resFour10265.ErrMsg
  6695. res.Cainfo = resFour10265.Cainfo
  6696. res.WarnMsg = resFour10265.WarnMsg
  6697. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6698. res.Infcode = infocode
  6699. } else {
  6700. if miConfig.Code == "H15049901371" {
  6701. 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)
  6702. var dat map[string]interface{}
  6703. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6704. fmt.Println(dat)
  6705. } else {
  6706. fmt.Println(err)
  6707. }
  6708. saveLog(result, request_log, "2204", "上传费用明细")
  6709. userJSONBytes, _ := json.Marshal(dat)
  6710. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6711. utils.ErrorLog("解析失败:%v", err)
  6712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6713. return
  6714. }
  6715. res.InfRefmsgid = resFour10265.InfRefmsgid
  6716. res.Output = resFour10265.Output
  6717. res.ErrMsg = resFour10265.ErrMsg
  6718. res.Cainfo = resFour10265.Cainfo
  6719. res.WarnMsg = resFour10265.WarnMsg
  6720. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6721. res.Infcode = infocode
  6722. } else {
  6723. 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)
  6724. var dat map[string]interface{}
  6725. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6726. fmt.Println(dat)
  6727. } else {
  6728. fmt.Println(err)
  6729. }
  6730. saveLog(result, request_log, "2204", "上传费用明细")
  6731. userJSONBytes, _ := json.Marshal(dat)
  6732. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6733. utils.ErrorLog("解析失败:%v", err)
  6734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6735. return
  6736. }
  6737. }
  6738. }
  6739. if res.Infcode == 0 {
  6740. order := &models.HisOrder{
  6741. UserOrgId: adminUser.CurrentOrgId,
  6742. HisPatientId: his.ID,
  6743. PatientId: his.PatientId,
  6744. SettleAccountsDate: recordDateTime,
  6745. Ctime: time.Now().Unix(),
  6746. Mtime: time.Now().Unix(),
  6747. MdtrtId: his.Number,
  6748. PsnNo: his.PsnNo,
  6749. MedType: strconv.FormatInt(reg_type, 10),
  6750. Status: 1,
  6751. Number: chrg_bchno,
  6752. Infcode: res.Infcode,
  6753. WarnMsg: res.WarnMsg,
  6754. Cainfo: res.Cainfo,
  6755. ErrMsg: res.ErrMsg,
  6756. RespondTime: res.RefmsgTime,
  6757. InfRefmsgid: res.InfRefmsgid,
  6758. OrderStatus: 1,
  6759. IsMedicineInsurance: 1,
  6760. SettleType: settle_accounts_type,
  6761. SettleStartTime: start_time,
  6762. SettleEndTime: end_time,
  6763. Creator: roles.AdminUserId,
  6764. Modify: roles.AdminUserId,
  6765. PType: 2,
  6766. Diagnosis: diagnosis_id,
  6767. }
  6768. err = service.CreateOrder(order)
  6769. if err != nil {
  6770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6771. return
  6772. }
  6773. for _, item := range res.Output.Result {
  6774. temp := strings.Split(item.FeedetlSn, "-")
  6775. var advice_id int64 = 0
  6776. var project_id int64 = 0
  6777. var types int64 = 0
  6778. id, _ := strconv.ParseInt(temp[2], 10, 64)
  6779. types, _ = strconv.ParseInt(temp[1], 10, 64)
  6780. if temp[1] == "1" {
  6781. advice_id = id
  6782. project_id = 0
  6783. } else if temp[1] == "2" {
  6784. advice_id = 0
  6785. project_id = id
  6786. }
  6787. info := &models.HisOrderInfo{
  6788. OrderNumber: order.Number,
  6789. FeedetlSn: item.FeedetlSn,
  6790. UploadDate: time.Now().Unix(),
  6791. AdviceId: advice_id,
  6792. DetItemFeeSumamt: item.DetItemFeeSumamt,
  6793. Cnt: item.Cnt,
  6794. Pric: float64(item.Pric),
  6795. PatientId: his.PatientId,
  6796. PricUplmtAmt: item.PricUplmtAmt,
  6797. SelfpayProp: item.SelfpayProp,
  6798. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6799. OverlmtAmt: item.OverlmtAmt,
  6800. PreselfpayAmt: item.PreselfpayAmt,
  6801. BasMednFlag: item.BasMednFlag,
  6802. MedChrgitmType: item.MedChrgitmType,
  6803. HiNegoDrugFlag: item.HiNegoDrugFlag,
  6804. Status: 1,
  6805. Memo: item.Memo,
  6806. Mtime: time.Now().Unix(),
  6807. InscpScpAmt: item.InscpScpAmt,
  6808. DrtReimFlag: item.DrtReimFlag,
  6809. Ctime: time.Now().Unix(),
  6810. ListSpItemFlag: item.ListSpItemFlag,
  6811. ChldMedcFlag: item.ChldMedcFlag,
  6812. LmtUsedFlag: item.LmtUsedFlag,
  6813. ChrgitmLv: item.ChrgitmLv,
  6814. UserOrgId: adminUser.CurrentOrgId,
  6815. HisPatientId: his.ID,
  6816. OrderId: order.ID,
  6817. ProjectId: project_id,
  6818. Type: types,
  6819. }
  6820. service.CreateOrderInfo(info)
  6821. }
  6822. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6823. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  6824. var total float64
  6825. for _, item := range prescriptions {
  6826. if item.Type == 1 { //药品
  6827. for _, subItem := range item.HisDoctorAdviceInfo {
  6828. total = total + (subItem.Price * subItem.PrescribingNumber)
  6829. }
  6830. }
  6831. if item.Type == 2 { //项目
  6832. for _, subItem := range item.HisPrescriptionProject {
  6833. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6834. total = total + (subItem.Price * cnt)
  6835. }
  6836. }
  6837. }
  6838. for _, item := range prescriptions {
  6839. for _, subItem := range item.HisAdditionalCharge {
  6840. total = total + (subItem.Price * float64(subItem.Count))
  6841. }
  6842. }
  6843. allTotal := fmt.Sprintf("%.4f", total)
  6844. if res.Infcode == 0 {
  6845. var rf []*ResultFive
  6846. json.Unmarshal([]byte(his.Iinfo), &rf)
  6847. chrg_bchno := chrg_bchno
  6848. cert_no := his.Certno
  6849. var insutypes []string
  6850. var insutype string
  6851. var is390 int = 0
  6852. var is310 int = 0
  6853. for _, item := range rf {
  6854. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6855. insutypes = append(insutypes, item.Insutype)
  6856. }
  6857. }
  6858. if len(insutypes) == 1 {
  6859. insutype = insutypes[0]
  6860. } else {
  6861. for _, i := range insutypes {
  6862. if i == "390" {
  6863. is390 = 1
  6864. }
  6865. if i == "310" {
  6866. is310 = 1
  6867. }
  6868. }
  6869. }
  6870. if is390 == 1 {
  6871. insutype = "390"
  6872. }
  6873. if is310 == 1 {
  6874. insutype = "310"
  6875. }
  6876. if len(insutypes) == 0 {
  6877. insutype = "310"
  6878. }
  6879. if len(insutypes) == 2 {
  6880. insutype = strconv.FormatInt(his.SocialType, 64)
  6881. }
  6882. //insutype = "390"
  6883. if his.IdCardType == 1 {
  6884. cert_no = his.MedicalInsuranceNumber
  6885. } else {
  6886. cert_no = his.Certno
  6887. }
  6888. var res ResultSeven
  6889. var resSeven10265 ResultSeven10265
  6890. if miConfig.MdtrtareaAdmvs == "421300" {
  6891. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6892. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6893. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6894. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6895. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6896. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6897. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  6898. resp, requestErr := http.Get(api)
  6899. if requestErr != nil {
  6900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6901. return
  6902. }
  6903. body, ioErr := ioutil.ReadAll(resp.Body)
  6904. if ioErr != nil {
  6905. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6907. return
  6908. }
  6909. var respJSON map[string]interface{}
  6910. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6911. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6913. return
  6914. }
  6915. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6916. result, _ := json.Marshal(respJSON)
  6917. fmt.Println("log")
  6918. fmt.Println(string(result))
  6919. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6920. utils.ErrorLog("解析失败:%v", err)
  6921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6922. return
  6923. }
  6924. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6925. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6926. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6927. bas := strings.Split(psn_info.CardInfo, "|")
  6928. if his.IdCardType == 1 {
  6929. cert_no = bas[2]
  6930. } else {
  6931. cert_no = bas[1]
  6932. }
  6933. //江苏地区国家医保医疗类别
  6934. //职工透析:医疗类别选特殊情况门诊9933
  6935. //居民血透门慢: 医疗类别选门诊慢病1402
  6936. //var med_type string
  6937. //if his.Insutype == "310" {
  6938. // if reg_type == 14 {
  6939. // med_type = "9933"
  6940. // } else if reg_type == 11 {
  6941. // med_type = "11"
  6942. //
  6943. // }
  6944. //} else if his.Insutype == "390" {
  6945. // if reg_type == 14 {
  6946. // med_type = "1402"
  6947. // } else if reg_type == 11 {
  6948. // med_type = "11"
  6949. // }
  6950. //}
  6951. var api string
  6952. if miConfig.MdtrtareaAdmvs == "320921" {
  6953. api = "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6954. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6955. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6956. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6957. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6958. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6959. "&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
  6960. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6961. } else {
  6962. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6963. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6964. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6965. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6966. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6967. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6968. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6969. "&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
  6970. }
  6971. resp, requestErr := http.Get(api)
  6972. if requestErr != nil {
  6973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6974. return
  6975. }
  6976. body, ioErr := ioutil.ReadAll(resp.Body)
  6977. if ioErr != nil {
  6978. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6980. return
  6981. }
  6982. var respJSON map[string]interface{}
  6983. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6984. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6986. return
  6987. }
  6988. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6989. result, _ := json.Marshal(respJSON)
  6990. fmt.Println("log")
  6991. fmt.Println(string(result))
  6992. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6993. utils.ErrorLog("解析失败:%v", err)
  6994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6995. return
  6996. }
  6997. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6998. res.Output = resSeven10265.Output
  6999. res.ErrMsg = resSeven10265.ErrMsg
  7000. res.Cainfo = resSeven10265.Cainfo
  7001. res.WarnMsg = resSeven10265.WarnMsg
  7002. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7003. res.Infcode = infocode
  7004. } else {
  7005. var result string
  7006. var request_log string
  7007. if miConfig.Code == "H15049901371" {
  7008. //赤峰地区国家医保医疗类别
  7009. //职工透析:医疗类别选特殊情况门诊990502
  7010. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7011. var med_type string
  7012. if his.Insutype == "390" {
  7013. if reg_type == 14 {
  7014. med_type = "9933"
  7015. } else if reg_type == 11 {
  7016. med_type = "11"
  7017. }
  7018. } else if his.Insutype == "310" {
  7019. if reg_type == 14 {
  7020. med_type = "990502"
  7021. } else if reg_type == 11 {
  7022. med_type = "11"
  7023. }
  7024. }
  7025. 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)
  7026. } else {
  7027. 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)
  7028. }
  7029. var dat map[string]interface{}
  7030. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7031. fmt.Println(dat)
  7032. } else {
  7033. fmt.Println(err)
  7034. }
  7035. saveLog(result, request_log, "2206", "预结算")
  7036. //userJSONBytes, _ := json.Marshal(dat)
  7037. //
  7038. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7039. // utils.ErrorLog("解析失败:%v", err)
  7040. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7041. // return
  7042. //}
  7043. userJSONBytes, _ := json.Marshal(dat)
  7044. if miConfig.Code == "H15049901371" {
  7045. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7046. utils.ErrorLog("解析失败:%v", err)
  7047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7048. return
  7049. }
  7050. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7051. res.Output = resSeven10265.Output
  7052. res.ErrMsg = resSeven10265.ErrMsg
  7053. res.Cainfo = resSeven10265.Cainfo
  7054. res.WarnMsg = resSeven10265.WarnMsg
  7055. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7056. res.Infcode = infocode
  7057. } else {
  7058. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7059. utils.ErrorLog("解析失败:%v", err)
  7060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7061. return
  7062. }
  7063. }
  7064. }
  7065. if res.Infcode != 0 {
  7066. errlog := &models.HisOrderError{
  7067. UserOrgId: adminUser.CurrentOrgId,
  7068. Ctime: time.Now().Unix(),
  7069. Mtime: time.Now().Unix(),
  7070. Number: chrg_bchno,
  7071. ErrMsg: res.ErrMsg,
  7072. Status: 1,
  7073. PatientId: id,
  7074. RecordTime: recordDateTime,
  7075. Stage: 20,
  7076. }
  7077. service.CreateErrMsgLog(errlog)
  7078. c.ServeSuccessJSON(map[string]interface{}{
  7079. "failed_code": -10,
  7080. "msg": res.ErrMsg,
  7081. })
  7082. return
  7083. } else {
  7084. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7085. order.OrderStatus = 1
  7086. order.IsPre = 1
  7087. order.Status = 1
  7088. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7089. order.SetlId = res.Output.Setlinfo.SetlID
  7090. order.PsnNo = res.Output.Setlinfo.PsnNo
  7091. order.PsnName = res.Output.Setlinfo.PsnName
  7092. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7093. order.Certno = res.Output.Setlinfo.Certno
  7094. order.Gend = res.Output.Setlinfo.Gend
  7095. order.Naty = res.Output.Setlinfo.Naty
  7096. order.Age = res.Output.Setlinfo.Age
  7097. order.Insutype = res.Output.Setlinfo.Insutype
  7098. order.PsnType = res.Output.Setlinfo.PsnType
  7099. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7100. order.SetlTime = res.Output.Setlinfo.SetlTime
  7101. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7102. if res.Output.Setlinfo.MedType == "140101" {
  7103. order.MedType = "14"
  7104. } else {
  7105. order.MedType = res.Output.Setlinfo.MedType
  7106. }
  7107. if reg_type == 1112 {
  7108. order.MedType = "1112"
  7109. }
  7110. if reg_type == 1111 {
  7111. order.MedType = "1111"
  7112. }
  7113. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7114. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7115. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7116. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7117. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7118. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7119. order.HifpPay = res.Output.Setlinfo.HifpPay
  7120. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7121. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7122. order.HifesPay = res.Output.Setlinfo.HifesPay
  7123. order.HifobPay = res.Output.Setlinfo.HifobPay
  7124. order.MafPay = res.Output.Setlinfo.MafPay
  7125. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  7126. order.OthPay = res.Output.Setlinfo.OthPay
  7127. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7128. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7129. order.AcctPay = res.Output.Setlinfo.AcctPay
  7130. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7131. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7132. order.Balc = res.Output.Setlinfo.Balc
  7133. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7134. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7135. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7136. order.ClrWay = res.Output.Setlinfo.ClrWay
  7137. order.Creator = order.Creator
  7138. order.Modify = roles.AdminUserId
  7139. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7140. detailStr := string(setlDetail)
  7141. order.SetlDetail = detailStr
  7142. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7143. err = service.UpDateOrder(order)
  7144. if err == nil {
  7145. c.ServeSuccessJSON(map[string]interface{}{
  7146. "msg": "预结算成功",
  7147. })
  7148. } else {
  7149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7150. return
  7151. }
  7152. }
  7153. } else {
  7154. adminUser := c.GetAdminUserInfo()
  7155. errlog := &models.HisOrderError{
  7156. UserOrgId: adminUser.CurrentOrgId,
  7157. Ctime: time.Now().Unix(),
  7158. Mtime: time.Now().Unix(),
  7159. ErrMsg: res.ErrMsg,
  7160. Status: 1,
  7161. PatientId: id,
  7162. RecordTime: recordDateTime,
  7163. Stage: 4,
  7164. }
  7165. service.CreateErrMsgLog(errlog)
  7166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7167. return
  7168. }
  7169. } else {
  7170. adminUser := c.GetAdminUserInfo()
  7171. errlog := &models.HisOrderError{
  7172. UserOrgId: adminUser.CurrentOrgId,
  7173. Ctime: time.Now().Unix(),
  7174. Mtime: time.Now().Unix(),
  7175. ErrMsg: res.ErrMsg,
  7176. Status: 1,
  7177. PatientId: id,
  7178. RecordTime: recordDateTime,
  7179. Stage: 4,
  7180. }
  7181. service.CreateErrMsgLog(errlog)
  7182. c.ServeSuccessJSON(map[string]interface{}{
  7183. "failed_code": -10,
  7184. "msg": res.ErrMsg,
  7185. })
  7186. return
  7187. }
  7188. }
  7189. }
  7190. }
  7191. //func (c *HisApiController) GetSettleInfo() {
  7192. // id, _ := c.GetInt64("id")
  7193. // order_id, _ := c.GetInt64("order_id")
  7194. //
  7195. // record_time := c.GetString("record_time")
  7196. // pay_way, _ := c.GetInt64("pay_way")
  7197. // pay_price, _ := c.GetFloat("pay_price")
  7198. // pay_card_no := c.GetString("pay_card_no")
  7199. // discount_price, _ := c.GetFloat("discount_price")
  7200. // preferential_price, _ := c.GetFloat("preferential_price")
  7201. // reality_price, _ := c.GetFloat("reality_price")
  7202. // found_price, _ := c.GetFloat("found_price")
  7203. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  7204. // private_price, _ := c.GetFloat("private_price")
  7205. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7206. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7207. //
  7208. // timeLayout := "2006-01-02"
  7209. // loc, _ := time.LoadLocation("Local")
  7210. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7211. // if err != nil {
  7212. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7213. // return
  7214. // }
  7215. // recordDateTime := theTime.Unix()
  7216. // adminUser := c.GetAdminUserInfo()
  7217. //
  7218. // var prescriptions []*models.HisPrescription
  7219. //
  7220. // data := make(map[string]interface{})
  7221. // if settle_accounts_type == 1 { //日结
  7222. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  7223. // data["pre"] = prescriptions
  7224. //
  7225. // } else { //月结
  7226. // start_time_str := c.GetString("start_time")
  7227. // end_time_str := c.GetString("end_time")
  7228. // timeLayout := "2006-01-02"
  7229. // loc, _ := time.LoadLocation("Local")
  7230. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7231. // if err != nil {
  7232. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7233. // return
  7234. // }
  7235. // recordStartTime := theStartTime.Unix()
  7236. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7237. // if err != nil {
  7238. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7239. // return
  7240. // }
  7241. // recordEndTime := theEndTime.Unix()
  7242. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  7243. // data["pre"] = prescriptions
  7244. //
  7245. // }
  7246. //
  7247. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7248. //
  7249. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7250. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7251. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7252. // strconv.FormatInt(his.PatientId, 10)
  7253. //
  7254. // order_src, _ := service.GetHisOrderByID(order_id)
  7255. //
  7256. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7257. // if config.IsOpen == 1 { //对接了医保,走医保流程
  7258. //
  7259. // var total float64
  7260. // for _, item := range prescriptions {
  7261. // if item.Type == 1 { //药品
  7262. // for _, subItem := range item.HisDoctorAdviceInfo {
  7263. // total = total + (subItem.Price * subItem.PrescribingNumber)
  7264. // }
  7265. // }
  7266. // if item.Type == 2 { //项目
  7267. // for _, subItem := range item.HisPrescriptionProject {
  7268. // total = total + (subItem.Price * float64(subItem.Count))
  7269. // }
  7270. // }
  7271. // }
  7272. //
  7273. // for _, item := range prescriptions {
  7274. // for _, subItem := range item.HisAdditionalCharge {
  7275. // total = total + (subItem.Price * float64(subItem.Count))
  7276. // }
  7277. // }
  7278. //
  7279. // allTotal := fmt.Sprintf("%.2f", total)
  7280. // var rf []*ResultFive
  7281. // json.Unmarshal([]byte(his.Iinfo), &rf)
  7282. // psn_no := order_src.PsnNo
  7283. // mdtrt_id := order_src.MdtrtId
  7284. // chrg_bchno := order_src.Number
  7285. // cert_no := order_src.Certno
  7286. // insutype := rf[0].Insutype
  7287. //
  7288. // if his.IdCardType == 1 {
  7289. // cert_no = his.MedicalInsuranceNumber
  7290. // } else {
  7291. // cert_no = his.Certno
  7292. // }
  7293. //
  7294. // 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)
  7295. // var dat map[string]interface{}
  7296. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7297. // fmt.Println(dat)
  7298. // } else {
  7299. // fmt.Println(err)
  7300. // }
  7301. //
  7302. // userJSONBytes, _ := json.Marshal(dat)
  7303. //
  7304. //
  7305. //
  7306. // var res ResultSeven
  7307. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7308. // utils.ErrorLog("解析失败:%v", err)
  7309. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7310. // return
  7311. // }
  7312. // if res.Infcode == -1 {
  7313. // errlog := &models.HisOrderError{
  7314. // UserOrgId: adminUser.CurrentOrgId,
  7315. // Ctime: time.Now().Unix(),
  7316. // Mtime: time.Now().Unix(),
  7317. // Number: chrg_bchno,
  7318. // ErrMsg: res.ErrMsg,
  7319. // Status: 1,
  7320. // PatientId: id,
  7321. // RecordTime: recordDateTime,
  7322. // Stage: 6,
  7323. // }
  7324. // service.CreateErrMsgLog(errlog)
  7325. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7326. // return
  7327. // } else {
  7328. // order_src.OrderStatus = 2
  7329. // order_src.PayWay = pay_way
  7330. // order_src.PayPrice = pay_price
  7331. // order_src.PayCardNo = pay_card_no
  7332. // order_src.DiscountPrice = discount_price
  7333. // order_src.PreferentialPrice = preferential_price
  7334. // order_src.RealityPrice = reality_price
  7335. // order_src.FoundPrice = found_price
  7336. // order_src.MedicalInsurancePrice = medical_insurance_price
  7337. // order_src.PrivatePrice = private_price
  7338. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  7339. // order_src.SetlId = res.Output.Setlinfo.SetlID
  7340. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  7341. // order_src.PsnName = res.Output.Setlinfo.PsnName
  7342. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  7343. // order_src.Certno = res.Output.Setlinfo.Certno
  7344. // order_src.Gend = res.Output.Setlinfo.Gend
  7345. // order_src.Naty = res.Output.Setlinfo.Naty
  7346. // order_src.Age = res.Output.Setlinfo.Age
  7347. // order_src.Insutype = res.Output.Setlinfo.Insutype
  7348. // order_src.PsnType = res.Output.Setlinfo.PsnType
  7349. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7350. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  7351. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7352. // order_src.MedType = res.Output.Setlinfo.MedType
  7353. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7354. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7355. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7356. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7357. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7358. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7359. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  7360. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  7361. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7362. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  7363. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  7364. // order_src.MafPay = res.Output.Setlinfo.MafPay
  7365. // order_src.OthPay = res.Output.Setlinfo.OthPay
  7366. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7367. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7368. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  7369. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7370. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7371. // order_src.Balc = res.Output.Setlinfo.Balc
  7372. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7373. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7374. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  7375. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  7376. // order_src.Creator = order_src.Creator
  7377. // order_src.Modify = roles.ID
  7378. // order_src.RequestLog = src_resquest
  7379. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7380. // detailStr := string(setlDetail)
  7381. // order_src.SetlDetail = detailStr
  7382. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7383. // err = service.UpDateOrder(order_src)
  7384. //
  7385. // if err == nil {
  7386. // c.ServeSuccessJSON(map[string]interface{}{
  7387. // "msg": "结算成功",
  7388. // })
  7389. // } else {
  7390. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7391. // return
  7392. // }
  7393. // }
  7394. // }
  7395. //}
  7396. //退款
  7397. func (c *HisApiController) Refund() {
  7398. order_id, _ := c.GetInt64("order_id")
  7399. admin_user_id, _ := c.GetInt64("admin_user_id")
  7400. adminUser := c.GetAdminUserInfo()
  7401. var order models.HisOrder
  7402. order, _ = service.GetHisOrderByID(order_id)
  7403. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7404. if order.ID == 0 {
  7405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7406. return
  7407. }
  7408. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7409. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7410. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7411. if config.IsOpen == 1 { //对接了医保,走医保流程
  7412. var res ResultSixteen
  7413. var resSixteen10265 ResultSixteen10265
  7414. var src_resquest string
  7415. var result string
  7416. if miConfig.MdtrtareaAdmvs == "421300" {
  7417. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  7418. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7419. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7420. resp3, requestErr3 := http.Get(api3)
  7421. if requestErr3 != nil {
  7422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7423. return
  7424. }
  7425. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7426. if ioErr3 != nil {
  7427. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7429. return
  7430. }
  7431. var respJSON3 map[string]interface{}
  7432. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7433. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7435. return
  7436. }
  7437. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7438. userJSONBytes3, _ := json.Marshal(respJSON3)
  7439. fmt.Println("log")
  7440. fmt.Println(string(userJSONBytes3))
  7441. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  7442. utils.ErrorLog("解析失败:%v", err)
  7443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7444. return
  7445. }
  7446. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7447. var api3 string
  7448. if miConfig.MdtrtareaAdmvs == "320921" {
  7449. api3 = "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7450. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7451. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7452. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7453. } else {
  7454. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7455. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7456. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7457. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7458. }
  7459. resp3, requestErr3 := http.Get(api3)
  7460. if requestErr3 != nil {
  7461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7462. return
  7463. }
  7464. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7465. if ioErr3 != nil {
  7466. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7468. return
  7469. }
  7470. var respJSON3 map[string]interface{}
  7471. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7472. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7474. return
  7475. }
  7476. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7477. userJSONBytes3, _ := json.Marshal(respJSON3)
  7478. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  7479. utils.ErrorLog("解析失败:%v", err)
  7480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7481. return
  7482. }
  7483. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7484. res.Output = resSixteen10265.Output
  7485. res.ErrMsg = resSixteen10265.ErrMsg
  7486. res.Cainfo = resSixteen10265.Cainfo
  7487. res.WarnMsg = resSixteen10265.WarnMsg
  7488. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7489. res.Infcode = infocode
  7490. } else {
  7491. if miConfig.Code == "H15049901371" {
  7492. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7493. var dat map[string]interface{}
  7494. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7495. fmt.Println(dat)
  7496. } else {
  7497. fmt.Println(err)
  7498. }
  7499. saveLog(result, src_resquest, "2208", "退费")
  7500. userJSONBytes, _ := json.Marshal(dat)
  7501. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  7502. utils.ErrorLog("解析失败:%v", err)
  7503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7504. return
  7505. }
  7506. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7507. res.Output = resSixteen10265.Output
  7508. res.ErrMsg = resSixteen10265.ErrMsg
  7509. res.Cainfo = resSixteen10265.Cainfo
  7510. res.WarnMsg = resSixteen10265.WarnMsg
  7511. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7512. res.Infcode = infocode
  7513. } else {
  7514. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7515. var dat map[string]interface{}
  7516. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7517. fmt.Println(dat)
  7518. } else {
  7519. fmt.Println(err)
  7520. }
  7521. saveLog(result, src_resquest, "2208", "退费")
  7522. userJSONBytes, _ := json.Marshal(dat)
  7523. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7524. utils.ErrorLog("解析失败:%v", err)
  7525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7526. return
  7527. }
  7528. }
  7529. }
  7530. if res.Infcode == 0 {
  7531. var res2 ResultSix
  7532. var resSix10265 ResultSix10265
  7533. if miConfig.MdtrtareaAdmvs == "421300" {
  7534. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7535. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7536. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7537. resp3, requestErr3 := http.Get(api3)
  7538. if requestErr3 != nil {
  7539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7540. return
  7541. }
  7542. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7543. if ioErr3 != nil {
  7544. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7546. return
  7547. }
  7548. var respJSON3 map[string]interface{}
  7549. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7550. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7552. return
  7553. }
  7554. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7555. userJSONBytes3, _ := json.Marshal(respJSON3)
  7556. fmt.Println("log")
  7557. fmt.Println(string(userJSONBytes3))
  7558. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7559. utils.ErrorLog("解析失败:%v", err)
  7560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7561. return
  7562. }
  7563. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7564. var api3 string
  7565. if miConfig.MdtrtareaAdmvs == "320921" {
  7566. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7567. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7568. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7569. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7570. } else {
  7571. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7572. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7573. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7574. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7575. }
  7576. resp3, requestErr3 := http.Get(api3)
  7577. if requestErr3 != nil {
  7578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7579. return
  7580. }
  7581. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7582. if ioErr3 != nil {
  7583. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7585. return
  7586. }
  7587. var respJSON3 map[string]interface{}
  7588. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7589. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7591. return
  7592. }
  7593. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7594. userJSONBytes3, _ := json.Marshal(respJSON3)
  7595. fmt.Println("log")
  7596. fmt.Println(string(userJSONBytes3))
  7597. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7598. utils.ErrorLog("解析失败:%v", err)
  7599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7600. return
  7601. }
  7602. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7603. res2.Output = resSix10265.Output
  7604. res2.ErrMsg = resSix10265.ErrMsg
  7605. res2.Cainfo = resSix10265.Cainfo
  7606. res2.WarnMsg = resSix10265.WarnMsg
  7607. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7608. res2.Infcode = infocode
  7609. } else {
  7610. if miConfig.Code == "H15049901371" {
  7611. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7612. var dat map[string]interface{}
  7613. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7614. fmt.Println(dat)
  7615. } else {
  7616. fmt.Println(err)
  7617. }
  7618. saveLog(result2, src_request, "2205", "撤销明细")
  7619. userJSONBytes, _ := json.Marshal(dat)
  7620. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7621. utils.ErrorLog("解析失败:%v", err)
  7622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7623. return
  7624. }
  7625. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7626. res2.Output = resSix10265.Output
  7627. res2.ErrMsg = resSix10265.ErrMsg
  7628. res2.Cainfo = resSix10265.Cainfo
  7629. res2.WarnMsg = resSix10265.WarnMsg
  7630. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7631. res2.Infcode = infocode
  7632. } else {
  7633. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7634. var dat map[string]interface{}
  7635. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7636. fmt.Println(dat)
  7637. } else {
  7638. fmt.Println(err)
  7639. }
  7640. saveLog(result2, src_request, "2205", "撤销明细")
  7641. userJSONBytes, _ := json.Marshal(dat)
  7642. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7643. utils.ErrorLog("解析失败:%v", err)
  7644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7645. return
  7646. }
  7647. }
  7648. }
  7649. if res2.Infcode == 0 {
  7650. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  7651. if err == nil {
  7652. c.ServeSuccessJSON(map[string]interface{}{
  7653. "msg": "退费成功",
  7654. })
  7655. } else {
  7656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7657. return
  7658. }
  7659. } else {
  7660. c.ServeSuccessJSON(map[string]interface{}{
  7661. "code": -10,
  7662. "msg": res2.ErrMsg,
  7663. })
  7664. }
  7665. } else {
  7666. c.ServeSuccessJSON(map[string]interface{}{
  7667. "code": -10,
  7668. "msg": res.ErrMsg,
  7669. })
  7670. }
  7671. }
  7672. }
  7673. func (c *HisApiController) RefundNumber() {
  7674. record_time := c.GetString("record_time")
  7675. //patient_id, _ := c.GetInt64("patient_id")
  7676. admin_user_id, _ := c.GetInt64("admin_user_id")
  7677. his_patient_id, _ := c.GetInt64("id")
  7678. timeLayout := "2006-01-02"
  7679. loc, _ := time.LoadLocation("Local")
  7680. adminUser := c.GetAdminUserInfo()
  7681. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7682. fmt.Println(err)
  7683. if err != nil {
  7684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7685. return
  7686. }
  7687. recordDateTime := theTime.Unix()
  7688. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7689. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  7690. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7691. //order, _ := service.GetHisOrderByID(order_id)
  7692. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7693. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7694. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7695. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  7696. if count > 0 {
  7697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  7698. return
  7699. }
  7700. if config.IsOpen == 1 { //对接了医保,走医保流程
  7701. var res2 ResultSix
  7702. var resSix10265 ResultSix10265
  7703. if miConfig.MdtrtareaAdmvs == "421300" {
  7704. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  7705. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7706. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7707. resp3, requestErr3 := http.Get(api3)
  7708. if requestErr3 != nil {
  7709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7710. return
  7711. }
  7712. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7713. if ioErr3 != nil {
  7714. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7716. return
  7717. }
  7718. var respJSON3 map[string]interface{}
  7719. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7720. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7722. return
  7723. }
  7724. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7725. userJSONBytes3, _ := json.Marshal(respJSON3)
  7726. fmt.Println("log")
  7727. fmt.Println(string(userJSONBytes3))
  7728. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7729. utils.ErrorLog("解析失败:%v", err)
  7730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7731. return
  7732. }
  7733. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7734. var api3 string
  7735. if miConfig.MdtrtareaAdmvs == "320921" {
  7736. api3 = "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  7737. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7738. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7739. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7740. } else {
  7741. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7742. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  7743. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7744. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7745. }
  7746. resp3, requestErr3 := http.Get(api3)
  7747. if requestErr3 != nil {
  7748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7749. return
  7750. }
  7751. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7752. if ioErr3 != nil {
  7753. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7755. return
  7756. }
  7757. var respJSON3 map[string]interface{}
  7758. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7759. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7761. return
  7762. }
  7763. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7764. userJSONBytes3, _ := json.Marshal(respJSON3)
  7765. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7766. utils.ErrorLog("解析失败:%v", err)
  7767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7768. return
  7769. }
  7770. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7771. res2.Output = resSix10265.Output
  7772. res2.ErrMsg = resSix10265.ErrMsg
  7773. res2.Cainfo = resSix10265.Cainfo
  7774. res2.WarnMsg = resSix10265.WarnMsg
  7775. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7776. res2.Infcode = infocode
  7777. } else {
  7778. var api3 string
  7779. if miConfig.Code == "H15049901371" {
  7780. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7781. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7782. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7783. } else {
  7784. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7785. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7786. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7787. }
  7788. resp3, requestErr3 := http.Get(api3)
  7789. if requestErr3 != nil {
  7790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7791. return
  7792. }
  7793. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7794. if ioErr3 != nil {
  7795. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7797. return
  7798. }
  7799. var respJSON3 map[string]interface{}
  7800. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7801. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7803. return
  7804. }
  7805. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7806. userJSONBytes3, _ := json.Marshal(respJSON3)
  7807. if miConfig.Code == "H15049901371" {
  7808. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7809. utils.ErrorLog("解析失败:%v", err)
  7810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7811. return
  7812. }
  7813. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7814. res2.Output = resSix10265.Output
  7815. res2.ErrMsg = resSix10265.ErrMsg
  7816. res2.Cainfo = resSix10265.Cainfo
  7817. res2.WarnMsg = resSix10265.WarnMsg
  7818. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7819. res2.Infcode = infocode
  7820. } else {
  7821. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7822. utils.ErrorLog("解析失败:%v", err)
  7823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7824. return
  7825. }
  7826. }
  7827. }
  7828. if res2.Infcode == 0 {
  7829. if err == nil {
  7830. c.ServeSuccessJSON(map[string]interface{}{
  7831. "msg": "退号成功",
  7832. })
  7833. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  7834. } else {
  7835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7836. return
  7837. }
  7838. } else {
  7839. c.ServeSuccessJSON(map[string]interface{}{
  7840. "code": -10,
  7841. "msg": res2.ErrMsg,
  7842. })
  7843. }
  7844. } else {
  7845. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  7846. //if err == nil {
  7847. // c.ServeSuccessJSON(map[string]interface{}{
  7848. // "msg": "退费成功",
  7849. // })
  7850. //} else {
  7851. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7852. // return
  7853. //}
  7854. }
  7855. }
  7856. func (c *HisApiController) RefundDetail() {
  7857. order_id, _ := c.GetInt64("order_id")
  7858. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7859. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7860. number := c.GetString("number")
  7861. record_time := c.GetString("record_time")
  7862. patient_id, _ := c.GetInt64("patient_id")
  7863. //med_type, _ := c.GetInt64("med_type")
  7864. timeLayout := "2006-01-02"
  7865. loc, _ := time.LoadLocation("Local")
  7866. adminUser := c.GetAdminUserInfo()
  7867. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7868. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7869. fmt.Println(err)
  7870. if err != nil {
  7871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7872. return
  7873. }
  7874. recordDateTime := theTime.Unix()
  7875. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7876. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7877. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7878. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7879. var order models.HisOrder
  7880. order, _ = service.GetHisOrderByID(order_id)
  7881. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7882. if config.IsOpen == 1 { //对接了医保,走医保流程
  7883. var res2 ResultSix
  7884. if miConfig.MdtrtareaAdmvs == "421300" {
  7885. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7886. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7887. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7888. resp3, requestErr3 := http.Get(api3)
  7889. if requestErr3 != nil {
  7890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7891. return
  7892. }
  7893. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7894. if ioErr3 != nil {
  7895. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7897. return
  7898. }
  7899. var respJSON3 map[string]interface{}
  7900. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7901. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7903. return
  7904. }
  7905. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7906. userJSONBytes3, _ := json.Marshal(respJSON3)
  7907. fmt.Println("log")
  7908. fmt.Println(string(userJSONBytes3))
  7909. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7910. utils.ErrorLog("解析失败:%v", err)
  7911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7912. return
  7913. }
  7914. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7915. if err == nil {
  7916. c.ServeSuccessJSON(map[string]interface{}{
  7917. "msg": "撤销明细成功",
  7918. })
  7919. return
  7920. } else {
  7921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7922. return
  7923. }
  7924. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7925. var resSix10265 ResultSix10265
  7926. var api3 string
  7927. if miConfig.MdtrtareaAdmvs == "320921" {
  7928. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7929. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7930. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7931. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7932. } else {
  7933. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7934. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7935. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7936. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7937. }
  7938. resp3, requestErr3 := http.Get(api3)
  7939. if requestErr3 != nil {
  7940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7941. return
  7942. }
  7943. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7944. if ioErr3 != nil {
  7945. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7947. return
  7948. }
  7949. var respJSON3 map[string]interface{}
  7950. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7951. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7953. return
  7954. }
  7955. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7956. userJSONBytes3, _ := json.Marshal(respJSON3)
  7957. fmt.Println("log")
  7958. fmt.Println(string(userJSONBytes3))
  7959. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7960. utils.ErrorLog("解析失败:%v", err)
  7961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7962. return
  7963. }
  7964. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7965. res2.Output = resSix10265.Output
  7966. res2.ErrMsg = resSix10265.ErrMsg
  7967. res2.Cainfo = resSix10265.Cainfo
  7968. res2.WarnMsg = resSix10265.WarnMsg
  7969. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7970. res2.Infcode = infocode
  7971. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7972. if err == nil {
  7973. c.ServeSuccessJSON(map[string]interface{}{
  7974. "msg": "撤销明细成功",
  7975. })
  7976. return
  7977. } else {
  7978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7979. return
  7980. }
  7981. } else {
  7982. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  7983. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7984. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7985. resp2, requestErr2 := http.Get(api2)
  7986. if requestErr2 != nil {
  7987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7988. return
  7989. }
  7990. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7991. if ioErr2 != nil {
  7992. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7994. return
  7995. }
  7996. var respJSON2 map[string]interface{}
  7997. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  7998. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8000. return
  8001. }
  8002. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8003. if err == nil {
  8004. c.ServeSuccessJSON(map[string]interface{}{
  8005. "msg": "撤销明细成功",
  8006. })
  8007. return
  8008. } else {
  8009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8010. return
  8011. }
  8012. }
  8013. } else {
  8014. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8015. if err == nil {
  8016. c.ServeSuccessJSON(map[string]interface{}{
  8017. "msg": "退费成功",
  8018. })
  8019. } else {
  8020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8021. return
  8022. }
  8023. }
  8024. }
  8025. //对账
  8026. func (c *HisApiController) GetCheckAccount() {
  8027. start_time := c.GetString("start_time")
  8028. end_time := c.GetString("end_time")
  8029. insutype := c.GetString("insutype")
  8030. clr_type := c.GetString("clr_type")
  8031. clr_org := c.GetString("clr_optins")
  8032. admin_user_id, _ := c.GetInt64("admin_user_id")
  8033. adminUser := c.GetAdminUserInfo()
  8034. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8035. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8036. if len(clr_org) == 0 {
  8037. clr_org = miConfig.MdtrtareaAdmvs
  8038. }
  8039. timeLayout := "2006-01-02"
  8040. loc, _ := time.LoadLocation("Local")
  8041. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8042. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8043. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_org, clr_type)
  8044. fixmedins_setl_cnt := int64(len(orders))
  8045. var medfee_sumamt float64
  8046. var acct_pay float64
  8047. var fund_pay_sumamt float64
  8048. for _, item := range orders {
  8049. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8050. acct_pay = acct_pay + item.AcctPay
  8051. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8052. }
  8053. var user_name string
  8054. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8055. if role.ID == 0 {
  8056. user_name = "xxx"
  8057. } else {
  8058. user_name = role.UserName
  8059. }
  8060. var res ResultEight
  8061. var res10188 ResultEightFor10188
  8062. if config.IsOpen == 1 {
  8063. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8064. api := "http://192.168.3.111:9532/" + "jsyb/3201?" +
  8065. "insutype=" + insutype +
  8066. "&clr_type=" + "11" +
  8067. "&setl_optins=" + clr_org +
  8068. "&stmt_begndate=" + start_time +
  8069. "&stm_enddate=" + end_time +
  8070. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8071. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8072. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8073. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8074. "&fixmedins_code=" + miConfig.Code +
  8075. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8076. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8077. "&secret_key=" + miConfig.SecretKey +
  8078. "&org_name=" + miConfig.OrgName +
  8079. "&doctor=" + user_name +
  8080. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8081. fmt.Println(api)
  8082. resp, requestErr := http.Get(api)
  8083. if requestErr != nil {
  8084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8085. return
  8086. }
  8087. body, ioErr := ioutil.ReadAll(resp.Body)
  8088. fmt.Println(body)
  8089. if ioErr != nil {
  8090. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8092. return
  8093. }
  8094. var respJSON map[string]interface{}
  8095. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8096. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8098. return
  8099. }
  8100. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8101. userJSONBytes, _ := json.Marshal(respJSON)
  8102. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8103. utils.ErrorLog("解析失败:%v", err)
  8104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8105. return
  8106. }
  8107. res.InfRefmsgid = res10188.InfRefmsgid
  8108. res.Output = res10188.Output
  8109. res.ErrMsg = res10188.ErrMsg
  8110. res.Cainfo = res10188.Cainfo
  8111. res.WarnMsg = res10188.WarnMsg
  8112. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8113. res.Infcode = infocode
  8114. } else {
  8115. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8116. "insutype=" + insutype +
  8117. "&clr_type=" + clr_type +
  8118. "&setl_optins=" + clr_org +
  8119. "&stmt_begndate=" + start_time +
  8120. "&stm_enddate=" + end_time +
  8121. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8122. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8123. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8124. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8125. "&fixmedins_code=" + miConfig.Code +
  8126. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8127. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8128. "&secret_key=" + miConfig.SecretKey +
  8129. "&org_name=" + miConfig.OrgName +
  8130. "&doctor=" + user_name
  8131. fmt.Println(api)
  8132. resp, requestErr := http.Get(api)
  8133. if requestErr != nil {
  8134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8135. return
  8136. }
  8137. body, ioErr := ioutil.ReadAll(resp.Body)
  8138. fmt.Println(body)
  8139. if ioErr != nil {
  8140. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8142. return
  8143. }
  8144. var respJSON map[string]interface{}
  8145. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8146. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8148. return
  8149. }
  8150. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8151. userJSONBytes, _ := json.Marshal(respJSON)
  8152. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8153. utils.ErrorLog("解析失败:%v", err)
  8154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8155. return
  8156. }
  8157. }
  8158. if res.Infcode == 0 {
  8159. if res.Output.Stmtinfo.StmtRslt == "0" {
  8160. micc := &models.MedicalInsuranceCostCompare{
  8161. StartTime: startime.Unix(),
  8162. EndTime: endtime.Unix(),
  8163. Insutype: insutype,
  8164. CheckType: 1,
  8165. Num: fixmedins_setl_cnt,
  8166. Mtime: time.Now().Unix(),
  8167. Status: 1,
  8168. UserOrgId: adminUser.CurrentOrgId,
  8169. CostTotal: medfee_sumamt,
  8170. FuncTotal: fund_pay_sumamt,
  8171. PsnPay: acct_pay,
  8172. Creator: admin_user_id,
  8173. Ctime: time.Now().Unix(),
  8174. ClrType: clr_type,
  8175. }
  8176. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  8177. if err == nil {
  8178. c.ServeSuccessJSON(map[string]interface{}{
  8179. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8180. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8181. })
  8182. } else {
  8183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8184. }
  8185. } else {
  8186. c.ServeSuccessJSON(map[string]interface{}{
  8187. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8188. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8189. })
  8190. }
  8191. } else {
  8192. c.ServeSuccessJSON(map[string]interface{}{
  8193. "code": -10,
  8194. "msg": res.ErrMsg,
  8195. })
  8196. }
  8197. }
  8198. }
  8199. func (c *HisApiController) Check310() {
  8200. adminUser := c.GetAdminUserInfo()
  8201. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8202. var user_name string
  8203. user_name = "高慧裕"
  8204. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8205. "insutype=" + "310" +
  8206. "&clr_type=" + "" +
  8207. "&setl_optins=" + "441202" +
  8208. "&stmt_begndate=" + "2022-03-01" +
  8209. "&stm_enddate=" + "2022-03-31" +
  8210. "&medfee_sumamt=" + "194930.12" +
  8211. "&fund_pay_sumamt=" + "188741.46" +
  8212. "&acct_pay=" + "0" +
  8213. "&fixmedins_setl_cnt=" + "452" +
  8214. "&fixmedins_code=" + miConfig.Code +
  8215. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8216. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8217. "&secret_key=" + miConfig.SecretKey +
  8218. "&org_name=" + miConfig.OrgName +
  8219. "&doctor=" + user_name
  8220. fmt.Println(api)
  8221. resp, requestErr := http.Get(api)
  8222. if requestErr != nil {
  8223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8224. return
  8225. }
  8226. body, ioErr := ioutil.ReadAll(resp.Body)
  8227. fmt.Println(body)
  8228. if ioErr != nil {
  8229. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8231. return
  8232. }
  8233. var respJSON map[string]interface{}
  8234. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8235. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8237. return
  8238. }
  8239. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8240. userJSONBytes, _ := json.Marshal(respJSON)
  8241. var res ResultEight
  8242. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8243. utils.ErrorLog("解析失败:%v", err)
  8244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8245. return
  8246. }
  8247. }
  8248. func (c *HisApiController) Check390() {
  8249. adminUser := c.GetAdminUserInfo()
  8250. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8251. var user_name string
  8252. user_name = "高慧裕"
  8253. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8254. "insutype=" + "390" +
  8255. "&clr_type=" + "" +
  8256. "&setl_optins=" + "441202" +
  8257. "&stmt_begndate=" + "2022-03-01" +
  8258. "&stm_enddate=" + "2022-03-31" +
  8259. "&medfee_sumamt=" + "1068448.89" +
  8260. "&fund_pay_sumamt=" + "1014677.62" +
  8261. "&acct_pay=" + "0" +
  8262. "&fixmedins_setl_cnt=" + "1950" +
  8263. "&fixmedins_code=" + miConfig.Code +
  8264. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8265. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8266. "&secret_key=" + miConfig.SecretKey +
  8267. "&org_name=" + miConfig.OrgName +
  8268. "&doctor=" + user_name
  8269. fmt.Println(api)
  8270. resp, requestErr := http.Get(api)
  8271. if requestErr != nil {
  8272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8273. return
  8274. }
  8275. body, ioErr := ioutil.ReadAll(resp.Body)
  8276. fmt.Println(body)
  8277. if ioErr != nil {
  8278. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8280. return
  8281. }
  8282. var respJSON map[string]interface{}
  8283. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8284. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8286. return
  8287. }
  8288. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8289. userJSONBytes, _ := json.Marshal(respJSON)
  8290. var res ResultEight
  8291. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8292. utils.ErrorLog("解析失败:%v", err)
  8293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8294. return
  8295. }
  8296. }
  8297. //对账明细
  8298. func (c *HisApiController) GetCheckDetailAccount() {
  8299. start_time := c.GetString("start_time")
  8300. end_time := c.GetString("end_time")
  8301. admin_user_id, _ := c.GetInt64("admin_user_id")
  8302. adminUser := c.GetAdminUserInfo()
  8303. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8304. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8305. timeLayout := "2006-01-02"
  8306. loc, _ := time.LoadLocation("Local")
  8307. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8308. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8309. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  8310. Mkdir(miConfig.OrgName)
  8311. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  8312. file_name := file + ".txt"
  8313. zip_name := file + ".zip"
  8314. zip_path := miConfig.OrgName + "/" + zip_name
  8315. file_path := miConfig.OrgName + "/" + file_name
  8316. decimal.DivisionPrecision = 2
  8317. var medfee_sumamt float64
  8318. var psn_cash_pay float64
  8319. var fund_pay_sumamt float64
  8320. fixmedins_setl_cnt := int64(len(orders))
  8321. for _, item := range orders {
  8322. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8323. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  8324. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8325. }
  8326. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  8327. defer f.Close()
  8328. if err != nil {
  8329. fmt.Println(err.Error())
  8330. } else {
  8331. for _, item := range orders {
  8332. var refd_setl_flag string
  8333. if item.OrderStatus == 2 {
  8334. refd_setl_flag = "0"
  8335. var str string
  8336. str = item.SetlId + " " +
  8337. item.MdtrtId + " " +
  8338. item.PsnNo + " " +
  8339. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8340. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8341. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  8342. _, err = f.Write([]byte(str))
  8343. }
  8344. if item.OrderStatus == 3 {
  8345. var str string
  8346. str = item.SetlId + " " +
  8347. item.MdtrtId + " " +
  8348. item.PsnNo + " " +
  8349. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8350. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8351. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  8352. _, err = f.Write([]byte(str))
  8353. var str2 string
  8354. str2 = item.SetlId + " " +
  8355. item.MdtrtId + " " +
  8356. item.PsnNo + " " +
  8357. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  8358. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  8359. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  8360. _, err = f.Write([]byte(str2))
  8361. }
  8362. }
  8363. }
  8364. Zip(file_path, zip_path)
  8365. fmt.Println(ReadFile(zip_path))
  8366. fmt.Println(string(ReadFile(zip_path)))
  8367. if config.IsOpen == 1 {
  8368. var user_name string
  8369. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8370. if role.ID == 0 {
  8371. user_name = "管理员"
  8372. } else {
  8373. user_name = role.UserName
  8374. }
  8375. baseParams := models.BaseParams{
  8376. SecretKey: miConfig.SecretKey,
  8377. FixmedinsCode: miConfig.Code,
  8378. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8379. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8380. OrgName: miConfig.OrgName,
  8381. Doctor: user_name,
  8382. }
  8383. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  8384. var dat map[string]interface{}
  8385. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8386. fmt.Println(dat)
  8387. } else {
  8388. fmt.Println(err)
  8389. }
  8390. userJSONBytes, _ := json.Marshal(dat)
  8391. var res ResultNine
  8392. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8393. utils.ErrorLog("解析失败:%v", err)
  8394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8395. return
  8396. }
  8397. if res.Infcode == 0 {
  8398. fileNo := res.Output.FileQuryNo
  8399. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  8400. "file_qury_no=" + fileNo +
  8401. "&setl_optins=" + "定点医保中心" +
  8402. "&stmt_begndate=" + start_time +
  8403. "&stm_enddate=" + end_time +
  8404. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8405. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8406. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  8407. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8408. "&fixmedins_code=" + miConfig.Code +
  8409. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8410. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8411. "&secret_key=" + miConfig.SecretKey +
  8412. "&org_name=" + miConfig.OrgName +
  8413. "&doctor=" + user_name
  8414. resp, requestErr := http.Get(api)
  8415. if requestErr != nil {
  8416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8417. return
  8418. }
  8419. body, ioErr := ioutil.ReadAll(resp.Body)
  8420. if ioErr != nil {
  8421. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8423. return
  8424. }
  8425. var respJSON map[string]interface{}
  8426. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8427. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8429. return
  8430. }
  8431. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8432. userJSONBytes, _ := json.Marshal(respJSON)
  8433. var res ResultTen
  8434. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8435. utils.ErrorLog("解析失败:%v", err)
  8436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8437. return
  8438. }
  8439. if res.Infcode == 0 {
  8440. service.Gdyb9102(baseParams, zip_name, fileNo)
  8441. micc := &models.MedicalInsuranceCostCompare{
  8442. StartTime: startime.Unix(),
  8443. EndTime: endtime.Unix(),
  8444. Insutype: "0",
  8445. CheckType: 2,
  8446. Num: fixmedins_setl_cnt,
  8447. Mtime: time.Now().Unix(),
  8448. Status: 1,
  8449. UserOrgId: adminUser.CurrentOrgId,
  8450. CostTotal: medfee_sumamt,
  8451. FuncTotal: fund_pay_sumamt,
  8452. PsnPay: psn_cash_pay,
  8453. Creator: admin_user_id,
  8454. Ctime: time.Now().Unix(),
  8455. }
  8456. service.CreateMedicalInsuranceCostCompareRecord(micc)
  8457. c.ServeSuccessJSON(map[string]interface{}{
  8458. "msg": "明细对账成功",
  8459. })
  8460. }
  8461. } else {
  8462. }
  8463. }
  8464. }
  8465. type CustomOrderInfo struct {
  8466. Name string
  8467. Spec string
  8468. Unit string
  8469. Count float64
  8470. Price float64
  8471. Total float64
  8472. }
  8473. func (c *HisApiController) GetSettleAccounts() {
  8474. //id, _ := c.GetInt64("id")
  8475. //record_time := c.GetString("record_time")
  8476. order_id, _ := c.GetInt64("order_id")
  8477. admin_user_id, _ := c.GetInt64("admin_user_id")
  8478. //timeLayout := "2006-01-02"
  8479. //loc, _ := time.LoadLocation("Local")
  8480. //
  8481. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8482. //if err != nil {
  8483. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8484. // return
  8485. //}
  8486. //recordDateTime := theTime.Unix()
  8487. adminUser := c.GetAdminUserInfo()
  8488. order, _ := service.GetHisOrderByID(order_id)
  8489. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8490. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  8491. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8492. orderInfos = append(orderInfos, orderInfos_two...)
  8493. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8494. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  8495. var diagnosis_ids []string
  8496. if his.ID > 0 {
  8497. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  8498. } else {
  8499. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  8500. }
  8501. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  8502. var dia_config []*models.HisXtDiagnoseConfig
  8503. var name string
  8504. for _, item := range diagnosis_ids {
  8505. id, _ := strconv.ParseInt(item, 10, 64)
  8506. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8507. dia_config = append(dia_config, &diagnosisConfig)
  8508. if len(name) == 0 {
  8509. name = diagnosisConfig.ClassName
  8510. } else {
  8511. name = name + "," + diagnosisConfig.ClassName
  8512. }
  8513. }
  8514. var bedCostTotal float64 = 0 //床位总费
  8515. var bedCostSelfTotal float64 = 0 //床位自费
  8516. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  8517. var operationCostTotal float64 = 0 //手术费
  8518. var operationCostSelfTotal float64 = 0 //手术费
  8519. var operationCostPartSelfTotal float64 = 0 //手术费
  8520. var otherCostTotal float64 = 0 //其他费用
  8521. var otherCostSelfTotal float64 = 0 //其他费用
  8522. var otherCostPartSelfTotal float64 = 0 //其他费用
  8523. var materialCostTotal float64 = 0 //材料费
  8524. var materialCostSelfTotal float64 = 0 //材料费
  8525. var materialCostPartSelfTotal float64 = 0 //材料费
  8526. var westernMedicineCostTotal float64 = 0 //西药费
  8527. var westernMedicineCostSelfTotal float64 = 0 //西药费
  8528. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  8529. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  8530. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  8531. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  8532. var checkCostTotal float64 = 0 //检查费
  8533. var checkCostSelfTotal float64 = 0 //检查费
  8534. var checkCostPartSelfTotal float64 = 0 //检查费
  8535. var laboratoryCostTotal float64 = 0 //化验费
  8536. var laboratoryCostSelfTotal float64 = 0 //化验费
  8537. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  8538. var treatCostTotal float64 = 0 //治疗费用
  8539. var treatCostSelfTotal float64 = 0 //治疗费用
  8540. var treatCostPartSelfTotal float64 = 0 //治疗费用
  8541. decimal.DivisionPrecision = 2
  8542. for _, item := range orderInfos {
  8543. if item.MedChrgitmType == "01" { //床位费
  8544. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8545. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8546. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8547. }
  8548. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  8549. if item.MedChrgitmType == "03" { //检查费
  8550. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8551. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8552. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8553. }
  8554. } else {
  8555. if item.MedChrgitmType == "03" { //检查费
  8556. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8557. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8558. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8559. }
  8560. }
  8561. if item.MedChrgitmType == "04" { //化验费
  8562. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8563. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8564. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8565. }
  8566. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  8567. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8568. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8569. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8570. }
  8571. if item.MedChrgitmType == "06" { //手术费
  8572. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8573. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8574. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8575. }
  8576. if item.MedChrgitmType == "08" { //材料费
  8577. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8578. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8579. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8580. }
  8581. if item.MedChrgitmType == "09" { //西药费
  8582. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8583. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8584. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8585. }
  8586. if item.MedChrgitmType == "11" { //中成费
  8587. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8588. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8589. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8590. }
  8591. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  8592. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8593. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8594. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8595. }
  8596. }
  8597. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8598. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8599. var user_name string
  8600. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8601. if role.ID == 0 {
  8602. user_name = "管理员"
  8603. } else {
  8604. user_name = role.UserName
  8605. }
  8606. baseParams := models.BaseParams{
  8607. SecretKey: miConfig.SecretKey,
  8608. FixmedinsCode: miConfig.Code,
  8609. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8610. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8611. OrgName: miConfig.OrgName,
  8612. Doctor: user_name,
  8613. }
  8614. businessParams := models.BusinessParams{
  8615. PsnNo: order.PsnNo,
  8616. MdtrtId: order.MdtrtId,
  8617. SetlId: order.SetlId,
  8618. }
  8619. var res ResultEleven
  8620. var resEleven10265 ResultEleven10265
  8621. if config.IsOpen == 1 {
  8622. if miConfig.MdtrtareaAdmvs == "421300" {
  8623. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8624. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8625. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8626. resp, requestErr := http.Get(api)
  8627. if requestErr != nil {
  8628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8629. return
  8630. }
  8631. body, ioErr := ioutil.ReadAll(resp.Body)
  8632. if ioErr != nil {
  8633. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8635. return
  8636. }
  8637. var respJSON map[string]interface{}
  8638. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8639. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8641. return
  8642. }
  8643. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8644. result, _ := json.Marshal(respJSON)
  8645. fmt.Println("log")
  8646. fmt.Println(string(result))
  8647. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8648. utils.ErrorLog("解析失败:%v", err)
  8649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8650. return
  8651. }
  8652. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8653. var api string
  8654. if miConfig.MdtrtareaAdmvs == "320921" {
  8655. api = "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8656. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8657. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8658. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8659. } else {
  8660. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8661. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8662. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8663. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8664. }
  8665. resp, requestErr := http.Get(api)
  8666. if requestErr != nil {
  8667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8668. return
  8669. }
  8670. body, ioErr := ioutil.ReadAll(resp.Body)
  8671. if ioErr != nil {
  8672. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8674. return
  8675. }
  8676. var respJSON map[string]interface{}
  8677. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8678. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8680. return
  8681. }
  8682. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8683. result, _ := json.Marshal(respJSON)
  8684. fmt.Println("log")
  8685. fmt.Println(string(result))
  8686. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  8687. utils.ErrorLog("解析失败:%v", err)
  8688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8689. return
  8690. }
  8691. res.InfRefmsgid = resEleven10265.InfRefmsgid
  8692. res.Output = resEleven10265.Output
  8693. res.ErrMsg = resEleven10265.ErrMsg
  8694. res.Cainfo = resEleven10265.Cainfo
  8695. res.WarnMsg = resEleven10265.WarnMsg
  8696. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  8697. res.Infcode = infocode
  8698. } else {
  8699. //result2 := service.Gdyb1101()
  8700. //result2 := service.Gdyb5204(baseParams, businessParams)
  8701. //saveLog(result2, "", "5204", "查询")
  8702. result := service.Gdyb5203(baseParams, businessParams)
  8703. var dat map[string]interface{}
  8704. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8705. fmt.Println(dat)
  8706. } else {
  8707. fmt.Println(err)
  8708. }
  8709. userJSONBytes, _ := json.Marshal(dat)
  8710. if miConfig.Code == "H15049901371" {
  8711. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  8712. utils.ErrorLog("解析失败:%v", err)
  8713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8714. return
  8715. }
  8716. res.InfRefmsgid = resEleven10265.InfRefmsgid
  8717. res.Output = resEleven10265.Output
  8718. res.ErrMsg = resEleven10265.ErrMsg
  8719. res.Cainfo = resEleven10265.Cainfo
  8720. res.WarnMsg = resEleven10265.WarnMsg
  8721. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  8722. res.Infcode = infocode
  8723. } else {
  8724. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8725. utils.ErrorLog("解析失败:%v", err)
  8726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8727. return
  8728. }
  8729. }
  8730. }
  8731. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8732. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  8733. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  8734. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  8735. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  8736. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8737. var doctor_name string
  8738. if roles.ID == 0 {
  8739. doctor_name = "管理员"
  8740. } else {
  8741. doctor_name = roles.UserName
  8742. }
  8743. yiliao_leibie := ""
  8744. switch order.MedType {
  8745. case "11":
  8746. yiliao_leibie = "普通门诊"
  8747. break
  8748. case "12":
  8749. yiliao_leibie = "门诊挂号"
  8750. break
  8751. case "13":
  8752. yiliao_leibie = "急诊"
  8753. break
  8754. case "14":
  8755. yiliao_leibie = "门诊特殊病"
  8756. break
  8757. case "15":
  8758. yiliao_leibie = "门诊统筹"
  8759. break
  8760. case "16":
  8761. yiliao_leibie = "门诊慢性病"
  8762. break
  8763. case "21":
  8764. yiliao_leibie = "普通住院"
  8765. break
  8766. }
  8767. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8768. if res.Infcode == 0 {
  8769. c.ServeSuccessJSON(map[string]interface{}{
  8770. "diagnosis": name,
  8771. "order_infos": orderInfos,
  8772. "number": order.MdtrtId,
  8773. "date": order.SettleAccountsDate,
  8774. "charge_admin": charge_admin,
  8775. "printor_admin": printor_admin,
  8776. "info": res.Output.Setlinfo,
  8777. "order": order,
  8778. "bedCostTotal": bedCostTotal,
  8779. "bedCostSelfTotal": bedCostSelfTotal,
  8780. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  8781. "operationCostTotal": operationCostTotal,
  8782. "operationCostSelfTotal": operationCostSelfTotal,
  8783. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  8784. "otherCostTotal": otherCostTotal,
  8785. "otherCostSelfTotal": otherCostSelfTotal,
  8786. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  8787. "materialCostTotal": materialCostTotal,
  8788. "materialCostSelfTotal": materialCostSelfTotal,
  8789. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  8790. "westernMedicineCostTotal": westernMedicineCostTotal,
  8791. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  8792. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  8793. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  8794. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  8795. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  8796. "checkCostTotal": checkCostTotal,
  8797. "checkCostSelfTotal": checkCostSelfTotal,
  8798. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  8799. "laboratoryCostTotal": laboratoryCostTotal,
  8800. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  8801. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  8802. "treatCostTotal": treatCostTotal,
  8803. "treatCostSelfTotal": treatCostSelfTotal,
  8804. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  8805. "doctor_info": doctor_info,
  8806. "doctor_code": adminRole_two.DoctorCode,
  8807. "doctor_name": doctor_name,
  8808. "health_card_no": order.PsnNo,
  8809. "department": departments.Name,
  8810. "yiliao_leibie": yiliao_leibie,
  8811. "after_money": order.AccountPrice,
  8812. "patient": patient,
  8813. "org_name": miConfig.OrgName,
  8814. "org_code": miConfig.Code,
  8815. "order_number": order.Number,
  8816. "his_hospital": his_hospital,
  8817. "his": his,
  8818. "dia_config": dia_config,
  8819. //"check_order_info": cus_slice,
  8820. })
  8821. }
  8822. }
  8823. }
  8824. func (c *HisApiController) CheckTreatment() {
  8825. patient_id, _ := c.GetInt64("patient_id")
  8826. id_card_no := c.GetString("id_card_no")
  8827. insutype := c.GetString("insutype")
  8828. med_type := c.GetString("med_type")
  8829. admin_user_id, _ := c.GetInt64("admin_user_id")
  8830. adminUser := c.GetAdminUserInfo()
  8831. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8832. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8833. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8834. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8835. if miConfig.MdtrtareaAdmvs == "421300" {
  8836. var res ResultTwo
  8837. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  8838. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8839. "&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)
  8840. resp, requestErr := http.Get(api)
  8841. if requestErr != nil {
  8842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8843. return
  8844. }
  8845. body, ioErr := ioutil.ReadAll(resp.Body)
  8846. if ioErr != nil {
  8847. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8849. return
  8850. }
  8851. var respJSON map[string]interface{}
  8852. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8853. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8855. return
  8856. }
  8857. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8858. result, _ := json.Marshal(respJSON)
  8859. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8860. utils.ErrorLog("解析失败:%v", err)
  8861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8862. return
  8863. }
  8864. if res.Infcode == 0 {
  8865. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  8866. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8867. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  8868. resp, requestErr := http.Get(api)
  8869. if requestErr != nil {
  8870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8871. return
  8872. }
  8873. body, ioErr := ioutil.ReadAll(resp.Body)
  8874. if ioErr != nil {
  8875. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8877. return
  8878. }
  8879. var respJSON map[string]interface{}
  8880. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8881. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8883. return
  8884. }
  8885. var res Result2001
  8886. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8887. result2, _ := json.Marshal(respJSON)
  8888. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  8889. utils.ErrorLog("解析失败:%v", err)
  8890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8891. return
  8892. }
  8893. if res.Infcode == 0 {
  8894. c.ServeSuccessJSON(map[string]interface{}{
  8895. "msg": res.Output.Trtinfo,
  8896. })
  8897. }
  8898. } else {
  8899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8900. return
  8901. }
  8902. } else {
  8903. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  8904. var dat map[string]interface{}
  8905. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8906. fmt.Println(dat)
  8907. } else {
  8908. fmt.Println(err)
  8909. }
  8910. userJSONBytes, _ := json.Marshal(dat)
  8911. var res ResultTwo
  8912. var res10265 ResultTwo10265
  8913. if miConfig.Code == "H15049901371" {
  8914. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8915. utils.ErrorLog("解析失败:%v", err)
  8916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8917. return
  8918. }
  8919. res.ErrMsg = res10265.ErrMsg
  8920. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8921. res.Infcode = infocode
  8922. res.Output = res10265.Output
  8923. res.InfRefmsgid = res10265.InfRefmsgid
  8924. } else {
  8925. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8926. utils.ErrorLog("解析失败:%v", err)
  8927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8928. return
  8929. }
  8930. }
  8931. var user_name string
  8932. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  8933. if role.ID == 0 {
  8934. user_name = "xxx"
  8935. } else {
  8936. user_name = role.UserName
  8937. }
  8938. baseParams := models.BaseParams{
  8939. SecretKey: miConfig.SecretKey,
  8940. FixmedinsCode: miConfig.Code,
  8941. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8942. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8943. OrgName: miConfig.OrgName,
  8944. Doctor: user_name,
  8945. }
  8946. if config.IsOpen == 1 {
  8947. if miConfig.Code == "H15049901371" {
  8948. if med_type == "14" {
  8949. if insutype == "390" {
  8950. med_type = "9933"
  8951. } else if insutype == "310" {
  8952. med_type = "990502"
  8953. }
  8954. } else if med_type == "11" {
  8955. med_type = "11"
  8956. }
  8957. }
  8958. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  8959. var dat map[string]interface{}
  8960. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8961. fmt.Println(dat)
  8962. } else {
  8963. fmt.Println(err)
  8964. }
  8965. var res Result2001
  8966. var res10265 Result2001Org10265
  8967. if miConfig.Code == "H15049901371" {
  8968. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8969. utils.ErrorLog("解析失败:%v", err)
  8970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8971. return
  8972. }
  8973. res.ErrMsg = res10265.ErrMsg
  8974. res.Output = res10265.Output
  8975. res.InfRefmsgid = res10265.InfRefmsgid
  8976. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8977. res.Infcode = infocode
  8978. } else {
  8979. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8980. utils.ErrorLog("解析失败:%v", err)
  8981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8982. return
  8983. }
  8984. }
  8985. if res.Infcode == 0 {
  8986. c.ServeSuccessJSON(map[string]interface{}{
  8987. "msg": res.Output.Trtinfo,
  8988. })
  8989. }
  8990. }
  8991. }
  8992. }
  8993. //func (c *HisApiController) PutRecord() {
  8994. // id, _ := c.GetInt64("id")
  8995. // record_time := c.GetString("record_time")
  8996. // timeLayout := "2006-01-02"
  8997. // loc, _ := time.LoadLocation("Local")
  8998. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8999. // if err != nil {
  9000. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9001. // return
  9002. // }
  9003. // recordDateTime := theTime.Unix()
  9004. //
  9005. // adminInfo := c.GetAdminUserInfo()
  9006. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  9007. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9008. //
  9009. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9010. //
  9011. // fmt.Println(miConfig.SecretKey)
  9012. //
  9013. // if patient == nil {
  9014. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9015. // return
  9016. // }
  9017. // if len(patient.IdCardNo) == 0 {
  9018. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  9019. // return
  9020. // }
  9021. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  9022. // if config.IsOpen == 1 {
  9023. // 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
  9024. // resp, requestErr := http.Get(api)
  9025. // if requestErr != nil {
  9026. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9027. // return
  9028. // }
  9029. // defer resp.Body.Close()
  9030. // body, ioErr := ioutil.ReadAll(resp.Body)
  9031. // if ioErr != nil {
  9032. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9033. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9034. // return
  9035. // }
  9036. // var respJSON map[string]interface{}
  9037. //
  9038. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9039. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9040. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9041. // return
  9042. // }
  9043. //
  9044. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9045. // userJSONBytes, _ := json.Marshal(userJSON)
  9046. // var res ResultTwo
  9047. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9048. // utils.ErrorLog("解析失败:%v", err)
  9049. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9050. // return
  9051. // }
  9052. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9053. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9054. // infoStr := string(Iinfos)
  9055. // idetinfoStr := string(Idetinfos)
  9056. //
  9057. // if res.Infcode == 0 {
  9058. // his := models.VMHisPatient{
  9059. // Status: 1,
  9060. // Ctime: time.Now().Unix(),
  9061. // Mtime: time.Now().Unix(),
  9062. // PsnNo: res.Output.Baseinfo.PsnNo,
  9063. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  9064. // Certno: res.Output.Baseinfo.Certno,
  9065. // PsnName: res.Output.Baseinfo.PsnName,
  9066. // Gend: res.Output.Baseinfo.Gend,
  9067. // Naty: res.Output.Baseinfo.Naty,
  9068. // Brdy: res.Output.Baseinfo.Brdy,
  9069. // Age: res.Output.Baseinfo.Age,
  9070. // Iinfo: infoStr,
  9071. // Idetinfo: idetinfoStr,
  9072. // PatientId: patient.ID,
  9073. // RecordDate: theTime.Unix(),
  9074. // UserOrgId: adminInfo.CurrentOrgId,
  9075. // AdminUserId: adminInfo.AdminUser.Id,
  9076. // IsReturn: 1,
  9077. // }
  9078. //
  9079. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  9080. // //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")
  9081. // //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")
  9082. //
  9083. // //var dat map[string]interface{}
  9084. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9085. // // fmt.Println(dat)
  9086. // //} else {
  9087. // // fmt.Println(err)
  9088. // //}
  9089. //
  9090. // var dat2 map[string]interface{}
  9091. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9092. // fmt.Println(dat2)
  9093. // } else {
  9094. // fmt.Println(err)
  9095. // }
  9096. //
  9097. // } else {
  9098. // adminUser := c.GetAdminUserInfo()
  9099. // errlog := &models.HisOrderError{
  9100. // UserOrgId: adminUser.CurrentOrgId,
  9101. // Ctime: time.Now().Unix(),
  9102. // Mtime: time.Now().Unix(),
  9103. // ErrMsg: res.ErrMsg,
  9104. // Status: 1,
  9105. // PatientId: id,
  9106. // RecordTime: recordDateTime,
  9107. // Stage: 1,
  9108. // }
  9109. // service.CreateErrMsgLog(errlog)
  9110. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  9111. // return
  9112. // }
  9113. // }
  9114. //
  9115. //}
  9116. //func (c *HisApiController) GetUploadDiag() {
  9117. // id, _ := c.GetInt64("id")
  9118. // record_time := c.GetString("record_time")
  9119. //
  9120. // diagnosis_id, _ := c.GetInt64("diagnosis")
  9121. // sick_type, _ := c.GetInt64("sick_type")
  9122. // reg_type, _ := c.GetInt64("reg_type")
  9123. //
  9124. // timeLayout := "2006-01-02"
  9125. // loc, _ := time.LoadLocation("Local")
  9126. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9127. // if err != nil {
  9128. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9129. // return
  9130. // }
  9131. //
  9132. // var patientPrescription models.HisPrescriptionInfo
  9133. // recordDateTime := theTime.Unix()
  9134. // adminInfo := c.GetAdminUserInfo()
  9135. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9136. //
  9137. // if patientPrescription.ID == 0 {
  9138. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9139. // }
  9140. //
  9141. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9142. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9143. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9144. // sickConfig, _ := service.FindSickById(sick_type)
  9145. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9146. //
  9147. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  9148. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  9149. // "&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 +
  9150. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  9151. // resp2, requestErr2 := http.Get(api2)
  9152. // if requestErr2 != nil {
  9153. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9154. // return
  9155. // }
  9156. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  9157. // if ioErr2 != nil {
  9158. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  9159. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9160. // return
  9161. // }
  9162. // var respJSON2 map[string]interface{}
  9163. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  9164. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9165. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9166. // return
  9167. // }
  9168. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9169. // userJSONBytes2, _ := json.Marshal(respJSON2)
  9170. //
  9171. // var res2 ResultSix
  9172. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9173. // utils.ErrorLog("解析失败:%v", err)
  9174. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9175. // return
  9176. // }
  9177. // if res2.Infcode != 0 {
  9178. // adminUser := c.GetAdminUserInfo()
  9179. // errlog := &models.HisOrderError{
  9180. // UserOrgId: adminUser.CurrentOrgId,
  9181. // Ctime: time.Now().Unix(),
  9182. // Mtime: time.Now().Unix(),
  9183. // ErrMsg: res2.ErrMsg,
  9184. // Status: 1,
  9185. // PatientId: id,
  9186. // RecordTime: recordDateTime,
  9187. // Stage: 3,
  9188. // }
  9189. // service.CreateErrMsgLog(errlog)
  9190. //
  9191. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  9192. // return
  9193. // }
  9194. //
  9195. // c.ServeSuccessJSON(map[string]interface{}{
  9196. // "msg": "上传成功",
  9197. // })
  9198. //
  9199. //}
  9200. type QueryResult struct {
  9201. ID int64
  9202. Name string
  9203. Code string
  9204. List_type_code string
  9205. }
  9206. func (c *HisApiController) GetCheckCode() {
  9207. ids_str := c.GetString("ids")
  9208. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9209. ids_arr := strings.Split(ids_str, ",")
  9210. var queryResult []QueryResult
  9211. ids := make([]int64, 0)
  9212. for _, item := range ids_arr {
  9213. id, _ := strconv.ParseInt(item, 10, 64)
  9214. ids = append(ids, id)
  9215. }
  9216. if record_type == 1 {
  9217. drugs, _ := service.GetBatchDrugList(ids)
  9218. for _, item := range drugs {
  9219. result := QueryResult{
  9220. ID: item.ID,
  9221. Name: item.DrugName,
  9222. Code: item.MedicalInsuranceNumber,
  9223. List_type_code: "101",
  9224. }
  9225. queryResult = append(queryResult, result)
  9226. }
  9227. } else if record_type == 2 {
  9228. goods, _ := service.GetBatchGoodInformationList(ids)
  9229. for _, item := range goods {
  9230. result := QueryResult{
  9231. ID: item.ID,
  9232. Name: item.GoodName,
  9233. Code: item.MedicalInsuranceNumber,
  9234. List_type_code: "301",
  9235. }
  9236. queryResult = append(queryResult, result)
  9237. }
  9238. } else if record_type == 3 {
  9239. projects, _ := service.GetBathchMyPorjecgList(ids)
  9240. for _, item := range projects {
  9241. result := QueryResult{
  9242. ID: item.ID,
  9243. Name: item.ProjectName,
  9244. Code: item.MedicalCode,
  9245. List_type_code: "201",
  9246. }
  9247. queryResult = append(queryResult, result)
  9248. }
  9249. }
  9250. admin_user_id, _ := c.GetInt64("admin_user_id")
  9251. adminUser := c.GetAdminUserInfo()
  9252. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9253. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9254. var user_name string
  9255. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9256. if role.ID == 0 {
  9257. user_name = "xxx"
  9258. } else {
  9259. user_name = role.UserName
  9260. }
  9261. baseParams := &models.BaseParams{
  9262. SecretKey: miConfig.SecretKey,
  9263. FixmedinsCode: miConfig.Code,
  9264. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9265. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9266. OrgName: miConfig.OrgName,
  9267. Doctor: user_name,
  9268. }
  9269. if config.IsOpen == 1 {
  9270. for _, item := range queryResult {
  9271. var result string
  9272. if record_type == 1 {
  9273. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9274. } else if record_type == 2 {
  9275. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9276. } else if record_type == 3 {
  9277. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9278. }
  9279. var dat map[string]interface{}
  9280. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9281. fmt.Println(dat)
  9282. } else {
  9283. fmt.Println(err)
  9284. }
  9285. userJSONBytes, _ := json.Marshal(dat)
  9286. var res ResultSix
  9287. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9288. utils.ErrorLog("解析失败:%v", err)
  9289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9290. return
  9291. }
  9292. if res.Infcode == 0 {
  9293. if record_type == 1 {
  9294. service.UpdateBaseDrugById(item.ID)
  9295. } else if record_type == 2 {
  9296. service.UpdateGoodInformaitonByDetail(item.ID)
  9297. } else if record_type == 3 {
  9298. service.UpdateProjectById(item.ID)
  9299. }
  9300. c.ServeSuccessJSON(map[string]interface{}{
  9301. "failed_code": 0,
  9302. "msg": "目录对照成功",
  9303. })
  9304. } else {
  9305. c.ServeSuccessJSON(map[string]interface{}{
  9306. "failed_code": -10,
  9307. "msg": res.ErrMsg,
  9308. })
  9309. }
  9310. }
  9311. }
  9312. }
  9313. func (c *HisApiController) UnCheckCode() {
  9314. ids_str := c.GetString("ids")
  9315. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9316. admin_user_id, _ := c.GetInt64("admin_user_id")
  9317. ids_arr := strings.Split(ids_str, ",")
  9318. var queryResult []QueryResult
  9319. ids := make([]int64, 0)
  9320. for _, item := range ids_arr {
  9321. id, _ := strconv.ParseInt(item, 10, 64)
  9322. ids = append(ids, id)
  9323. }
  9324. if record_type == 1 {
  9325. drugs, _ := service.GetBatchDrugList(ids)
  9326. for _, item := range drugs {
  9327. result := QueryResult{
  9328. ID: item.ID,
  9329. Name: item.DrugName,
  9330. Code: item.MedicalInsuranceNumber,
  9331. List_type_code: "101",
  9332. }
  9333. queryResult = append(queryResult, result)
  9334. }
  9335. } else if record_type == 2 {
  9336. goods, _ := service.GetBatchGoodInformationList(ids)
  9337. for _, item := range goods {
  9338. result := QueryResult{
  9339. ID: item.ID,
  9340. Name: item.GoodName,
  9341. Code: item.MedicalInsuranceNumber,
  9342. List_type_code: "301",
  9343. }
  9344. queryResult = append(queryResult, result)
  9345. }
  9346. } else if record_type == 3 {
  9347. projects, _ := service.GetBathchMyPorjecgList(ids)
  9348. for _, item := range projects {
  9349. result := QueryResult{
  9350. ID: item.ID,
  9351. Name: item.ProjectName,
  9352. Code: item.MedicalCode,
  9353. List_type_code: "201",
  9354. }
  9355. queryResult = append(queryResult, result)
  9356. }
  9357. }
  9358. adminUser := c.GetAdminUserInfo()
  9359. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9360. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9361. var user_name string
  9362. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9363. if role.ID == 0 {
  9364. user_name = "xxx"
  9365. } else {
  9366. user_name = role.UserName
  9367. }
  9368. baseParams := &models.BaseParams{
  9369. SecretKey: miConfig.SecretKey,
  9370. FixmedinsCode: miConfig.Code,
  9371. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9372. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9373. OrgName: miConfig.OrgName,
  9374. Doctor: user_name,
  9375. }
  9376. if config.IsOpen == 1 {
  9377. for _, item := range queryResult {
  9378. var result string
  9379. if record_type == 1 {
  9380. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9381. } else if record_type == 2 {
  9382. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9383. } else if record_type == 3 {
  9384. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9385. }
  9386. var dat2 map[string]interface{}
  9387. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  9388. fmt.Println(dat2)
  9389. } else {
  9390. fmt.Println(err)
  9391. }
  9392. userJSONBytes, _ := json.Marshal(dat2)
  9393. var res ResultSix
  9394. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9395. utils.ErrorLog("解析失败:%v", err)
  9396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9397. return
  9398. }
  9399. if res.Infcode == 0 {
  9400. if record_type == 1 {
  9401. service.UpdateDrugByIdDetail(item.ID)
  9402. } else if record_type == 2 {
  9403. service.UpdateGoodInfoById(item.ID)
  9404. } else if record_type == 3 {
  9405. service.UpdateMyProjectById(item.ID)
  9406. }
  9407. c.ServeSuccessJSON(map[string]interface{}{
  9408. "failed_code": 0,
  9409. "msg": "撤销目录对照成功",
  9410. })
  9411. } else {
  9412. c.ServeSuccessJSON(map[string]interface{}{
  9413. "failed_code": -10,
  9414. "msg": res.ErrMsg,
  9415. })
  9416. }
  9417. }
  9418. }
  9419. }
  9420. func (c *HisApiController) GetPatientInfo() {
  9421. id_card_no := c.GetString("id_card_no")
  9422. admin_user_id, _ := c.GetInt64("admin_user_id")
  9423. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  9424. if patient.ID == 0 {
  9425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9426. return
  9427. }
  9428. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9429. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9430. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  9431. if config.IsOpen == 1 {
  9432. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9433. var dat map[string]interface{}
  9434. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9435. fmt.Println(dat)
  9436. } else {
  9437. fmt.Println(err)
  9438. }
  9439. userJSONBytes, _ := json.Marshal(dat)
  9440. var res ResultTwo
  9441. var res10265 ResultTwo10265
  9442. if miConfig.Code == "H15049901371" {
  9443. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9444. utils.ErrorLog("解析失败:%v", err)
  9445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9446. return
  9447. }
  9448. res.ErrMsg = res10265.ErrMsg
  9449. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9450. res.Infcode = infocode
  9451. res.Output = res10265.Output
  9452. res.InfRefmsgid = res10265.InfRefmsgid
  9453. } else {
  9454. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9455. utils.ErrorLog("解析失败:%v", err)
  9456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9457. return
  9458. }
  9459. }
  9460. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9461. // utils.ErrorLog("解析失败:%v", err)
  9462. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9463. // return
  9464. //}
  9465. if res.Infcode != 0 {
  9466. c.ServeSuccessJSON(map[string]interface{}{
  9467. "failed_code": -10,
  9468. "msg": res.ErrMsg,
  9469. })
  9470. } else {
  9471. c.ServeSuccessJSON(map[string]interface{}{
  9472. "failed_code": 0,
  9473. "info": res,
  9474. })
  9475. }
  9476. }
  9477. }
  9478. func (c *HisApiController) PsnPutOnRecord() {
  9479. record_type, _ := c.GetInt64("type")
  9480. patient_id, _ := c.GetInt64("patient_id")
  9481. admin_user_id, _ := c.GetInt64("admin_user_id")
  9482. start_time := c.GetString("start_time")
  9483. end_time := c.GetString("end_time")
  9484. adminUser := c.GetAdminUserInfo()
  9485. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9486. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9487. var patients []*models.Patients
  9488. if record_type == 1 { //全部备案
  9489. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  9490. patients = append(patients, patient...)
  9491. } else { //单个备案
  9492. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9493. patients = append(patients, patient)
  9494. }
  9495. var user_name string
  9496. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9497. if role.ID == 0 {
  9498. user_name = "xxx"
  9499. } else {
  9500. user_name = role.UserName
  9501. }
  9502. if config.IsOpen == 1 {
  9503. for _, item := range patients {
  9504. 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
  9505. resp, requestErr := http.Get(api)
  9506. if requestErr != nil {
  9507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9508. return
  9509. }
  9510. defer resp.Body.Close()
  9511. body, ioErr := ioutil.ReadAll(resp.Body)
  9512. if ioErr != nil {
  9513. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9515. return
  9516. }
  9517. var respJSON map[string]interface{}
  9518. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9519. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9521. return
  9522. }
  9523. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9524. userJSONBytes, _ := json.Marshal(userJSON)
  9525. var res ResultTwo
  9526. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9527. utils.ErrorLog("解析失败:%v", err)
  9528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9529. return
  9530. }
  9531. if res.Infcode == 0 {
  9532. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  9533. var dat map[string]interface{}
  9534. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9535. fmt.Println(dat)
  9536. } else {
  9537. fmt.Println(err)
  9538. }
  9539. userJSONBytes, _ := json.Marshal(dat)
  9540. var res2 ResultThirteen
  9541. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9542. utils.ErrorLog("解析失败:%v", err)
  9543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9544. return
  9545. }
  9546. if res2.Infcode == 0 {
  9547. psnResult := &models.GdybPsnRecord{
  9548. UserOrgId: adminUser.CurrentOrgId,
  9549. PatientId: item.ID,
  9550. PsnNo: res.Output.Baseinfo.PsnNo,
  9551. Ctime: time.Now().Unix(),
  9552. Mtime: time.Now().Unix(),
  9553. Status: 1,
  9554. IsCancel: 1,
  9555. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  9556. }
  9557. service.CreatePsnRecord(psnResult)
  9558. } else {
  9559. c.ServeSuccessJSON(map[string]interface{}{
  9560. "failed_code": -10,
  9561. "msg": res2.ErrMsg,
  9562. })
  9563. return
  9564. }
  9565. }
  9566. }
  9567. }
  9568. }
  9569. func (c *HisApiController) PsnUnPutOnRecord() {
  9570. id, _ := c.GetInt64("id")
  9571. //record_type, _ := c.GetInt64("type")
  9572. admin_user_id, _ := c.GetInt64("admin_user_id")
  9573. adminUser := c.GetAdminUserInfo()
  9574. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9575. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9576. var user_name string
  9577. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9578. if role.ID == 0 {
  9579. user_name = "xxx"
  9580. } else {
  9581. user_name = role.UserName
  9582. }
  9583. psn_record, _ := service.GetPsnRecordById(id)
  9584. if psn_record.ID == 0 {
  9585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  9586. return
  9587. }
  9588. if config.IsOpen == 1 {
  9589. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  9590. var dat map[string]interface{}
  9591. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9592. fmt.Println(dat)
  9593. } else {
  9594. fmt.Println(err)
  9595. }
  9596. userJSONBytes, _ := json.Marshal(dat)
  9597. var res ResultFourteen
  9598. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9599. utils.ErrorLog("解析失败:%v", err)
  9600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9601. return
  9602. }
  9603. if res.Infcode == 0 {
  9604. psn_record.IsCancel = 2
  9605. service.CreatePsnRecord(&psn_record)
  9606. } else {
  9607. c.ServeSuccessJSON(map[string]interface{}{
  9608. "failed_code": -10,
  9609. "msg": res.ErrMsg,
  9610. })
  9611. return
  9612. }
  9613. }
  9614. }
  9615. func (c *HisApiController) PsnPutNCDSOnRecord() {
  9616. patient_id, _ := c.GetInt64("patient_id")
  9617. insutype_two := c.GetString("insutype")
  9618. psn_no := c.GetString("psn_no")
  9619. doctor_id, _ := c.GetInt64("doctor_id")
  9620. sick_id, _ := c.GetInt64("sick_id")
  9621. department_id, _ := c.GetInt64("department_id")
  9622. start_time := c.GetString("start_time")
  9623. end_time := c.GetString("end_time")
  9624. check_time := c.GetString("check_time")
  9625. adminUser := c.GetAdminUserInfo()
  9626. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9627. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9628. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9629. sick, _ := service.FindSickById(sick_id)
  9630. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  9631. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  9632. var res ResultTwo
  9633. var res10265 ResultTwo10265
  9634. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9635. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  9636. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  9637. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  9638. "&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
  9639. resp, requestErr := http.Get(api)
  9640. if requestErr != nil {
  9641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9642. return
  9643. }
  9644. body, ioErr := ioutil.ReadAll(resp.Body)
  9645. if ioErr != nil {
  9646. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9648. return
  9649. }
  9650. var respJSON map[string]interface{}
  9651. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9652. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9654. return
  9655. }
  9656. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9657. result, _ := json.Marshal(respJSON)
  9658. fmt.Println("log")
  9659. fmt.Println(string(result))
  9660. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9661. utils.ErrorLog("解析失败:%v", err)
  9662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9663. return
  9664. }
  9665. res.ErrMsg = res10265.ErrMsg
  9666. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9667. res.Infcode = infocode
  9668. res.Output = res10265.Output
  9669. res.InfRefmsgid = res10265.InfRefmsgid
  9670. } else {
  9671. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  9672. if miConfig.Code == "H15049901371" {
  9673. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9674. utils.ErrorLog("解析失败:%v", err)
  9675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9676. return
  9677. }
  9678. res.ErrMsg = res10265.ErrMsg
  9679. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9680. res.Infcode = infocode
  9681. res.Output = res10265.Output
  9682. res.InfRefmsgid = res10265.InfRefmsgid
  9683. } else {
  9684. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9685. utils.ErrorLog("解析失败:%v", err)
  9686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9687. return
  9688. }
  9689. }
  9690. }
  9691. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9692. infoStr := string(Iinfos)
  9693. var rf []*ResultFive
  9694. json.Unmarshal([]byte(infoStr), &rf)
  9695. var insuplc_admdvs string
  9696. var insutype string
  9697. var is390 int = 0
  9698. var is310 int = 0
  9699. var insutypes []*ResultFive
  9700. for _, item := range rf {
  9701. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9702. insutypes = append(insutypes, item)
  9703. }
  9704. }
  9705. if len(insutypes) == 1 {
  9706. insutype = insutypes[0].Insutype
  9707. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9708. } else {
  9709. for _, i := range insutypes {
  9710. if i.Insutype == "390" {
  9711. is390 = 1
  9712. }
  9713. if i.Insutype == "310" {
  9714. is310 = 1
  9715. }
  9716. }
  9717. }
  9718. if is390 == 1 {
  9719. insutype = "390"
  9720. }
  9721. if is310 == 1 {
  9722. insutype = "310"
  9723. }
  9724. if len(insutypes) == 2 {
  9725. insutype = insutype_two
  9726. }
  9727. if len(insutypes) == 0 {
  9728. insutype = "310"
  9729. }
  9730. insutype = insutype_two
  9731. fmt.Println(insutype)
  9732. for _, item := range rf {
  9733. fmt.Println(item.Insutype)
  9734. fmt.Println(insutype)
  9735. if item.Insutype == insutype {
  9736. fmt.Println(item.Insutype)
  9737. fmt.Println(insutype)
  9738. insuplc_admdvs = item.InsuplcAdmdvs
  9739. }
  9740. }
  9741. fmt.Println(insuplc_admdvs)
  9742. var res2 ResultThirteen
  9743. var res10265_2 ResultThirteen10265
  9744. if config.IsOpen == 1 {
  9745. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9746. } else {
  9747. 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)
  9748. var dat map[string]interface{}
  9749. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9750. fmt.Println(dat)
  9751. } else {
  9752. fmt.Println(err)
  9753. }
  9754. userJSONBytes, _ := json.Marshal(dat)
  9755. if miConfig.Code == "H15049901371" {
  9756. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  9757. utils.ErrorLog("解析失败:%v", err)
  9758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9759. return
  9760. }
  9761. res2.ErrMsg = res10265_2.ErrMsg
  9762. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  9763. res2.Infcode = infocode
  9764. res2.Output = res10265_2.Output
  9765. res2.InfRefmsgid = res10265_2.InfRefmsgid
  9766. } else {
  9767. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9768. utils.ErrorLog("解析失败:%v", err)
  9769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9770. return
  9771. }
  9772. }
  9773. }
  9774. if res2.Infcode == 0 {
  9775. psnResult := &models.GdybPsnNcdsRecord{
  9776. UserOrgId: adminUser.CurrentOrgId,
  9777. PatientId: patient.ID,
  9778. PsnNo: psn_no,
  9779. DoctorId: doctor.AdminUserId,
  9780. DepartmentId: department_id,
  9781. SickType: sick_id,
  9782. Insutype: insutype,
  9783. Ctime: time.Now().Unix(),
  9784. Mtime: time.Now().Unix(),
  9785. Status: 1,
  9786. IsCancel: 1,
  9787. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  9788. }
  9789. service.CreatePsnNCDSRecord(psnResult)
  9790. c.ServeSuccessJSON(map[string]interface{}{
  9791. "failed_code": 0,
  9792. "msg": "备案成功",
  9793. "result": psnResult,
  9794. })
  9795. } else {
  9796. c.ServeSuccessJSON(map[string]interface{}{
  9797. "failed_code": -10,
  9798. "msg": res2.ErrMsg,
  9799. })
  9800. return
  9801. }
  9802. }
  9803. }
  9804. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  9805. id, _ := c.GetInt64("id")
  9806. admin_user_id, _ := c.GetInt64("admin_user_id")
  9807. adminUser := c.GetAdminUserInfo()
  9808. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9809. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9810. //config, _ := service.Ge(adminUser.CurrentOrgId)
  9811. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  9812. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9813. //var user_name string
  9814. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9815. //if role.ID == 0 {
  9816. // user_name = "xxx"
  9817. //} else {
  9818. // user_name = role.UserName
  9819. //}
  9820. psn_record, _ := service.GetPsnNCDSRecordById(id)
  9821. if psn_record.ID == 0 {
  9822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  9823. return
  9824. }
  9825. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  9826. var res ResultTwo
  9827. var res10265 ResultTwo10265
  9828. if miConfig.Code == "H15049901371" {
  9829. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9830. utils.ErrorLog("解析失败:%v", err)
  9831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9832. return
  9833. }
  9834. res.ErrMsg = res10265.ErrMsg
  9835. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9836. res.Infcode = infocode
  9837. res.Output = res10265.Output
  9838. res.InfRefmsgid = res10265.InfRefmsgid
  9839. } else {
  9840. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9841. utils.ErrorLog("解析失败:%v", err)
  9842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9843. return
  9844. }
  9845. }
  9846. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9847. infoStr := string(Iinfos)
  9848. var rf []*ResultFive
  9849. json.Unmarshal([]byte(infoStr), &rf)
  9850. var insuplc_admdvs string
  9851. var insutype string
  9852. var is390 int = 0
  9853. var is310 int = 0
  9854. var insutypes []*ResultFive
  9855. for _, item := range rf {
  9856. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9857. insutypes = append(insutypes, item)
  9858. }
  9859. }
  9860. if len(insutypes) == 1 {
  9861. insutype = insutypes[0].Insutype
  9862. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9863. } else {
  9864. for _, i := range insutypes {
  9865. if i.Insutype == "390" {
  9866. is390 = 1
  9867. }
  9868. if i.Insutype == "310" {
  9869. is310 = 1
  9870. }
  9871. }
  9872. }
  9873. if is390 == 1 {
  9874. insutype = "390"
  9875. }
  9876. if is310 == 1 {
  9877. insutype = "310"
  9878. }
  9879. if len(insutypes) == 0 {
  9880. insutype = "310"
  9881. }
  9882. insutype = psn_record.Insutype
  9883. for _, item := range rf {
  9884. if item.Insutype == insutype {
  9885. insuplc_admdvs = item.InsuplcAdmdvs
  9886. }
  9887. }
  9888. if config.IsOpen == 1 {
  9889. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  9890. var dat map[string]interface{}
  9891. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9892. fmt.Println(dat)
  9893. } else {
  9894. fmt.Println(err)
  9895. }
  9896. userJSONBytes, _ := json.Marshal(dat)
  9897. var res ResultFourteen
  9898. var res10265 ResultFourteen10265
  9899. if miConfig.Code == "H15049901371" {
  9900. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9901. utils.ErrorLog("解析失败:%v", err)
  9902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9903. return
  9904. }
  9905. res.ErrMsg = res10265.ErrMsg
  9906. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9907. res.Infcode = infocode
  9908. res.Output = res10265.Output
  9909. res.InfRefmsgid = res10265.InfRefmsgid
  9910. } else {
  9911. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9912. utils.ErrorLog("解析失败:%v", err)
  9913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9914. return
  9915. }
  9916. }
  9917. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9918. // utils.ErrorLog("解析失败:%v", err)
  9919. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9920. // return
  9921. //}
  9922. if res.Infcode == 0 {
  9923. psn_record.IsCancel = 2
  9924. service.CreatePsnNCDSRecord(&psn_record)
  9925. c.ServeSuccessJSON(map[string]interface{}{
  9926. "failed_code": 0,
  9927. "msg": "撤销备案成功",
  9928. })
  9929. } else {
  9930. c.ServeSuccessJSON(map[string]interface{}{
  9931. "failed_code": -10,
  9932. "msg": res.ErrMsg,
  9933. })
  9934. return
  9935. }
  9936. }
  9937. }
  9938. func (c *HisApiController) TestTest() {
  9939. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  9940. fmt.Println(patient.Iinfo)
  9941. }
  9942. type CustomData struct {
  9943. MsgId string
  9944. PsnNo string
  9945. Info string
  9946. }
  9947. func (c *HisApiController) ReversalData() {
  9948. var customData []*CustomData
  9949. custom := &CustomData{
  9950. MsgId: "H44022900158202103301714472004",
  9951. PsnNo: "44020000001101329945",
  9952. Info: "2207",
  9953. }
  9954. customData = append(customData, custom)
  9955. custom1 := &CustomData{
  9956. MsgId: "H4402290015820210330172057803",
  9957. PsnNo: "44020000001101161813",
  9958. Info: "2207",
  9959. }
  9960. customData = append(customData, custom1)
  9961. custom2 := &CustomData{
  9962. MsgId: "H44022900158202103301705198813",
  9963. PsnNo: "44190000133097375417",
  9964. Info: "2207",
  9965. }
  9966. customData = append(customData, custom2)
  9967. custom3 := &CustomData{
  9968. MsgId: "H44022900158202103301715524756",
  9969. PsnNo: "44020000001100187221",
  9970. Info: "2207",
  9971. }
  9972. customData = append(customData, custom3)
  9973. custom4 := &CustomData{
  9974. MsgId: "H44022900158202103301730376224",
  9975. PsnNo: "44020000001101959155",
  9976. Info: "2207",
  9977. }
  9978. customData = append(customData, custom4)
  9979. custom5 := &CustomData{
  9980. MsgId: "H44022900158202103301748008725",
  9981. PsnNo: "44020000001104246641",
  9982. Info: "2207",
  9983. }
  9984. customData = append(customData, custom5)
  9985. custom6 := &CustomData{
  9986. MsgId: "H44022900158202103301718096755",
  9987. PsnNo: "44020000001102211860",
  9988. Info: "2207",
  9989. }
  9990. customData = append(customData, custom6)
  9991. custom7 := &CustomData{
  9992. MsgId: "H44022900158202103301736551640",
  9993. PsnNo: "44020000001102687718",
  9994. Info: "2207",
  9995. }
  9996. customData = append(customData, custom7)
  9997. custom8 := &CustomData{
  9998. MsgId: "H44022900158202103301743097676",
  9999. PsnNo: "44020000001102127785",
  10000. Info: "2207",
  10001. }
  10002. customData = append(customData, custom8)
  10003. custom9 := &CustomData{
  10004. MsgId: "H44022900158202103301712304203",
  10005. PsnNo: "44020000001101518097",
  10006. Info: "2207",
  10007. }
  10008. customData = append(customData, custom9)
  10009. custom10 := &CustomData{
  10010. MsgId: "H44022900158202103301738448785",
  10011. PsnNo: "44020000001100500813",
  10012. Info: "2207",
  10013. }
  10014. customData = append(customData, custom10)
  10015. custom11 := &CustomData{
  10016. MsgId: "H44022900158202103301732455843",
  10017. PsnNo: "44020000001102690557",
  10018. Info: "2207",
  10019. }
  10020. customData = append(customData, custom11)
  10021. custom12 := &CustomData{
  10022. MsgId: "H44022900158202103301745421708",
  10023. PsnNo: "44020000001102211928",
  10024. Info: "2207",
  10025. }
  10026. customData = append(customData, custom12)
  10027. custom1212 := &CustomData{
  10028. MsgId: "H440229001582021033017351627",
  10029. PsnNo: "44020000001102481733",
  10030. Info: "2207",
  10031. }
  10032. customData = append(customData, custom1212)
  10033. custom13 := &CustomData{
  10034. MsgId: "H44022900158202103301740327951",
  10035. PsnNo: "44020000001103174866",
  10036. Info: "2207",
  10037. }
  10038. customData = append(customData, custom13)
  10039. custom14 := &CustomData{
  10040. MsgId: "H4402290015820210330174922668",
  10041. PsnNo: "44020000001102927272",
  10042. Info: "2207",
  10043. }
  10044. customData = append(customData, custom14)
  10045. custom15 := &CustomData{
  10046. MsgId: "H44022900158202103301752362273",
  10047. PsnNo: "44020000001102942890",
  10048. Info: "2207",
  10049. }
  10050. customData = append(customData, custom15)
  10051. custom16 := &CustomData{
  10052. MsgId: "H44022900158202103301751082917",
  10053. PsnNo: "44020000001101662162",
  10054. Info: "2207",
  10055. }
  10056. customData = append(customData, custom16)
  10057. custom17 := &CustomData{
  10058. MsgId: "H44022900158202103301754147728",
  10059. PsnNo: "44020000000229014511",
  10060. Info: "2207",
  10061. }
  10062. customData = append(customData, custom17)
  10063. adminUser := c.GetAdminUserInfo()
  10064. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10065. for _, item := range customData {
  10066. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10067. fmt.Println(result)
  10068. }
  10069. }
  10070. func (c *HisApiController) GetAllopatry() {
  10071. year := c.GetString("year")
  10072. month := c.GetString("month")
  10073. admin_user_id, _ := c.GetInt64("admin_user_id")
  10074. adminUser := c.GetAdminUserInfo()
  10075. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10076. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10077. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10078. var dat map[string]interface{}
  10079. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10080. fmt.Println(dat)
  10081. } else {
  10082. fmt.Println(err)
  10083. }
  10084. userJSONBytes, _ := json.Marshal(dat)
  10085. var res models.Result9001
  10086. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10087. utils.ErrorLog("解析失败:%v", err)
  10088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10089. return
  10090. }
  10091. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10092. var dat2 map[string]interface{}
  10093. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10094. fmt.Println(dat)
  10095. } else {
  10096. fmt.Println(err)
  10097. }
  10098. userJSONBytes2, _ := json.Marshal(dat2)
  10099. var res2 models.Result3260
  10100. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10101. utils.ErrorLog("解析失败:%v", err)
  10102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10103. return
  10104. }
  10105. if res2.Infcode == 0 {
  10106. c.ServeSuccessJSON(map[string]interface{}{
  10107. "list": res2.Output.Data,
  10108. })
  10109. return
  10110. } else {
  10111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10112. return
  10113. }
  10114. }
  10115. func (c *HisApiController) ComfirmAllopatry() {
  10116. year := c.GetString("year")
  10117. month := c.GetString("month")
  10118. admin_user_id, _ := c.GetInt64("admin_user_id")
  10119. adminUser := c.GetAdminUserInfo()
  10120. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10121. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10122. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10123. var dat map[string]interface{}
  10124. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10125. fmt.Println(dat)
  10126. } else {
  10127. fmt.Println(err)
  10128. }
  10129. userJSONBytes, _ := json.Marshal(dat)
  10130. var res models.Result9001
  10131. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10132. utils.ErrorLog("解析失败:%v", err)
  10133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10134. return
  10135. }
  10136. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10137. var dat2 map[string]interface{}
  10138. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10139. fmt.Println(dat)
  10140. } else {
  10141. fmt.Println(err)
  10142. }
  10143. userJSONBytes2, _ := json.Marshal(dat2)
  10144. var res2 models.Result3260
  10145. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10146. utils.ErrorLog("解析失败:%v", err)
  10147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10148. return
  10149. }
  10150. if res2.Infcode == 0 {
  10151. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  10152. var dat map[string]interface{}
  10153. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10154. fmt.Println(dat)
  10155. } else {
  10156. fmt.Println(err)
  10157. }
  10158. userJSONBytes, _ := json.Marshal(dat)
  10159. var res3 models.Result3261
  10160. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  10161. utils.ErrorLog("解析失败:%v", err)
  10162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10163. return
  10164. }
  10165. if res3.Infcode == 0 {
  10166. record := &models.HisYidiClearRecord{
  10167. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10168. Ctime: time.Now().Unix(),
  10169. Mtime: time.Now().Unix(),
  10170. Status: 1,
  10171. MsgId: msgId,
  10172. }
  10173. service.SaveClearRecord(record)
  10174. c.ServeSuccessJSON(map[string]interface{}{
  10175. "msg": "提取成功",
  10176. })
  10177. }
  10178. }
  10179. }
  10180. func (c *HisApiController) RefundAllopatry() {
  10181. year := c.GetString("year")
  10182. month := c.GetString("month")
  10183. id, _ := c.GetInt64("id")
  10184. admin_user_id, _ := c.GetInt64("admin_user_id")
  10185. adminUser := c.GetAdminUserInfo()
  10186. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10187. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10188. record, _ := service.GetClearRecordById(id)
  10189. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  10190. var dat map[string]interface{}
  10191. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10192. fmt.Println(dat)
  10193. } else {
  10194. fmt.Println(err)
  10195. }
  10196. userJSONBytes, _ := json.Marshal(dat)
  10197. var empty ResultFourteen
  10198. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  10199. utils.ErrorLog("解析失败:%v", err)
  10200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10201. return
  10202. }
  10203. if empty.Infcode == 0 {
  10204. c.ServeSuccessJSON(map[string]interface{}{
  10205. "msg": "撤销成功",
  10206. })
  10207. return
  10208. }
  10209. }
  10210. func (c *HisApiController) ReversalOtherData() {
  10211. var customData []*CustomData
  10212. custom := &CustomData{
  10213. MsgId: "H44022900158202103301714472004",
  10214. PsnNo: "44020000001101329945",
  10215. Info: "2208",
  10216. }
  10217. customData = append(customData, custom)
  10218. custom1 := &CustomData{
  10219. MsgId: "H4402290015820210330172057803",
  10220. PsnNo: "44020000001101161813",
  10221. Info: "2208",
  10222. }
  10223. customData = append(customData, custom1)
  10224. custom2 := &CustomData{
  10225. MsgId: "H44022900158202103301705198813",
  10226. PsnNo: "44190000133097375417",
  10227. Info: "2208",
  10228. }
  10229. customData = append(customData, custom2)
  10230. custom3 := &CustomData{
  10231. MsgId: "H44022900158202103301715524756",
  10232. PsnNo: "44020000001100187221",
  10233. Info: "2208",
  10234. }
  10235. customData = append(customData, custom3)
  10236. custom4 := &CustomData{
  10237. MsgId: "H44022900158202103301730376224",
  10238. PsnNo: "44020000001101959155",
  10239. Info: "2208",
  10240. }
  10241. customData = append(customData, custom4)
  10242. custom5 := &CustomData{
  10243. MsgId: "H44022900158202103301748008725",
  10244. PsnNo: "44020000001104246641",
  10245. Info: "2208",
  10246. }
  10247. customData = append(customData, custom5)
  10248. custom6 := &CustomData{
  10249. MsgId: "H44022900158202103301718096755",
  10250. PsnNo: "44020000001102211860",
  10251. Info: "2208",
  10252. }
  10253. customData = append(customData, custom6)
  10254. custom7 := &CustomData{
  10255. MsgId: "H44022900158202103301736551640",
  10256. PsnNo: "44020000001102687718",
  10257. Info: "2208",
  10258. }
  10259. customData = append(customData, custom7)
  10260. custom8 := &CustomData{
  10261. MsgId: "H44022900158202103301743097676",
  10262. PsnNo: "44020000001102127785",
  10263. Info: "2208",
  10264. }
  10265. customData = append(customData, custom8)
  10266. custom9 := &CustomData{
  10267. MsgId: "H44022900158202103301712304203",
  10268. PsnNo: "44020000001101518097",
  10269. Info: "2208",
  10270. }
  10271. customData = append(customData, custom9)
  10272. custom10 := &CustomData{
  10273. MsgId: "H44022900158202103301738448785",
  10274. PsnNo: "44020000001100500813",
  10275. Info: "2208",
  10276. }
  10277. customData = append(customData, custom10)
  10278. custom11 := &CustomData{
  10279. MsgId: "H44022900158202103301732455843",
  10280. PsnNo: "44020000001102690557",
  10281. Info: "2208",
  10282. }
  10283. customData = append(customData, custom11)
  10284. custom12 := &CustomData{
  10285. MsgId: "H44022900158202103301745421708",
  10286. PsnNo: "44020000001102211928",
  10287. Info: "2208",
  10288. }
  10289. customData = append(customData, custom12)
  10290. custom1212 := &CustomData{
  10291. MsgId: "H440229001582021033017351627",
  10292. PsnNo: "44020000001102481733",
  10293. Info: "2208",
  10294. }
  10295. customData = append(customData, custom1212)
  10296. custom13 := &CustomData{
  10297. MsgId: "H44022900158202103301740327951",
  10298. PsnNo: "44020000001103174866",
  10299. Info: "2208",
  10300. }
  10301. customData = append(customData, custom13)
  10302. custom14 := &CustomData{
  10303. MsgId: "H4402290015820210330174922668",
  10304. PsnNo: "44020000001102927272",
  10305. Info: "2208",
  10306. }
  10307. customData = append(customData, custom14)
  10308. custom15 := &CustomData{
  10309. MsgId: "H44022900158202103301752362273",
  10310. PsnNo: "44020000001102942890",
  10311. Info: "2208",
  10312. }
  10313. customData = append(customData, custom15)
  10314. custom16 := &CustomData{
  10315. MsgId: "H44022900158202103301751082917",
  10316. PsnNo: "44020000001101662162",
  10317. Info: "2208",
  10318. }
  10319. customData = append(customData, custom16)
  10320. custom17 := &CustomData{
  10321. MsgId: "H44022900158202103301754147728",
  10322. PsnNo: "44020000000229014511",
  10323. Info: "2208",
  10324. }
  10325. customData = append(customData, custom17)
  10326. adminUser := c.GetAdminUserInfo()
  10327. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10328. for _, item := range customData {
  10329. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10330. fmt.Println(result)
  10331. }
  10332. }
  10333. func PathExists(path string) (bool, error) {
  10334. _, err := os.Stat(path)
  10335. if err == nil {
  10336. return true, nil
  10337. }
  10338. if os.IsNotExist(err) {
  10339. return false, nil
  10340. }
  10341. return false, err
  10342. }
  10343. //创建文件夹
  10344. func Mkdir(dir string) {
  10345. // 创建文件夹
  10346. exist, err := PathExists(dir)
  10347. if err != nil {
  10348. fmt.Println(err.Error())
  10349. } else {
  10350. if exist {
  10351. fmt.Println(dir + "文件夹已存在!")
  10352. } else {
  10353. // 文件夹名称,权限
  10354. err := os.Mkdir(dir, os.ModePerm)
  10355. if err != nil {
  10356. fmt.Println(dir+"文件夹创建失败:", err.Error())
  10357. } else {
  10358. fmt.Println(dir + "文件夹创建成功!")
  10359. }
  10360. }
  10361. }
  10362. }
  10363. //压缩文件
  10364. func Zip(srcFile string, destZip string) error {
  10365. zipfile, err := os.Create(destZip)
  10366. if err != nil {
  10367. return err
  10368. }
  10369. defer zipfile.Close()
  10370. archive := zip.NewWriter(zipfile)
  10371. defer archive.Close()
  10372. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  10373. if err != nil {
  10374. return err
  10375. }
  10376. header, err := zip.FileInfoHeader(info)
  10377. if err != nil {
  10378. return err
  10379. }
  10380. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  10381. // header.Name = path
  10382. if info.IsDir() {
  10383. header.Name += "/"
  10384. } else {
  10385. header.Method = zip.Deflate
  10386. }
  10387. writer, err := archive.CreateHeader(header)
  10388. if err != nil {
  10389. return err
  10390. }
  10391. if !info.IsDir() {
  10392. file, err := os.Open(path)
  10393. if err != nil {
  10394. return err
  10395. }
  10396. defer file.Close()
  10397. _, err = io.Copy(writer, file)
  10398. }
  10399. return err
  10400. })
  10401. return err
  10402. }
  10403. func ReadFile(filePath string) []byte {
  10404. f, err := os.Open(filePath)
  10405. if err != nil {
  10406. fmt.Println("read file fail", err)
  10407. return nil
  10408. }
  10409. defer f.Close()
  10410. fd, err := ioutil.ReadAll(f)
  10411. if err != nil {
  10412. fmt.Println("read to fd fail", err)
  10413. return nil
  10414. }
  10415. return fd
  10416. }
  10417. func saveLog(result string, request string, infno string, desc string) {
  10418. org_id, _ := beego.AppConfig.Int64("org_id")
  10419. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  10420. dir := miConfig.OrgName + "日志"
  10421. utils.Mkdir(dir)
  10422. month := time.Unix(1557042972, 0).Format("1")
  10423. year := time.Now().Format("2006")
  10424. month = time.Now().Format("01")
  10425. day := time.Now().Format("02")
  10426. hour := time.Now().Format("15")
  10427. min := time.Now().Format("04")
  10428. sec := time.Now().Format("05")
  10429. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  10430. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  10431. file_name := file + ".txt"
  10432. file_path := miConfig.OrgName + "日志" + "/" + file_name
  10433. exist, _ := utils.PathExists(file_path)
  10434. if exist { //存在
  10435. fmt.Println("存在")
  10436. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  10437. if err != nil {
  10438. fmt.Println("read fail")
  10439. }
  10440. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  10441. n, _ := f.Seek(0, 2)
  10442. _, err = f.WriteAt([]byte(content), n)
  10443. } else { //不存在
  10444. fmt.Println("文件不存在,创建文件")
  10445. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  10446. defer f.Close()
  10447. if err != nil {
  10448. } else {
  10449. _, err = f.Write([]byte("记录日志"))
  10450. }
  10451. }
  10452. }
  10453. type Charset string
  10454. const (
  10455. UTF8 = Charset("UTF-8")
  10456. GB18030 = Charset("GB18030")
  10457. )
  10458. func ConvertToString(src string, srcCode string, tagCode string) string {
  10459. srcCoder := mahonia.NewDecoder(srcCode)
  10460. srcResult := srcCoder.ConvertString(src)
  10461. tagCoder := mahonia.NewDecoder(tagCode)
  10462. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  10463. result := string(cdata)
  10464. return result
  10465. }