his_api_controller.go 454KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377
  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. "regexp"
  23. "strconv"
  24. "strings"
  25. "syscall"
  26. "time"
  27. "unsafe"
  28. )
  29. type HisApiController struct {
  30. controllers.BaseAuthAPIController
  31. }
  32. func HisManagerApiRegistRouters() {
  33. //挂号
  34. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  35. //上传就诊信息-上传明细-结算
  36. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  37. //查询
  38. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  39. //对总账
  40. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  41. //对明细
  42. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  43. //退费,退明细
  44. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  45. //退号
  46. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  47. //退明细
  48. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  49. //上传就诊信息-上传明细-预结算
  50. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  51. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  52. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  53. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  54. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  55. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  56. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  57. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  58. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  59. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  60. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  61. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  62. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  63. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  64. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  65. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  66. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  67. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  68. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  69. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  70. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  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. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  76. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  77. beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  78. }
  79. func (c *HisApiController) Get9001() {
  80. adminUser := c.GetAdminUserInfo()
  81. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  82. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  83. if miConfig.MdtrtareaAdmvs == "350500" {
  84. fmt.Println("350500")
  85. service.GetFjAuthorizationInfo(miConfig.Code)
  86. } else {
  87. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  88. var dat map[string]interface{}
  89. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  90. fmt.Println(dat)
  91. } else {
  92. fmt.Println(err)
  93. }
  94. userJSONBytes, _ := json.Marshal(dat)
  95. var res models.Result9001
  96. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  97. utils.ErrorLog("解析失败:%v", err)
  98. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  99. return
  100. }
  101. }
  102. }
  103. func (c *HisApiController) Check3101() {
  104. patient_id, _ := c.GetInt64("patient_id")
  105. his_patient_id, _ := c.GetInt64("his_patient_id")
  106. admin_user_id, _ := c.GetInt64("admin_user_id")
  107. adminUser := c.GetAdminUserInfo()
  108. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  109. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  110. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  111. record_time := c.GetString("record_time")
  112. trig_scen := c.GetString("trig_scen")
  113. timeLayout := "2006-01-02"
  114. loc, _ := time.LoadLocation("Local")
  115. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  116. if err != nil {
  117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  118. return
  119. }
  120. recordDateTime := theTime.Unix()
  121. var patientPrescription models.HisPrescriptionInfo
  122. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  123. if patientPrescription.ID == 0 {
  124. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  125. }
  126. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  127. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  128. //
  129. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  130. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  131. var pp models.PublicParams
  132. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  133. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  134. pp.FixmedinsName = miConfig.OrgName
  135. pp.FixmedinsCode = miConfig.Code
  136. pp.RequestUrl = miConfig.Url
  137. pp.Cainfo = miConfig.Cainfo
  138. pp.SecretKey = miConfig.SecretKey
  139. pp.AccessKey = miConfig.AccessKey
  140. pp.OpterName = roles.UserName
  141. var config []*models.HisXtDiagnoseConfig
  142. for _, item := range diagnosis_ids {
  143. id, _ := strconv.ParseInt(item, 10, 64)
  144. diagnosisConfig, _ := service.FindDiagnoseById(id)
  145. config = append(config, &diagnosisConfig)
  146. }
  147. var pd models.PatientDtos
  148. pd.PatnID = his.PsnNo
  149. pd.PatnName = his.Name
  150. pd.Gend = his.Gend
  151. pd.Brdy = his.Brdy
  152. pd.Poolarea = his.InsuplcAdmdvs
  153. pd.CurrMdtrtID = his.Number
  154. var fed models.FsiEncounterDtos
  155. fed.MdtrtID = his.Number
  156. fed.MedinsID = miConfig.Code
  157. fed.MedinsName = miConfig.OrgName
  158. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  159. fed.MedMdtrtType = "1"
  160. fed.MedinsType = "1"
  161. fed.MedinsLv = "11"
  162. tm := time.Unix(his.RecordDate, 0)
  163. s_tm := tm.Format("2006-01-02 15:04:05")
  164. fed.AdmDate = s_tm
  165. fed.DscgDate = s_tm
  166. fed.DscgMainDiseCodg = config[0].CountryCode
  167. fed.DscgMainDiseName = config[0].CountryContentName
  168. //诊断信息
  169. var fdds []*models.FsiDiagnoseDtos
  170. for index, item := range config {
  171. if index == 0 {
  172. var fdd models.FsiDiagnoseDtos
  173. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  174. fdd.InoutDiseType = "1"
  175. fdd.MaindiseFlag = "1"
  176. fdd.DiseDate = s_tm
  177. fdd.DiasSrtNo = "1"
  178. fdd.DiseName = item.CountryContentName
  179. fdd.DiseCodg = item.CountryCode
  180. fdds = append(fdds, &fdd)
  181. } else {
  182. var fdd models.FsiDiagnoseDtos
  183. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  184. fdd.InoutDiseType = "1"
  185. fdd.MaindiseFlag = "1"
  186. fdd.DiseDate = s_tm
  187. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  188. fdd.DiseName = item.CountryContentName
  189. fdd.DiseCodg = item.CountryCode
  190. fdds = append(fdds, &fdd)
  191. }
  192. }
  193. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  194. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  195. fed.AdmDeptName = department.Name
  196. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  197. fed.DscgDeptName = department.Name
  198. fed.MedMdtrtType = "1"
  199. fed.MedType = "11"
  200. //if his.Insutype == "390" {
  201. // fed.MedType = "1402"
  202. //} else {
  203. // fed.MedType = "9933"
  204. //}
  205. var orders []*models.FsiOrderDtos
  206. if trig_scen == "2" {
  207. //处方医嘱信息
  208. for _, item := range prescriptions {
  209. for _, subItem := range item.HisDoctorAdviceInfo {
  210. var order models.FsiOrderDtos
  211. order.RxID = strconv.FormatInt(item.ID, 10)
  212. order.Rxno = strconv.FormatInt(item.ID, 10)
  213. order.LongDrordFlag = "0"
  214. order.HilistType = "1"
  215. order.ChrgType = "1"
  216. order.DrordBhvr = "-"
  217. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  218. order.HosplistName = subItem.BaseDrugLib.DrugName
  219. order.HilistLv = "1"
  220. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  221. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  222. order.HosplistName = subItem.BaseDrugLib.DrugName
  223. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  224. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  225. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  226. order.OwnpayAmt = ""
  227. order.SelfpayAmt = ""
  228. order.Spec = ""
  229. order.SpecUnt = ""
  230. order.DrordBegnDate = s_tm
  231. order.DrordStopDate = ""
  232. order.DrordDrCodg = "1"
  233. order.DrordDeptName = department.Name
  234. order.DrordDrCodg = "1"
  235. order.DrordDrName = doctor_info.UserName
  236. order.DrordDrProfttl = ""
  237. order.CurrDrordFlag = "1"
  238. orders = append(orders, &order)
  239. }
  240. for _, subItem := range item.HisPrescriptionProject {
  241. if subItem.Type == 2 {
  242. var order models.FsiOrderDtos
  243. order.RxID = strconv.FormatInt(item.ID, 10)
  244. order.Rxno = strconv.FormatInt(item.ID, 10)
  245. order.LongDrordFlag = "0"
  246. order.HilistType = "1"
  247. order.ChrgType = "1"
  248. order.DrordBhvr = "-"
  249. order.HilistCode = subItem.HisProject.MedicalCode
  250. order.HosplistName = subItem.HisProject.ProjectName
  251. order.HilistLv = "1"
  252. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  253. order.HosplistCode = subItem.HisProject.MedicalCode
  254. order.HosplistName = subItem.HisProject.ProjectName
  255. order.Cnt = subItem.Count
  256. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  257. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  258. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  259. order.OwnpayAmt = ""
  260. order.SelfpayAmt = ""
  261. order.Spec = ""
  262. order.SpecUnt = ""
  263. order.DrordBegnDate = s_tm
  264. order.DrordStopDate = ""
  265. order.DrordDrCodg = "1"
  266. order.DrordDeptName = department.Name
  267. order.DrordDrCodg = "1"
  268. order.DrordDrName = doctor_info.UserName
  269. order.DrordDrProfttl = ""
  270. order.CurrDrordFlag = "1"
  271. orders = append(orders, &order)
  272. }
  273. if subItem.Type == 3 {
  274. var order models.FsiOrderDtos
  275. order.RxID = strconv.FormatInt(item.ID, 10)
  276. order.Rxno = strconv.FormatInt(item.ID, 10)
  277. order.LongDrordFlag = "0"
  278. order.HilistType = "1"
  279. order.ChrgType = "1"
  280. order.DrordBhvr = "-"
  281. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  282. order.HosplistName = subItem.GoodInfo.GoodName
  283. order.HilistLv = "1"
  284. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  285. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  286. order.HosplistName = subItem.GoodInfo.GoodName
  287. order.Cnt = subItem.Count
  288. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  289. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  290. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  291. order.OwnpayAmt = ""
  292. order.SelfpayAmt = ""
  293. order.Spec = ""
  294. order.SpecUnt = ""
  295. order.DrordBegnDate = s_tm
  296. order.DrordStopDate = ""
  297. order.DrordDrCodg = "1"
  298. order.DrordDeptName = department.Name
  299. order.DrordDrCodg = "1"
  300. order.DrordDrName = doctor_info.UserName
  301. order.DrordDrProfttl = ""
  302. order.CurrDrordFlag = "1"
  303. orders = append(orders, &order)
  304. }
  305. }
  306. }
  307. //处方医嘱信息
  308. }
  309. fed.MatnStas = "0"
  310. fed.MedfeeSumamt = "0"
  311. fed.OwnpayAmt = "0"
  312. fed.SelfpayAmt = "0"
  313. fed.AcctPayamt = "0"
  314. fed.MaAmt = "0"
  315. fed.HifpPayamt = "0"
  316. fed.SetlTotlnum = "1"
  317. fed.Insutype = his.Insutype
  318. fed.ReimFlag = "0"
  319. fed.OutSetlFlag = "0"
  320. var fopd []*models.FsiOperationDtosData
  321. data := make(map[string]interface{})
  322. data["fed"] = fed
  323. data["fdd"] = fdds
  324. data["fod"] = orders
  325. data["pd"] = pd
  326. data["pp"] = pp
  327. data["fopd"] = fopd
  328. data["trig_scen"] = trig_scen
  329. fmt.Println(data)
  330. fmt.Println(fed)
  331. fmt.Println(fdds)
  332. fmt.Println(orders)
  333. fmt.Println(pd)
  334. fmt.Println(pp)
  335. fmt.Println(fopd)
  336. client := &http.Client{}
  337. bytesData, _ := json.Marshal(data)
  338. var req *http.Request
  339. if miConfig.MdtrtareaAdmvs == "320921" {
  340. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  341. } else {
  342. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  343. }
  344. resp, _ := client.Do(req)
  345. defer resp.Body.Close()
  346. body, ioErr := ioutil.ReadAll(resp.Body)
  347. if ioErr != nil {
  348. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  350. return
  351. }
  352. var respJSON map[string]interface{}
  353. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  354. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  356. return
  357. }
  358. //手术操作集合
  359. //手术操作集合
  360. }
  361. func (c *HisApiController) Check3102() {
  362. patient_id, _ := c.GetInt64("patient_id")
  363. order_id, _ := c.GetInt64("order_id")
  364. his_patient_id, _ := c.GetInt64("his_patient_id")
  365. admin_user_id, _ := c.GetInt64("admin_user_id")
  366. trig_scen := c.GetString("trig_scen")
  367. adminUser := c.GetAdminUserInfo()
  368. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  369. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  370. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  371. record_time := c.GetString("record_time")
  372. order, _ := service.GetHisOrderByID(order_id)
  373. timeLayout := "2006-01-02"
  374. loc, _ := time.LoadLocation("Local")
  375. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  376. if err != nil {
  377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  378. return
  379. }
  380. recordDateTime := theTime.Unix()
  381. var patientPrescription models.HisPrescriptionInfo
  382. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  383. if patientPrescription.ID == 0 {
  384. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  385. }
  386. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  387. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  388. //
  389. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  390. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  391. var pp models.PublicParams
  392. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  393. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  394. pp.FixmedinsName = miConfig.OrgName
  395. pp.FixmedinsCode = miConfig.Code
  396. pp.RequestUrl = miConfig.Url
  397. pp.Cainfo = miConfig.Cainfo
  398. pp.SecretKey = miConfig.SecretKey
  399. pp.AccessKey = miConfig.AccessKey
  400. pp.OpterName = roles.UserName
  401. var config []*models.HisXtDiagnoseConfig
  402. for _, item := range diagnosis_ids {
  403. id, _ := strconv.ParseInt(item, 10, 64)
  404. diagnosisConfig, _ := service.FindDiagnoseById(id)
  405. config = append(config, &diagnosisConfig)
  406. }
  407. var pd models.PatientDtos
  408. pd.PatnID = his.PsnNo
  409. pd.PatnName = his.Name
  410. pd.Gend = his.Gend
  411. pd.Brdy = his.Brdy
  412. pd.Poolarea = his.InsuplcAdmdvs
  413. pd.CurrMdtrtID = his.Number
  414. var fed models.FsiEncounterDtos
  415. fed.MdtrtID = his.Number
  416. fed.MedinsID = miConfig.Code
  417. fed.MedinsName = miConfig.OrgName
  418. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  419. fed.MedMdtrtType = "1"
  420. fed.MedinsType = "1"
  421. fed.MedinsLv = "11"
  422. tm := time.Unix(his.RecordDate, 0)
  423. s_tm := tm.Format("2006-01-02 15:04:05")
  424. fed.AdmDate = s_tm
  425. fed.DscgDate = s_tm
  426. fed.DscgMainDiseCodg = config[0].CountryCode
  427. fed.DscgMainDiseName = config[0].CountryContentName
  428. //诊断信息
  429. var fdds []*models.FsiDiagnoseDtos
  430. for index, item := range config {
  431. if index == 0 {
  432. var fdd models.FsiDiagnoseDtos
  433. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  434. fdd.InoutDiseType = "1"
  435. fdd.MaindiseFlag = "1"
  436. fdd.DiseDate = s_tm
  437. fdd.DiasSrtNo = "1"
  438. fdd.DiseName = item.CountryContentName
  439. fdd.DiseCodg = item.CountryCode
  440. fdds = append(fdds, &fdd)
  441. } else {
  442. var fdd models.FsiDiagnoseDtos
  443. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  444. fdd.InoutDiseType = "1"
  445. fdd.MaindiseFlag = "1"
  446. fdd.DiseDate = s_tm
  447. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  448. fdd.DiseName = item.CountryContentName
  449. fdd.DiseCodg = item.CountryCode
  450. fdds = append(fdds, &fdd)
  451. }
  452. }
  453. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  454. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  455. fed.AdmDeptName = department.Name
  456. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  457. fed.DscgDeptName = department.Name
  458. fed.MedType = order.MedType
  459. //处方医嘱信息
  460. var orders []*models.FsiOrderDtos
  461. //for _, item := range prescriptions {
  462. // for _, subItem := range item.HisDoctorAdviceInfo {
  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.BaseDrugLib.MedicalInsuranceNumber
  471. // order.HosplistName = subItem.BaseDrugLib.DrugName
  472. // order.HilistLv = "1"
  473. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  474. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  475. // order.HosplistName = subItem.BaseDrugLib.DrugName
  476. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  477. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  478. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  479. // order.OwnpayAmt = ""
  480. // order.SelfpayAmt = ""
  481. // order.Spec = ""
  482. // order.SpecUnt = ""
  483. // order.DrordBegnDate = s_tm
  484. // order.DrordStopDate = ""
  485. // order.DrordDrCodg = "1"
  486. // order.DrordDeptName = department.Name
  487. // order.DrordDrCodg = "1"
  488. // order.DrordDrName = doctor_info.UserName
  489. // order.DrordDrProfttl = ""
  490. // order.CurrDrordFlag = "1"
  491. // orders = append(orders, &order)
  492. // }
  493. // for _, subItem := range item.HisPrescriptionProject {
  494. // if subItem.Type == 2 {
  495. // var order models.FsiOrderDtos
  496. // order.RxID = strconv.FormatInt(item.ID, 10)
  497. // order.Rxno = strconv.FormatInt(item.ID, 10)
  498. // order.LongDrordFlag = "0"
  499. // order.HilistType = "1"
  500. // order.ChrgType = "1"
  501. // order.DrordBhvr = "-"
  502. // order.HilistCode = subItem.HisProject.MedicalCode
  503. // order.HosplistName = subItem.HisProject.ProjectName
  504. // order.HilistLv = "1"
  505. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  506. // order.HosplistCode = subItem.HisProject.MedicalCode
  507. // order.HosplistName = subItem.HisProject.ProjectName
  508. // order.Cnt = subItem.Count
  509. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  510. //
  511. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  512. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  513. // order.OwnpayAmt = ""
  514. // order.SelfpayAmt = ""
  515. // order.Spec = ""
  516. // order.SpecUnt = ""
  517. // order.DrordBegnDate = s_tm
  518. // order.DrordStopDate = ""
  519. // order.DrordDrCodg = "1"
  520. // order.DrordDeptName = department.Name
  521. // order.DrordDrCodg = "1"
  522. // order.DrordDrName = doctor_info.UserName
  523. // order.DrordDrProfttl = ""
  524. // order.CurrDrordFlag = "1"
  525. // orders = append(orders, &order)
  526. //
  527. // }
  528. // if subItem.Type == 3 {
  529. //
  530. // var order models.FsiOrderDtos
  531. // order.RxID = strconv.FormatInt(item.ID, 10)
  532. // order.Rxno = strconv.FormatInt(item.ID, 10)
  533. // order.LongDrordFlag = "0"
  534. // order.HilistType = "1"
  535. // order.ChrgType = "1"
  536. // order.DrordBhvr = "-"
  537. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  538. // order.HosplistName = subItem.GoodInfo.GoodName
  539. // order.HilistLv = "1"
  540. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  541. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  542. // order.HosplistName = subItem.GoodInfo.GoodName
  543. // order.Cnt = subItem.Count
  544. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  545. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  546. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  547. // order.OwnpayAmt = ""
  548. // order.SelfpayAmt = ""
  549. // order.Spec = ""
  550. // order.SpecUnt = ""
  551. // order.DrordBegnDate = s_tm
  552. // order.DrordStopDate = ""
  553. // order.DrordDrCodg = "1"
  554. // order.DrordDeptName = department.Name
  555. // order.DrordDrCodg = "1"
  556. // order.DrordDrName = doctor_info.UserName
  557. // order.DrordDrProfttl = ""
  558. // order.CurrDrordFlag = "1"
  559. // orders = append(orders, &order)
  560. //
  561. // }
  562. // }
  563. //}
  564. for _, item := range prescriptions {
  565. for _, subItem := range item.HisDoctorAdviceInfo {
  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.BaseDrugLib.MedicalInsuranceNumber
  574. order.HosplistName = subItem.BaseDrugLib.DrugName
  575. order.HilistLv = "1"
  576. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  577. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  578. order.HosplistName = subItem.BaseDrugLib.DrugName
  579. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  580. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  581. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  582. order.OwnpayAmt = ""
  583. order.SelfpayAmt = ""
  584. order.Spec = ""
  585. order.SpecUnt = ""
  586. order.DrordBegnDate = s_tm
  587. order.DrordStopDate = ""
  588. order.DrordDrCodg = "1"
  589. order.DrordDeptName = department.Name
  590. order.DrordDrCodg = "1"
  591. order.DrordDrName = doctor_info.UserName
  592. order.DrordDrProfttl = ""
  593. order.CurrDrordFlag = "1"
  594. orders = append(orders, &order)
  595. }
  596. for _, subItem := range item.HisPrescriptionProject {
  597. if subItem.Type == 2 {
  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.HisProject.MedicalCode
  606. order.HosplistName = subItem.HisProject.ProjectName
  607. order.HilistLv = "1"
  608. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  609. order.HosplistCode = subItem.HisProject.MedicalCode
  610. order.HosplistName = subItem.HisProject.ProjectName
  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. if subItem.Type == 3 {
  630. var order models.FsiOrderDtos
  631. order.RxID = strconv.FormatInt(item.ID, 10)
  632. order.Rxno = strconv.FormatInt(item.ID, 10)
  633. order.LongDrordFlag = "0"
  634. order.HilistType = "1"
  635. order.ChrgType = "1"
  636. order.DrordBhvr = "-"
  637. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  638. order.HosplistName = subItem.GoodInfo.GoodName
  639. order.HilistLv = "1"
  640. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  641. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  642. order.HosplistName = subItem.GoodInfo.GoodName
  643. order.Cnt = subItem.Count
  644. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  645. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  646. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  647. order.OwnpayAmt = ""
  648. order.SelfpayAmt = ""
  649. order.Spec = ""
  650. order.SpecUnt = ""
  651. order.DrordBegnDate = s_tm
  652. order.DrordStopDate = ""
  653. order.DrordDrCodg = "1"
  654. order.DrordDeptName = department.Name
  655. order.DrordDrCodg = "1"
  656. order.DrordDrName = doctor_info.UserName
  657. order.DrordDrProfttl = ""
  658. order.CurrDrordFlag = "1"
  659. orders = append(orders, &order)
  660. }
  661. }
  662. }
  663. //处方医嘱信息
  664. fed.MatnStas = "0"
  665. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  666. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  667. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  668. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  669. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  670. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  671. fed.SetlTotlnum = "1"
  672. fed.Insutype = his.Insutype
  673. fed.ReimFlag = "0"
  674. fed.OutSetlFlag = "0"
  675. var fopd []*models.FsiOperationDtosData
  676. data := make(map[string]interface{})
  677. data["fed"] = fed
  678. data["fdd"] = fdds
  679. data["fod"] = orders
  680. data["pd"] = pd
  681. data["pp"] = pp
  682. data["fopd"] = fopd
  683. data["trig_scen"] = trig_scen
  684. client := &http.Client{}
  685. bytesData, _ := json.Marshal(data)
  686. var req *http.Request
  687. if miConfig.MdtrtareaAdmvs == "320921" {
  688. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  689. } else {
  690. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  691. }
  692. resp, _ := client.Do(req)
  693. defer resp.Body.Close()
  694. body, ioErr := ioutil.ReadAll(resp.Body)
  695. if ioErr != nil {
  696. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  698. return
  699. }
  700. var respJSON map[string]interface{}
  701. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  702. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  704. return
  705. }
  706. //手术操作集合
  707. //手术操作集合
  708. }
  709. func (c *HisApiController) Check() {
  710. psn_no := c.GetString("psn_no")
  711. in := c.GetString("in")
  712. mt := c.GetString("mt")
  713. baseParams := models.BaseParams{
  714. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  715. FixmedinsCode: "H15049901371",
  716. InsuplcAdmdvs: "150499",
  717. MdtrtareaAdmvs: "150499",
  718. OrgName: "赤峰费森血液透析中心",
  719. Doctor: "1111",
  720. }
  721. service.Gdyb2001(baseParams, psn_no, in, mt)
  722. }
  723. func (c *HisApiController) GetPsnNcdsInfo() {
  724. admin_user_id, _ := c.GetInt64("admin_user_id")
  725. patient_id, _ := c.GetInt64("patient_id")
  726. id, _ := c.GetInt64("id")
  727. adminUser := c.GetAdminUserInfo()
  728. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  729. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  730. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  731. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  732. psn_record, _ := service.GetPsnNCDSRecordById(id)
  733. //
  734. //if psn_record.ID == 0 {
  735. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  736. // return
  737. //}
  738. var res Result5301
  739. var res10265 Result5301For10265
  740. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  741. psn_info, _ := service.GetPsnByPatientId(patient_id)
  742. var api string
  743. if miConfig.MdtrtareaAdmvs == "320921" {
  744. api = "http://192.168.2.110:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  745. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  746. } else {
  747. 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 +
  748. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  749. }
  750. resp, requestErr := http.Get(api)
  751. if requestErr != nil {
  752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  753. return
  754. }
  755. body, ioErr := ioutil.ReadAll(resp.Body)
  756. if ioErr != nil {
  757. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  759. return
  760. }
  761. var respJSON map[string]interface{}
  762. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  763. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  765. return
  766. }
  767. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  768. result, _ := json.Marshal(respJSON)
  769. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  770. utils.ErrorLog("解析失败:%v", err)
  771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  772. return
  773. }
  774. res.ErrMsg = res10265.ErrMsg
  775. res.Output = res10265.Output
  776. res.InfRefmsgid = res10265.InfRefmsgid
  777. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  778. res.Infcode = infocode
  779. } else {
  780. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  781. var dat map[string]interface{}
  782. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  783. fmt.Println(dat)
  784. } else {
  785. fmt.Println(err)
  786. }
  787. userJSONBytes, _ := json.Marshal(dat)
  788. if miConfig.Code == "H15049901371" {
  789. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  790. utils.ErrorLog("解析失败:%v", err)
  791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  792. return
  793. }
  794. res.InfRefmsgid = res10265.InfRefmsgid
  795. res.Output = res10265.Output
  796. res.ErrMsg = res10265.ErrMsg
  797. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  798. res.Infcode = infocode
  799. } else {
  800. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  801. utils.ErrorLog("解析失败:%v", err)
  802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  803. return
  804. }
  805. }
  806. }
  807. if res.Infcode == 0 {
  808. c.ServeSuccessJSON(map[string]interface{}{
  809. "result": res.Output.Result,
  810. })
  811. }
  812. }
  813. func (c *HisApiController) CheckInsutype() {
  814. his_patient_id, _ := c.GetInt64("his_patient_id")
  815. admin_user_id, _ := c.GetInt64("admin_user_id")
  816. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  817. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  818. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  819. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  820. var dat map[string]interface{}
  821. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  822. fmt.Println(dat)
  823. } else {
  824. fmt.Println(err)
  825. }
  826. userJSONBytes, _ := json.Marshal(dat)
  827. var res Result90100
  828. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  829. utils.ErrorLog("解析失败:%v", err)
  830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  831. return
  832. }
  833. if res.Infcode != 0 {
  834. c.ServeSuccessJSON(map[string]interface{}{
  835. "failed_code": -10,
  836. "msg": res.ErrMsg,
  837. })
  838. return
  839. } else {
  840. fmt.Println(res)
  841. }
  842. }
  843. func (c *HisApiController) CheckCardPWD() {
  844. card_pwd := c.GetString("card_pwd")
  845. his_patient_id, _ := c.GetInt64("his_patient_id")
  846. admin_user_id, _ := c.GetInt64("admin_user_id")
  847. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  848. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  849. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  850. psn, _ := service.GetPsnByPatientId(his.PatientId)
  851. bas := strings.Split(psn.CardInfo, "|")
  852. basNumber := bas[2]
  853. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  854. var dat map[string]interface{}
  855. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  856. fmt.Println(dat)
  857. } else {
  858. fmt.Println(err)
  859. }
  860. userJSONBytes, _ := json.Marshal(dat)
  861. var res Result90991
  862. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  863. utils.ErrorLog("解析失败:%v", err)
  864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  865. return
  866. }
  867. if res.Infcode != 0 {
  868. c.ServeSuccessJSON(map[string]interface{}{
  869. "failed_code": -10,
  870. "msg": res.ErrMsg,
  871. })
  872. return
  873. } else {
  874. if res.Output.Result.SscnoCheckStat == "0" {
  875. var msg string
  876. switch res.Output.Result.CardStat {
  877. case "00":
  878. msg = "未激活"
  879. break
  880. case "10":
  881. msg = "激活"
  882. break
  883. case "20":
  884. msg = "窗口挂失"
  885. break
  886. case "21":
  887. msg = "电话挂失"
  888. break
  889. case "22":
  890. msg = "单位网上申报挂失"
  891. break
  892. case "23":
  893. msg = "保健办挂失"
  894. break
  895. case "24":
  896. msg = "个人网上挂失"
  897. break
  898. case "25":
  899. msg = "网上服务大厅挂失"
  900. break
  901. case "30":
  902. msg = "注销"
  903. break
  904. case "40":
  905. msg = "回收"
  906. break
  907. case "99":
  908. msg = "制卡中(无效卡)"
  909. break
  910. }
  911. c.ServeSuccessJSON(map[string]interface{}{
  912. "failed_code": -10,
  913. "msg": msg,
  914. })
  915. return
  916. } else {
  917. c.ServeSuccessJSON(map[string]interface{}{
  918. "msg": "校验成功",
  919. })
  920. return
  921. }
  922. }
  923. }
  924. func (c *HisApiController) CheckCardPWDTwo() {
  925. //card_pwd := c.GetString("card_pwd")
  926. //his_patient_id, _ := c.GetInt64("his_patient_id")
  927. admin_user_id, _ := c.GetInt64("admin_user_id")
  928. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  929. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  930. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  931. var dat map[string]interface{}
  932. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  933. fmt.Println(dat)
  934. } else {
  935. fmt.Println(err)
  936. }
  937. userJSONBytes, _ := json.Marshal(dat)
  938. var res Result90991
  939. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  940. utils.ErrorLog("解析失败:%v", err)
  941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  942. return
  943. }
  944. if res.Infcode != 0 {
  945. c.ServeSuccessJSON(map[string]interface{}{
  946. "failed_code": -10,
  947. "msg": res.ErrMsg,
  948. })
  949. return
  950. } else {
  951. if res.Output.Result.SscnoCheckStat == "0" {
  952. var msg string
  953. switch res.Output.Result.CardStat {
  954. case "00":
  955. msg = "未激活"
  956. break
  957. case "10":
  958. msg = "激活"
  959. break
  960. case "20":
  961. msg = "窗口挂失"
  962. break
  963. case "21":
  964. msg = "电话挂失"
  965. break
  966. case "22":
  967. msg = "单位网上申报挂失"
  968. break
  969. case "23":
  970. msg = "保健办挂失"
  971. break
  972. case "24":
  973. msg = "个人网上挂失"
  974. break
  975. case "25":
  976. msg = "网上服务大厅挂失"
  977. break
  978. case "30":
  979. msg = "注销"
  980. break
  981. case "40":
  982. msg = "回收"
  983. break
  984. case "99":
  985. msg = "制卡中(无效卡)"
  986. break
  987. }
  988. c.ServeSuccessJSON(map[string]interface{}{
  989. "failed_code": -10,
  990. "msg": msg,
  991. })
  992. return
  993. } else {
  994. c.ServeSuccessJSON(map[string]interface{}{
  995. "msg": "校验成功",
  996. })
  997. return
  998. }
  999. }
  1000. }
  1001. func (c *HisApiController) ReadCard() {
  1002. id_card_type, _ := c.GetInt64("id_card_type")
  1003. admin_user_id, _ := c.GetInt64("admin_user_id")
  1004. certificates, _ := c.GetInt64("certificates")
  1005. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  1006. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1007. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1008. switch id_card_type {
  1009. case 1:
  1010. if miConfig.MdtrtareaAdmvs == "421300" {
  1011. var res ResultTwo
  1012. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  1013. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  1014. "&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)
  1015. resp, requestErr := http.Get(api)
  1016. if requestErr != nil {
  1017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1018. return
  1019. }
  1020. body, ioErr := ioutil.ReadAll(resp.Body)
  1021. if ioErr != nil {
  1022. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1024. return
  1025. }
  1026. var respJSON map[string]interface{}
  1027. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1028. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1030. return
  1031. }
  1032. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1033. result, _ := json.Marshal(respJSON)
  1034. fmt.Println("log")
  1035. fmt.Println(string(result))
  1036. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1037. utils.ErrorLog("解析失败:%v", err)
  1038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1039. return
  1040. }
  1041. if res.Infcode == 0 {
  1042. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1043. if err == gorm.ErrRecordNotFound {
  1044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1045. return
  1046. } else if err != nil {
  1047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1048. return
  1049. } else {
  1050. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1051. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1052. infoStr := string(Iinfos)
  1053. idetinfoStr := string(Idetinfos)
  1054. psn := &models.HisPsn{
  1055. PsnNo: res.Output.Baseinfo.PsnNo,
  1056. Age: res.Output.Baseinfo.Age,
  1057. PatientId: patient.ID,
  1058. Certno: res.Output.Baseinfo.Certno,
  1059. Brdy: res.Output.Baseinfo.Brdy,
  1060. Gend: res.Output.Baseinfo.Gend,
  1061. Naty: res.Output.Baseinfo.Naty,
  1062. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1063. PsnName: res.Output.Baseinfo.PsnName,
  1064. Idetinfo: idetinfoStr,
  1065. Insuinfo: infoStr,
  1066. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1067. }
  1068. service.CreateHisPsn(psn)
  1069. c.ServeSuccessJSON(map[string]interface{}{
  1070. "patient": patient,
  1071. "number": res.Output.Baseinfo.Certno,
  1072. })
  1073. }
  1074. } else {
  1075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1076. return
  1077. }
  1078. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1079. var api string
  1080. if miConfig.MdtrtareaAdmvs == "320921" {
  1081. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1082. "&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
  1083. fmt.Println(api)
  1084. } else {
  1085. 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 +
  1086. "&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)
  1087. }
  1088. resp, requestErr := http.Get(api)
  1089. if requestErr != nil {
  1090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1091. return
  1092. }
  1093. body, ioErr := ioutil.ReadAll(resp.Body)
  1094. if ioErr != nil {
  1095. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1097. return
  1098. }
  1099. var respJSON map[string]interface{}
  1100. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1101. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1103. return
  1104. }
  1105. var status string
  1106. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1107. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1108. //console.log()
  1109. fmt.Println("type===")
  1110. fmt.Println(card_type)
  1111. var token string
  1112. var res ResultTwo //1101结果
  1113. var res10265 ResultTwo10265 //1101结果
  1114. var card_info string //卡信息
  1115. var busi_card_info string
  1116. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1117. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1118. if status == "0" { //读卡成功
  1119. if card_type == "1" {
  1120. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1121. result, _ := json.Marshal(respJSON)
  1122. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1123. utils.ErrorLog("解析失败:%v", err)
  1124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1125. return
  1126. }
  1127. res.ErrMsg = res10265.ErrMsg
  1128. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1129. res.Infcode = infocode
  1130. res.Output = res10265.Output
  1131. res.InfRefmsgid = res10265.InfRefmsgid
  1132. } else {
  1133. //var card_info string //卡信息
  1134. //var busi_card_info string
  1135. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1136. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1137. //fmt.Println(card_info)
  1138. //fmt.Println(busi_card_info)
  1139. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1140. result, _ := json.Marshal(respJSON)
  1141. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1142. utils.ErrorLog("解析失败:%v", err)
  1143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1144. return
  1145. }
  1146. res.ErrMsg = res10265.ErrMsg
  1147. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1148. res.Infcode = infocode
  1149. res.Output = res10265.Output
  1150. res.InfRefmsgid = res10265.InfRefmsgid
  1151. }
  1152. if res.Infcode == 0 {
  1153. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1154. if err == gorm.ErrRecordNotFound {
  1155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1156. return
  1157. } else if err != nil {
  1158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1159. return
  1160. } else {
  1161. if card_type == "1" {
  1162. bas := strings.Split(card_info, "|")
  1163. basNumber := bas[2]
  1164. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1165. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1166. infoStr := string(Iinfos)
  1167. idetinfoStr := string(Idetinfos)
  1168. psn := &models.HisPsn{
  1169. PsnNo: res.Output.Baseinfo.PsnNo,
  1170. Age: res.Output.Baseinfo.Age,
  1171. PatientId: patient.ID,
  1172. Certno: res.Output.Baseinfo.Certno,
  1173. Brdy: res.Output.Baseinfo.Brdy,
  1174. Gend: res.Output.Baseinfo.Gend,
  1175. Naty: res.Output.Baseinfo.Naty,
  1176. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1177. PsnName: res.Output.Baseinfo.PsnName,
  1178. Idetinfo: idetinfoStr,
  1179. Insuinfo: infoStr,
  1180. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1181. CardInfo: card_info,
  1182. VerifyNumber: busi_card_info,
  1183. }
  1184. service.CreateHisPsn(psn)
  1185. var rf []*ResultFive
  1186. json.Unmarshal([]byte(infoStr), &rf)
  1187. var insutypes []*ResultFive
  1188. var insutype string
  1189. var is390 int = 0
  1190. var is310 int = 0
  1191. for _, item := range rf {
  1192. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1193. insutypes = append(insutypes, item)
  1194. }
  1195. }
  1196. if len(insutypes) == 1 {
  1197. insutype = insutypes[0].Insutype
  1198. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1199. } else {
  1200. for _, i := range insutypes {
  1201. if i.Insutype == "390" {
  1202. is390 = 1
  1203. }
  1204. if i.Insutype == "310" {
  1205. is310 = 1
  1206. }
  1207. }
  1208. }
  1209. if is390 == 1 {
  1210. insutype = "390"
  1211. }
  1212. if is310 == 1 {
  1213. insutype = "310"
  1214. }
  1215. if len(insutypes) == 0 {
  1216. insutype = "310"
  1217. }
  1218. c.ServeSuccessJSON(map[string]interface{}{
  1219. "patient": patient,
  1220. "number": basNumber,
  1221. "insutype": insutype,
  1222. })
  1223. } else {
  1224. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1225. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1226. infoStr := string(Iinfos)
  1227. idetinfoStr := string(Idetinfos)
  1228. psn := &models.HisPsn{
  1229. PsnNo: res.Output.Baseinfo.PsnNo,
  1230. Age: res.Output.Baseinfo.Age,
  1231. PatientId: patient.ID,
  1232. Certno: res.Output.Baseinfo.Certno,
  1233. Brdy: res.Output.Baseinfo.Brdy,
  1234. Gend: res.Output.Baseinfo.Gend,
  1235. Naty: res.Output.Baseinfo.Naty,
  1236. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1237. PsnName: res.Output.Baseinfo.PsnName,
  1238. Idetinfo: idetinfoStr,
  1239. Insuinfo: infoStr,
  1240. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1241. CardInfo: card_info,
  1242. VerifyNumber: token,
  1243. }
  1244. service.CreateHisPsn(psn)
  1245. c.ServeSuccessJSON(map[string]interface{}{
  1246. "patient": patient,
  1247. "number": token,
  1248. })
  1249. }
  1250. }
  1251. } else {
  1252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1253. return
  1254. }
  1255. } else { //读卡失败
  1256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1257. return
  1258. }
  1259. } else if miConfig.MdtrtareaAdmvs == "350500" {
  1260. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  1261. cardnum = DeleteExtraSpaceTwo(cardnum)
  1262. cardCode = DeleteExtraSpaceTwo(cardCode)
  1263. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  1264. name = DeleteExtraSpaceTwo(name)
  1265. errmsg = DeleteExtraSpaceTwo(errmsg)
  1266. cardnum = Remove0000(cardnum)
  1267. cardCode = Remove0000(cardCode)
  1268. id_card_no = Remove0000(id_card_no)
  1269. name = Remove0000(name)
  1270. errmsg = Remove0000(errmsg)
  1271. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  1272. result, _ := service.FJyb1101(cardnum, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, cardCode, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  1273. var dat map[string]interface{}
  1274. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1275. fmt.Println(dat)
  1276. } else {
  1277. fmt.Println(err)
  1278. }
  1279. userJSONBytes, _ := json.Marshal(dat)
  1280. var res ResultTwo
  1281. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1282. utils.ErrorLog("解析失败:%v", err)
  1283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1284. return
  1285. }
  1286. if res.Infcode == 0 {
  1287. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  1288. if err == gorm.ErrRecordNotFound {
  1289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1290. return
  1291. } else if err != nil {
  1292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1293. return
  1294. } else {
  1295. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1296. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1297. infoStr := string(Iinfos)
  1298. idetinfoStr := string(Idetinfos)
  1299. psn := &models.HisPsn{
  1300. PsnNo: res.Output.Baseinfo.PsnNo,
  1301. Age: res.Output.Baseinfo.Age,
  1302. PatientId: patient.ID,
  1303. Certno: res.Output.Baseinfo.Certno,
  1304. Brdy: res.Output.Baseinfo.Brdy,
  1305. Gend: res.Output.Baseinfo.Gend,
  1306. Naty: res.Output.Baseinfo.Naty,
  1307. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1308. PsnName: res.Output.Baseinfo.PsnName,
  1309. Idetinfo: idetinfoStr,
  1310. Insuinfo: infoStr,
  1311. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1312. CardInfo: basStr,
  1313. VerifyNumber: "",
  1314. }
  1315. service.CreateHisPsn(psn)
  1316. c.ServeSuccessJSON(map[string]interface{}{
  1317. "patient": patient,
  1318. "number": cardnum,
  1319. })
  1320. }
  1321. } else {
  1322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1323. return
  1324. }
  1325. } else {
  1326. if initFlag == 0 {
  1327. c.TestGetBasBaseInit()
  1328. }
  1329. basStr := c.GetBasBaseInfo()
  1330. if len(basStr) == 0 {
  1331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1332. return
  1333. }
  1334. fmt.Println(basStr)
  1335. bas := strings.Split(basStr, "|")
  1336. basNumber := bas[1]
  1337. fmt.Println(basNumber)
  1338. card_sn := bas[3]
  1339. fmt.Println(card_sn)
  1340. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1341. var dat map[string]interface{}
  1342. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1343. fmt.Println(dat)
  1344. } else {
  1345. fmt.Println(err)
  1346. }
  1347. userJSONBytes, _ := json.Marshal(dat)
  1348. var res ResultTwo
  1349. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1350. utils.ErrorLog("解析失败:%v", err)
  1351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1352. return
  1353. }
  1354. if res.Infcode == 0 {
  1355. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1356. if err == gorm.ErrRecordNotFound {
  1357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1358. return
  1359. } else if err != nil {
  1360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1361. return
  1362. } else {
  1363. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1364. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1365. infoStr := string(Iinfos)
  1366. idetinfoStr := string(Idetinfos)
  1367. psn := &models.HisPsn{
  1368. PsnNo: res.Output.Baseinfo.PsnNo,
  1369. Age: res.Output.Baseinfo.Age,
  1370. PatientId: patient.ID,
  1371. Certno: res.Output.Baseinfo.Certno,
  1372. Brdy: res.Output.Baseinfo.Brdy,
  1373. Gend: res.Output.Baseinfo.Gend,
  1374. Naty: res.Output.Baseinfo.Naty,
  1375. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1376. PsnName: res.Output.Baseinfo.PsnName,
  1377. Idetinfo: idetinfoStr,
  1378. Insuinfo: infoStr,
  1379. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1380. CardInfo: basStr,
  1381. VerifyNumber: "",
  1382. }
  1383. service.CreateHisPsn(psn)
  1384. c.ServeSuccessJSON(map[string]interface{}{
  1385. "patient": patient,
  1386. "number": basNumber,
  1387. })
  1388. }
  1389. } else {
  1390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1391. return
  1392. }
  1393. break
  1394. }
  1395. case 2:
  1396. SFZStr := c.GetSFZBaseInfo()
  1397. id_card_str := strings.Split(SFZStr, "^")
  1398. id_card_number := id_card_str[0]
  1399. card_sn := ""
  1400. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1401. var dat map[string]interface{}
  1402. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1403. fmt.Println(dat)
  1404. } else {
  1405. fmt.Println(err)
  1406. }
  1407. userJSONBytes, _ := json.Marshal(dat)
  1408. var res ResultTwo
  1409. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1410. utils.ErrorLog("解析失败:%v", err)
  1411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1412. return
  1413. }
  1414. if res.Infcode == 0 {
  1415. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1416. if err == gorm.ErrRecordNotFound {
  1417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1418. return
  1419. } else if err != nil {
  1420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1421. return
  1422. } else {
  1423. c.ServeSuccessJSON(map[string]interface{}{
  1424. "patient": patient,
  1425. "number": id_card_number,
  1426. })
  1427. }
  1428. } else {
  1429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1430. return
  1431. }
  1432. break
  1433. case 3:
  1434. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1435. var api string
  1436. if miConfig.MdtrtareaAdmvs == "320921" {
  1437. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1438. "&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
  1439. fmt.Println(api)
  1440. } else {
  1441. 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 +
  1442. "&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)
  1443. }
  1444. resp, requestErr := http.Get(api)
  1445. if requestErr != nil {
  1446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1447. return
  1448. }
  1449. body, ioErr := ioutil.ReadAll(resp.Body)
  1450. if ioErr != nil {
  1451. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1453. return
  1454. }
  1455. var respJSON map[string]interface{}
  1456. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1457. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1459. return
  1460. }
  1461. var status string
  1462. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1463. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1464. var token string
  1465. var res ResultTwo //1101结果
  1466. var res10265 ResultTwo10265 //1101结果
  1467. var card_info string //卡信息
  1468. var busi_card_info string
  1469. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1470. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1471. if status == "0" { //读卡成功
  1472. if card_type == "1" {
  1473. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1474. result, _ := json.Marshal(respJSON)
  1475. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1476. utils.ErrorLog("解析失败:%v", err)
  1477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1478. return
  1479. }
  1480. res.ErrMsg = res10265.ErrMsg
  1481. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1482. res.Infcode = infocode
  1483. res.Output = res10265.Output
  1484. res.InfRefmsgid = res10265.InfRefmsgid
  1485. } else {
  1486. //var card_info string //卡信息
  1487. //var busi_card_info string
  1488. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1489. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1490. //fmt.Println(card_info)
  1491. //fmt.Println(busi_card_info)
  1492. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1493. result, _ := json.Marshal(respJSON)
  1494. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1495. utils.ErrorLog("解析失败:%v", err)
  1496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1497. return
  1498. }
  1499. res.ErrMsg = res10265.ErrMsg
  1500. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1501. res.Infcode = infocode
  1502. res.Output = res10265.Output
  1503. res.InfRefmsgid = res10265.InfRefmsgid
  1504. }
  1505. if res.Infcode == 0 {
  1506. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1507. if err == gorm.ErrRecordNotFound {
  1508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1509. return
  1510. } else if err != nil {
  1511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1512. return
  1513. } else {
  1514. if card_type == "1" {
  1515. bas := strings.Split(card_info, "|")
  1516. basNumber := bas[2]
  1517. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1518. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1519. infoStr := string(Iinfos)
  1520. idetinfoStr := string(Idetinfos)
  1521. psn := &models.HisPsn{
  1522. PsnNo: res.Output.Baseinfo.PsnNo,
  1523. Age: res.Output.Baseinfo.Age,
  1524. PatientId: patient.ID,
  1525. Certno: res.Output.Baseinfo.Certno,
  1526. Brdy: res.Output.Baseinfo.Brdy,
  1527. Gend: res.Output.Baseinfo.Gend,
  1528. Naty: res.Output.Baseinfo.Naty,
  1529. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1530. PsnName: res.Output.Baseinfo.PsnName,
  1531. Idetinfo: idetinfoStr,
  1532. Insuinfo: infoStr,
  1533. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1534. CardInfo: card_info,
  1535. VerifyNumber: busi_card_info,
  1536. }
  1537. service.CreateHisPsn(psn)
  1538. c.ServeSuccessJSON(map[string]interface{}{
  1539. "patient": patient,
  1540. "number": basNumber,
  1541. })
  1542. } else {
  1543. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1544. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1545. infoStr := string(Iinfos)
  1546. idetinfoStr := string(Idetinfos)
  1547. psn := &models.HisPsn{
  1548. PsnNo: res.Output.Baseinfo.PsnNo,
  1549. Age: res.Output.Baseinfo.Age,
  1550. PatientId: patient.ID,
  1551. Certno: res.Output.Baseinfo.Certno,
  1552. Brdy: res.Output.Baseinfo.Brdy,
  1553. Gend: res.Output.Baseinfo.Gend,
  1554. Naty: res.Output.Baseinfo.Naty,
  1555. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1556. PsnName: res.Output.Baseinfo.PsnName,
  1557. Idetinfo: idetinfoStr,
  1558. Insuinfo: infoStr,
  1559. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1560. CardInfo: card_info,
  1561. VerifyNumber: token,
  1562. }
  1563. service.CreateHisPsn(psn)
  1564. var rf []*ResultFive
  1565. json.Unmarshal([]byte(infoStr), &rf)
  1566. var insutypes []*ResultFive
  1567. var insutype string
  1568. var is390 int = 0
  1569. var is310 int = 0
  1570. for _, item := range rf {
  1571. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1572. insutypes = append(insutypes, item)
  1573. }
  1574. }
  1575. if len(insutypes) == 1 {
  1576. insutype = insutypes[0].Insutype
  1577. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1578. } else {
  1579. for _, i := range insutypes {
  1580. if i.Insutype == "390" {
  1581. is390 = 1
  1582. }
  1583. if i.Insutype == "310" {
  1584. is310 = 1
  1585. }
  1586. }
  1587. }
  1588. if is390 == 1 {
  1589. insutype = "390"
  1590. }
  1591. if is310 == 1 {
  1592. insutype = "310"
  1593. }
  1594. if len(insutypes) == 0 {
  1595. insutype = "310"
  1596. }
  1597. c.ServeSuccessJSON(map[string]interface{}{
  1598. "patient": patient,
  1599. "number": token,
  1600. "insutype": insutype,
  1601. })
  1602. }
  1603. }
  1604. } else {
  1605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1606. return
  1607. }
  1608. } else { //读卡失败
  1609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1610. return
  1611. }
  1612. }
  1613. break
  1614. case 4:
  1615. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1616. var api string
  1617. if miConfig.MdtrtareaAdmvs == "320921" {
  1618. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1619. "&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
  1620. fmt.Println(api)
  1621. } else {
  1622. 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 +
  1623. "&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)
  1624. }
  1625. resp, requestErr := http.Get(api)
  1626. if requestErr != nil {
  1627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1628. return
  1629. }
  1630. body, ioErr := ioutil.ReadAll(resp.Body)
  1631. if ioErr != nil {
  1632. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1634. return
  1635. }
  1636. var respJSON map[string]interface{}
  1637. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1638. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1640. return
  1641. }
  1642. var status string
  1643. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1644. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1645. var token string
  1646. var res ResultTwo //1101结果
  1647. var res10265 ResultTwo10265 //1101结果
  1648. if status == "0" { //读卡成功
  1649. var card_info string //卡信息
  1650. var busi_card_info string
  1651. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1652. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1653. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1654. fmt.Println(card_info)
  1655. fmt.Println(busi_card_info)
  1656. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1657. result, _ := json.Marshal(respJSON)
  1658. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1659. utils.ErrorLog("解析失败:%v", err)
  1660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1661. return
  1662. }
  1663. res.ErrMsg = res10265.ErrMsg
  1664. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1665. res.Infcode = infocode
  1666. res.Output = res10265.Output
  1667. res.InfRefmsgid = res10265.InfRefmsgid
  1668. if res.Infcode == 0 {
  1669. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1670. if err == gorm.ErrRecordNotFound {
  1671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1672. return
  1673. } else if err != nil {
  1674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1675. return
  1676. } else {
  1677. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1678. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1679. infoStr := string(Iinfos)
  1680. idetinfoStr := string(Idetinfos)
  1681. psn := &models.HisPsn{
  1682. PsnNo: res.Output.Baseinfo.PsnNo,
  1683. Age: res.Output.Baseinfo.Age,
  1684. PatientId: patient.ID,
  1685. Certno: res.Output.Baseinfo.Certno,
  1686. Brdy: res.Output.Baseinfo.Brdy,
  1687. Gend: res.Output.Baseinfo.Gend,
  1688. Naty: res.Output.Baseinfo.Naty,
  1689. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1690. PsnName: res.Output.Baseinfo.PsnName,
  1691. Idetinfo: idetinfoStr,
  1692. Insuinfo: infoStr,
  1693. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1694. CardInfo: card_info,
  1695. VerifyNumber: token,
  1696. }
  1697. service.CreateHisPsn(psn)
  1698. c.ServeSuccessJSON(map[string]interface{}{
  1699. "patient": patient,
  1700. "number": token,
  1701. })
  1702. }
  1703. } else {
  1704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1705. return
  1706. }
  1707. } else { //读卡失败
  1708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1709. return
  1710. }
  1711. } else if miConfig.MdtrtareaAdmvs == "440300" || miConfig.MdtrtareaAdmvs == "440305" {
  1712. }
  1713. break
  1714. }
  1715. }
  1716. var initFlag int64 = 0
  1717. func (c *HisApiController) TestGetBasBaseInit() {
  1718. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1719. Iinit := DllDef.MustFindProc("Init")
  1720. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1721. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  1722. if ret != 0 {
  1723. fmt.Println("SSCard的报错原因:", err)
  1724. fmt.Println("SSCard的运算结果为:", ret)
  1725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1726. return
  1727. }
  1728. result := int(ret)
  1729. fmt.Println("SSCard的运算结果为1:", result)
  1730. initFlag = 1
  1731. return
  1732. }
  1733. func (c *HisApiController) GetSFZBaseInfo() string {
  1734. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1735. readCard := DllDef.MustFindProc("ReadSFZ")
  1736. if readCard == nil {
  1737. fmt.Println("readcard is nil")
  1738. readCard = DllDef.MustFindProc("ReadSFZ")
  1739. }
  1740. str := make([]byte, 256)
  1741. str1 := make([]byte, 256)
  1742. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1743. fmt.Println(r)
  1744. return string(str)
  1745. }
  1746. func (c *HisApiController) GetBasBaseInfo() string {
  1747. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1748. readCard := DllDef.MustFindProc("ReadCardBas")
  1749. if readCard == nil {
  1750. fmt.Println("readcard is nil")
  1751. readCard = DllDef.MustFindProc("ReadCardBas")
  1752. }
  1753. str := make([]byte, 1024)
  1754. str1 := make([]byte, 1024)
  1755. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  1756. fmt.Println(string(str1))
  1757. fmt.Println(string(str))
  1758. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1759. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1760. if ret2 != 0 {
  1761. return ""
  1762. }
  1763. return string(str)
  1764. }
  1765. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  1766. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  1767. readCard := DllDef.MustFindProc("read_cardinfo")
  1768. if readCard == nil {
  1769. fmt.Println("readcard is nil")
  1770. readCard = DllDef.MustFindProc("read_cardinfo")
  1771. }
  1772. str := make([]byte, 1024) //卡号
  1773. str1 := make([]byte, 1024) //卡识别码
  1774. str2 := make([]byte, 1024) //身份证号
  1775. str3 := make([]byte, 1024) //姓名
  1776. str4 := make([]byte, 1024) //错误信息
  1777. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])), (uintptr)(unsafe.Pointer(&str2[0])), (uintptr)(unsafe.Pointer(&str3[0])), (uintptr)(unsafe.Pointer(&str4[0])))
  1778. fmt.Println(string(str1))
  1779. fmt.Println(string(str))
  1780. fmt.Println(string(str2))
  1781. fmt.Println(string(str3))
  1782. fmt.Println(string(str4))
  1783. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1784. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1785. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  1786. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  1787. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  1788. if ret2 != 0 {
  1789. return "", "", "", "", ""
  1790. }
  1791. return string(str), string(str1), string(str2), string(str3), string(str4)
  1792. }
  1793. type CustomFundPay struct {
  1794. FundPayType string `json:"fund_pay_type"`
  1795. FundPayamt float64 `json:"fund_payamt"`
  1796. }
  1797. func (c *HisApiController) GetSettleList() {
  1798. order_id, _ := c.GetInt64("order_id")
  1799. admin_user_id, _ := c.GetInt64("admin_user_id")
  1800. order, _ := service.GetHisOrderByIDTwo(order_id)
  1801. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1802. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1803. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1804. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1805. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1806. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1807. if order.ID == 0 {
  1808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1809. return
  1810. }
  1811. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1812. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1813. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1814. fmt.Println(count)
  1815. var zero string
  1816. number := count + 1
  1817. if number >= 1000 {
  1818. zero = "0000" + strconv.FormatInt(number, 10)
  1819. } else if number >= 10000 {
  1820. zero = "000" + strconv.FormatInt(number, 10)
  1821. } else if number >= 100000 {
  1822. zero = "00" + strconv.FormatInt(number, 10)
  1823. } else if number >= 1000000 {
  1824. zero = "0" + strconv.FormatInt(number, 10)
  1825. } else {
  1826. zero = strconv.FormatInt(number, 10)
  1827. }
  1828. fmt.Println(zero)
  1829. struct4101 := service.Struct4101{
  1830. PsnNo: order.PsnNo,
  1831. MdtrtId: order.MdtrtId,
  1832. SetlId: order.SetlId,
  1833. PsnName: order.PsnName,
  1834. Gend: order.Gend,
  1835. Brdy: his.Brdy,
  1836. Age: his.Age,
  1837. Naty: order.Naty,
  1838. PatnCertType: "01",
  1839. Certno: order.Certno,
  1840. Prfs: "90",
  1841. ConerName: roles[0].UserName,
  1842. PatnRlts: "99",
  1843. ConerAddr: miConfig.OrgName,
  1844. ConerTel: admin.Mobile,
  1845. HiType: order.Insutype,
  1846. Insuplc: miConfig.InsuplcAdmdvs,
  1847. MaindiagFlag: "1",
  1848. BillCode: last_order.FaPiaoCode,
  1849. BillNo: zero,
  1850. BizSn: order.Number,
  1851. PsnSelfPay: order.PsnPartAmt,
  1852. PsnOwnPay: order.PsnPartAmt,
  1853. AcctPay: order.AcctPay,
  1854. PsnCashpay: order.PsnCashPay,
  1855. HiPaymtd: "1",
  1856. Hsorg: miConfig.InsuplcAdmdvs,
  1857. HsorgOpter: miConfig.InsuplcAdmdvs,
  1858. MedinsFillPsn: curRoles.UserName,
  1859. MedinsFillDept: depart.Name,
  1860. IptMedType: "2",
  1861. }
  1862. struct4101.SetlBegnDate = order.SetlTime
  1863. struct4101.SetlEndDate = order.SetlTime
  1864. time_arr := strings.Split(order.SetlTime, " ")
  1865. struct4101.AdmTime = time_arr[0]
  1866. struct4101.AdmEndTime = time_arr[0]
  1867. var rf []CustomFundPay
  1868. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1869. var tempFunPays []service.CustomStruct
  1870. for _, item := range rf {
  1871. var tempFunPay service.CustomStruct
  1872. tempFunPay.FundPayamt = item.FundPayamt
  1873. tempFunPay.FundPayType = item.FundPayType
  1874. tempFunPays = append(tempFunPays, tempFunPay)
  1875. }
  1876. struct4101.CustomStruct = tempFunPays
  1877. var tempDiaginfos []service.DiaginfoStructTwo
  1878. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1879. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1880. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  1881. var config []*models.HisXtDiagnoseConfig
  1882. for _, item := range diagnosis_ids {
  1883. id, _ := strconv.ParseInt(item, 10, 64)
  1884. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1885. config = append(config, &diagnosisConfig)
  1886. }
  1887. for index, item := range config {
  1888. if index == 0 {
  1889. var tempDiaginfo service.DiaginfoStructTwo
  1890. tempDiaginfo.DiagCode = item.CountryCode
  1891. tempDiaginfo.DiagName = item.CountryContentName
  1892. tempDiaginfo.DiagType = "1"
  1893. tempDiaginfo.MaindiagFlag = "1"
  1894. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1895. } else {
  1896. var tempDiaginfo service.DiaginfoStructTwo
  1897. tempDiaginfo.DiagCode = item.CountryCode
  1898. tempDiaginfo.DiagName = item.CountryContentName
  1899. tempDiaginfo.DiagType = "2"
  1900. tempDiaginfo.MaindiagFlag = "0"
  1901. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1902. }
  1903. }
  1904. struct4101.Diseinfo = tempDiaginfos
  1905. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1906. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1907. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1908. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  1909. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  1910. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1911. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1912. var iteminfo service.IteminfoStruct
  1913. var bedCostTotal float64 = 0 //床位总费
  1914. var bedCostSelfTotal float64 = 0 //床位自费
  1915. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1916. var operationCostTotal float64 = 0 //手术费
  1917. var operationCostSelfTotal float64 = 0 //手术费
  1918. var operationCostPartSelfTotal float64 = 0 //手术费
  1919. var otherCostTotal float64 = 0 //其他费用
  1920. var otherCostSelfTotal float64 = 0 //其他费用
  1921. var otherCostPartSelfTotal float64 = 0 //其他费用
  1922. var materialCostTotal float64 = 0 //材料费
  1923. var materialCostSelfTotal float64 = 0 //材料费
  1924. var materialCostPartSelfTotal float64 = 0 //材料费
  1925. var westernMedicineCostTotal float64 = 0 //西药费
  1926. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1927. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1928. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1929. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1930. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1931. var checkCostTotal float64 = 0 //检查费
  1932. var checkCostSelfTotal float64 = 0 //检查费
  1933. var checkCostPartSelfTotal float64 = 0 //检查费
  1934. var laboratoryCostTotal float64 = 0 //化验费
  1935. var laboratoryCostSelfTotal float64 = 0 //化验费
  1936. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1937. var treatCostTotal float64 = 0 //治疗费用
  1938. var treatCostSelfTotal float64 = 0 //治疗费用
  1939. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1940. decimal.DivisionPrecision = 2
  1941. var bed_fulamt_ownpay_amt float64 = 0
  1942. var operation_fulamt_ownpay_amt float64 = 0
  1943. var other_fulamt_ownpay_amt float64 = 0
  1944. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1945. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1946. var check_fulamt_ownpay_amt float64 = 0
  1947. var material_fulamt_ownpay_amt float64 = 0
  1948. var laboratory_fulamt_ownpay_amt float64 = 0
  1949. var treat_fulamt_ownpay_amt float64 = 0
  1950. var bed_claa_sunmfee float64 = 0
  1951. var bed_clab_amt float64 = 0
  1952. var bed_other_amt float64 = 0
  1953. var operation_claa_sunmfee float64 = 0
  1954. var operation_clab_amt float64 = 0
  1955. var operation_other_amt float64 = 0
  1956. var other_claa_sunmfee float64 = 0
  1957. var other_clab_amt float64 = 0
  1958. var other_other_amt float64 = 0
  1959. var westernMedicine_claa_sunmfee float64 = 0
  1960. var westernMedicine_clab_amt float64 = 0
  1961. var westernMedicine_other_amt float64 = 0
  1962. var chineseTraditional_claa_sunmfee float64 = 0
  1963. var chineseTraditional_clab_amt float64 = 0
  1964. var chineseTraditional_other_amt float64 = 0
  1965. var check_claa_sunmfee float64 = 0
  1966. var check_clab_amt float64 = 0
  1967. var check_other_amt float64 = 0
  1968. var material_claa_sunmfee float64 = 0
  1969. var material_clab_amt float64 = 0
  1970. var material_other_amt float64 = 0
  1971. var laboratory_claa_sunmfee float64 = 0
  1972. var laboratory_clab_amt float64 = 0
  1973. var laboratory_other_amt float64 = 0
  1974. var treat_claa_sunmfee float64 = 0
  1975. var treat_clab_amt float64 = 0
  1976. var treat_other_amt float64 = 0
  1977. for _, item := range order.HisOrderInfo {
  1978. if item.MedChrgitmType == "01" { //床位费
  1979. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1980. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1981. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1982. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1983. if item.ChrgitmLv == "1" {
  1984. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1985. }
  1986. if item.ChrgitmLv == "2" {
  1987. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1988. }
  1989. if item.ChrgitmLv == "3" {
  1990. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1991. }
  1992. }
  1993. if item.MedChrgitmType == "03" { //检查费
  1994. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1995. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1996. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1997. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1998. if item.ChrgitmLv == "1" {
  1999. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2000. }
  2001. if item.ChrgitmLv == "2" {
  2002. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2003. }
  2004. if item.ChrgitmLv == "3" {
  2005. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2006. }
  2007. }
  2008. if item.MedChrgitmType == "04" { //化验费
  2009. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2010. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2011. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2012. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2013. if item.ChrgitmLv == "1" {
  2014. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2015. }
  2016. if item.ChrgitmLv == "2" {
  2017. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2018. }
  2019. if item.ChrgitmLv == "3" {
  2020. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2021. }
  2022. }
  2023. if item.MedChrgitmType == "05" { //治疗费
  2024. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2025. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2026. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2027. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2028. if item.ChrgitmLv == "1" {
  2029. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2030. }
  2031. if item.ChrgitmLv == "2" {
  2032. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2033. }
  2034. if item.ChrgitmLv == "3" {
  2035. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2036. }
  2037. }
  2038. if item.MedChrgitmType == "06" { //手术费
  2039. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2040. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2041. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2042. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2043. if item.ChrgitmLv == "1" {
  2044. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2045. }
  2046. if item.ChrgitmLv == "2" {
  2047. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2048. }
  2049. if item.ChrgitmLv == "3" {
  2050. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2051. }
  2052. }
  2053. if item.MedChrgitmType == "08" { //材料费
  2054. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2055. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2056. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2057. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2058. if item.ChrgitmLv == "1" {
  2059. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2060. }
  2061. if item.ChrgitmLv == "2" {
  2062. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2063. }
  2064. if item.ChrgitmLv == "3" {
  2065. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2066. }
  2067. }
  2068. if item.MedChrgitmType == "09" { //西药费
  2069. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2070. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2071. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2072. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2073. if item.ChrgitmLv == "1" {
  2074. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2075. }
  2076. if item.ChrgitmLv == "2" {
  2077. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2078. }
  2079. if item.ChrgitmLv == "3" {
  2080. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2081. }
  2082. }
  2083. if item.MedChrgitmType == "11" { //中成费
  2084. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2085. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2086. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2087. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2088. if item.ChrgitmLv == "1" {
  2089. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2090. }
  2091. if item.ChrgitmLv == "2" {
  2092. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2093. }
  2094. if item.ChrgitmLv == "3" {
  2095. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2096. }
  2097. }
  2098. if item.MedChrgitmType == "14" { //其他费
  2099. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2100. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2101. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2102. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2103. if item.ChrgitmLv == "1" {
  2104. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2105. }
  2106. if item.ChrgitmLv == "2" {
  2107. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2108. }
  2109. if item.ChrgitmLv == "3" {
  2110. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2111. }
  2112. }
  2113. }
  2114. var iteminfoStructs []service.IteminfoStruct
  2115. if bedCostTotal != 0 {
  2116. iteminfo.MedChrgitm = "01"
  2117. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2118. iteminfo.Amt = bedCostTotal
  2119. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2120. iteminfo.ClabAmt = bed_clab_amt
  2121. iteminfo.OthAmt = bed_other_amt
  2122. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2123. }
  2124. if checkCostTotal != 0 {
  2125. iteminfo.MedChrgitm = "03"
  2126. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2127. iteminfo.Amt = checkCostTotal
  2128. iteminfo.ClaaSumfee = check_claa_sunmfee
  2129. iteminfo.ClabAmt = check_clab_amt
  2130. iteminfo.OthAmt = check_other_amt
  2131. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2132. }
  2133. if laboratoryCostTotal != 0 {
  2134. iteminfo.MedChrgitm = "04"
  2135. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2136. iteminfo.Amt = laboratoryCostTotal
  2137. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2138. iteminfo.ClabAmt = laboratory_clab_amt
  2139. iteminfo.OthAmt = laboratory_other_amt
  2140. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2141. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2142. }
  2143. if treatCostTotal != 0 {
  2144. iteminfo.MedChrgitm = "05"
  2145. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2146. iteminfo.Amt = treatCostTotal
  2147. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2148. iteminfo.ClabAmt = treat_clab_amt
  2149. iteminfo.OthAmt = treat_other_amt
  2150. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2151. //(struct4101.IteminfoStruct, iteminfo)
  2152. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2153. }
  2154. if operationCostTotal != 0 {
  2155. iteminfo.MedChrgitm = "06"
  2156. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2157. iteminfo.Amt = operationCostTotal
  2158. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2159. iteminfo.ClabAmt = operation_clab_amt
  2160. iteminfo.OthAmt = operation_other_amt
  2161. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2162. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2163. }
  2164. if materialCostTotal != 0 {
  2165. iteminfo.MedChrgitm = "08"
  2166. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2167. iteminfo.Amt = materialCostTotal
  2168. iteminfo.ClaaSumfee = material_claa_sunmfee
  2169. iteminfo.ClabAmt = material_clab_amt
  2170. iteminfo.OthAmt = material_other_amt
  2171. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2172. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2173. }
  2174. if westernMedicineCostTotal != 0 {
  2175. iteminfo.MedChrgitm = "09"
  2176. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2177. iteminfo.Amt = westernMedicineCostTotal
  2178. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2179. iteminfo.ClabAmt = westernMedicine_clab_amt
  2180. iteminfo.OthAmt = westernMedicine_other_amt
  2181. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2182. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2183. }
  2184. if chineseTraditionalMedicineCostTotal != 0 {
  2185. iteminfo.MedChrgitm = "11"
  2186. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2187. iteminfo.Amt = westernMedicineCostTotal
  2188. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2189. iteminfo.ClabAmt = westernMedicine_clab_amt
  2190. iteminfo.OthAmt = westernMedicine_other_amt
  2191. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2192. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2193. }
  2194. if otherCostTotal != 0 {
  2195. iteminfo.MedChrgitm = "14"
  2196. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2197. iteminfo.Amt = otherCostTotal
  2198. iteminfo.ClaaSumfee = other_claa_sunmfee
  2199. iteminfo.ClabAmt = other_clab_amt
  2200. iteminfo.OthAmt = other_other_amt
  2201. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2202. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2203. }
  2204. struct4101.IteminfoStruct = iteminfoStructs
  2205. struct4101.Ntly = "中国"
  2206. struct4101.AdmCaty = "A03.06"
  2207. var res ResultSeventeen
  2208. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2209. var resOther ResultSeventeenOther
  2210. var pp models.PublicParams
  2211. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2212. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2213. pp.FixmedinsName = miConfig.OrgName
  2214. pp.FixmedinsCode = miConfig.Code
  2215. pp.RequestUrl = miConfig.Url
  2216. pp.Cainfo = miConfig.Cainfo
  2217. pp.SecretKey = miConfig.SecretKey
  2218. pp.AccessKey = miConfig.AccessKey
  2219. pp.OpterName = curRoles.UserName
  2220. client := &http.Client{}
  2221. var req *http.Request
  2222. data := make(map[string]interface{})
  2223. data["struct4101"] = struct4101
  2224. data["pp"] = pp
  2225. bytesData, _ := json.Marshal(data)
  2226. if miConfig.MdtrtareaAdmvs == "320921" {
  2227. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2228. } else {
  2229. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2230. }
  2231. resp, _ := client.Do(req)
  2232. defer resp.Body.Close()
  2233. body, ioErr := ioutil.ReadAll(resp.Body)
  2234. if ioErr != nil {
  2235. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2237. return
  2238. }
  2239. var respJSON map[string]interface{}
  2240. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2241. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2243. return
  2244. }
  2245. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2246. userJSONBytes, _ := json.Marshal(respJSON)
  2247. fmt.Println("log")
  2248. fmt.Println(string(userJSONBytes))
  2249. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  2250. utils.ErrorLog("解析失败:%v", err)
  2251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2252. return
  2253. }
  2254. res.InfRefmsgid = resOther.InfRefmsgid
  2255. res.Output = resOther.Output
  2256. res.ErrMsg = resOther.ErrMsg
  2257. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  2258. res.Infcode = infocode
  2259. } else {
  2260. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2261. var dat map[string]interface{}
  2262. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2263. fmt.Println(dat)
  2264. } else {
  2265. fmt.Println(err)
  2266. }
  2267. userJSONBytes, _ := json.Marshal(dat)
  2268. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2269. utils.ErrorLog("解析失败:%v", err)
  2270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2271. return
  2272. }
  2273. }
  2274. if res.Infcode != 0 {
  2275. c.ServeSuccessJSON(map[string]interface{}{
  2276. "failed_code": -10,
  2277. "msg": res.ErrMsg,
  2278. })
  2279. return
  2280. } else {
  2281. order.FaPiaoNumber = zero
  2282. order.FaPiaoCode = last_order.FaPiaoCode
  2283. service.UpdateOrder(order)
  2284. hisFundSettleListResult := &models.HisFundSettleListResult{
  2285. Number: res.Output.SetlListId,
  2286. Status: 1,
  2287. Ctime: time.Now().Unix(),
  2288. Mtime: time.Now().Unix(),
  2289. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2290. IsUpload: 1,
  2291. OrderId: order_id,
  2292. }
  2293. service.CreateUploadRecord(hisFundSettleListResult)
  2294. c.ServeSuccessJSON(map[string]interface{}{
  2295. "msg": "上传成功",
  2296. "result": hisFundSettleListResult,
  2297. })
  2298. return
  2299. }
  2300. }
  2301. func (c *HisApiController) GetSettleListHospital() {
  2302. order_id, _ := c.GetInt64("order_id")
  2303. admin_user_id, _ := c.GetInt64("admin_user_id")
  2304. order, _ := service.GetHisOrderByIDTwo(order_id)
  2305. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2306. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2307. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2308. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2309. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2310. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2311. if order.ID == 0 {
  2312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2313. return
  2314. }
  2315. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  2316. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  2317. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  2318. fmt.Println(count)
  2319. var zero string
  2320. number := count + 1
  2321. if number >= 1000 {
  2322. zero = "0000" + strconv.FormatInt(number, 10)
  2323. } else if number >= 10000 {
  2324. zero = "000" + strconv.FormatInt(number, 10)
  2325. } else if number >= 100000 {
  2326. zero = "00" + strconv.FormatInt(number, 10)
  2327. } else if number >= 1000000 {
  2328. zero = "0" + strconv.FormatInt(number, 10)
  2329. } else {
  2330. zero = strconv.FormatInt(number, 10)
  2331. }
  2332. fmt.Println(zero)
  2333. struct4101 := service.Struct4101{
  2334. PsnNo: order.PsnNo,
  2335. MdtrtId: order.MdtrtId,
  2336. SetlId: order.SetlId,
  2337. PsnName: order.PsnName,
  2338. Gend: order.Gend,
  2339. Brdy: his.Brdy,
  2340. Age: int64(order.Age),
  2341. Naty: order.Naty,
  2342. PatnCertType: "01",
  2343. Certno: order.Certno,
  2344. Prfs: "90",
  2345. ConerName: roles[0].UserName,
  2346. PatnRlts: "99",
  2347. ConerAddr: miConfig.OrgName,
  2348. ConerTel: admin.Mobile,
  2349. HiType: order.Insutype,
  2350. Insuplc: miConfig.InsuplcAdmdvs,
  2351. MaindiagFlag: "1",
  2352. BillCode: last_order.FaPiaoCode,
  2353. BillNo: zero,
  2354. BizSn: order.Number,
  2355. PsnSelfPay: order.PsnPartAmt,
  2356. PsnOwnPay: order.PsnPartAmt,
  2357. AcctPay: order.AcctPay,
  2358. PsnCashpay: order.PsnCashPay,
  2359. HiPaymtd: "1",
  2360. Hsorg: miConfig.InsuplcAdmdvs,
  2361. HsorgOpter: miConfig.InsuplcAdmdvs,
  2362. MedinsFillPsn: curRoles.UserName,
  2363. MedinsFillDept: depart.Name,
  2364. IptMedType: "2",
  2365. AdmTime: his.InHosptialTime,
  2366. AdmEndTime: his.OutHosptialTime,
  2367. }
  2368. struct4101.SetlBegnDate = order.SetlTime
  2369. struct4101.SetlEndDate = order.SetlTime
  2370. var rf []CustomFundPay
  2371. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2372. var tempFunPays []service.CustomStruct
  2373. for _, item := range rf {
  2374. var tempFunPay service.CustomStruct
  2375. tempFunPay.FundPayamt = item.FundPayamt
  2376. tempFunPay.FundPayType = item.FundPayType
  2377. tempFunPays = append(tempFunPays, tempFunPay)
  2378. }
  2379. struct4101.CustomStruct = tempFunPays
  2380. var tempDiaginfos []service.DiaginfoStructTwo
  2381. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2382. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2383. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2384. var config []*models.HisXtDiagnoseConfig
  2385. for _, item := range diagnosis_ids {
  2386. id, _ := strconv.ParseInt(item, 10, 64)
  2387. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2388. config = append(config, &diagnosisConfig)
  2389. }
  2390. for index, item := range config {
  2391. if index == 0 {
  2392. var tempDiaginfo service.DiaginfoStructTwo
  2393. tempDiaginfo.DiagCode = item.CountryCode
  2394. tempDiaginfo.DiagName = item.CountryContentName
  2395. tempDiaginfo.DiagType = "1"
  2396. tempDiaginfo.MaindiagFlag = "1"
  2397. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2398. } else {
  2399. var tempDiaginfo service.DiaginfoStructTwo
  2400. tempDiaginfo.DiagCode = item.CountryCode
  2401. tempDiaginfo.DiagName = item.CountryContentName
  2402. tempDiaginfo.DiagType = "2"
  2403. tempDiaginfo.MaindiagFlag = "0"
  2404. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2405. }
  2406. }
  2407. struct4101.Diseinfo = tempDiaginfos
  2408. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2409. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2410. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2411. tempOpspdiseinfo2.OprnOprtCode = ""
  2412. tempOpspdiseinfo2.OprnOprtName = ""
  2413. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2414. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2415. var iteminfo service.IteminfoStruct
  2416. var bedCostTotal float64 = 0 //床位总费
  2417. var bedCostSelfTotal float64 = 0 //床位自费
  2418. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2419. var operationCostTotal float64 = 0 //手术费
  2420. var operationCostSelfTotal float64 = 0 //手术费
  2421. var operationCostPartSelfTotal float64 = 0 //手术费
  2422. var otherCostTotal float64 = 0 //其他费用
  2423. var otherCostSelfTotal float64 = 0 //其他费用
  2424. var otherCostPartSelfTotal float64 = 0 //其他费用
  2425. var materialCostTotal float64 = 0 //材料费
  2426. var materialCostSelfTotal float64 = 0 //材料费
  2427. var materialCostPartSelfTotal float64 = 0 //材料费
  2428. var westernMedicineCostTotal float64 = 0 //西药费
  2429. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2430. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2431. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2432. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2433. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2434. var checkCostTotal float64 = 0 //检查费
  2435. var checkCostSelfTotal float64 = 0 //检查费
  2436. var checkCostPartSelfTotal float64 = 0 //检查费
  2437. var laboratoryCostTotal float64 = 0 //化验费
  2438. var laboratoryCostSelfTotal float64 = 0 //化验费
  2439. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2440. var treatCostTotal float64 = 0 //治疗费用
  2441. var treatCostSelfTotal float64 = 0 //治疗费用
  2442. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2443. decimal.DivisionPrecision = 2
  2444. var bed_fulamt_ownpay_amt float64 = 0
  2445. var operation_fulamt_ownpay_amt float64 = 0
  2446. var other_fulamt_ownpay_amt float64 = 0
  2447. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2448. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2449. var check_fulamt_ownpay_amt float64 = 0
  2450. var material_fulamt_ownpay_amt float64 = 0
  2451. var laboratory_fulamt_ownpay_amt float64 = 0
  2452. var treat_fulamt_ownpay_amt float64 = 0
  2453. var bed_claa_sunmfee float64 = 0
  2454. var bed_clab_amt float64 = 0
  2455. var bed_other_amt float64 = 0
  2456. var operation_claa_sunmfee float64 = 0
  2457. var operation_clab_amt float64 = 0
  2458. var operation_other_amt float64 = 0
  2459. var other_claa_sunmfee float64 = 0
  2460. var other_clab_amt float64 = 0
  2461. var other_other_amt float64 = 0
  2462. var westernMedicine_claa_sunmfee float64 = 0
  2463. var westernMedicine_clab_amt float64 = 0
  2464. var westernMedicine_other_amt float64 = 0
  2465. var chineseTraditional_claa_sunmfee float64 = 0
  2466. var chineseTraditional_clab_amt float64 = 0
  2467. var chineseTraditional_other_amt float64 = 0
  2468. var check_claa_sunmfee float64 = 0
  2469. var check_clab_amt float64 = 0
  2470. var check_other_amt float64 = 0
  2471. var material_claa_sunmfee float64 = 0
  2472. var material_clab_amt float64 = 0
  2473. var material_other_amt float64 = 0
  2474. var laboratory_claa_sunmfee float64 = 0
  2475. var laboratory_clab_amt float64 = 0
  2476. var laboratory_other_amt float64 = 0
  2477. var treat_claa_sunmfee float64 = 0
  2478. var treat_clab_amt float64 = 0
  2479. var treat_other_amt float64 = 0
  2480. for _, item := range order.HisOrderInfo {
  2481. if item.MedChrgitmType == "01" { //床位费
  2482. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2483. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2484. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2485. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2486. if item.ChrgitmLv == "1" {
  2487. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2488. }
  2489. if item.ChrgitmLv == "2" {
  2490. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2491. }
  2492. if item.ChrgitmLv == "3" {
  2493. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2494. }
  2495. }
  2496. if item.MedChrgitmType == "03" { //检查费
  2497. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2498. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2499. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2500. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2501. if item.ChrgitmLv == "1" {
  2502. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2503. }
  2504. if item.ChrgitmLv == "2" {
  2505. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2506. }
  2507. if item.ChrgitmLv == "3" {
  2508. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2509. }
  2510. }
  2511. if item.MedChrgitmType == "04" { //化验费
  2512. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2513. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2514. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2515. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2516. if item.ChrgitmLv == "1" {
  2517. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2518. }
  2519. if item.ChrgitmLv == "2" {
  2520. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2521. }
  2522. if item.ChrgitmLv == "3" {
  2523. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2524. }
  2525. }
  2526. if item.MedChrgitmType == "05" { //治疗费
  2527. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2528. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2529. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2530. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2531. if item.ChrgitmLv == "1" {
  2532. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2533. }
  2534. if item.ChrgitmLv == "2" {
  2535. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2536. }
  2537. if item.ChrgitmLv == "3" {
  2538. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2539. }
  2540. }
  2541. if item.MedChrgitmType == "06" { //手术费
  2542. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2543. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2544. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2545. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2546. if item.ChrgitmLv == "1" {
  2547. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2548. }
  2549. if item.ChrgitmLv == "2" {
  2550. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2551. }
  2552. if item.ChrgitmLv == "3" {
  2553. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2554. }
  2555. }
  2556. if item.MedChrgitmType == "08" { //材料费
  2557. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2558. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2559. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2560. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2561. if item.ChrgitmLv == "1" {
  2562. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2563. }
  2564. if item.ChrgitmLv == "2" {
  2565. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2566. }
  2567. if item.ChrgitmLv == "3" {
  2568. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2569. }
  2570. }
  2571. if item.MedChrgitmType == "09" { //西药费
  2572. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2573. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2574. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2575. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2576. if item.ChrgitmLv == "1" {
  2577. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2578. }
  2579. if item.ChrgitmLv == "2" {
  2580. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2581. }
  2582. if item.ChrgitmLv == "3" {
  2583. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2584. }
  2585. }
  2586. if item.MedChrgitmType == "11" { //中成费
  2587. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2588. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2589. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2590. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2591. if item.ChrgitmLv == "1" {
  2592. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2593. }
  2594. if item.ChrgitmLv == "2" {
  2595. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2596. }
  2597. if item.ChrgitmLv == "3" {
  2598. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2599. }
  2600. }
  2601. if item.MedChrgitmType == "14" { //其他费
  2602. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2603. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2604. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2605. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2606. if item.ChrgitmLv == "1" {
  2607. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2608. }
  2609. if item.ChrgitmLv == "2" {
  2610. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2611. }
  2612. if item.ChrgitmLv == "3" {
  2613. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2614. }
  2615. }
  2616. }
  2617. var iteminfoStructs []service.IteminfoStruct
  2618. if bedCostTotal != 0 {
  2619. iteminfo.MedChrgitm = "01"
  2620. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2621. iteminfo.Amt = bedCostTotal
  2622. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2623. iteminfo.ClabAmt = bed_clab_amt
  2624. iteminfo.OthAmt = bed_other_amt
  2625. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2626. }
  2627. if checkCostTotal != 0 {
  2628. iteminfo.MedChrgitm = "03"
  2629. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2630. iteminfo.Amt = checkCostTotal
  2631. iteminfo.ClaaSumfee = check_claa_sunmfee
  2632. iteminfo.ClabAmt = check_clab_amt
  2633. iteminfo.OthAmt = check_other_amt
  2634. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2635. }
  2636. if laboratoryCostTotal != 0 {
  2637. iteminfo.MedChrgitm = "04"
  2638. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2639. iteminfo.Amt = laboratoryCostTotal
  2640. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2641. iteminfo.ClabAmt = laboratory_clab_amt
  2642. iteminfo.OthAmt = laboratory_other_amt
  2643. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2644. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2645. }
  2646. if treatCostTotal != 0 {
  2647. iteminfo.MedChrgitm = "05"
  2648. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2649. iteminfo.Amt = treatCostTotal
  2650. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2651. iteminfo.ClabAmt = treat_clab_amt
  2652. iteminfo.OthAmt = treat_other_amt
  2653. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2654. //(struct4101.IteminfoStruct, iteminfo)
  2655. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2656. }
  2657. if operationCostTotal != 0 {
  2658. iteminfo.MedChrgitm = "06"
  2659. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2660. iteminfo.Amt = operationCostTotal
  2661. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2662. iteminfo.ClabAmt = operation_clab_amt
  2663. iteminfo.OthAmt = operation_other_amt
  2664. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2665. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2666. }
  2667. if materialCostTotal != 0 {
  2668. iteminfo.MedChrgitm = "08"
  2669. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2670. iteminfo.Amt = materialCostTotal
  2671. iteminfo.ClaaSumfee = material_claa_sunmfee
  2672. iteminfo.ClabAmt = material_clab_amt
  2673. iteminfo.OthAmt = material_other_amt
  2674. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2675. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2676. }
  2677. if westernMedicineCostTotal != 0 {
  2678. iteminfo.MedChrgitm = "09"
  2679. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2680. iteminfo.Amt = westernMedicineCostTotal
  2681. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2682. iteminfo.ClabAmt = westernMedicine_clab_amt
  2683. iteminfo.OthAmt = westernMedicine_other_amt
  2684. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2685. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2686. }
  2687. if chineseTraditionalMedicineCostTotal != 0 {
  2688. iteminfo.MedChrgitm = "11"
  2689. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2690. iteminfo.Amt = westernMedicineCostTotal
  2691. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2692. iteminfo.ClabAmt = westernMedicine_clab_amt
  2693. iteminfo.OthAmt = westernMedicine_other_amt
  2694. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2695. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2696. }
  2697. if otherCostTotal != 0 {
  2698. iteminfo.MedChrgitm = "14"
  2699. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2700. iteminfo.Amt = otherCostTotal
  2701. iteminfo.ClaaSumfee = other_claa_sunmfee
  2702. iteminfo.ClabAmt = other_clab_amt
  2703. iteminfo.OthAmt = other_other_amt
  2704. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2705. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2706. }
  2707. struct4101.IteminfoStruct = iteminfoStructs
  2708. struct4101.Ntly = "中国"
  2709. struct4101.AdmCaty = "A03.06"
  2710. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2711. fmt.Println(result)
  2712. var dat map[string]interface{}
  2713. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2714. fmt.Println(dat)
  2715. } else {
  2716. fmt.Println(err)
  2717. }
  2718. userJSONBytes, _ := json.Marshal(dat)
  2719. var res ResultSeventeen
  2720. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2721. utils.ErrorLog("解析失败:%v", err)
  2722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2723. return
  2724. }
  2725. if res.Infcode != 0 {
  2726. c.ServeSuccessJSON(map[string]interface{}{
  2727. "failed_code": -10,
  2728. "msg": res.ErrMsg,
  2729. })
  2730. return
  2731. } else {
  2732. order.FaPiaoNumber = zero
  2733. order.FaPiaoCode = last_order.FaPiaoCode
  2734. service.UpdateOrder(order)
  2735. hisFundSettleListResult := &models.HisFundSettleListResult{
  2736. Number: res.Output.SetlListId,
  2737. Status: 1,
  2738. Ctime: time.Now().Unix(),
  2739. Mtime: time.Now().Unix(),
  2740. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2741. IsUpload: 1,
  2742. OrderId: order_id,
  2743. }
  2744. service.CreateUploadRecord(hisFundSettleListResult)
  2745. c.ServeSuccessJSON(map[string]interface{}{
  2746. "msg": "上传成功",
  2747. "result": hisFundSettleListResult,
  2748. })
  2749. return
  2750. }
  2751. }
  2752. func (c *HisApiController) GetBatchSettleList() {
  2753. orders, _ := service.GetAllHisOrder(10106)
  2754. for _, item := range orders {
  2755. order_id := item.ID
  2756. order, _ := service.GetHisOrderByIDTwo(order_id)
  2757. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2758. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2759. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2760. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  2761. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2762. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2763. if order.ID == 0 {
  2764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2765. return
  2766. }
  2767. if his.BalanceAccountsType == 2 {
  2768. continue
  2769. }
  2770. struct4101 := service.Struct4101{
  2771. PsnNo: order.PsnNo,
  2772. MdtrtId: order.MdtrtId,
  2773. SetlId: order.SetlId,
  2774. PsnName: order.PsnName,
  2775. Gend: order.Gend,
  2776. Brdy: his.Brdy,
  2777. Age: his.Age,
  2778. Naty: order.Naty,
  2779. PatnCertType: "01",
  2780. Certno: order.Certno,
  2781. Prfs: "90",
  2782. ConerName: roles[0].UserName,
  2783. PatnRlts: "99",
  2784. ConerAddr: miConfig.OrgName,
  2785. ConerTel: admin.Mobile,
  2786. HiType: order.Insutype,
  2787. Insuplc: his.InsuplcAdmdvs,
  2788. MaindiagFlag: "1",
  2789. BillCode: order.FaPiaoCode,
  2790. BillNo: order.FaPiaoNumber,
  2791. BizSn: order.Number,
  2792. PsnSelfPay: order.PsnPartAmt,
  2793. PsnOwnPay: order.PsnPartAmt,
  2794. AcctPay: order.AcctPay,
  2795. PsnCashpay: order.PsnCashPay,
  2796. HiPaymtd: "1",
  2797. Hsorg: his.InsuplcAdmdvs,
  2798. HsorgOpter: his.InsuplcAdmdvs,
  2799. MedinsFillPsn: curRoles.UserName,
  2800. MedinsFillDept: depart.Name,
  2801. IptMedType: "2",
  2802. }
  2803. struct4101.SetlBegnDate = order.SetlTime
  2804. struct4101.SetlEndDate = order.SetlTime
  2805. //if order.SettleType == 1 {
  2806. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  2807. // dateStr := t.Format("2006-01-02")
  2808. // struct4101.SetlBegnDate = dateStr
  2809. // struct4101.SetlEndDate = dateStr
  2810. //} else {
  2811. // t := time.Unix(int64(order.SettleStartTime), 0)
  2812. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  2813. // dateStartStr := t.Format("2006-01-02")
  2814. // dateEndStr := t2.Format("2006-01-02")
  2815. // struct4101.SetlBegnDate = dateStartStr
  2816. // struct4101.SetlEndDate = dateEndStr
  2817. //}
  2818. var rf []CustomFundPay
  2819. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2820. var tempFunPays []service.CustomStruct
  2821. var tempFunPay610100 service.CustomStruct
  2822. for _, item := range rf {
  2823. if item.FundPayType == "610100" {
  2824. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  2825. tempFunPay610100.FundPayType = item.FundPayType
  2826. } else {
  2827. var tempFunPay service.CustomStruct
  2828. tempFunPay.FundPayamt = item.FundPayamt
  2829. tempFunPay.FundPayType = item.FundPayType
  2830. tempFunPays = append(tempFunPays, tempFunPay)
  2831. }
  2832. }
  2833. tempFunPays = append(tempFunPays, tempFunPay610100)
  2834. struct4101.CustomStruct = tempFunPays
  2835. var tempDiaginfos []service.DiaginfoStructTwo
  2836. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2837. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2838. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2839. var config []*models.HisXtDiagnoseConfig
  2840. for _, item := range diagnosis_ids {
  2841. id, _ := strconv.ParseInt(item, 10, 64)
  2842. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2843. config = append(config, &diagnosisConfig)
  2844. }
  2845. for index, item := range config {
  2846. if index == 0 {
  2847. var tempDiaginfo service.DiaginfoStructTwo
  2848. tempDiaginfo.DiagCode = item.CountryCode
  2849. tempDiaginfo.DiagName = item.CountryContentName
  2850. tempDiaginfo.DiagType = "1"
  2851. tempDiaginfo.MaindiagFlag = "1"
  2852. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2853. } else {
  2854. var tempDiaginfo service.DiaginfoStructTwo
  2855. tempDiaginfo.DiagCode = item.CountryCode
  2856. tempDiaginfo.DiagName = item.CountryContentName
  2857. tempDiaginfo.DiagType = "2"
  2858. tempDiaginfo.MaindiagFlag = "0"
  2859. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2860. }
  2861. }
  2862. struct4101.Diseinfo = tempDiaginfos
  2863. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2864. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2865. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2866. tempOpspdiseinfo2.OprnOprtCode = ""
  2867. tempOpspdiseinfo2.OprnOprtName = ""
  2868. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2869. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2870. var iteminfo service.IteminfoStruct
  2871. var bedCostTotal float64 = 0 //床位总费
  2872. var bedCostSelfTotal float64 = 0 //床位自费
  2873. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2874. var examineCostTotal float64 = 0 //诊查总费
  2875. var examineCostSelfTotal float64 = 0 //诊查自费
  2876. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  2877. var nursingCostTotal float64 = 0 //护理总费
  2878. var nursingCostSelfTotal float64 = 0 //护理自费
  2879. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  2880. var chineseMedicineCostTotal float64 = 0 //中成药
  2881. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  2882. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  2883. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  2884. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  2885. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  2886. var registerCostTotal float64 = 0 //一般诊疗费
  2887. var registerCostSelfTotal float64 = 0 //一般诊疗费
  2888. var registerPartSelfTotal float64 = 0 //一般诊疗费
  2889. var operationCostTotal float64 = 0 //手术费
  2890. var operationCostSelfTotal float64 = 0 //手术费
  2891. var operationCostPartSelfTotal float64 = 0 //手术费
  2892. var otherCostTotal float64 = 0 //其他费用
  2893. var otherCostSelfTotal float64 = 0 //其他费用
  2894. var otherCostPartSelfTotal float64 = 0 //其他费用
  2895. var materialCostTotal float64 = 0 //材料费
  2896. var materialCostSelfTotal float64 = 0 //材料费
  2897. var materialCostPartSelfTotal float64 = 0 //材料费
  2898. var westernMedicineCostTotal float64 = 0 //西药费
  2899. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2900. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2901. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2902. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2903. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2904. var checkCostTotal float64 = 0 //检查费
  2905. var checkCostSelfTotal float64 = 0 //检查费
  2906. var checkCostPartSelfTotal float64 = 0 //检查费
  2907. var laboratoryCostTotal float64 = 0 //化验费
  2908. var laboratoryCostSelfTotal float64 = 0 //化验费
  2909. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2910. var treatCostTotal float64 = 0 //治疗费用
  2911. var treatCostSelfTotal float64 = 0 //治疗费用
  2912. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2913. decimal.DivisionPrecision = 2
  2914. var bed_fulamt_ownpay_amt float64 = 0
  2915. var examine_fulamt_ownpay_amt float64 = 0
  2916. var nursing_fulamt_ownpay_amt float64 = 0
  2917. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  2918. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  2919. var register_fulamt_ownpay_amt float64 = 0
  2920. var operation_fulamt_ownpay_amt float64 = 0
  2921. var other_fulamt_ownpay_amt float64 = 0
  2922. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2923. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2924. var check_fulamt_ownpay_amt float64 = 0
  2925. var material_fulamt_ownpay_amt float64 = 0
  2926. var laboratory_fulamt_ownpay_amt float64 = 0
  2927. var treat_fulamt_ownpay_amt float64 = 0
  2928. var bed_claa_sunmfee float64 = 0
  2929. var bed_clab_amt float64 = 0
  2930. var bed_other_amt float64 = 0
  2931. var examine_claa_sunmfee float64 = 0
  2932. var examine_clab_amt float64 = 0
  2933. var examine_other_amt float64 = 0
  2934. var nursing_claa_sunmfee float64 = 0
  2935. var nursing_clab_amt float64 = 0
  2936. var nursing_other_amt float64 = 0
  2937. var chinese_medicine_claa_sunmfee float64 = 0
  2938. var chinese_medicine_clab_amt float64 = 0
  2939. var chinese_medicine_other_amt float64 = 0
  2940. var commonly_treatment_claa_sunmfee float64 = 0
  2941. var commonly_treatment_clab_amt float64 = 0
  2942. var commonly_treatment_other_amt float64 = 0
  2943. var operation_claa_sunmfee float64 = 0
  2944. var operation_clab_amt float64 = 0
  2945. var operation_other_amt float64 = 0
  2946. var other_claa_sunmfee float64 = 0
  2947. var other_clab_amt float64 = 0
  2948. var other_other_amt float64 = 0
  2949. var westernMedicine_claa_sunmfee float64 = 0
  2950. var westernMedicine_clab_amt float64 = 0
  2951. var westernMedicine_other_amt float64 = 0
  2952. var chineseTraditional_claa_sunmfee float64 = 0
  2953. var chineseTraditional_clab_amt float64 = 0
  2954. var chineseTraditional_other_amt float64 = 0
  2955. var check_claa_sunmfee float64 = 0
  2956. var check_clab_amt float64 = 0
  2957. var check_other_amt float64 = 0
  2958. var material_claa_sunmfee float64 = 0
  2959. var material_clab_amt float64 = 0
  2960. var material_other_amt float64 = 0
  2961. var laboratory_claa_sunmfee float64 = 0
  2962. var laboratory_clab_amt float64 = 0
  2963. var laboratory_other_amt float64 = 0
  2964. var treat_claa_sunmfee float64 = 0
  2965. var treat_clab_amt float64 = 0
  2966. var treat_other_amt float64 = 0
  2967. var register_claa_sunmfee float64 = 0
  2968. var register_clab_amt float64 = 0
  2969. var register_other_amt float64 = 0
  2970. for _, item := range order.HisOrderInfo {
  2971. if item.MedChrgitmType == "01" { //床位费
  2972. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2973. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2974. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2975. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2976. if item.ChrgitmLv == "1" {
  2977. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2978. }
  2979. if item.ChrgitmLv == "2" {
  2980. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2981. }
  2982. if item.ChrgitmLv == "3" {
  2983. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2984. }
  2985. }
  2986. if item.MedChrgitmType == "02" { //诊查
  2987. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2988. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2989. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2990. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2991. if item.ChrgitmLv == "1" {
  2992. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2993. }
  2994. if item.ChrgitmLv == "2" {
  2995. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2996. }
  2997. if item.ChrgitmLv == "3" {
  2998. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2999. }
  3000. }
  3001. if item.MedChrgitmType == "03" { //检查费
  3002. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3003. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3004. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3005. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3006. if item.ChrgitmLv == "1" {
  3007. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3008. }
  3009. if item.ChrgitmLv == "2" {
  3010. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3011. }
  3012. if item.ChrgitmLv == "3" {
  3013. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3014. }
  3015. }
  3016. if item.MedChrgitmType == "04" { //化验费
  3017. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3018. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3019. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3020. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3021. if item.ChrgitmLv == "1" {
  3022. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3023. }
  3024. if item.ChrgitmLv == "2" {
  3025. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3026. }
  3027. if item.ChrgitmLv == "3" {
  3028. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3029. }
  3030. }
  3031. if item.MedChrgitmType == "05" { //治疗费
  3032. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3033. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3034. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3035. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3036. if item.ChrgitmLv == "1" {
  3037. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3038. }
  3039. if item.ChrgitmLv == "2" {
  3040. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3041. }
  3042. if item.ChrgitmLv == "3" {
  3043. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3044. }
  3045. }
  3046. if item.MedChrgitmType == "06" { //手术费
  3047. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3048. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3049. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3050. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3051. if item.ChrgitmLv == "1" {
  3052. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3053. }
  3054. if item.ChrgitmLv == "2" {
  3055. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3056. }
  3057. if item.ChrgitmLv == "3" {
  3058. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3059. }
  3060. }
  3061. if item.MedChrgitmType == "07" { //手术费
  3062. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3063. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3064. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3065. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3066. if item.ChrgitmLv == "1" {
  3067. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3068. }
  3069. if item.ChrgitmLv == "2" {
  3070. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3071. }
  3072. if item.ChrgitmLv == "3" {
  3073. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3074. }
  3075. }
  3076. if item.MedChrgitmType == "08" { //材料费
  3077. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3078. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3079. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3080. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3081. if item.ChrgitmLv == "1" {
  3082. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3083. }
  3084. if item.ChrgitmLv == "2" {
  3085. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3086. }
  3087. if item.ChrgitmLv == "3" {
  3088. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3089. }
  3090. }
  3091. if item.MedChrgitmType == "09" { //西药费
  3092. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3093. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3094. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3095. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3096. if item.ChrgitmLv == "1" {
  3097. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3098. }
  3099. if item.ChrgitmLv == "2" {
  3100. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3101. }
  3102. if item.ChrgitmLv == "3" {
  3103. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3104. }
  3105. }
  3106. if item.MedChrgitmType == "10" { //中药饮片
  3107. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3108. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3109. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3110. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3111. if item.ChrgitmLv == "1" {
  3112. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3113. }
  3114. if item.ChrgitmLv == "2" {
  3115. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3116. }
  3117. if item.ChrgitmLv == "3" {
  3118. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3119. }
  3120. }
  3121. if item.MedChrgitmType == "11" { //中成费
  3122. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3123. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3124. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3125. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3126. if item.ChrgitmLv == "1" {
  3127. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3128. }
  3129. if item.ChrgitmLv == "2" {
  3130. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3131. }
  3132. if item.ChrgitmLv == "3" {
  3133. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3134. }
  3135. }
  3136. if item.MedChrgitmType == "12" { //中成费
  3137. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3138. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3139. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3140. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3141. if item.ChrgitmLv == "1" {
  3142. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3143. }
  3144. if item.ChrgitmLv == "2" {
  3145. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3146. }
  3147. if item.ChrgitmLv == "3" {
  3148. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3149. }
  3150. }
  3151. if item.MedChrgitmType == "13" { //中成费
  3152. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3153. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3154. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3155. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3156. if item.ChrgitmLv == "1" {
  3157. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3158. }
  3159. if item.ChrgitmLv == "2" {
  3160. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3161. }
  3162. if item.ChrgitmLv == "3" {
  3163. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3164. }
  3165. }
  3166. if item.MedChrgitmType == "14" { //其他费
  3167. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3168. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3169. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3170. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3171. if item.ChrgitmLv == "1" {
  3172. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3173. }
  3174. if item.ChrgitmLv == "2" {
  3175. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3176. }
  3177. if item.ChrgitmLv == "3" {
  3178. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3179. }
  3180. }
  3181. }
  3182. var iteminfoStructs []service.IteminfoStruct
  3183. if bedCostTotal != 0 {
  3184. iteminfo.MedChrgitm = "01"
  3185. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3186. iteminfo.Amt = bedCostTotal
  3187. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3188. iteminfo.ClabAmt = bed_clab_amt
  3189. iteminfo.OthAmt = bed_other_amt
  3190. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3191. }
  3192. if examineCostTotal != 0 {
  3193. iteminfo.MedChrgitm = "02"
  3194. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  3195. iteminfo.Amt = examineCostTotal
  3196. iteminfo.ClaaSumfee = examine_claa_sunmfee
  3197. iteminfo.ClabAmt = examine_clab_amt
  3198. iteminfo.OthAmt = examine_other_amt
  3199. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3200. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3201. }
  3202. if checkCostTotal != 0 {
  3203. iteminfo.MedChrgitm = "03"
  3204. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3205. iteminfo.Amt = checkCostTotal
  3206. iteminfo.ClaaSumfee = check_claa_sunmfee
  3207. iteminfo.ClabAmt = check_clab_amt
  3208. iteminfo.OthAmt = check_other_amt
  3209. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3210. }
  3211. if laboratoryCostTotal != 0 {
  3212. iteminfo.MedChrgitm = "04"
  3213. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3214. iteminfo.Amt = laboratoryCostTotal
  3215. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3216. iteminfo.ClabAmt = laboratory_clab_amt
  3217. iteminfo.OthAmt = laboratory_other_amt
  3218. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3219. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3220. }
  3221. if treatCostTotal != 0 {
  3222. iteminfo.MedChrgitm = "05"
  3223. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3224. iteminfo.Amt = treatCostTotal
  3225. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3226. iteminfo.ClabAmt = treat_clab_amt
  3227. iteminfo.OthAmt = treat_other_amt
  3228. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3229. //(struct4101.IteminfoStruct, iteminfo)
  3230. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3231. }
  3232. if operationCostTotal != 0 {
  3233. iteminfo.MedChrgitm = "06"
  3234. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3235. iteminfo.Amt = operationCostTotal
  3236. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3237. iteminfo.ClabAmt = operation_clab_amt
  3238. iteminfo.OthAmt = operation_other_amt
  3239. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3240. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3241. }
  3242. if nursingCostTotal != 0 {
  3243. iteminfo.MedChrgitm = "07"
  3244. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  3245. iteminfo.Amt = nursingCostTotal
  3246. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  3247. iteminfo.ClabAmt = nursing_clab_amt
  3248. iteminfo.OthAmt = nursing_other_amt
  3249. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3250. }
  3251. if materialCostTotal != 0 {
  3252. iteminfo.MedChrgitm = "08"
  3253. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3254. iteminfo.Amt = materialCostTotal
  3255. iteminfo.ClaaSumfee = material_claa_sunmfee
  3256. iteminfo.ClabAmt = material_clab_amt
  3257. iteminfo.OthAmt = material_other_amt
  3258. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3259. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3260. }
  3261. if westernMedicineCostTotal != 0 {
  3262. iteminfo.MedChrgitm = "09"
  3263. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3264. iteminfo.Amt = westernMedicineCostTotal
  3265. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3266. iteminfo.ClabAmt = westernMedicine_clab_amt
  3267. iteminfo.OthAmt = westernMedicine_other_amt
  3268. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3269. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3270. }
  3271. if chineseMedicineCostTotal != 0 {
  3272. iteminfo.MedChrgitm = "10"
  3273. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  3274. iteminfo.Amt = chineseMedicineCostTotal
  3275. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  3276. iteminfo.ClabAmt = chinese_medicine_clab_amt
  3277. iteminfo.OthAmt = chinese_medicine_other_amt
  3278. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3279. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3280. }
  3281. if chineseTraditionalMedicineCostTotal != 0 {
  3282. iteminfo.MedChrgitm = "11"
  3283. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3284. iteminfo.Amt = westernMedicineCostTotal
  3285. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3286. iteminfo.ClabAmt = westernMedicine_clab_amt
  3287. iteminfo.OthAmt = westernMedicine_other_amt
  3288. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3289. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3290. }
  3291. if commonlyTreatmentCostTotal != 0 {
  3292. iteminfo.MedChrgitm = "12"
  3293. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  3294. iteminfo.Amt = commonlyTreatmentCostTotal
  3295. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  3296. iteminfo.ClabAmt = commonly_treatment_clab_amt
  3297. iteminfo.OthAmt = commonly_treatment_other_amt
  3298. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3299. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3300. }
  3301. if registerCostTotal != 0 {
  3302. iteminfo.MedChrgitm = "13"
  3303. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  3304. iteminfo.Amt = registerCostTotal
  3305. iteminfo.ClaaSumfee = register_claa_sunmfee
  3306. iteminfo.ClabAmt = register_clab_amt
  3307. iteminfo.OthAmt = register_other_amt
  3308. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3309. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3310. }
  3311. if otherCostTotal != 0 {
  3312. iteminfo.MedChrgitm = "14"
  3313. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3314. iteminfo.Amt = otherCostTotal
  3315. iteminfo.ClaaSumfee = other_claa_sunmfee
  3316. iteminfo.ClabAmt = other_clab_amt
  3317. iteminfo.OthAmt = other_other_amt
  3318. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3319. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3320. }
  3321. struct4101.IteminfoStruct = iteminfoStructs
  3322. struct4101.Ntly = "中国"
  3323. struct4101.AdmCaty = "A03.06"
  3324. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  3325. fmt.Println(result)
  3326. var dat map[string]interface{}
  3327. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3328. fmt.Println(dat)
  3329. } else {
  3330. fmt.Println(err)
  3331. }
  3332. userJSONBytes, _ := json.Marshal(dat)
  3333. var res ResultSeventeen
  3334. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3335. utils.ErrorLog("解析失败:%v", err)
  3336. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3337. adminUser := c.GetAdminUserInfo()
  3338. errlog := &models.HisOrderError{
  3339. UserOrgId: adminUser.CurrentOrgId,
  3340. Ctime: time.Now().Unix(),
  3341. Mtime: time.Now().Unix(),
  3342. ErrMsg: res.ErrMsg + "解析失败",
  3343. Status: 1,
  3344. PatientId: order_id,
  3345. Stage: 10106,
  3346. }
  3347. service.CreateErrMsgLog(errlog)
  3348. continue
  3349. }
  3350. if res.Infcode != 0 {
  3351. adminUser := c.GetAdminUserInfo()
  3352. errlog := &models.HisOrderError{
  3353. UserOrgId: adminUser.CurrentOrgId,
  3354. Ctime: time.Now().Unix(),
  3355. Mtime: time.Now().Unix(),
  3356. ErrMsg: res.ErrMsg,
  3357. Status: 1,
  3358. PatientId: order_id,
  3359. Stage: 10106,
  3360. }
  3361. service.CreateErrMsgLog(errlog)
  3362. continue
  3363. } else {
  3364. hisFundSettleListResult := &models.HisFundSettleListResult{
  3365. Number: res.Output.SetlListId,
  3366. Status: 1,
  3367. Ctime: time.Now().Unix(),
  3368. Mtime: time.Now().Unix(),
  3369. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3370. IsUpload: 1,
  3371. OrderId: order_id,
  3372. }
  3373. service.CreateUploadRecord(hisFundSettleListResult)
  3374. continue
  3375. }
  3376. }
  3377. }
  3378. func (c *HisApiController) GetOrgInfo() {
  3379. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  3380. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  3381. }
  3382. func (c *HisApiController) GetHisPatientInfo() {
  3383. medical_insurance_card := c.GetString("medical_insurance_card")
  3384. id_card_type, _ := c.GetInt64("id_card_type")
  3385. id_card := c.GetString("id_card")
  3386. adminInfo := c.GetAdminUserInfo()
  3387. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3388. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3389. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  3390. IdCardNo := ""
  3391. if id_card_type == 1 {
  3392. IdCardNo = medical_insurance_card
  3393. } else if id_card_type == 2 {
  3394. IdCardNo = id_card
  3395. }
  3396. if config.IsOpen == 1 {
  3397. 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
  3398. resp, requestErr := http.Get(api)
  3399. if requestErr != nil {
  3400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3401. return
  3402. }
  3403. defer resp.Body.Close()
  3404. body, ioErr := ioutil.ReadAll(resp.Body)
  3405. if ioErr != nil {
  3406. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3408. return
  3409. }
  3410. var respJSON map[string]interface{}
  3411. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3412. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3414. return
  3415. }
  3416. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3417. userJSONBytes, _ := json.Marshal(userJSON)
  3418. var res ResultTwo
  3419. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3420. utils.ErrorLog("解析失败:%v", err)
  3421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3422. return
  3423. }
  3424. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3425. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3426. infoStr := string(Iinfos)
  3427. idetinfoStr := string(Idetinfos)
  3428. if res.Infcode == 0 {
  3429. his := models.VMHisPatient{
  3430. Status: 1,
  3431. Ctime: time.Now().Unix(),
  3432. Mtime: time.Now().Unix(),
  3433. PsnNo: res.Output.Baseinfo.PsnNo,
  3434. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3435. Certno: res.Output.Baseinfo.Certno,
  3436. PsnName: res.Output.Baseinfo.PsnName,
  3437. Gend: res.Output.Baseinfo.Gend,
  3438. Naty: res.Output.Baseinfo.Naty,
  3439. Brdy: res.Output.Baseinfo.Brdy,
  3440. Age: res.Output.Baseinfo.Age,
  3441. Iinfo: infoStr,
  3442. Idetinfo: idetinfoStr,
  3443. UserOrgId: adminInfo.CurrentOrgId,
  3444. IsReturn: 1,
  3445. IdCardType: id_card_type,
  3446. }
  3447. c.ServeSuccessJSON(map[string]interface{}{
  3448. "info": his,
  3449. })
  3450. } else {
  3451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3452. return
  3453. }
  3454. }
  3455. }
  3456. //func GetBasBaseInfo() (jsonStr string, err error) {
  3457. //
  3458. // handle := syscall.NewLazyDLL("SSCard.dll")
  3459. // add := handle.NewProc("ReadCardBas")
  3460. // str := make([]byte, 1024)
  3461. // str1 := make([]byte, 1024)
  3462. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3463. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3464. //
  3465. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3466. //
  3467. // fmt.Println("> Add(4,5)的结果为:", ret)
  3468. // handle.Release()
  3469. //
  3470. // return "", nil
  3471. //
  3472. //}
  3473. //func GetQRBaseInfo() (jsonStr string, err error) {
  3474. // handle := syscall.LoadDLL("SSCard.dll")
  3475. // ReadCardBas := handle.FindProc("GetQRBase")
  3476. //
  3477. // str := make([]byte, 256)
  3478. // str1 := make([]byte, 256)
  3479. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3480. //
  3481. // fmt.Println(string(str))
  3482. // fmt.Println(r)
  3483. // return string(str), nil
  3484. //}
  3485. //func CardInit() int {
  3486. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  3487. // add := DllTestDef.MustFindProc("Init")
  3488. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3489. // if err != nil {
  3490. // fmt.Println("SSCard的运算结果为:", ret)
  3491. // }
  3492. // result := int(ret)
  3493. // return result
  3494. //}
  3495. //func CardInit() int {
  3496. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3497. // if err != nil {
  3498. // fmt.Println("SSCard的运算结果为:", ret)
  3499. // }
  3500. // fmt.Println(err)
  3501. // result := int(ret)
  3502. // return result
  3503. //}
  3504. func IntPtr(n int) uintptr {
  3505. return uintptr(n)
  3506. }
  3507. func StrPtr(s string) uintptr {
  3508. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3509. }
  3510. type Result2001 struct {
  3511. Cainfo interface{} `json:"cainfo"`
  3512. ErrMsg string `json:"err_msg"`
  3513. InfRefmsgid string `json:"inf_refmsgid"`
  3514. Infcode int64 `json:"infcode"`
  3515. Output struct {
  3516. Trtinfo struct {
  3517. PsnNo string `json:"psn_no"`
  3518. TrtChkType string `json:"trt_chk_type"`
  3519. FundPayType string `json:"fund_pay_type"`
  3520. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3521. Begndate string `json:"begndate"`
  3522. Enddate string `json:"enddate"`
  3523. TrtChkRslt string `json:"trt_chk_rslt"`
  3524. } `json:"trtinfo"`
  3525. } `json:"output"`
  3526. RefmsgTime string `json:"refmsg_time"`
  3527. RespondTime string `json:"respond_time"`
  3528. Signtype interface{} `json:"signtype"`
  3529. WarnMsg interface{} `json:"warn_msg"`
  3530. }
  3531. type Result2001Org10265 struct {
  3532. Cainfo interface{} `json:"cainfo"`
  3533. ErrMsg string `json:"err_msg"`
  3534. InfRefmsgid string `json:"inf_refmsgid"`
  3535. Infcode string `json:"infcode"`
  3536. Output struct {
  3537. Trtinfo struct {
  3538. PsnNo string `json:"psn_no"`
  3539. TrtChkType string `json:"trt_chk_type"`
  3540. FundPayType string `json:"fund_pay_type"`
  3541. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3542. Begndate string `json:"begndate"`
  3543. Enddate string `json:"enddate"`
  3544. TrtChkRslt string `json:"trt_chk_rslt"`
  3545. } `json:"trtinfo"`
  3546. } `json:"output"`
  3547. RefmsgTime string `json:"refmsg_time"`
  3548. RespondTime string `json:"respond_time"`
  3549. Signtype interface{} `json:"signtype"`
  3550. WarnMsg interface{} `json:"warn_msg"`
  3551. }
  3552. type ResultTwo struct {
  3553. ErrMsg string `json:"err_msg"`
  3554. InfRefmsgid string `json:"inf_refmsgid"`
  3555. Infcode int64 `json:"infcode"`
  3556. Output struct {
  3557. Baseinfo struct {
  3558. Age float64 `json:"age"`
  3559. Brdy string `json:"brdy"`
  3560. Certno string `json:"certno"`
  3561. Gend string `json:"gend"`
  3562. Naty string `json:"naty"`
  3563. PsnCertType string `json:"psn_cert_type"`
  3564. PsnName string `json:"psn_name"`
  3565. PsnNo string `json:"psn_no"`
  3566. } `json:"baseinfo"`
  3567. Idetinfo []interface{} `json:"idetinfo"`
  3568. Iinfo []struct {
  3569. Balc float64 `json:"balc"`
  3570. CvlservFlag string `json:"cvlserv_flag"`
  3571. EmpName string `json:"emp_name"`
  3572. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3573. Insutype string `json:"insutype"`
  3574. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3575. PausInsuDate string `json:"paus_insu_date"`
  3576. PsnInsuDate string `json:"psn_insu_date"`
  3577. PsnInsuStas string `json:"psn_insu_stas"`
  3578. PsnType string `json:"psn_type"`
  3579. } `json:"insuinfo"`
  3580. } `json:"output"`
  3581. RefmsgTime string `json:"refmsg_time"`
  3582. RespondTime string `json:"respond_time"`
  3583. Signtype interface{} `json:"signtype"`
  3584. WarnInfo interface{} `json:"warn_info"`
  3585. }
  3586. type ResultTwo10265 struct {
  3587. ErrMsg string `json:"err_msg"`
  3588. InfRefmsgid string `json:"inf_refmsgid"`
  3589. Infcode string `json:"infcode"`
  3590. Output struct {
  3591. Baseinfo struct {
  3592. Age float64 `json:"age"`
  3593. Brdy string `json:"brdy"`
  3594. Certno string `json:"certno"`
  3595. Gend string `json:"gend"`
  3596. Naty string `json:"naty"`
  3597. PsnCertType string `json:"psn_cert_type"`
  3598. PsnName string `json:"psn_name"`
  3599. PsnNo string `json:"psn_no"`
  3600. } `json:"baseinfo"`
  3601. Idetinfo []interface{} `json:"idetinfo"`
  3602. Iinfo []struct {
  3603. Balc float64 `json:"balc"`
  3604. CvlservFlag string `json:"cvlserv_flag"`
  3605. EmpName string `json:"emp_name"`
  3606. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3607. Insutype string `json:"insutype"`
  3608. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3609. PausInsuDate string `json:"paus_insu_date"`
  3610. PsnInsuDate string `json:"psn_insu_date"`
  3611. PsnInsuStas string `json:"psn_insu_stas"`
  3612. PsnType string `json:"psn_type"`
  3613. } `json:"insuinfo"`
  3614. } `json:"output"`
  3615. RefmsgTime string `json:"refmsg_time"`
  3616. RespondTime string `json:"respond_time"`
  3617. Signtype interface{} `json:"signtype"`
  3618. WarnInfo interface{} `json:"warn_info"`
  3619. }
  3620. type ResultThree struct {
  3621. Cainfo interface{} `json:"cainfo"`
  3622. ErrMsg string `json:"err_msg"`
  3623. InfRefmsgid string `json:"inf_refmsgid"`
  3624. Infcode int64 `json:"infcode"`
  3625. Output struct {
  3626. Data struct {
  3627. IptOtpNo string `json:"ipt_otp_no"`
  3628. MdtrtID string `json:"mdtrt_id"`
  3629. PsnNo string `json:"psn_no"`
  3630. } `json:"data"`
  3631. } `json:"output"`
  3632. RefmsgTime string `json:"refmsg_time"`
  3633. RespondTime string `json:"respond_time"`
  3634. Signtype interface{} `json:"signtype"`
  3635. WarnMsg interface{} `json:"warn_msg"`
  3636. }
  3637. type ResultThree10265 struct {
  3638. Cainfo interface{} `json:"cainfo"`
  3639. ErrMsg string `json:"err_msg"`
  3640. InfRefmsgid string `json:"inf_refmsgid"`
  3641. Infcode string `json:"infcode"`
  3642. Output struct {
  3643. Data struct {
  3644. IptOtpNo string `json:"ipt_otp_no"`
  3645. MdtrtID string `json:"mdtrt_id"`
  3646. PsnNo string `json:"psn_no"`
  3647. } `json:"data"`
  3648. } `json:"output"`
  3649. RefmsgTime string `json:"refmsg_time"`
  3650. RespondTime string `json:"respond_time"`
  3651. Signtype interface{} `json:"signtype"`
  3652. WarnMsg interface{} `json:"warn_msg"`
  3653. }
  3654. type ResultFour struct {
  3655. Cainfo string `json:"cainfo"`
  3656. ErrMsg string `json:"err_msg"`
  3657. InfRefmsgid string `json:"inf_refmsgid"`
  3658. Infcode int64 `json:"infcode"`
  3659. Output struct {
  3660. Result []struct {
  3661. BasMednFlag string `json:"bas_medn_flag"`
  3662. ChldMedcFlag string `json:"chld_medc_flag"`
  3663. ChrgitmLv string `json:"chrgitm_lv"`
  3664. Cnt float64 `json:"cnt"`
  3665. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3666. DrtReimFlag string `json:"drt_reim_flag"`
  3667. FeedetlSn string `json:"feedetl_sn"`
  3668. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3669. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3670. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3671. ListSpItemFlag string `json:"list_sp_item_flag"`
  3672. LmtUsedFlag string `json:"lmt_used_flag"`
  3673. MedChrgitmType string `json:"med_chrgitm_type"`
  3674. Memo string `json:"memo"`
  3675. OverlmtAmt float64 `json:"overlmt_amt"`
  3676. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3677. Pric float64 `json:"pric"`
  3678. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3679. SelfpayProp float64 `json:"selfpay_prop"`
  3680. } `json:"result"`
  3681. } `json:"output"`
  3682. RefmsgTime string `json:"refmsg_time"`
  3683. RespondTime string `json:"respond_time"`
  3684. Signtype string `json:"signtype"`
  3685. WarnMsg string `json:"warn_msg"`
  3686. }
  3687. type ResultFour10265 struct {
  3688. Cainfo string `json:"cainfo"`
  3689. ErrMsg string `json:"err_msg"`
  3690. InfRefmsgid string `json:"inf_refmsgid"`
  3691. Infcode string `json:"infcode"`
  3692. Output struct {
  3693. Result []struct {
  3694. BasMednFlag string `json:"bas_medn_flag"`
  3695. ChldMedcFlag string `json:"chld_medc_flag"`
  3696. ChrgitmLv string `json:"chrgitm_lv"`
  3697. Cnt float64 `json:"cnt"`
  3698. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3699. DrtReimFlag string `json:"drt_reim_flag"`
  3700. FeedetlSn string `json:"feedetl_sn"`
  3701. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3702. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3703. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3704. ListSpItemFlag string `json:"list_sp_item_flag"`
  3705. LmtUsedFlag string `json:"lmt_used_flag"`
  3706. MedChrgitmType string `json:"med_chrgitm_type"`
  3707. Memo string `json:"memo"`
  3708. OverlmtAmt float64 `json:"overlmt_amt"`
  3709. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3710. Pric float64 `json:"pric"`
  3711. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3712. SelfpayProp float64 `json:"selfpay_prop"`
  3713. } `json:"result"`
  3714. } `json:"output"`
  3715. RefmsgTime string `json:"refmsg_time"`
  3716. RespondTime string `json:"respond_time"`
  3717. Signtype string `json:"signtype"`
  3718. WarnMsg string `json:"warn_msg"`
  3719. }
  3720. type ResultFive struct {
  3721. Balc float64 `json:"balc"`
  3722. CvlservFlag string `json:"cvlserv_flag"`
  3723. EmpName string `json:"emp_name"`
  3724. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3725. Insutype string `json:"insutype"`
  3726. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3727. PausInsuDate string `json:"paus_insu_date"`
  3728. PsnInsuDate string `json:"psn_insu_date"`
  3729. PsnInsuStas string `json:"psn_insu_stas"`
  3730. PsnType string `json:"psn_type"`
  3731. }
  3732. type ResultSix struct {
  3733. Cainfo interface{} `json:"cainfo"`
  3734. ErrMsg string `json:"err_msg"`
  3735. InfRefmsgid string `json:"inf_refmsgid"`
  3736. Infcode int64 `json:"infcode"`
  3737. Output struct {
  3738. } `json:"output"`
  3739. RefmsgTime string `json:"refmsg_time"`
  3740. RespondTime string `json:"respond_time"`
  3741. Signtype interface{} `json:"signtype"`
  3742. WarnMsg interface{} `json:"warn_msg"`
  3743. }
  3744. type ResultSix10265 struct {
  3745. Cainfo interface{} `json:"cainfo"`
  3746. ErrMsg string `json:"err_msg"`
  3747. InfRefmsgid string `json:"inf_refmsgid"`
  3748. Infcode string `json:"infcode"`
  3749. Output struct {
  3750. } `json:"output"`
  3751. RefmsgTime string `json:"refmsg_time"`
  3752. RespondTime string `json:"respond_time"`
  3753. Signtype interface{} `json:"signtype"`
  3754. WarnMsg interface{} `json:"warn_msg"`
  3755. }
  3756. type ResultSeven struct {
  3757. Cainfo string `json:"cainfo"`
  3758. ErrMsg string `json:"err_msg"`
  3759. InfRefmsgid string `json:"inf_refmsgid"`
  3760. Infcode int64 `json:"infcode"`
  3761. Output struct {
  3762. Setldetail []interface{} `json:"setldetail"`
  3763. Setlinfo struct {
  3764. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3765. AcctPay float64 `json:"acct_pay"`
  3766. ActPayDedc float64 `json:"act_pay_dedc"`
  3767. Age float64 `json:"age"`
  3768. Balc float64 `json:"balc"`
  3769. Brdy string `json:"brdy"`
  3770. Certno string `json:"certno"`
  3771. ClrOptins string `json:"clr_optins"`
  3772. ClrType string `json:"clr_type"`
  3773. ClrWay string `json:"clr_way"`
  3774. CvlservFlag string `json:"cvlserv_flag"`
  3775. CvlservPay float64 `json:"cvlserv_pay"`
  3776. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3777. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3778. Gend string `json:"gend"`
  3779. HifesPay float64 `json:"hifes_pay"`
  3780. HifmiPay float64 `json:"hifmi_pay"`
  3781. HifpPay float64 `json:"hifp_pay"`
  3782. HospPartAmt float64 `json:"hosp_part_amt"`
  3783. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3784. Insutype string `json:"insutype"`
  3785. MafPay float64 `json:"maf_pay"`
  3786. MdtrtCertType string `json:"mdtrt_cert_type"`
  3787. HifobPay float64 `json:"hifob_pay"`
  3788. MdtrtID string `json:"mdtrt_id"`
  3789. MedType string `json:"med_type"`
  3790. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3791. MedinsSetlID string `json:"medins_setl_id"`
  3792. Naty string `json:"naty"`
  3793. OthPay float64 `json:"oth_pay"`
  3794. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3795. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3796. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3797. PsnCashPay float64 `json:"psn_cash_pay"`
  3798. PsnCertType string `json:"psn_cert_type"`
  3799. PsnName string `json:"psn_name"`
  3800. PsnNo string `json:"psn_no"`
  3801. PsnPartAmt float64 `json:"psn_part_amt"`
  3802. PsnType string `json:"psn_type"`
  3803. SetlID string `json:"setl_id"`
  3804. SetlTime string `json:"setl_time"`
  3805. } `json:"setlinfo"`
  3806. } `json:"output"`
  3807. RefmsgTime string `json:"refmsg_time"`
  3808. RespondTime string `json:"respond_time"`
  3809. Signtype interface{} `json:"signtype"`
  3810. WarnMsg interface{} `json:"warn_msg"`
  3811. }
  3812. type ResultSeven10265 struct {
  3813. Cainfo string `json:"cainfo"`
  3814. ErrMsg string `json:"err_msg"`
  3815. InfRefmsgid string `json:"inf_refmsgid"`
  3816. Infcode string `json:"infcode"`
  3817. Output struct {
  3818. Setldetail []interface{} `json:"setldetail"`
  3819. Setlinfo struct {
  3820. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3821. AcctPay float64 `json:"acct_pay"`
  3822. ActPayDedc float64 `json:"act_pay_dedc"`
  3823. Age float64 `json:"age"`
  3824. Balc float64 `json:"balc"`
  3825. Brdy string `json:"brdy"`
  3826. Certno string `json:"certno"`
  3827. ClrOptins string `json:"clr_optins"`
  3828. ClrType string `json:"clr_type"`
  3829. ClrWay string `json:"clr_way"`
  3830. CvlservFlag string `json:"cvlserv_flag"`
  3831. CvlservPay float64 `json:"cvlserv_pay"`
  3832. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3833. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3834. Gend string `json:"gend"`
  3835. HifesPay float64 `json:"hifes_pay"`
  3836. HifmiPay float64 `json:"hifmi_pay"`
  3837. HifpPay float64 `json:"hifp_pay"`
  3838. HospPartAmt float64 `json:"hosp_part_amt"`
  3839. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3840. Insutype string `json:"insutype"`
  3841. MafPay float64 `json:"maf_pay"`
  3842. MdtrtCertType string `json:"mdtrt_cert_type"`
  3843. HifobPay float64 `json:"hifob_pay"`
  3844. MdtrtID string `json:"mdtrt_id"`
  3845. MedType string `json:"med_type"`
  3846. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3847. MedinsSetlID string `json:"medins_setl_id"`
  3848. Naty string `json:"naty"`
  3849. OthPay float64 `json:"oth_pay"`
  3850. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3851. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3852. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3853. PsnCashPay float64 `json:"psn_cash_pay"`
  3854. PsnCertType string `json:"psn_cert_type"`
  3855. PsnName string `json:"psn_name"`
  3856. PsnNo string `json:"psn_no"`
  3857. PsnPartAmt float64 `json:"psn_part_amt"`
  3858. PsnType string `json:"psn_type"`
  3859. SetlID string `json:"setl_id"`
  3860. SetlTime string `json:"setl_time"`
  3861. } `json:"setlinfo"`
  3862. } `json:"output"`
  3863. RefmsgTime string `json:"refmsg_time"`
  3864. RespondTime string `json:"respond_time"`
  3865. Signtype interface{} `json:"signtype"`
  3866. WarnMsg interface{} `json:"warn_msg"`
  3867. }
  3868. type ResultEight struct {
  3869. Cainfo string `json:"cainfo"`
  3870. ErrMsg string `json:"err_msg"`
  3871. InfRefmsgid string `json:"inf_refmsgid"`
  3872. Infcode int64 `json:"infcode"`
  3873. Output struct {
  3874. Stmtinfo struct {
  3875. SetlOptins string `json:"setl_optins"`
  3876. StmtRslt string `json:"stmt_rslt"`
  3877. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3878. } `json:"stmtinfo"`
  3879. } `json:"output"`
  3880. RefmsgTime string `json:"refmsg_time"`
  3881. RespondTime string `json:"respond_time"`
  3882. Signtype interface{} `json:"signtype"`
  3883. WarnMsg interface{} `json:"warn_msg"`
  3884. }
  3885. type ResultEightFor10188 struct {
  3886. Cainfo string `json:"cainfo"`
  3887. ErrMsg string `json:"err_msg"`
  3888. InfRefmsgid string `json:"inf_refmsgid"`
  3889. Infcode string `json:"infcode"`
  3890. Output struct {
  3891. Stmtinfo struct {
  3892. SetlOptins string `json:"setl_optins"`
  3893. StmtRslt string `json:"stmt_rslt"`
  3894. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3895. } `json:"stmtinfo"`
  3896. } `json:"output"`
  3897. RefmsgTime string `json:"refmsg_time"`
  3898. RespondTime string `json:"respond_time"`
  3899. Signtype interface{} `json:"signtype"`
  3900. WarnMsg interface{} `json:"warn_msg"`
  3901. }
  3902. type ResultNine struct {
  3903. Cainfo string `json:"cainfo"`
  3904. ErrMsg string `json:"err_msg"`
  3905. InfRefmsgid string `json:"inf_refmsgid"`
  3906. Infcode int64 `json:"infcode"`
  3907. Output struct {
  3908. FileQuryNo string `json:"file_qury_no"`
  3909. } `json:"output"`
  3910. RefmsgTime string `json:"refmsg_time"`
  3911. RespondTime string `json:"respond_time"`
  3912. Signtype interface{} `json:"signtype"`
  3913. WarnMsg interface{} `json:"warn_msg"`
  3914. }
  3915. type ResultTen struct {
  3916. Cainfo string `json:"cainfo"`
  3917. ErrMsg string `json:"err_msg"`
  3918. InfRefmsgid string `json:"inf_refmsgid"`
  3919. Infcode int64 `json:"infcode"`
  3920. Output struct {
  3921. DldEndtime string `json:"dld_endtime"`
  3922. FileQuryNo string `json:"file_qury_no"`
  3923. Filename string `json:"filename"`
  3924. } `json:"output"`
  3925. RefmsgTime string `json:"refmsg_time"`
  3926. RespondTime string `json:"respond_time"`
  3927. Signtype interface{} `json:"signtype"`
  3928. WarnMsg interface{} `json:"warn_msg"`
  3929. }
  3930. //type Autogenerated struct {
  3931. // Output struct {
  3932. // Setlinfo struct {
  3933. // SetlTime string `json:"setl_time"`
  3934. // CvlservPay float64 `json:"cvlserv_pay"`
  3935. // Year string `json:"year"`
  3936. // MedType string `json:"med_type"`
  3937. // PsnPay float64 `json:"psn_pay"`
  3938. // OpterID string `json:"opter_id"`
  3939. // Begndate string `json:"begndate"`
  3940. // FlxempeFlag string `json:"flxempe_flag"`
  3941. // HifmiPay float64 `json:"hifmi_pay"`
  3942. // PsnNo string `json:"psn_no"`
  3943. // ActPayDedc float64 `json:"act_pay_dedc"`
  3944. // MedinsSetlID interface{} `json:"medins_setl_id"`
  3945. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3946. // ClrWay string `json:"clr_way"`
  3947. // OthPay float64 `json:"oth_pay"`
  3948. // Gend string `json:"gend"`
  3949. // MdtrtID string `json:"mdtrt_id"`
  3950. // AcctPay float64 `json:"acct_pay"`
  3951. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  3952. // Insutype string `json:"insutype"`
  3953. // Invono interface{} `json:"invono"`
  3954. // Enddate string `json:"enddate"`
  3955. // CashPayamt float64 `json:"cash_payamt"`
  3956. // PsnType string `json:"psn_type"`
  3957. // FixmedinsName string `json:"fixmedins_name"`
  3958. // HifpPay float64 `json:"hifp_pay"`
  3959. // NewFlag interface{} `json:"new_flag"`
  3960. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3961. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  3962. // PayLoc string `json:"pay_loc"`
  3963. // ClrType string `json:"clr_type"`
  3964. // RefdSetlFlag string `json:"refd_setl_flag"`
  3965. // CvlservFlag string `json:"cvlserv_flag"`
  3966. // EmpName string `json:"emp_name"`
  3967. // Brdy string `json:"brdy"`
  3968. // Naty string `json:"naty"`
  3969. // Certno string `json:"certno"`
  3970. // DiseCode string `json:"dise_code"`
  3971. // FixmedinsCode string `json:"fixmedins_code"`
  3972. // DedcHospLv string `json:"dedc_hosp_lv"`
  3973. // OpterName string `json:"opter_name"`
  3974. // Balc float64 `json:"balc"`
  3975. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3976. // PsnCertType string `json:"psn_cert_type"`
  3977. // HifobPay float64 `json:"hifob_pay"`
  3978. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  3979. // HifesPay float64 `json:"hifes_pay"`
  3980. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3981. // OptTime string `json:"opt_time"`
  3982. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3983. // SetlID string `json:"setl_id"`
  3984. // MafPay float64 `json:"maf_pay"`
  3985. // PsnName string `json:"psn_name"`
  3986. // InsuOptins interface{} `json:"insu_optins"`
  3987. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3988. // ClrOptins string `json:"clr_optins"`
  3989. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3990. // DiseName string `json:"dise_name"`
  3991. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3992. // Age float64 `json:"age"`
  3993. // DtrtCertType string `json:"dtrt_cert_type"`
  3994. // HospLv string `json:"hosp_lv"`
  3995. // } `json:"setlinfo"`
  3996. // Setldetail []struct {
  3997. // FundPayType string `json:"fund_pay_type"`
  3998. // FundPayamt float64 `json:"fund_payamt"`
  3999. // SetlProcInfo interface{} `json:"setl_proc_info"`
  4000. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  4001. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  4002. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  4003. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4004. // } `json:"setldetail"`
  4005. // } `json:"output"`
  4006. // Infcode int `json:"infcode"`
  4007. // WarnMsg interface{} `json:"warn_msg"`
  4008. // Cainfo interface{} `json:"cainfo"`
  4009. // ErrMsg interface{} `json:"err_msg"`
  4010. // RefmsgTime string `json:"refmsg_time"`
  4011. // Signtype interface{} `json:"signtype"`
  4012. // RespondTime string `json:"respond_time"`
  4013. // InfRefmsgid string `json:"inf_refmsgid"`
  4014. //}
  4015. type ResultEleven struct {
  4016. Cainfo string `json:"cainfo"`
  4017. ErrMsg string `json:"err_msg"`
  4018. InfRefmsgid string `json:"inf_refmsgid"`
  4019. Infcode int64 `json:"infcode"`
  4020. Output struct {
  4021. Setlinfo struct {
  4022. SetlTime string `json:"setl_time"`
  4023. CvlservPay float64 `json:"cvlserv_pay"`
  4024. Year string `json:"year"`
  4025. MedType string `json:"med_type"`
  4026. PsnPay float64 `json:"psn_pay"`
  4027. OpterID string `json:"opter_id"`
  4028. Begndate string `json:"begndate"`
  4029. FlxempeFlag string `json:"flxempe_flag"`
  4030. HifmiPay float64 `json:"hifmi_pay"`
  4031. PsnNo string `json:"psn_no"`
  4032. ActPayDedc float64 `json:"act_pay_dedc"`
  4033. MedinsSetlID interface{} `json:"medins_setl_id"`
  4034. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4035. ClrWay string `json:"clr_way"`
  4036. OthPay float64 `json:"oth_pay"`
  4037. Gend string `json:"gend"`
  4038. MdtrtID string `json:"mdtrt_id"`
  4039. AcctPay float64 `json:"acct_pay"`
  4040. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4041. Insutype string `json:"insutype"`
  4042. Invono interface{} `json:"invono"`
  4043. Enddate string `json:"enddate"`
  4044. CashPayamt float64 `json:"cash_payamt"`
  4045. PsnType string `json:"psn_type"`
  4046. FixmedinsName string `json:"fixmedins_name"`
  4047. HifpPay float64 `json:"hifp_pay"`
  4048. NewFlag interface{} `json:"new_flag"`
  4049. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4050. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4051. PayLoc string `json:"pay_loc"`
  4052. ClrType string `json:"clr_type"`
  4053. RefdSetlFlag string `json:"refd_setl_flag"`
  4054. CvlservFlag string `json:"cvlserv_flag"`
  4055. EmpName string `json:"emp_name"`
  4056. Brdy string `json:"brdy"`
  4057. Naty string `json:"naty"`
  4058. Certno string `json:"certno"`
  4059. DiseCode string `json:"dise_code"`
  4060. FixmedinsCode string `json:"fixmedins_code"`
  4061. DedcHospLv string `json:"dedc_hosp_lv"`
  4062. OpterName string `json:"opter_name"`
  4063. Balc float64 `json:"balc"`
  4064. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4065. PsnCertType string `json:"psn_cert_type"`
  4066. HifobPay float64 `json:"hifob_pay"`
  4067. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4068. HifesPay float64 `json:"hifes_pay"`
  4069. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4070. OptTime string `json:"opt_time"`
  4071. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4072. SetlID string `json:"setl_id"`
  4073. MafPay float64 `json:"maf_pay"`
  4074. PsnName string `json:"psn_name"`
  4075. InsuOptins interface{} `json:"insu_optins"`
  4076. PrefFundPay interface{} `json:"pref_fund_pay"`
  4077. ClrOptins string `json:"clr_optins"`
  4078. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4079. DiseName string `json:"dise_name"`
  4080. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4081. Age float64 `json:"age"`
  4082. DtrtCertType string `json:"dtrt_cert_type"`
  4083. HospLv string `json:"hosp_lv"`
  4084. } `json:"setlinfo"`
  4085. } `json:"output"`
  4086. RefmsgTime string `json:"refmsg_time"`
  4087. RespondTime string `json:"respond_time"`
  4088. Signtype interface{} `json:"signtype"`
  4089. WarnMsg interface{} `json:"warn_msg"`
  4090. }
  4091. type ResultEleven10265 struct {
  4092. Cainfo string `json:"cainfo"`
  4093. ErrMsg string `json:"err_msg"`
  4094. InfRefmsgid string `json:"inf_refmsgid"`
  4095. Infcode string `json:"infcode"`
  4096. Output struct {
  4097. Setlinfo struct {
  4098. SetlTime string `json:"setl_time"`
  4099. CvlservPay float64 `json:"cvlserv_pay"`
  4100. Year string `json:"year"`
  4101. MedType string `json:"med_type"`
  4102. PsnPay float64 `json:"psn_pay"`
  4103. OpterID string `json:"opter_id"`
  4104. Begndate string `json:"begndate"`
  4105. FlxempeFlag string `json:"flxempe_flag"`
  4106. HifmiPay float64 `json:"hifmi_pay"`
  4107. PsnNo string `json:"psn_no"`
  4108. ActPayDedc float64 `json:"act_pay_dedc"`
  4109. MedinsSetlID interface{} `json:"medins_setl_id"`
  4110. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4111. ClrWay string `json:"clr_way"`
  4112. OthPay float64 `json:"oth_pay"`
  4113. Gend string `json:"gend"`
  4114. MdtrtID string `json:"mdtrt_id"`
  4115. AcctPay float64 `json:"acct_pay"`
  4116. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4117. Insutype string `json:"insutype"`
  4118. Invono interface{} `json:"invono"`
  4119. Enddate string `json:"enddate"`
  4120. CashPayamt float64 `json:"cash_payamt"`
  4121. PsnType string `json:"psn_type"`
  4122. FixmedinsName string `json:"fixmedins_name"`
  4123. HifpPay float64 `json:"hifp_pay"`
  4124. NewFlag interface{} `json:"new_flag"`
  4125. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4126. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4127. PayLoc string `json:"pay_loc"`
  4128. ClrType string `json:"clr_type"`
  4129. RefdSetlFlag string `json:"refd_setl_flag"`
  4130. CvlservFlag string `json:"cvlserv_flag"`
  4131. EmpName string `json:"emp_name"`
  4132. Brdy string `json:"brdy"`
  4133. Naty string `json:"naty"`
  4134. Certno string `json:"certno"`
  4135. DiseCode string `json:"dise_code"`
  4136. FixmedinsCode string `json:"fixmedins_code"`
  4137. DedcHospLv string `json:"dedc_hosp_lv"`
  4138. OpterName string `json:"opter_name"`
  4139. Balc float64 `json:"balc"`
  4140. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4141. PsnCertType string `json:"psn_cert_type"`
  4142. HifobPay float64 `json:"hifob_pay"`
  4143. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4144. HifesPay float64 `json:"hifes_pay"`
  4145. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4146. OptTime string `json:"opt_time"`
  4147. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4148. SetlID string `json:"setl_id"`
  4149. MafPay float64 `json:"maf_pay"`
  4150. PsnName string `json:"psn_name"`
  4151. InsuOptins interface{} `json:"insu_optins"`
  4152. PrefFundPay interface{} `json:"pref_fund_pay"`
  4153. ClrOptins string `json:"clr_optins"`
  4154. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4155. DiseName string `json:"dise_name"`
  4156. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4157. Age float64 `json:"age"`
  4158. DtrtCertType string `json:"dtrt_cert_type"`
  4159. HospLv string `json:"hosp_lv"`
  4160. } `json:"setlinfo"`
  4161. } `json:"output"`
  4162. RefmsgTime string `json:"refmsg_time"`
  4163. RespondTime string `json:"respond_time"`
  4164. Signtype interface{} `json:"signtype"`
  4165. WarnMsg interface{} `json:"warn_msg"`
  4166. }
  4167. type ResultTwelve struct {
  4168. Cainfo string `json:"cainfo"`
  4169. ErrMsg string `json:"err_msg"`
  4170. InfRefmsgid string `json:"inf_refmsgid"`
  4171. Infcode int64 `json:"infcode"`
  4172. Output struct {
  4173. MdtrtId string `json:"mdtrt_id"`
  4174. ChrgBchno string `json:"chrg_bchno"`
  4175. PsnNo string `json:"psn_no"`
  4176. } `json:"output"`
  4177. RefmsgTime string `json:"refmsg_time"`
  4178. RespondTime string `json:"respond_time"`
  4179. Signtype interface{} `json:"signtype"`
  4180. WarnMsg interface{} `json:"warn_msg"`
  4181. }
  4182. type ResultThirteen struct {
  4183. ErrMsg string `json:"err_msg"`
  4184. InfRefmsgid string `json:"inf_refmsgid"`
  4185. Infcode int64 `json:"infcode"`
  4186. Output struct {
  4187. Result struct {
  4188. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4189. } `json:"result"`
  4190. } `json:"output"`
  4191. RefmsgTime string `json:"refmsg_time"`
  4192. RespondTime string `json:"respond_time"`
  4193. Signtype interface{} `json:"signtype"`
  4194. WarnInfo interface{} `json:"warn_info"`
  4195. }
  4196. type ResultThirteen10265 struct {
  4197. ErrMsg string `json:"err_msg"`
  4198. InfRefmsgid string `json:"inf_refmsgid"`
  4199. Infcode string `json:"infcode"`
  4200. Output struct {
  4201. Result struct {
  4202. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4203. } `json:"result"`
  4204. } `json:"output"`
  4205. RefmsgTime string `json:"refmsg_time"`
  4206. RespondTime string `json:"respond_time"`
  4207. Signtype interface{} `json:"signtype"`
  4208. WarnInfo interface{} `json:"warn_info"`
  4209. }
  4210. type ResultFourteen struct {
  4211. ErrMsg string `json:"err_msg"`
  4212. InfRefmsgid string `json:"inf_refmsgid"`
  4213. Infcode int64 `json:"infcode"`
  4214. Output struct {
  4215. } `json:"output"`
  4216. RefmsgTime string `json:"refmsg_time"`
  4217. RespondTime string `json:"respond_time"`
  4218. Signtype interface{} `json:"signtype"`
  4219. WarnInfo interface{} `json:"warn_info"`
  4220. }
  4221. type ResultFourteen10265 struct {
  4222. ErrMsg string `json:"err_msg"`
  4223. InfRefmsgid string `json:"inf_refmsgid"`
  4224. Infcode string `json:"infcode"`
  4225. Output struct {
  4226. } `json:"output"`
  4227. RefmsgTime string `json:"refmsg_time"`
  4228. RespondTime string `json:"respond_time"`
  4229. Signtype interface{} `json:"signtype"`
  4230. WarnInfo interface{} `json:"warn_info"`
  4231. }
  4232. type ResultSixteen struct {
  4233. Cainfo string `json:"cainfo"`
  4234. ErrMsg string `json:"err_msg"`
  4235. InfRefmsgid string `json:"inf_refmsgid"`
  4236. Infcode int64 `json:"infcode"`
  4237. Output struct {
  4238. Setldetail []interface{} `json:"setldetail"`
  4239. Setlinfo struct {
  4240. MdtrtID string `json:"mdtrt_id"`
  4241. SetlID string `json:"setl_id"`
  4242. ClrOptins string `json:"clr_optins"`
  4243. SetlTime string `json:"setl_time"`
  4244. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4245. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4246. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4247. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4248. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4249. ActPayDedc float64 `json:"act_pay_dedc"`
  4250. HifpPay float64 `json:"hifp_pay"`
  4251. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4252. Lfpay float64 `json:"selfpay"`
  4253. CvlservPay float64 `json:"cvlserv_pay"`
  4254. HifesPay float64 `json:"hifes_pay"`
  4255. HifmiPay float64 `json:"hifmi_pay"`
  4256. HifobPay float64 `json:"hifob_pay"`
  4257. MafPay float64 `json:"maf_pay"`
  4258. OthPay float64 `json:"oth_pay"`
  4259. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4260. PsnPartAmt float64 `json:"psn_part_amt"`
  4261. AcctPay float64 `json:"acct_pay"`
  4262. Balc float64 `json:"balc"`
  4263. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4264. HospPartAmt float64 `json:"hosp_part_amt"`
  4265. MedinsSetlID string `json:"medins_setl_id"`
  4266. PdnCashPay string `json:"pdn_cash_pay"`
  4267. } `json:"setlinfo"`
  4268. } `json:"output"`
  4269. RefmsgTime string `json:"refmsg_time"`
  4270. RespondTime string `json:"respond_time"`
  4271. Signtype interface{} `json:"signtype"`
  4272. WarnMsg interface{} `json:"warn_msg"`
  4273. }
  4274. type ResultSixteen10265 struct {
  4275. Cainfo string `json:"cainfo"`
  4276. ErrMsg string `json:"err_msg"`
  4277. InfRefmsgid string `json:"inf_refmsgid"`
  4278. Infcode string `json:"infcode"`
  4279. Output struct {
  4280. Setldetail []interface{} `json:"setldetail"`
  4281. Setlinfo struct {
  4282. MdtrtID string `json:"mdtrt_id"`
  4283. SetlID string `json:"setl_id"`
  4284. ClrOptins string `json:"clr_optins"`
  4285. SetlTime string `json:"setl_time"`
  4286. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4287. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4288. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4289. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4290. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4291. ActPayDedc float64 `json:"act_pay_dedc"`
  4292. HifpPay float64 `json:"hifp_pay"`
  4293. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4294. Lfpay float64 `json:"selfpay"`
  4295. CvlservPay float64 `json:"cvlserv_pay"`
  4296. HifesPay float64 `json:"hifes_pay"`
  4297. HifmiPay float64 `json:"hifmi_pay"`
  4298. HifobPay float64 `json:"hifob_pay"`
  4299. MafPay float64 `json:"maf_pay"`
  4300. OthPay float64 `json:"oth_pay"`
  4301. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4302. PsnPartAmt float64 `json:"psn_part_amt"`
  4303. AcctPay float64 `json:"acct_pay"`
  4304. Balc float64 `json:"balc"`
  4305. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4306. HospPartAmt float64 `json:"hosp_part_amt"`
  4307. MedinsSetlID string `json:"medins_setl_id"`
  4308. PdnCashPay string `json:"pdn_cash_pay"`
  4309. } `json:"setlinfo"`
  4310. } `json:"output"`
  4311. RefmsgTime string `json:"refmsg_time"`
  4312. RespondTime string `json:"respond_time"`
  4313. Signtype interface{} `json:"signtype"`
  4314. WarnMsg interface{} `json:"warn_msg"`
  4315. }
  4316. type ResultSeventeen struct {
  4317. ErrMsg string `json:"err_msg"`
  4318. InfRefmsgid string `json:"inf_refmsgid"`
  4319. Infcode int64 `json:"infcode"`
  4320. Output struct {
  4321. SetlListId string `json:"setl_list_id"`
  4322. } `json:"output"`
  4323. RefmsgTime string `json:"refmsg_time"`
  4324. RespondTime string `json:"respond_time"`
  4325. Signtype string `json:"signtype"`
  4326. WarnInfo string `json:"warn_info"`
  4327. }
  4328. type ResultSeventeenOther struct {
  4329. ErrMsg string `json:"err_msg"`
  4330. InfRefmsgid string `json:"inf_refmsgid"`
  4331. Infcode string `json:"infcode"`
  4332. Output struct {
  4333. SetlListId string `json:"setl_list_id"`
  4334. } `json:"output"`
  4335. RefmsgTime string `json:"refmsg_time"`
  4336. RespondTime string `json:"respond_time"`
  4337. Signtype string `json:"signtype"`
  4338. WarnInfo string `json:"warn_info"`
  4339. }
  4340. type Result90991 struct {
  4341. ErrMsg string `json:"err_msg"`
  4342. InfRefmsgid string `json:"inf_refmsgid"`
  4343. Infcode int64 `json:"infcode"`
  4344. Output struct {
  4345. Result struct {
  4346. PsnNo string `json:"psn_no"`
  4347. CardStat string `json:"card_stat"`
  4348. Certno string `json:"certno"`
  4349. PsnName string `json:"psn_name"`
  4350. CheckStat string `json:"check_stat"`
  4351. SscnoCheckStat string `json:"sscno_check_stat"`
  4352. } `json:"result"`
  4353. } `json:"output"`
  4354. RefmsgTime string `json:"refmsg_time"`
  4355. RespondTime string `json:"respond_time"`
  4356. Signtype interface{} `json:"signtype"`
  4357. WarnInfo interface{} `json:"warn_info"`
  4358. }
  4359. type Result90100 struct {
  4360. ErrMsg string `json:"err_msg"`
  4361. InfRefmsgid string `json:"inf_refmsgid"`
  4362. Infcode int64 `json:"infcode"`
  4363. Output struct {
  4364. PoolareaNo string `json:"poolarea_no"`
  4365. PoolareaNoName string `json:"poolarea_no_name"`
  4366. Insutype string `json:"insutype"`
  4367. InsutypeName string `json:"insutype_name"`
  4368. ClctType string `json:"clct_type"`
  4369. ClctTypeName string `json:"clct_type_name"`
  4370. ClctFlag string `json:"clct_flag"`
  4371. ClctFlagName string `json:"clct_flag_name"`
  4372. AccrymBegn string `json:"accrym_begn"`
  4373. AccrymEnd string `json:"accrym_end"`
  4374. ClctTime string `json:"clct_time"`
  4375. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  4376. } `json:"output"`
  4377. RefmsgTime string `json:"refmsg_time"`
  4378. RespondTime string `json:"respond_time"`
  4379. Signtype interface{} `json:"signtype"`
  4380. WarnInfo interface{} `json:"warn_info"`
  4381. }
  4382. type Custom struct {
  4383. DetItemFeeSumamt string
  4384. Cut string
  4385. FeedetlSn string
  4386. Price string
  4387. MedListCodg string
  4388. Type int64
  4389. AdviceId int64
  4390. ProjectId int64
  4391. ItemId int64
  4392. }
  4393. type Result5301 struct {
  4394. ErrMsg string `json:"err_msg"`
  4395. InfRefmsgid string `json:"inf_refmsgid"`
  4396. Infcode int64 `json:"infcode"`
  4397. Output struct {
  4398. Result []struct {
  4399. OpspDiseCode string `json:"opsp_dise_code"`
  4400. OpspDiseName string `json:"opsp_dise_name"`
  4401. Begndate string `json:"begndate"`
  4402. Enddate string `json:"enddate"`
  4403. } `json:"feedetail"`
  4404. } `json:"output"`
  4405. RefmsgTime string `json:"refmsg_time"`
  4406. RespondTime string `json:"respond_time"`
  4407. Signtype interface{} `json:"signtype"`
  4408. WarnInfo interface{} `json:"warn_info"`
  4409. }
  4410. type Result5301For10265 struct {
  4411. ErrMsg string `json:"err_msg"`
  4412. InfRefmsgid string `json:"inf_refmsgid"`
  4413. Infcode string `json:"infcode"`
  4414. Output struct {
  4415. Result []struct {
  4416. OpspDiseCode string `json:"opsp_dise_code"`
  4417. OpspDiseName string `json:"opsp_dise_name"`
  4418. Begndate string `json:"begndate"`
  4419. Enddate string `json:"enddate"`
  4420. } `json:"feedetail"`
  4421. } `json:"output"`
  4422. RefmsgTime string `json:"refmsg_time"`
  4423. RespondTime string `json:"respond_time"`
  4424. Signtype interface{} `json:"signtype"`
  4425. WarnInfo interface{} `json:"warn_info"`
  4426. }
  4427. //获取个人信息----挂号-----上传就诊信息
  4428. func (c *HisApiController) GetRegisterInfo() {
  4429. id, _ := c.GetInt64("id")
  4430. record_time := c.GetString("record_time")
  4431. settlementValue, _ := c.GetInt64("settlement_value")
  4432. medical_insurance_card := c.GetString("medical_insurance_card")
  4433. name := c.GetString("name")
  4434. id_card_type, _ := c.GetInt64("id_card_type")
  4435. certificates, _ := c.GetInt64("certificates")
  4436. medical_care, _ := c.GetInt64("medical_care")
  4437. birthday := c.GetString("birthday")
  4438. id_card := c.GetString("id_card")
  4439. register_type, _ := c.GetInt64("register")
  4440. doctor, _ := c.GetInt64("doctor")
  4441. department, _ := c.GetInt64("department")
  4442. gender, _ := c.GetInt64("sex")
  4443. registration_fee, _ := c.GetFloat("registration_fee")
  4444. medical_expenses, _ := c.GetFloat("medical_expenses")
  4445. social_type, _ := c.GetInt64("social_type")
  4446. med_type := c.GetString("social_type")
  4447. admin_user_id, _ := c.GetInt64("admin_user_id")
  4448. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4449. timeLayout := "2006-01-02"
  4450. loc, _ := time.LoadLocation("Local")
  4451. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4452. birthUnix := birthdays.Unix()
  4453. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4454. if err != nil {
  4455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4456. return
  4457. }
  4458. recordDateTime := theTime.Unix()
  4459. adminInfo := c.GetAdminUserInfo()
  4460. var patient service.Patients
  4461. if id == 0 {
  4462. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4463. } else {
  4464. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4465. }
  4466. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4467. if patientPrescription.ID == 0 {
  4468. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4469. }
  4470. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4471. if patient.ID == 0 {
  4472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4473. return
  4474. }
  4475. if len(patient.IdCardNo) == 0 {
  4476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4477. return
  4478. }
  4479. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4480. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4481. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4482. //就诊结算未完成,不能进行二次挂号
  4483. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4484. if len(his) >= 1 {
  4485. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  4486. if len(his) >= 1 && order.ID == 0 {
  4487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  4488. return
  4489. }
  4490. }
  4491. //var register_log string
  4492. if config.IsOpen == 1 {
  4493. var res ResultTwo
  4494. var res10265 ResultTwo10265
  4495. var PsnNo string
  4496. var PsnCertType string
  4497. var Certno string
  4498. var PsnName string
  4499. var Gend string
  4500. var Naty string
  4501. var Brdy string
  4502. var Age float64
  4503. var infoStr string
  4504. var idetinfoStr string
  4505. var infocode int64
  4506. var verify_number string
  4507. fmt.Println(verify_number)
  4508. if miConfig.MdtrtareaAdmvs == "421300" {
  4509. psn_info, _ := service.GetPsnByPatientId(id)
  4510. PsnNo = psn_info.PsnNo
  4511. PsnCertType = psn_info.PsnCertType
  4512. Certno = psn_info.Certno
  4513. PsnName = psn_info.PsnName
  4514. Gend = psn_info.Gend
  4515. Naty = psn_info.Naty
  4516. Brdy = psn_info.Brdy
  4517. Age = psn_info.Age
  4518. infoStr = psn_info.Insuinfo
  4519. idetinfoStr = psn_info.Idetinfo
  4520. infocode = 0
  4521. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4522. psn_info, _ := service.GetPsnByPatientId(id)
  4523. PsnNo = psn_info.PsnNo
  4524. PsnCertType = psn_info.PsnCertType
  4525. Certno = psn_info.Certno
  4526. PsnName = psn_info.PsnName
  4527. Gend = psn_info.Gend
  4528. Naty = psn_info.Naty
  4529. Brdy = psn_info.Brdy
  4530. Age = psn_info.Age
  4531. infoStr = psn_info.Insuinfo
  4532. idetinfoStr = psn_info.Idetinfo
  4533. infocode = 0
  4534. verify_number = psn_info.VerifyNumber
  4535. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4536. psn_info, _ := service.GetPsnByPatientId(id)
  4537. PsnNo = psn_info.PsnNo
  4538. PsnCertType = psn_info.PsnCertType
  4539. Certno = psn_info.Certno
  4540. PsnName = psn_info.PsnName
  4541. Gend = psn_info.Gend
  4542. Naty = psn_info.Naty
  4543. Brdy = psn_info.Brdy
  4544. Age = psn_info.Age
  4545. infoStr = psn_info.Insuinfo
  4546. idetinfoStr = psn_info.Idetinfo
  4547. infocode = 0
  4548. verify_number = psn_info.VerifyNumber
  4549. } else {
  4550. var result string
  4551. var requestLog string
  4552. if miConfig.UserOrgId == 10138 {
  4553. 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)
  4554. } else {
  4555. 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)
  4556. }
  4557. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4558. if miConfig.Code == "H15049901371" {
  4559. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4560. utils.ErrorLog("解析失败:%v", err)
  4561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4562. return
  4563. }
  4564. res.ErrMsg = res10265.ErrMsg
  4565. res.Output = res10265.Output
  4566. res.InfRefmsgid = res10265.InfRefmsgid
  4567. } else {
  4568. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4569. utils.ErrorLog("解析失败:%v", err)
  4570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4571. return
  4572. }
  4573. }
  4574. PsnNo = res.Output.Baseinfo.PsnNo
  4575. PsnCertType = res.Output.Baseinfo.PsnCertType
  4576. Certno = res.Output.Baseinfo.Certno
  4577. PsnName = res.Output.Baseinfo.PsnName
  4578. Gend = res.Output.Baseinfo.Gend
  4579. Naty = res.Output.Baseinfo.Naty
  4580. Brdy = res.Output.Baseinfo.Brdy
  4581. Age = res.Output.Baseinfo.Age
  4582. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4583. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4584. infoStr = string(Iinfos)
  4585. idetinfoStr = string(Idetinfos)
  4586. if miConfig.Code == "H15049901371" {
  4587. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  4588. } else {
  4589. infocode = res.Infcode
  4590. }
  4591. }
  4592. if infocode == 0 {
  4593. his := models.VMHisPatient{
  4594. Name: name,
  4595. Gender: gender,
  4596. Birthday: birthUnix,
  4597. MedicalTreatmentType: medical_care,
  4598. IdType: certificates,
  4599. IdCardNo: id_card,
  4600. BalanceAccountsType: settlementValue,
  4601. SocialType: social_type,
  4602. MedicalInsuranceNumber: medical_insurance_card,
  4603. RegisterType: register_type,
  4604. RegisterCost: registration_fee,
  4605. TreatmentCost: medical_expenses,
  4606. Status: 1,
  4607. Ctime: time.Now().Unix(),
  4608. Mtime: time.Now().Unix(),
  4609. PsnNo: PsnNo,
  4610. PsnCertType: PsnCertType,
  4611. Certno: Certno,
  4612. PsnName: PsnName,
  4613. Gend: Gend,
  4614. Naty: Naty,
  4615. Brdy: Brdy,
  4616. Age: Age,
  4617. Iinfo: infoStr,
  4618. Idetinfo: idetinfoStr,
  4619. PatientId: patient.ID,
  4620. RecordDate: theTime.Unix(),
  4621. UserOrgId: adminInfo.CurrentOrgId,
  4622. AdminUserId: admin_user_id,
  4623. IsReturn: 1,
  4624. IdCardType: id_card_type,
  4625. Doctor: doctor,
  4626. Departments: department,
  4627. }
  4628. timestamp := time.Now().Unix()
  4629. tempTime := time.Unix(timestamp, 0)
  4630. timeFormat := tempTime.Format("20060102150405")
  4631. chrgBchno := rand.Intn(100000) + 10000
  4632. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4633. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  4634. department, _ := service.GetDepartMentDetail(department)
  4635. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  4636. IdCardNo := ""
  4637. if id_card_type == 1 {
  4638. // IdCardNo = medical_insurance_card
  4639. IdCardNo = patient.IdCardNo
  4640. } else {
  4641. IdCardNo = patient.IdCardNo
  4642. }
  4643. var rf []*ResultFive
  4644. json.Unmarshal([]byte(his.Iinfo), &rf)
  4645. var insutypes []*ResultFive
  4646. var insutype string
  4647. var insuplc_admdvs_temp string
  4648. var is390 int = 0
  4649. var is310 int = 0
  4650. for _, item := range rf {
  4651. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4652. insutypes = append(insutypes, item)
  4653. }
  4654. }
  4655. if len(insutypes) == 1 {
  4656. insutype = insutypes[0].Insutype
  4657. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4658. } else {
  4659. for _, i := range insutypes {
  4660. if i.Insutype == "390" {
  4661. is390 = 1
  4662. }
  4663. if i.Insutype == "310" {
  4664. is310 = 1
  4665. }
  4666. }
  4667. }
  4668. if is390 == 1 {
  4669. insutype = "390"
  4670. }
  4671. if is310 == 1 {
  4672. insutype = "310"
  4673. }
  4674. if len(insutypes) == 0 {
  4675. insutype = "310"
  4676. }
  4677. if len(insutypes) == 2 {
  4678. insutype = med_type
  4679. }
  4680. if len(med_type) > 0 {
  4681. insutype = med_type
  4682. }
  4683. //for _, item := range rf {
  4684. // if item.Insutype == insutype {
  4685. // insuplc_admdvs = item.InsuplcAdmdvs
  4686. // }
  4687. //}
  4688. var infocode int64
  4689. var resThree ResultThree
  4690. var resThree10265 ResultThree10265
  4691. if len(insuplc_admdvs) == 0 {
  4692. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  4693. } else {
  4694. insuplc_admdvs_temp = insuplc_admdvs
  4695. }
  4696. if miConfig.MdtrtareaAdmvs == "421300" {
  4697. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  4698. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  4699. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4700. "&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=" + hb_doctor_info.DoctorNumber + "&doctor_name=" + hb_doctor_info.UserName + "&opter=" + roles.UserName
  4701. resp, requestErr := http.Get(api)
  4702. if requestErr != nil {
  4703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4704. return
  4705. }
  4706. body, ioErr := ioutil.ReadAll(resp.Body)
  4707. if ioErr != nil {
  4708. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4710. return
  4711. }
  4712. var respJSON map[string]interface{}
  4713. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4714. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4716. return
  4717. }
  4718. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4719. result, _ := json.Marshal(respJSON)
  4720. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4721. utils.ErrorLog("解析失败:%v", err)
  4722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4723. return
  4724. }
  4725. infocode = resThree.Infcode
  4726. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4727. psn_info, _ := service.GetPsnByPatientId(id)
  4728. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4729. var cert_no string
  4730. if id_card_type == 3 {
  4731. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  4732. cert_no = IdCardNo
  4733. } else if id_card_type == 4 {
  4734. cert_no = IdCardNo
  4735. psn_info.VerifyNumber = psn_info.VerifyNumber
  4736. } else {
  4737. bas := strings.Split(psn_info.CardInfo, "|")
  4738. cert_no = bas[2]
  4739. }
  4740. var api string
  4741. if miConfig.MdtrtareaAdmvs == "320921" {
  4742. api = "http://192.168.2.110:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4743. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4744. "&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
  4745. } else {
  4746. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4747. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4748. "&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
  4749. }
  4750. resp, requestErr := http.Get(api)
  4751. if requestErr != nil {
  4752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4753. return
  4754. }
  4755. body, ioErr := ioutil.ReadAll(resp.Body)
  4756. if ioErr != nil {
  4757. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4759. return
  4760. }
  4761. var respJSON map[string]interface{}
  4762. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4763. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4765. return
  4766. }
  4767. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4768. result, _ := json.Marshal(respJSON)
  4769. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4770. utils.ErrorLog("解析失败:%v", err)
  4771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4772. return
  4773. }
  4774. resThree.ErrMsg = resThree10265.ErrMsg
  4775. resThree.Output = resThree10265.Output
  4776. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4777. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4778. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4779. psn_info, _ := service.GetPsnByPatientId(id)
  4780. var cert_no string
  4781. if id_card_type == 1 {
  4782. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  4783. }
  4784. result, requestLog := service.FJyb2201(res.Output.Baseinfo.PsnNo, insutype, IdCardNo, miConfig.OrgName, doctor_info.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_id, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, roles.UserName, doctor_info.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, cert_no)
  4785. saveLog(result, requestLog, "2201", "挂号")
  4786. if miConfig.Code == "H15049901371" {
  4787. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4788. utils.ErrorLog("解析失败:%v", err)
  4789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4790. return
  4791. }
  4792. resThree.ErrMsg = resThree10265.ErrMsg
  4793. resThree.Output = resThree10265.Output
  4794. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4795. } else {
  4796. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4797. utils.ErrorLog("解析失败:%v", err)
  4798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4799. return
  4800. }
  4801. }
  4802. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4803. } else {
  4804. 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)
  4805. saveLog(result, requestLog, "2201A", "挂号")
  4806. if miConfig.Code == "H15049901371" {
  4807. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4808. utils.ErrorLog("解析失败:%v", err)
  4809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4810. return
  4811. }
  4812. resThree.ErrMsg = resThree10265.ErrMsg
  4813. resThree.Output = resThree10265.Output
  4814. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4815. } else {
  4816. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4817. utils.ErrorLog("解析失败:%v", err)
  4818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4819. return
  4820. }
  4821. }
  4822. if miConfig.Code == "H15049901371" {
  4823. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4824. } else {
  4825. infocode = resThree.Infcode
  4826. }
  4827. }
  4828. if infocode != 0 {
  4829. adminUser := c.GetAdminUserInfo()
  4830. errlog := &models.HisOrderError{
  4831. UserOrgId: adminUser.CurrentOrgId,
  4832. Ctime: time.Now().Unix(),
  4833. Mtime: time.Now().Unix(),
  4834. ErrMsg: resThree.ErrMsg,
  4835. Status: 1,
  4836. PatientId: id,
  4837. RecordTime: recordDateTime,
  4838. Stage: 2,
  4839. }
  4840. service.CreateErrMsgLog(errlog)
  4841. c.ServeSuccessJSON(map[string]interface{}{
  4842. "failed_code": -10,
  4843. "msg": resThree.ErrMsg,
  4844. })
  4845. return
  4846. }
  4847. his.Number = resThree.Output.Data.MdtrtID
  4848. his.PsnNo = resThree.Output.Data.PsnNo
  4849. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  4850. his.IdCardNo = patient.IdCardNo
  4851. his.PhoneNumber = patient.Phone
  4852. his.UserOrgId = adminInfo.CurrentOrgId
  4853. his.Insutype = insutype
  4854. his.Ctime = time.Now().Unix()
  4855. his.Mtime = time.Now().Unix()
  4856. his.InsuplcAdmdvs = insuplc_admdvs_temp
  4857. his.Status = 1
  4858. service.UpdateHisPatientStatus(&his)
  4859. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  4860. c.ServeSuccessJSON(map[string]interface{}{
  4861. "his_info": his,
  4862. })
  4863. } else {
  4864. adminUser := c.GetAdminUserInfo()
  4865. errlog := &models.HisOrderError{
  4866. UserOrgId: adminUser.CurrentOrgId,
  4867. Ctime: time.Now().Unix(),
  4868. Mtime: time.Now().Unix(),
  4869. ErrMsg: res.ErrMsg,
  4870. Status: 1,
  4871. PatientId: id,
  4872. RecordTime: recordDateTime,
  4873. Stage: 1,
  4874. }
  4875. service.CreateErrMsgLog(errlog)
  4876. c.ServeSuccessJSON(map[string]interface{}{
  4877. "failed_code": -10,
  4878. "msg": res.ErrMsg,
  4879. })
  4880. return
  4881. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  4882. }
  4883. }
  4884. }
  4885. //上传明细----预结算----确认订单
  4886. func (c *HisApiController) GetUploadInfo() {
  4887. id, _ := c.GetInt64("id")
  4888. record_time := c.GetString("record_time")
  4889. his_patient_id, _ := c.GetInt64("his_patient_id")
  4890. order_id, _ := c.GetInt64("order_id")
  4891. pay_way, _ := c.GetInt64("pay_way")
  4892. pay_price, _ := c.GetFloat("pay_price")
  4893. pay_card_no := c.GetString("pay_card_no")
  4894. token := c.GetString("token")
  4895. discount_price, _ := c.GetFloat("discount_price")
  4896. preferential_price, _ := c.GetFloat("preferential_price")
  4897. reality_price, _ := c.GetFloat("reality_price")
  4898. found_price, _ := c.GetFloat("found_price")
  4899. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  4900. private_price, _ := c.GetFloat("private_price")
  4901. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4902. admin_user_id, _ := c.GetInt64("admin_user_id")
  4903. fapiao_code := c.GetString("fapiao_code")
  4904. fapiao_number := c.GetString("fapiao_number")
  4905. diagnosis_id := c.GetString("diagnosis")
  4906. sick_type, _ := c.GetInt64("sick_type")
  4907. reg_type, _ := c.GetInt64("p_type")
  4908. begin_time := c.GetString("begin_time")
  4909. id_str := c.GetString("ids")
  4910. ids_arr := strings.Split(id_str, ",")
  4911. timeLayout := "2006-01-02"
  4912. loc, _ := time.LoadLocation("Local")
  4913. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4914. if err != nil {
  4915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4916. return
  4917. }
  4918. recordDateTime := theTime.Unix()
  4919. adminUser := c.GetAdminUserInfo()
  4920. var tempOrder models.HisOrder
  4921. tempOrder, _ = service.GetHisOrderByID(order_id)
  4922. var prescriptions []*models.HisPrescription
  4923. var start_time int64
  4924. var end_time int64
  4925. //押金模块
  4926. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  4927. tmp_decimal := c.GetString("tmp_decimal")
  4928. var decimal float64 //本次使用的押金
  4929. var errmsg error
  4930. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  4931. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  4932. return
  4933. }
  4934. if len(tmp_decimal) > 0 {
  4935. if tmp_decimal[0] == 45 {
  4936. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  4937. return
  4938. }
  4939. }
  4940. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  4941. fmt.Println(errs)
  4942. decimal = tt
  4943. //if adminUser.CurrentOrgId == 10106{
  4944. // if len(fapiao_code) == 0{
  4945. // fapiao_code = "144072080589"
  4946. // }
  4947. // if len(fapiao_number) == 0{
  4948. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  4949. // if order.ID == 0{
  4950. // fapiao_number = "00001520"
  4951. // }else{
  4952. // //fapiao_code = "00001520"
  4953. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  4954. // var zero string
  4955. // if fpNumber >= 1000{
  4956. // zero = "0000" + strconv.Itoa(fpNumber)
  4957. // }else if fpNumber >= 10000{
  4958. // zero = "000" + strconv.Itoa(fpNumber)
  4959. // } else if fpNumber >= 100000{
  4960. // zero = "00" + strconv.Itoa(fpNumber)
  4961. // } else if fpNumber >= 1000000{
  4962. // zero = "0" + strconv.Itoa(fpNumber)
  4963. // }else {
  4964. // zero = strconv.Itoa(fpNumber)
  4965. // }
  4966. // fapiao_number = zero
  4967. // }
  4968. // }
  4969. //}
  4970. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4971. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4972. var patientPrescription models.HisPrescriptionInfo
  4973. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4974. if patientPrescription.ID == 0 {
  4975. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4976. }
  4977. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4978. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4979. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4980. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4981. var config []*models.HisXtDiagnoseConfig
  4982. for _, item := range diagnosis_ids {
  4983. id, _ := strconv.ParseInt(item, 10, 64)
  4984. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4985. config = append(config, &diagnosisConfig)
  4986. }
  4987. sickConfig, _ := service.FindSickById(sick_type)
  4988. //if tempOrder.ID == 0 {
  4989. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  4990. //}
  4991. if tempOrder.ID == 0 {
  4992. var result string
  4993. var requestLog string
  4994. var res2 ResultSix
  4995. var ressix10265 ResultSix10265
  4996. if miConfig.MdtrtareaAdmvs == "421300" {
  4997. data := make(map[string]interface{})
  4998. client := &http.Client{}
  4999. data["psn_no"] = his.PsnNo
  5000. data["mdtrt_id"] = his.Number
  5001. data["opter"] = roles.UserName
  5002. data["org_name"] = miConfig.OrgName
  5003. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5004. data["doctor_id"] = doctor_info.DoctorNumber
  5005. data["doctor_name"] = doctor_info.UserName
  5006. data["department"] = department.Name
  5007. data["fixmedins_code"] = miConfig.Code
  5008. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5009. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5010. data["secret_key"] = miConfig.SecretKey
  5011. data["sick_code"] = sickConfig.CountryCode
  5012. data["sick_name"] = sickConfig.ClassName
  5013. data["dept"] = strconv.FormatInt(department.ID, 10)
  5014. data["config"] = config
  5015. data["begin_time"] = begin_time
  5016. bytesData, _ := json.Marshal(data)
  5017. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5018. resp, _ := client.Do(req)
  5019. defer resp.Body.Close()
  5020. body, ioErr := ioutil.ReadAll(resp.Body)
  5021. if ioErr != nil {
  5022. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5024. return
  5025. }
  5026. var respJSON map[string]interface{}
  5027. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5028. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5030. return
  5031. }
  5032. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5033. userJSONBytes, _ := json.Marshal(respJSON)
  5034. fmt.Println("log")
  5035. fmt.Println(string(userJSONBytes))
  5036. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5037. utils.ErrorLog("解析失败:%v", err)
  5038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5039. return
  5040. }
  5041. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5042. //江苏地区国家医保医疗类别
  5043. //职工透析:医疗类别选特殊情况门诊9933
  5044. //居民血透门慢: 医疗类别选门诊慢病1402
  5045. //var med_type string
  5046. //if his.Insutype == "310" {
  5047. // if reg_type == 14 {
  5048. // med_type = "9933"
  5049. // } else if reg_type == 11 {
  5050. // med_type = "11"
  5051. //
  5052. // }
  5053. //} else if his.Insutype == "390" {
  5054. // if reg_type == 14 {
  5055. // med_type = "1402"
  5056. // } else if reg_type == 11 {
  5057. // med_type = "11"
  5058. // }
  5059. //}
  5060. data := make(map[string]interface{})
  5061. client := &http.Client{}
  5062. data["psn_no"] = his.PsnNo
  5063. data["mdtrt_id"] = his.Number
  5064. data["doctor"] = roles.UserName
  5065. data["department"] = department.Name
  5066. data["org_name"] = miConfig.OrgName
  5067. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5068. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5069. data["fixmedins_code"] = miConfig.Code
  5070. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5071. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5072. data["secret_key"] = miConfig.SecretKey
  5073. data["sick_code"] = sickConfig.CountryCode
  5074. data["sick_name"] = sickConfig.ClassName
  5075. data["url"] = miConfig.Url
  5076. data["ak"] = miConfig.AccessKey
  5077. data["begin_time"] = begin_time
  5078. data["cainfo"] = miConfig.Cainfo
  5079. data["dept"] = strconv.FormatInt(department.ID, 10)
  5080. data["config"] = config
  5081. bytesData, _ := json.Marshal(data)
  5082. var req *http.Request
  5083. if miConfig.MdtrtareaAdmvs == "320921" {
  5084. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5085. //api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  5086. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  5087. } else {
  5088. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5089. }
  5090. resp, _ := client.Do(req)
  5091. defer resp.Body.Close()
  5092. body, ioErr := ioutil.ReadAll(resp.Body)
  5093. if ioErr != nil {
  5094. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5096. return
  5097. }
  5098. var respJSON map[string]interface{}
  5099. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5100. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5102. return
  5103. }
  5104. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5105. userJSONBytes, _ := json.Marshal(respJSON)
  5106. fmt.Println("log")
  5107. fmt.Println(string(userJSONBytes))
  5108. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5109. utils.ErrorLog("解析失败:%v", err)
  5110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5111. return
  5112. }
  5113. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5114. res2.Output = ressix10265.Output
  5115. res2.ErrMsg = ressix10265.ErrMsg
  5116. res2.Cainfo = ressix10265.Cainfo
  5117. res2.WarnMsg = ressix10265.WarnMsg
  5118. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5119. res2.Infcode = infocode
  5120. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5121. result, requestLog = service.FJyb2203(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, doctor_info.UserName, roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  5122. saveLog(result, requestLog, "2203", "上传就诊信息")
  5123. var respJSON2 map[string]interface{}
  5124. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5125. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5127. return
  5128. }
  5129. userJSONBytes2, _ := json.Marshal(respJSON2)
  5130. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5131. utils.ErrorLog("解析失败:%v", err)
  5132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5133. return
  5134. }
  5135. } else {
  5136. if miConfig.MdtrtareaAdmvs == "440781" { //
  5137. 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)
  5138. } else {
  5139. if miConfig.Code == "H15049901371" {
  5140. //赤峰地区国家医保医疗类别
  5141. //职工透析:医疗类别选特殊情况门诊990502
  5142. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5143. var med_type string
  5144. if his.Insutype == "390" {
  5145. if reg_type == 14 {
  5146. med_type = "9933"
  5147. } else if reg_type == 11 {
  5148. med_type = "11"
  5149. }
  5150. } else if his.Insutype == "310" {
  5151. if reg_type == 14 {
  5152. med_type = "990502"
  5153. } else if reg_type == 11 {
  5154. med_type = "11"
  5155. }
  5156. }
  5157. 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)
  5158. } else {
  5159. 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)
  5160. }
  5161. }
  5162. saveLog(result, requestLog, "2203", "上传就诊信息")
  5163. var respJSON2 map[string]interface{}
  5164. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5165. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5167. return
  5168. }
  5169. userJSONBytes2, _ := json.Marshal(respJSON2)
  5170. if miConfig.Code == "H15049901371" {
  5171. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  5172. utils.ErrorLog("解析失败:%v", err)
  5173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5174. return
  5175. }
  5176. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5177. res2.Output = ressix10265.Output
  5178. res2.ErrMsg = ressix10265.ErrMsg
  5179. res2.Cainfo = ressix10265.Cainfo
  5180. res2.WarnMsg = ressix10265.WarnMsg
  5181. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5182. res2.Infcode = infocode
  5183. } else {
  5184. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5185. utils.ErrorLog("解析失败:%v", err)
  5186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5187. return
  5188. }
  5189. }
  5190. }
  5191. if res2.Infcode != 0 {
  5192. adminUser := c.GetAdminUserInfo()
  5193. errlog := &models.HisOrderError{
  5194. UserOrgId: adminUser.CurrentOrgId,
  5195. Ctime: time.Now().Unix(),
  5196. Mtime: time.Now().Unix(),
  5197. ErrMsg: res2.ErrMsg,
  5198. Status: 1,
  5199. PatientId: id,
  5200. RecordTime: recordDateTime,
  5201. Stage: 3,
  5202. }
  5203. service.CreateErrMsgLog(errlog)
  5204. c.ServeSuccessJSON(map[string]interface{}{
  5205. "failed_code": -10,
  5206. "msg": res2.ErrMsg,
  5207. })
  5208. return
  5209. } else {
  5210. his.Diagnosis = diagnosis_id
  5211. his.SickType = sickConfig.ID
  5212. //var p_type int64
  5213. //if reg_type == 1111 || reg_type == 1112 {
  5214. // p_type = 11
  5215. //
  5216. //}
  5217. his.PType = fmt.Sprintf("%d", reg_type)
  5218. service.UpdateHisPatientThree(&his)
  5219. data := make(map[string]interface{})
  5220. if settle_accounts_type == 1 { //日结
  5221. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5222. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5223. } else {
  5224. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5225. }
  5226. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  5227. data["pre"] = prescriptions
  5228. } else { //月结
  5229. start_time_str := c.GetString("start_time")
  5230. end_time_str := c.GetString("end_time")
  5231. timeLayout := "2006-01-02"
  5232. loc, _ := time.LoadLocation("Local")
  5233. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5234. if err != nil {
  5235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5236. return
  5237. }
  5238. recordStartTime := theStartTime.Unix()
  5239. start_time = recordStartTime
  5240. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5241. if err != nil {
  5242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5243. return
  5244. }
  5245. recordEndTime := theEndTime.Unix()
  5246. end_time = recordEndTime
  5247. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5248. data["pre"] = prescriptions
  5249. }
  5250. timestamp := time.Now().Unix()
  5251. tempTime := time.Unix(timestamp, 0)
  5252. timeFormat := tempTime.Format("20060102150405")
  5253. chrgBchno := rand.Intn(100000) + 10000
  5254. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5255. strconv.FormatInt(his.PatientId, 10)
  5256. client := &http.Client{}
  5257. data["psn_no"] = his.PsnNo
  5258. data["mdtrt_id"] = his.Number
  5259. data["chrg_bchno"] = chrg_bchno
  5260. data["org_name"] = miConfig.OrgName
  5261. data["doctor"] = doctor_info.UserName
  5262. data["doctor_id"] = doctor_info.DoctorNumber
  5263. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5264. data["fixmedins_code"] = miConfig.Code
  5265. data["opter"] = roles.UserName
  5266. data["dept_code"] = department.Number
  5267. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5268. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5269. data["secret_key"] = miConfig.SecretKey
  5270. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5271. data["url"] = miConfig.Url
  5272. data["ak"] = miConfig.AccessKey
  5273. data["new_doctor_name"] = patientPrescription.Doctor
  5274. data["diag_code"] = sickConfig.CountryCode
  5275. data["cainfo"] = miConfig.Cainfo
  5276. var ids []int64
  5277. for _, item := range prescriptions {
  5278. ids = append(ids, item.ID)
  5279. }
  5280. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5281. if config.IsOpen == 1 { //对接了医保,走医保流程
  5282. var res ResultFour
  5283. var resFour10265 ResultFour10265
  5284. if miConfig.MdtrtareaAdmvs == "421300" {
  5285. bytesData, _ := json.Marshal(data)
  5286. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5287. resp, _ := client.Do(req)
  5288. defer resp.Body.Close()
  5289. body, ioErr := ioutil.ReadAll(resp.Body)
  5290. if ioErr != nil {
  5291. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5293. return
  5294. }
  5295. var respJSON map[string]interface{}
  5296. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5297. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5299. return
  5300. }
  5301. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5302. userJSONBytes, _ := json.Marshal(respJSON)
  5303. fmt.Println("log")
  5304. fmt.Println(string(userJSONBytes))
  5305. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5306. utils.ErrorLog("解析失败:%v", err)
  5307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5308. return
  5309. }
  5310. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5311. bytesData, _ := json.Marshal(data)
  5312. var req *http.Request
  5313. if miConfig.MdtrtareaAdmvs == "320921" {
  5314. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5315. } else {
  5316. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5317. }
  5318. resp, _ := client.Do(req)
  5319. defer resp.Body.Close()
  5320. body, ioErr := ioutil.ReadAll(resp.Body)
  5321. if ioErr != nil {
  5322. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5324. return
  5325. }
  5326. var respJSON map[string]interface{}
  5327. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5328. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5330. return
  5331. }
  5332. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5333. userJSONBytes, _ := json.Marshal(respJSON)
  5334. fmt.Println("log")
  5335. fmt.Println(string(userJSONBytes))
  5336. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5337. utils.ErrorLog("解析失败:%v", err)
  5338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5339. return
  5340. }
  5341. res.InfRefmsgid = resFour10265.InfRefmsgid
  5342. res.Output = resFour10265.Output
  5343. res.ErrMsg = resFour10265.ErrMsg
  5344. res.Cainfo = resFour10265.Cainfo
  5345. res.WarnMsg = resFour10265.WarnMsg
  5346. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5347. res.Infcode = infocode
  5348. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5349. result, request_log := service.FJyb2204(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), roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  5350. var dat map[string]interface{}
  5351. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5352. fmt.Println(dat)
  5353. } else {
  5354. fmt.Println(err)
  5355. }
  5356. saveLog(result, request_log, "2204", "上传费用明细")
  5357. userJSONBytes, _ := json.Marshal(dat)
  5358. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5359. utils.ErrorLog("解析失败:%v", err)
  5360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5361. return
  5362. }
  5363. res.InfRefmsgid = resFour10265.InfRefmsgid
  5364. res.Output = resFour10265.Output
  5365. res.ErrMsg = resFour10265.ErrMsg
  5366. res.Cainfo = resFour10265.Cainfo
  5367. res.WarnMsg = resFour10265.WarnMsg
  5368. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5369. res.Infcode = infocode
  5370. } else {
  5371. if miConfig.Code == "H15049901371" {
  5372. 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)
  5373. var dat map[string]interface{}
  5374. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5375. fmt.Println(dat)
  5376. } else {
  5377. fmt.Println(err)
  5378. }
  5379. saveLog(result, request_log, "2204", "上传费用明细")
  5380. userJSONBytes, _ := json.Marshal(dat)
  5381. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5382. utils.ErrorLog("解析失败:%v", err)
  5383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5384. return
  5385. }
  5386. res.InfRefmsgid = resFour10265.InfRefmsgid
  5387. res.Output = resFour10265.Output
  5388. res.ErrMsg = resFour10265.ErrMsg
  5389. res.Cainfo = resFour10265.Cainfo
  5390. res.WarnMsg = resFour10265.WarnMsg
  5391. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5392. res.Infcode = infocode
  5393. } else {
  5394. 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)
  5395. var dat map[string]interface{}
  5396. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5397. fmt.Println(dat)
  5398. } else {
  5399. fmt.Println(err)
  5400. }
  5401. saveLog(result, request_log, "2204", "上传费用明细")
  5402. userJSONBytes, _ := json.Marshal(dat)
  5403. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5404. utils.ErrorLog("解析失败:%v", err)
  5405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5406. return
  5407. }
  5408. }
  5409. }
  5410. if res.Infcode == 0 {
  5411. order := &models.HisOrder{
  5412. UserOrgId: adminUser.CurrentOrgId,
  5413. HisPatientId: his.ID,
  5414. PatientId: his.PatientId,
  5415. SettleAccountsDate: recordDateTime,
  5416. MdtrtId: his.Number,
  5417. PsnNo: his.PsnNo,
  5418. MedType: strconv.FormatInt(reg_type, 10),
  5419. Ctime: time.Now().Unix(),
  5420. Mtime: time.Now().Unix(),
  5421. Status: 1,
  5422. Number: chrg_bchno,
  5423. Infcode: res.Infcode,
  5424. WarnMsg: res.WarnMsg,
  5425. Cainfo: res.Cainfo,
  5426. ErrMsg: res.ErrMsg,
  5427. RespondTime: res.RefmsgTime,
  5428. InfRefmsgid: res.InfRefmsgid,
  5429. OrderStatus: 1,
  5430. PayWay: pay_way,
  5431. PayPrice: pay_price,
  5432. PayCardNo: pay_card_no,
  5433. DiscountPrice: discount_price,
  5434. PreferentialPrice: preferential_price,
  5435. RealityPrice: reality_price,
  5436. FoundPrice: found_price,
  5437. MedicalInsurancePrice: medical_insurance_price,
  5438. PrivatePrice: private_price,
  5439. IsMedicineInsurance: 1,
  5440. SettleType: settle_accounts_type,
  5441. SettleStartTime: start_time,
  5442. SettleEndTime: end_time,
  5443. Creator: roles.AdminUserId,
  5444. Modify: roles.AdminUserId,
  5445. FaPiaoNumber: fapiao_number,
  5446. FaPiaoCode: fapiao_code,
  5447. PType: 2,
  5448. Diagnosis: diagnosis_id,
  5449. }
  5450. err = service.CreateOrder(order)
  5451. if err != nil {
  5452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5453. return
  5454. }
  5455. for _, item := range res.Output.Result {
  5456. temp := strings.Split(item.FeedetlSn, "-")
  5457. var advice_id int64 = 0
  5458. var project_id int64 = 0
  5459. var types int64 = 0
  5460. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5461. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5462. if temp[1] == "1" {
  5463. advice_id = id
  5464. project_id = 0
  5465. } else if temp[1] == "2" {
  5466. advice_id = 0
  5467. project_id = id
  5468. }
  5469. info := &models.HisOrderInfo{
  5470. OrderNumber: order.Number,
  5471. FeedetlSn: item.FeedetlSn,
  5472. UploadDate: time.Now().Unix(),
  5473. AdviceId: advice_id,
  5474. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5475. Cnt: item.Cnt,
  5476. Pric: float64(item.Pric),
  5477. PatientId: his.PatientId,
  5478. PricUplmtAmt: item.PricUplmtAmt,
  5479. SelfpayProp: item.SelfpayProp,
  5480. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5481. OverlmtAmt: item.OverlmtAmt,
  5482. PreselfpayAmt: item.PreselfpayAmt,
  5483. BasMednFlag: item.BasMednFlag,
  5484. MedChrgitmType: item.MedChrgitmType,
  5485. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5486. Status: 1,
  5487. Memo: item.Memo,
  5488. Mtime: time.Now().Unix(),
  5489. InscpScpAmt: item.InscpScpAmt,
  5490. DrtReimFlag: item.DrtReimFlag,
  5491. Ctime: time.Now().Unix(),
  5492. ListSpItemFlag: item.ListSpItemFlag,
  5493. ChldMedcFlag: item.ChldMedcFlag,
  5494. LmtUsedFlag: item.LmtUsedFlag,
  5495. ChrgitmLv: item.ChrgitmLv,
  5496. UserOrgId: adminUser.CurrentOrgId,
  5497. HisPatientId: his.ID,
  5498. OrderId: order.ID,
  5499. ProjectId: project_id,
  5500. Type: types,
  5501. }
  5502. service.CreateOrderInfo(info)
  5503. }
  5504. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5505. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5506. var total float64
  5507. for _, item := range prescriptions {
  5508. if item.Type == 1 { //药品
  5509. for _, subItem := range item.HisDoctorAdviceInfo {
  5510. total = total + (subItem.Price * subItem.PrescribingNumber)
  5511. }
  5512. }
  5513. if item.Type == 2 { //项目
  5514. for _, subItem := range item.HisPrescriptionProject {
  5515. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5516. total = total + (subItem.Price * cnt)
  5517. }
  5518. }
  5519. }
  5520. for _, item := range prescriptions {
  5521. for _, subItem := range item.HisAdditionalCharge {
  5522. total = total + (subItem.Price * float64(subItem.Count))
  5523. }
  5524. }
  5525. var allTotal string
  5526. if adminUser.CurrentOrgId == 9919 {
  5527. allTotal = fmt.Sprintf("%.4f", total)
  5528. } else {
  5529. allTotal = fmt.Sprintf("%.4f", total)
  5530. }
  5531. if res.Infcode == 0 {
  5532. var rf []*ResultFive
  5533. json.Unmarshal([]byte(his.Iinfo), &rf)
  5534. chrg_bchno := chrg_bchno
  5535. cert_no := his.Certno
  5536. var insutypes []string
  5537. var insutype string
  5538. var is390 int = 0
  5539. var is310 int = 0
  5540. for _, item := range rf {
  5541. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5542. insutypes = append(insutypes, item.Insutype)
  5543. }
  5544. }
  5545. if len(insutypes) == 1 {
  5546. insutype = insutypes[0]
  5547. } else {
  5548. for _, i := range insutypes {
  5549. if i == "390" {
  5550. is390 = 1
  5551. }
  5552. if i == "310" {
  5553. is310 = 1
  5554. }
  5555. }
  5556. }
  5557. if is390 == 1 {
  5558. insutype = "390"
  5559. }
  5560. if is310 == 1 {
  5561. insutype = "310"
  5562. }
  5563. if len(insutypes) == 0 {
  5564. insutype = "310"
  5565. }
  5566. if len(insutypes) == 2 {
  5567. insutype = strconv.FormatInt(his.SocialType, 10)
  5568. }
  5569. insutype = strconv.FormatInt(his.SocialType, 10)
  5570. //insutype = "390"
  5571. if his.IdCardType == 1 {
  5572. // cert_no = his.MedicalInsuranceNumber
  5573. cert_no = his.Certno
  5574. } else {
  5575. cert_no = his.Certno
  5576. }
  5577. var res ResultSeven
  5578. var resSeven10265 ResultSeven10265
  5579. var src_resquest string
  5580. var result2 string
  5581. var acct_used_flag string
  5582. fmt.Println("pay_way")
  5583. fmt.Println(pay_way)
  5584. fmt.Println("pay_way")
  5585. if pay_way == 4 {
  5586. acct_used_flag = "1"
  5587. } else {
  5588. acct_used_flag = "0"
  5589. }
  5590. if miConfig.MdtrtareaAdmvs == "421300" {
  5591. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5592. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5593. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5594. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5595. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5596. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5597. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5598. resp, requestErr := http.Get(api)
  5599. if requestErr != nil {
  5600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5601. return
  5602. }
  5603. body, ioErr := ioutil.ReadAll(resp.Body)
  5604. if ioErr != nil {
  5605. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5607. return
  5608. }
  5609. var respJSON map[string]interface{}
  5610. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5611. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5613. return
  5614. }
  5615. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5616. result, _ := json.Marshal(respJSON)
  5617. if miConfig.Code == "H15049901371" {
  5618. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5619. utils.ErrorLog("解析失败:%v", err)
  5620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5621. return
  5622. }
  5623. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5624. res.Output = resSeven10265.Output
  5625. res.ErrMsg = resSeven10265.ErrMsg
  5626. res.Cainfo = resSeven10265.Cainfo
  5627. res.WarnMsg = resSeven10265.WarnMsg
  5628. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5629. res.Infcode = infocode
  5630. } else {
  5631. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5632. utils.ErrorLog("解析失败:%v", err)
  5633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5634. return
  5635. }
  5636. }
  5637. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5638. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5639. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5640. bas := strings.Split(psn_info.CardInfo, "|")
  5641. if his.IdCardType == 1 {
  5642. cert_no = bas[2]
  5643. } else if his.IdCardType == 3 {
  5644. cert_no = his.Certno
  5645. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  5646. } else if his.IdCardType == 4 {
  5647. cert_no = his.Certno
  5648. psn_info.VerifyNumber = token
  5649. }
  5650. var api string
  5651. if miConfig.MdtrtareaAdmvs == "320921" {
  5652. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5653. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5654. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5655. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5656. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5657. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5658. "&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
  5659. } else {
  5660. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5661. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5662. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5663. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5664. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5665. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5666. "&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
  5667. }
  5668. resp, requestErr := http.Get(api)
  5669. if requestErr != nil {
  5670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5671. return
  5672. }
  5673. body, ioErr := ioutil.ReadAll(resp.Body)
  5674. if ioErr != nil {
  5675. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5677. return
  5678. }
  5679. var respJSON map[string]interface{}
  5680. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5681. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5683. return
  5684. }
  5685. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5686. result, _ := json.Marshal(respJSON)
  5687. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5688. utils.ErrorLog("解析失败:%v", err)
  5689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5690. return
  5691. }
  5692. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5693. res.Output = resSeven10265.Output
  5694. res.ErrMsg = resSeven10265.ErrMsg
  5695. res.Cainfo = resSeven10265.Cainfo
  5696. res.WarnMsg = resSeven10265.WarnMsg
  5697. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5698. res.Infcode = infocode
  5699. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5700. result2, src_resquest = service.FJyb2207(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, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  5701. //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)
  5702. var dat map[string]interface{}
  5703. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5704. fmt.Println(dat)
  5705. } else {
  5706. fmt.Println(err)
  5707. }
  5708. saveLog(result2, src_resquest, "2207", "结算")
  5709. userJSONBytes, _ := json.Marshal(dat)
  5710. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5711. utils.ErrorLog("解析失败:%v", err)
  5712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5713. return
  5714. }
  5715. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5716. res.Output = resSeven10265.Output
  5717. res.ErrMsg = resSeven10265.ErrMsg
  5718. res.Cainfo = resSeven10265.Cainfo
  5719. res.WarnMsg = resSeven10265.WarnMsg
  5720. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5721. res.Infcode = infocode
  5722. } else {
  5723. if miConfig.Code == "H15049901371" {
  5724. //赤峰地区国家医保医疗类别
  5725. //职工透析:医疗类别选特殊情况门诊990502
  5726. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5727. var med_type string
  5728. if his.Insutype == "390" {
  5729. if reg_type == 14 {
  5730. med_type = "9933"
  5731. } else if reg_type == 11 {
  5732. med_type = "11"
  5733. }
  5734. } else if his.Insutype == "310" {
  5735. if reg_type == 14 {
  5736. med_type = "990502"
  5737. } else if reg_type == 11 {
  5738. med_type = "11"
  5739. }
  5740. }
  5741. 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)
  5742. } else {
  5743. 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)
  5744. }
  5745. //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)
  5746. var dat map[string]interface{}
  5747. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5748. fmt.Println(dat)
  5749. } else {
  5750. fmt.Println(err)
  5751. }
  5752. saveLog(result2, src_resquest, "2207", "结算")
  5753. userJSONBytes, _ := json.Marshal(dat)
  5754. if miConfig.Code == "H15049901371" {
  5755. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5756. utils.ErrorLog("解析失败:%v", err)
  5757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5758. return
  5759. }
  5760. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5761. res.Output = resSeven10265.Output
  5762. res.ErrMsg = resSeven10265.ErrMsg
  5763. res.Cainfo = resSeven10265.Cainfo
  5764. res.WarnMsg = resSeven10265.WarnMsg
  5765. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5766. res.Infcode = infocode
  5767. } else {
  5768. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5769. utils.ErrorLog("解析失败:%v", err)
  5770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5771. return
  5772. }
  5773. }
  5774. }
  5775. if res.Infcode != 0 {
  5776. errlog := &models.HisOrderError{
  5777. UserOrgId: adminUser.CurrentOrgId,
  5778. Ctime: time.Now().Unix(),
  5779. Mtime: time.Now().Unix(),
  5780. Number: chrg_bchno,
  5781. ErrMsg: res.ErrMsg,
  5782. Status: 1,
  5783. PatientId: id,
  5784. RecordTime: recordDateTime,
  5785. Stage: 6,
  5786. }
  5787. service.CreateErrMsgLog(errlog)
  5788. c.ServeSuccessJSON(map[string]interface{}{
  5789. "failed_code": -10,
  5790. "msg": res.ErrMsg,
  5791. })
  5792. return
  5793. } else {
  5794. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5795. order.OrderStatus = 2
  5796. order.Status = 1
  5797. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5798. order.SetlId = res.Output.Setlinfo.SetlID
  5799. order.PsnNo = res.Output.Setlinfo.PsnNo
  5800. order.PsnName = res.Output.Setlinfo.PsnName
  5801. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5802. order.Certno = res.Output.Setlinfo.Certno
  5803. order.Gend = res.Output.Setlinfo.Gend
  5804. order.Naty = res.Output.Setlinfo.Naty
  5805. order.Age = res.Output.Setlinfo.Age
  5806. order.Insutype = res.Output.Setlinfo.Insutype
  5807. order.PsnType = res.Output.Setlinfo.PsnType
  5808. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5809. order.SetlTime = res.Output.Setlinfo.SetlTime
  5810. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5811. if res.Output.Setlinfo.MedType == "140101" {
  5812. order.MedType = "14"
  5813. } else {
  5814. order.MedType = res.Output.Setlinfo.MedType
  5815. }
  5816. if reg_type == 1112 {
  5817. order.MedType = "1112"
  5818. }
  5819. if reg_type == 1111 {
  5820. order.MedType = "1111"
  5821. }
  5822. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5823. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5824. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5825. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5826. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5827. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5828. order.HifpPay = res.Output.Setlinfo.HifpPay
  5829. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5830. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5831. order.HifesPay = res.Output.Setlinfo.HifesPay
  5832. order.HifobPay = res.Output.Setlinfo.HifobPay
  5833. order.MafPay = res.Output.Setlinfo.MafPay
  5834. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5835. order.OthPay = res.Output.Setlinfo.OthPay
  5836. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5837. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5838. order.AcctPay = res.Output.Setlinfo.AcctPay
  5839. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5840. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5841. order.Balc = res.Output.Setlinfo.Balc
  5842. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5843. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5844. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5845. order.ClrType = res.Output.Setlinfo.ClrType
  5846. order.ClrWay = res.Output.Setlinfo.ClrWay
  5847. order.Creator = order.Creator
  5848. order.Modify = roles.AdminUserId
  5849. order.RequestLog = src_resquest
  5850. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5851. detailStr := string(setlDetail)
  5852. order.SetlDetail = detailStr
  5853. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5854. err = service.UpDateOrder(order)
  5855. if err == nil {
  5856. //判断是否使用了押金
  5857. if dec_way == "true" {
  5858. tmpstring := strconv.FormatInt(order.ID, 10)
  5859. order.Decimal = decimal
  5860. service.UpDateOrder(order)
  5861. //扣押金
  5862. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  5863. if errmsg != nil {
  5864. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  5865. return
  5866. }
  5867. }
  5868. c.ServeSuccessJSON(map[string]interface{}{
  5869. "msg": "结算成功",
  5870. })
  5871. } else {
  5872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5873. return
  5874. }
  5875. }
  5876. } else {
  5877. adminUser := c.GetAdminUserInfo()
  5878. errlog := &models.HisOrderError{
  5879. UserOrgId: adminUser.CurrentOrgId,
  5880. Ctime: time.Now().Unix(),
  5881. Mtime: time.Now().Unix(),
  5882. ErrMsg: res.ErrMsg,
  5883. Status: 1,
  5884. PatientId: id,
  5885. RecordTime: recordDateTime,
  5886. Stage: 4,
  5887. }
  5888. service.CreateErrMsgLog(errlog)
  5889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5890. return
  5891. }
  5892. } else {
  5893. adminUser := c.GetAdminUserInfo()
  5894. errlog := &models.HisOrderError{
  5895. UserOrgId: adminUser.CurrentOrgId,
  5896. Ctime: time.Now().Unix(),
  5897. Mtime: time.Now().Unix(),
  5898. ErrMsg: res.ErrMsg,
  5899. Status: 1,
  5900. PatientId: id,
  5901. RecordTime: recordDateTime,
  5902. Stage: 4,
  5903. }
  5904. service.CreateErrMsgLog(errlog)
  5905. c.ServeSuccessJSON(map[string]interface{}{
  5906. "failed_code": -10,
  5907. "msg": res.ErrMsg,
  5908. })
  5909. return
  5910. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5911. //return
  5912. }
  5913. }
  5914. }
  5915. } else if tempOrder.ID > 0 {
  5916. if tempOrder.IsPre == 1 {
  5917. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  5918. var rf []*ResultFive
  5919. json.Unmarshal([]byte(his.Iinfo), &rf)
  5920. chrg_bchno := tempOrder.Number
  5921. cert_no := his.Certno
  5922. var insutypes []string
  5923. var insutype string
  5924. var is390 int = 0
  5925. var is310 int = 0
  5926. for _, item := range rf {
  5927. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5928. insutypes = append(insutypes, item.Insutype)
  5929. }
  5930. }
  5931. if len(insutypes) == 1 {
  5932. insutype = insutypes[0]
  5933. } else {
  5934. for _, i := range insutypes {
  5935. if i == "390" {
  5936. is390 = 1
  5937. }
  5938. if i == "310" {
  5939. is310 = 1
  5940. }
  5941. }
  5942. }
  5943. if is390 == 1 {
  5944. insutype = "390"
  5945. }
  5946. if is310 == 1 {
  5947. insutype = "310"
  5948. }
  5949. if len(insutypes) == 0 {
  5950. insutype = "310"
  5951. }
  5952. if len(insutypes) == 2 {
  5953. insutype = strconv.FormatInt(his.SocialType, 64)
  5954. }
  5955. //insutype = "390"
  5956. if his.IdCardType == 1 {
  5957. // cert_no = his.MedicalInsuranceNumber
  5958. cert_no = his.Certno
  5959. } else {
  5960. cert_no = his.Certno
  5961. }
  5962. var res ResultSeven
  5963. var resSeven10265 ResultSeven10265
  5964. var src_resquest string
  5965. var result2 string
  5966. var acct_used_flag string
  5967. fmt.Println("pay_way")
  5968. fmt.Println(pay_way)
  5969. fmt.Println("pay_way")
  5970. if pay_way == 4 {
  5971. acct_used_flag = "1"
  5972. } else {
  5973. acct_used_flag = "0"
  5974. }
  5975. if miConfig.MdtrtareaAdmvs == "421300" {
  5976. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5977. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5978. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5979. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5980. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5981. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5982. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5983. resp, requestErr := http.Get(api)
  5984. if requestErr != nil {
  5985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5986. return
  5987. }
  5988. body, ioErr := ioutil.ReadAll(resp.Body)
  5989. if ioErr != nil {
  5990. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5992. return
  5993. }
  5994. var respJSON map[string]interface{}
  5995. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5996. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5998. return
  5999. }
  6000. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6001. result, _ := json.Marshal(respJSON)
  6002. fmt.Println("log")
  6003. fmt.Println(string(result))
  6004. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6005. utils.ErrorLog("解析失败:%v", err)
  6006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6007. return
  6008. }
  6009. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6010. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6011. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6012. //psn_info, _ := service.GetPsnByPatientId(id)
  6013. bas := strings.Split(psn_info.CardInfo, "|")
  6014. if his.IdCardType == 1 {
  6015. cert_no = bas[2]
  6016. } else {
  6017. cert_no = bas[1]
  6018. }
  6019. //江苏地区国家医保医疗类别
  6020. //职工透析:医疗类别选特殊情况门诊9933
  6021. //居民血透门慢: 医疗类别选门诊慢病1402
  6022. //var med_type string
  6023. //if his.Insutype == "310" {
  6024. // if reg_type == 14 {
  6025. // med_type = "9933"
  6026. // } else if reg_type == 11 {
  6027. // med_type = "11"
  6028. //
  6029. // }
  6030. //} else if his.Insutype == "390" {
  6031. // if reg_type == 14 {
  6032. // med_type = "1402"
  6033. // } else if reg_type == 11 {
  6034. // med_type = "11"
  6035. // }
  6036. //}
  6037. var api string
  6038. if miConfig.MdtrtareaAdmvs == "320921" {
  6039. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6040. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6041. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6042. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6043. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6044. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6045. "&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
  6046. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6047. } else {
  6048. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6049. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6050. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6051. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6052. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6053. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6054. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6055. "&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
  6056. }
  6057. resp, requestErr := http.Get(api)
  6058. if requestErr != nil {
  6059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6060. return
  6061. }
  6062. body, ioErr := ioutil.ReadAll(resp.Body)
  6063. if ioErr != nil {
  6064. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6066. return
  6067. }
  6068. var respJSON map[string]interface{}
  6069. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6070. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6072. return
  6073. }
  6074. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6075. result, _ := json.Marshal(respJSON)
  6076. fmt.Println("log")
  6077. fmt.Println(string(result))
  6078. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6079. utils.ErrorLog("解析失败:%v", err)
  6080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6081. return
  6082. }
  6083. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6084. res.Output = resSeven10265.Output
  6085. res.ErrMsg = resSeven10265.ErrMsg
  6086. res.Cainfo = resSeven10265.Cainfo
  6087. res.WarnMsg = resSeven10265.WarnMsg
  6088. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6089. res.Infcode = infocode
  6090. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6091. result2, src_resquest = service.FJyb2207(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, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  6092. var dat map[string]interface{}
  6093. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6094. fmt.Println(dat)
  6095. } else {
  6096. fmt.Println(err)
  6097. }
  6098. saveLog(result2, src_resquest, "2207", "结算")
  6099. userJSONBytes, _ := json.Marshal(dat)
  6100. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6101. utils.ErrorLog("解析失败:%v", err)
  6102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6103. return
  6104. }
  6105. } else {
  6106. var src_resquest string
  6107. if miConfig.Code == "H15049901371" {
  6108. //赤峰地区国家医保医疗类别
  6109. //职工透析:医疗类别选特殊情况门诊990502
  6110. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6111. var med_type string
  6112. if his.Insutype == "390" {
  6113. if reg_type == 14 {
  6114. med_type = "9933"
  6115. } else if reg_type == 11 {
  6116. med_type = "11"
  6117. }
  6118. } else if his.Insutype == "310" {
  6119. if reg_type == 14 {
  6120. med_type = "990502"
  6121. } else if reg_type == 11 {
  6122. med_type = "11"
  6123. }
  6124. }
  6125. 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)
  6126. } else {
  6127. 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)
  6128. }
  6129. var dat map[string]interface{}
  6130. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6131. fmt.Println(dat)
  6132. } else {
  6133. fmt.Println(err)
  6134. }
  6135. saveLog(result2, src_resquest, "2207", "结算")
  6136. userJSONBytes, _ := json.Marshal(dat)
  6137. if miConfig.Code == "H15049901371" {
  6138. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6139. utils.ErrorLog("解析失败:%v", err)
  6140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6141. return
  6142. }
  6143. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6144. res.Output = resSeven10265.Output
  6145. res.ErrMsg = resSeven10265.ErrMsg
  6146. res.Cainfo = resSeven10265.Cainfo
  6147. res.WarnMsg = resSeven10265.WarnMsg
  6148. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6149. res.Infcode = infocode
  6150. } else {
  6151. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6152. utils.ErrorLog("解析失败:%v", err)
  6153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6154. return
  6155. }
  6156. }
  6157. }
  6158. if res.Infcode != 0 {
  6159. errlog := &models.HisOrderError{
  6160. UserOrgId: adminUser.CurrentOrgId,
  6161. Ctime: time.Now().Unix(),
  6162. Mtime: time.Now().Unix(),
  6163. Number: chrg_bchno,
  6164. ErrMsg: res.ErrMsg,
  6165. Status: 1,
  6166. PatientId: id,
  6167. RecordTime: recordDateTime,
  6168. Stage: 6,
  6169. }
  6170. service.CreateErrMsgLog(errlog)
  6171. c.ServeSuccessJSON(map[string]interface{}{
  6172. "failed_code": -10,
  6173. "msg": res.ErrMsg,
  6174. })
  6175. return
  6176. } else {
  6177. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6178. order.OrderStatus = 2
  6179. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6180. order.SetlId = res.Output.Setlinfo.SetlID
  6181. order.PsnNo = res.Output.Setlinfo.PsnNo
  6182. order.PsnName = res.Output.Setlinfo.PsnName
  6183. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6184. order.Certno = res.Output.Setlinfo.Certno
  6185. order.Gend = res.Output.Setlinfo.Gend
  6186. order.Naty = res.Output.Setlinfo.Naty
  6187. order.Age = res.Output.Setlinfo.Age
  6188. order.Insutype = res.Output.Setlinfo.Insutype
  6189. order.PsnType = res.Output.Setlinfo.PsnType
  6190. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6191. order.SetlTime = res.Output.Setlinfo.SetlTime
  6192. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6193. //order.MedType = res.Output.Setlinfo.MedType
  6194. if reg_type == 1112 {
  6195. order.MedType = "1112"
  6196. }
  6197. if reg_type == 1111 {
  6198. order.MedType = "1111"
  6199. }
  6200. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6201. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6202. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6203. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6204. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6205. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6206. order.HifpPay = res.Output.Setlinfo.HifpPay
  6207. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6208. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6209. order.HifesPay = res.Output.Setlinfo.HifesPay
  6210. order.HifobPay = res.Output.Setlinfo.HifobPay
  6211. order.MafPay = res.Output.Setlinfo.MafPay
  6212. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6213. order.OthPay = res.Output.Setlinfo.OthPay
  6214. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6215. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6216. order.AcctPay = res.Output.Setlinfo.AcctPay
  6217. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6218. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6219. order.Balc = res.Output.Setlinfo.Balc
  6220. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6221. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6222. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6223. order.ClrWay = res.Output.Setlinfo.ClrWay
  6224. order.Creator = order.Creator
  6225. order.Modify = roles.AdminUserId
  6226. order.RequestLog = src_resquest
  6227. order.Diagnosis = diagnosis_id
  6228. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6229. detailStr := string(setlDetail)
  6230. order.SetlDetail = detailStr
  6231. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6232. err = service.UpDateOrder(order)
  6233. if err == nil {
  6234. //判断是否使用了押金
  6235. if dec_way == "true" {
  6236. tmpstring := strconv.FormatInt(order.ID, 10)
  6237. //扣押金
  6238. order.Decimal = decimal
  6239. service.UpDateOrder(order)
  6240. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6241. if errmsg != nil {
  6242. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6243. return
  6244. }
  6245. }
  6246. c.ServeSuccessJSON(map[string]interface{}{
  6247. "msg": "结算成功",
  6248. })
  6249. } else {
  6250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6251. return
  6252. }
  6253. }
  6254. }
  6255. }
  6256. }
  6257. //func (c *HisApiController) GetPreUploadInfo() {
  6258. // id, _ := c.GetInt64("id")
  6259. // record_time := c.GetString("record_time")
  6260. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6261. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6262. //
  6263. // timeLayout := "2006-01-02"
  6264. // loc, _ := time.LoadLocation("Local")
  6265. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6266. // if err != nil {
  6267. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6268. // return
  6269. // }
  6270. // recordDateTime := theTime.Unix()
  6271. // adminUser := c.GetAdminUserInfo()
  6272. //
  6273. // var prescriptions []*models.HisPrescription
  6274. //
  6275. // var start_time int64
  6276. // var end_time int64
  6277. //
  6278. // data := make(map[string]interface{})
  6279. // if settle_accounts_type == 1 { //日结
  6280. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6281. // data["pre"] = prescriptions
  6282. //
  6283. // } else { //月结
  6284. // start_time_str := c.GetString("start_time")
  6285. // end_time_str := c.GetString("end_time")
  6286. // timeLayout := "2006-01-02"
  6287. // loc, _ := time.LoadLocation("Local")
  6288. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6289. // if err != nil {
  6290. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6291. // return
  6292. // }
  6293. // recordStartTime := theStartTime.Unix()
  6294. // start_time = recordStartTime
  6295. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6296. // if err != nil {
  6297. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6298. // return
  6299. // }
  6300. // recordEndTime := theEndTime.Unix()
  6301. // end_time = recordEndTime
  6302. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6303. // data["pre"] = prescriptions
  6304. //
  6305. // }
  6306. //
  6307. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6308. //
  6309. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6310. // timestamp := time.Now().Unix()
  6311. // tempTime := time.Unix(timestamp, 0)
  6312. // timeFormat := tempTime.Format("20060102150405")
  6313. // chrgBchno := rand.Intn(100000) + 10000
  6314. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6315. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6316. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6317. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6318. // strconv.FormatInt(his.PatientId, 10)
  6319. // client := &http.Client{}
  6320. // data["psn_no"] = his.PsnNo
  6321. // data["mdtrt_id"] = his.Number
  6322. // data["chrg_bchno"] = chrg_bchno
  6323. // data["org_name"] = miConfig.OrgName
  6324. // data["doctor"] = roles.UserName
  6325. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6326. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6327. // data["fixmedins_code"] = miConfig.Code
  6328. // data["dept_code"] = department.Number
  6329. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6330. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6331. // data["secret_key"] = miConfig.SecretKey
  6332. // var ids []int64
  6333. //
  6334. // for _, item := range prescriptions {
  6335. // ids = append(ids, item.ID)
  6336. // }
  6337. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6338. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6339. // bytesData, _ := json.Marshal(data)
  6340. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  6341. // resp, _ := client.Do(req)
  6342. // defer resp.Body.Close()
  6343. // body, ioErr := ioutil.ReadAll(resp.Body)
  6344. // if ioErr != nil {
  6345. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6346. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6347. // return
  6348. // }
  6349. // var respJSON map[string]interface{}
  6350. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6351. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6352. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6353. // return
  6354. // }
  6355. //
  6356. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6357. // userJSONBytes, _ := json.Marshal(respJSON)
  6358. // var res ResultFour
  6359. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6360. // utils.ErrorLog("解析失败:%v", err)
  6361. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6362. // return
  6363. // }
  6364. //
  6365. // if res.Infcode == 0 {
  6366. // order := &models.HisOrder{
  6367. // UserOrgId: adminUser.CurrentOrgId,
  6368. // HisPatientId: his.ID,
  6369. // PatientId: his.PatientId,
  6370. // SettleAccountsDate: recordDateTime,
  6371. // Ctime: time.Now().Unix(),
  6372. // Mtime: time.Now().Unix(),
  6373. // Status: 1,
  6374. // Number: chrg_bchno,
  6375. // Infcode: res.Infcode,
  6376. // WarnMsg: res.WarnMsg,
  6377. // Cainfo: res.Cainfo,
  6378. // ErrMsg: res.ErrMsg,
  6379. // RespondTime: res.RefmsgTime,
  6380. // InfRefmsgid: res.InfRefmsgid,
  6381. // OrderStatus: 1,
  6382. // IsMedicineInsurance: 1,
  6383. // SettleType: settle_accounts_type,
  6384. // SettleStartTime: start_time,
  6385. // SettleEndTime: end_time,
  6386. // Creator: roles.ID,
  6387. // Modify: roles.ID,
  6388. // PType: 2,
  6389. // }
  6390. // err = service.CreateOrder(order)
  6391. // if err != nil {
  6392. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6393. // return
  6394. // }
  6395. //
  6396. // for _, item := range res.Output.Result {
  6397. // temp := strings.Split(item.FeedetlSn, "-")
  6398. // var advice_id int64 = 0
  6399. // var project_id int64 = 0
  6400. // var types int64 = 0
  6401. //
  6402. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  6403. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  6404. //
  6405. // if temp[1] == "1" {
  6406. // advice_id = id
  6407. // project_id = 0
  6408. // } else if temp[1] == "2" {
  6409. // advice_id = 0
  6410. // project_id = id
  6411. // }
  6412. //
  6413. // info := &models.HisOrderInfo{
  6414. // OrderNumber: order.Number,
  6415. // FeedetlSn: item.FeedetlSn,
  6416. // UploadDate: time.Now().Unix(),
  6417. // AdviceId: advice_id,
  6418. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  6419. // Cnt: item.Cnt,
  6420. // Pric: float64(item.Pric),
  6421. // PatientId: his.PatientId,
  6422. // PricUplmtAmt: item.PricUplmtAmt,
  6423. // SelfpayProp: item.SelfpayProp,
  6424. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6425. // OverlmtAmt: item.OverlmtAmt,
  6426. // PreselfpayAmt: item.PreselfpayAmt,
  6427. // BasMednFlag: item.BasMednFlag,
  6428. // MedChrgitmType: item.MedChrgitmType,
  6429. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  6430. // Status: 1,
  6431. // Memo: item.Memo,
  6432. // Mtime: time.Now().Unix(),
  6433. // InscpScpAmt: item.InscpScpAmt,
  6434. // DrtReimFlag: item.DrtReimFlag,
  6435. // Ctime: time.Now().Unix(),
  6436. // ListSpItemFlag: item.ListSpItemFlag,
  6437. // ChldMedcFlag: item.ChldMedcFlag,
  6438. // LmtUsedFlag: item.LmtUsedFlag,
  6439. // ChrgitmLv: item.ChrgitmLv,
  6440. // UserOrgId: adminUser.CurrentOrgId,
  6441. // HisPatientId: his.ID,
  6442. // OrderId: order.ID,
  6443. // ProjectId: project_id,
  6444. // Type: types,
  6445. // }
  6446. // service.CreateOrderInfo(info)
  6447. //
  6448. // }
  6449. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6450. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  6451. //
  6452. // var total float64
  6453. // for _, item := range prescriptions {
  6454. // if item.Type == 1 { //药品
  6455. // for _, subItem := range item.HisDoctorAdviceInfo {
  6456. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6457. // }
  6458. // }
  6459. // if item.Type == 2 { //项目
  6460. // for _, subItem := range item.HisPrescriptionProject {
  6461. // total = total + (subItem.Price * float64(subItem.Count))
  6462. // }
  6463. // }
  6464. // }
  6465. //
  6466. // for _, item := range prescriptions {
  6467. // for _, subItem := range item.HisAdditionalCharge {
  6468. // total = total + (subItem.Price * float64(subItem.Count))
  6469. // }
  6470. // }
  6471. //
  6472. // allTotal := fmt.Sprintf("%.2f", total)
  6473. // if res.Infcode == 0 {
  6474. // var rf []*ResultFive
  6475. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6476. // psn_no := his.PsnNo
  6477. // mdtrt_id := his.Number
  6478. // chrg_bchno := chrg_bchno
  6479. // cert_no := his.Certno
  6480. // insutype := rf[0].Insutype
  6481. //
  6482. // if his.IdCardType == 1 {
  6483. // cert_no = his.MedicalInsuranceNumber
  6484. //
  6485. // } else {
  6486. //
  6487. // cert_no = his.Certno
  6488. //
  6489. // }
  6490. //
  6491. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  6492. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  6493. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  6494. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  6495. // resp, requestErr := http.Get(api)
  6496. // if requestErr != nil {
  6497. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6498. // return
  6499. // }
  6500. // defer resp.Body.Close()
  6501. // body, ioErr := ioutil.ReadAll(resp.Body)
  6502. // if ioErr != nil {
  6503. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6504. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6505. // return
  6506. // }
  6507. // var respJSON map[string]interface{}
  6508. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6509. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6510. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6511. // return
  6512. // }
  6513. // fmt.Println(respJSON)
  6514. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6515. // userJSONBytes, _ := json.Marshal(respJSON)
  6516. // var res ResultSeven
  6517. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6518. // utils.ErrorLog("解析失败:%v", err)
  6519. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6520. // return
  6521. // }
  6522. // if res.Infcode != 0 {
  6523. // errlog := &models.HisOrderError{
  6524. // UserOrgId: adminUser.CurrentOrgId,
  6525. // Ctime: time.Now().Unix(),
  6526. // Mtime: time.Now().Unix(),
  6527. // Number: chrg_bchno,
  6528. // ErrMsg: res.ErrMsg,
  6529. // Status: 1,
  6530. // PatientId: id,
  6531. // RecordTime: recordDateTime,
  6532. // Stage: 7,
  6533. // }
  6534. // service.CreateErrMsgLog(errlog)
  6535. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6536. // return
  6537. // } else {
  6538. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6539. // order.OrderStatus = 1
  6540. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6541. // order.SetlId = res.Output.Setlinfo.SetlID
  6542. // order.PsnNo = res.Output.Setlinfo.PsnNo
  6543. // order.PsnName = res.Output.Setlinfo.PsnName
  6544. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6545. // order.Certno = res.Output.Setlinfo.Certno
  6546. // order.Gend = res.Output.Setlinfo.Gend
  6547. // order.Naty = res.Output.Setlinfo.Naty
  6548. // order.Age = res.Output.Setlinfo.Age
  6549. // order.Insutype = res.Output.Setlinfo.Insutype
  6550. // order.PsnType = res.Output.Setlinfo.PsnType
  6551. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6552. // order.SetlTime = res.Output.Setlinfo.SetlTime
  6553. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6554. // order.MedType = res.Output.Setlinfo.MedType
  6555. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6556. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6557. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6558. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6559. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6560. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6561. // order.HifpPay = res.Output.Setlinfo.HifpPay
  6562. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6563. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6564. // order.HifesPay = res.Output.Setlinfo.HifesPay
  6565. // order.HifobPay = res.Output.Setlinfo.HifobPay
  6566. // order.MafPay = res.Output.Setlinfo.MafPay
  6567. // order.OthPay = res.Output.Setlinfo.OthPay
  6568. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6569. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6570. // order.AcctPay = res.Output.Setlinfo.AcctPay
  6571. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6572. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6573. // order.Balc = res.Output.Setlinfo.Balc
  6574. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6575. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6576. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6577. // order.ClrWay = res.Output.Setlinfo.ClrWay
  6578. // order.Creator = order.Creator
  6579. // order.Modify = roles.ID
  6580. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6581. // detailStr := string(setlDetail)
  6582. // order.SetlDetail = detailStr
  6583. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6584. // err = service.UpDateOrder(order)
  6585. // if err == nil {
  6586. // c.ServeSuccessJSON(map[string]interface{}{
  6587. // "msg": "预结算成功",
  6588. // })
  6589. // } else {
  6590. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6591. // return
  6592. // }
  6593. // }
  6594. // } else {
  6595. // adminUser := c.GetAdminUserInfo()
  6596. // errlog := &models.HisOrderError{
  6597. // UserOrgId: adminUser.CurrentOrgId,
  6598. // Ctime: time.Now().Unix(),
  6599. // Mtime: time.Now().Unix(),
  6600. // ErrMsg: res.ErrMsg,
  6601. // Status: 1,
  6602. // PatientId: id,
  6603. // RecordTime: recordDateTime,
  6604. // Stage: 4,
  6605. // }
  6606. // service.CreateErrMsgLog(errlog)
  6607. //
  6608. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6609. // return
  6610. // }
  6611. // } else {
  6612. // adminUser := c.GetAdminUserInfo()
  6613. // errlog := &models.HisOrderError{
  6614. // UserOrgId: adminUser.CurrentOrgId,
  6615. // Ctime: time.Now().Unix(),
  6616. // Mtime: time.Now().Unix(),
  6617. // ErrMsg: res.ErrMsg,
  6618. // Status: 1,
  6619. // PatientId: id,
  6620. // RecordTime: recordDateTime,
  6621. // Stage: 4,
  6622. // }
  6623. // service.CreateErrMsgLog(errlog)
  6624. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6625. // return
  6626. // }
  6627. //
  6628. // } else {
  6629. // var total float64
  6630. // for _, item := range prescriptions {
  6631. // if item.Type == 1 { //药品
  6632. // for _, subItem := range item.HisDoctorAdviceInfo {
  6633. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6634. // }
  6635. // }
  6636. // if item.Type == 2 { //项目
  6637. // for _, subItem := range item.HisPrescriptionProject {
  6638. // total = total + (subItem.Price * float64(subItem.Count))
  6639. // }
  6640. // }
  6641. //
  6642. // for _, subItem := range item.HisAdditionalCharge {
  6643. // total = total + (subItem.Price * float64(subItem.Count))
  6644. // }
  6645. // }
  6646. //
  6647. // allTotal := fmt.Sprintf("%.2f", total)
  6648. // totals, _ := strconv.ParseFloat(allTotal, 64)
  6649. // order := &models.HisOrder{
  6650. // UserOrgId: adminUser.CurrentOrgId,
  6651. // HisPatientId: his.ID,
  6652. // PatientId: id,
  6653. // SettleAccountsDate: recordDateTime,
  6654. // Ctime: time.Now().Unix(),
  6655. // Mtime: time.Now().Unix(),
  6656. // Status: 1,
  6657. // OrderStatus: 2,
  6658. // Number: chrg_bchno,
  6659. // MedfeeSumamt: totals,
  6660. // }
  6661. // err = service.CreateOrder(order)
  6662. // if err != nil {
  6663. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6664. // return
  6665. // }
  6666. //
  6667. // var customs []*Custom
  6668. // for _, item := range prescriptions {
  6669. //
  6670. // if item.Type == 1 { //药品
  6671. // for _, subItem := range item.HisDoctorAdviceInfo {
  6672. // cus := &Custom{
  6673. // AdviceId: subItem.ID,
  6674. // ProjectId: 0,
  6675. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  6676. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  6677. // FeedetlSn: subItem.FeedetlSn,
  6678. // Price: fmt.Sprintf("%.2f", subItem.Price),
  6679. // MedListCodg: subItem.MedListCodg,
  6680. // Type: 1,
  6681. // }
  6682. // customs = append(customs, cus)
  6683. // }
  6684. // }
  6685. //
  6686. // if item.Type == 2 { //项目
  6687. // for _, subItem := range item.HisPrescriptionProject {
  6688. //
  6689. // cus := &Custom{
  6690. // AdviceId: 0,
  6691. // ProjectId: subItem.ID,
  6692. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  6693. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  6694. // FeedetlSn: subItem.FeedetlSn,
  6695. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  6696. // MedListCodg: subItem.MedListCodg,
  6697. // Type: 2,
  6698. // }
  6699. //
  6700. // customs = append(customs, cus)
  6701. // }
  6702. // }
  6703. //
  6704. // for _, item := range item.HisAdditionalCharge {
  6705. // cus := &Custom{
  6706. // ItemId: item.ID,
  6707. // AdviceId: 0,
  6708. // ProjectId: 0,
  6709. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  6710. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  6711. // FeedetlSn: item.FeedetlSn,
  6712. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  6713. // MedListCodg: item.XtHisAddtionConfig.Code,
  6714. // Type: 3,
  6715. // }
  6716. //
  6717. // customs = append(customs, cus)
  6718. // }
  6719. //
  6720. // }
  6721. //
  6722. // for _, item := range customs {
  6723. // var advice_id int64 = 0
  6724. // var project_id int64 = 0
  6725. // var item_id int64 = 0
  6726. //
  6727. // var types int64 = 0
  6728. //
  6729. // if item.Type == 1 {
  6730. // advice_id = item.AdviceId
  6731. // project_id = 0
  6732. // item_id = 0
  6733. // } else if item.Type == 2 {
  6734. // advice_id = 0
  6735. // item_id = 0
  6736. //
  6737. // project_id = item.ProjectId
  6738. // } else if item.Type == 3 {
  6739. // advice_id = 0
  6740. // item_id = item.ItemId
  6741. // project_id = 0
  6742. // }
  6743. //
  6744. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  6745. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  6746. // pric, _ := strconv.ParseFloat(item.Price, 32)
  6747. //
  6748. // info := &models.HisOrderInfo{
  6749. // OrderNumber: order.Number,
  6750. // UploadDate: time.Now().Unix(),
  6751. // AdviceId: advice_id,
  6752. // DetItemFeeSumamt: detItemFeeSumamt,
  6753. // Cnt: cut,
  6754. // Pric: pric,
  6755. // PatientId: id,
  6756. // Status: 1,
  6757. // Mtime: time.Now().Unix(),
  6758. // Ctime: time.Now().Unix(),
  6759. // UserOrgId: adminUser.CurrentOrgId,
  6760. // HisPatientId: his.ID,
  6761. // OrderId: order.ID,
  6762. // ProjectId: project_id,
  6763. // Type: types,
  6764. // ItemId: item_id,
  6765. // }
  6766. // service.CreateOrderInfo(info)
  6767. // }
  6768. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6769. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6770. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  6771. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6772. // if err == nil {
  6773. // c.ServeSuccessJSON(map[string]interface{}{
  6774. // "msg": "结算成功",
  6775. // })
  6776. // } else {
  6777. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6778. // return
  6779. // }
  6780. // }
  6781. //}
  6782. //上传明细-预结算-
  6783. func (c *HisApiController) GetPreUploadInfo() {
  6784. id, _ := c.GetInt64("id")
  6785. record_time := c.GetString("record_time")
  6786. his_patient_id, _ := c.GetInt64("his_patient_id")
  6787. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6788. admin_user_id, _ := c.GetInt64("admin_user_id")
  6789. diagnosis_id := c.GetString("diagnosis")
  6790. sick_type, _ := c.GetInt64("sick_type")
  6791. reg_type, _ := c.GetInt64("p_type")
  6792. begin_time := c.GetString("begin_time")
  6793. id_str := c.GetString("ids")
  6794. ids_arr := strings.Split(id_str, ",")
  6795. timeLayout := "2006-01-02"
  6796. loc, _ := time.LoadLocation("Local")
  6797. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6798. if err != nil {
  6799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6800. return
  6801. }
  6802. recordDateTime := theTime.Unix()
  6803. adminUser := c.GetAdminUserInfo()
  6804. diagnosis_ids := strings.Split(diagnosis_id, ",")
  6805. var config []*models.HisXtDiagnoseConfig
  6806. for _, item := range diagnosis_ids {
  6807. id, _ := strconv.ParseInt(item, 10, 64)
  6808. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6809. config = append(config, &diagnosisConfig)
  6810. }
  6811. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  6812. sickConfig, _ := service.FindSickById(sick_type)
  6813. var prescriptions []*models.HisPrescription
  6814. var start_time int64
  6815. var end_time int64
  6816. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6817. fmt.Println(his_patient_id)
  6818. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6819. timestamp := time.Now().Unix()
  6820. tempTime := time.Unix(timestamp, 0)
  6821. timeFormat := tempTime.Format("20060102150405")
  6822. chrgBchno := rand.Intn(100000) + 10000
  6823. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6824. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6825. var patientPrescription models.HisPrescriptionInfo
  6826. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6827. if patientPrescription.ID == 0 {
  6828. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6829. }
  6830. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6831. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6832. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6833. strconv.FormatInt(his.PatientId, 10)
  6834. var res2 ResultSix
  6835. var resSix10265 ResultSix10265
  6836. var time_stamp string
  6837. if miConfig.MdtrtareaAdmvs == "421300" {
  6838. data := make(map[string]interface{})
  6839. client := &http.Client{}
  6840. data["psn_no"] = his.PsnNo
  6841. data["mdtrt_id"] = his.Number
  6842. data["department"] = department.Name
  6843. data["org_name"] = miConfig.OrgName
  6844. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6845. data["doctor_id"] = doctor_info.DoctorNumber
  6846. data["doctor_name"] = roles.UserName
  6847. data["fixmedins_code"] = miConfig.Code
  6848. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6849. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6850. data["secret_key"] = miConfig.SecretKey
  6851. data["sick_code"] = sickConfig.CountryCode
  6852. data["sick_name"] = sickConfig.ClassName
  6853. data["begin_time"] = begin_time
  6854. data["dept"] = strconv.FormatInt(department.ID, 10)
  6855. data["config"] = config
  6856. data["opter"] = roles.UserName
  6857. fmt.Println(data)
  6858. bytesData, _ := json.Marshal(data)
  6859. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  6860. resp, _ := client.Do(req)
  6861. defer resp.Body.Close()
  6862. body, ioErr := ioutil.ReadAll(resp.Body)
  6863. if ioErr != nil {
  6864. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6866. return
  6867. }
  6868. var respJSON map[string]interface{}
  6869. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6870. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6872. return
  6873. }
  6874. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6875. userJSONBytes, _ := json.Marshal(respJSON)
  6876. fmt.Println("log")
  6877. fmt.Println(string(userJSONBytes))
  6878. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6879. utils.ErrorLog("解析失败:%v", err)
  6880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6881. return
  6882. }
  6883. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6884. data := make(map[string]interface{})
  6885. client := &http.Client{}
  6886. data["psn_no"] = his.PsnNo
  6887. data["mdtrt_id"] = his.Number
  6888. data["doctor"] = roles.UserName
  6889. data["department"] = department.Name
  6890. data["org_name"] = miConfig.OrgName
  6891. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6892. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6893. data["fixmedins_code"] = miConfig.Code
  6894. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6895. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6896. data["secret_key"] = miConfig.SecretKey
  6897. data["sick_code"] = sickConfig.CountryCode
  6898. data["sick_name"] = sickConfig.ClassName
  6899. data["begin_time"] = begin_time
  6900. data["dept"] = strconv.FormatInt(department.ID, 10)
  6901. data["config"] = config
  6902. data["url"] = miConfig.Url
  6903. data["ak"] = miConfig.AccessKey
  6904. data["cainfo"] = miConfig.Cainfo
  6905. bytesData, _ := json.Marshal(data)
  6906. var req *http.Request
  6907. if miConfig.MdtrtareaAdmvs == "320921" {
  6908. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6909. //api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  6910. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  6911. } else {
  6912. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6913. }
  6914. resp, _ := client.Do(req)
  6915. defer resp.Body.Close()
  6916. body, ioErr := ioutil.ReadAll(resp.Body)
  6917. if ioErr != nil {
  6918. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6920. return
  6921. }
  6922. var respJSON map[string]interface{}
  6923. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6924. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6926. return
  6927. }
  6928. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  6929. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  6930. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  6931. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6932. userJSONBytes, _ := json.Marshal(respJSON)
  6933. fmt.Println("log")
  6934. fmt.Println(string(userJSONBytes))
  6935. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6936. utils.ErrorLog("解析失败:%v", err)
  6937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6938. return
  6939. }
  6940. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6941. res2.Output = resSix10265.Output
  6942. res2.ErrMsg = resSix10265.ErrMsg
  6943. res2.Cainfo = resSix10265.Cainfo
  6944. res2.WarnMsg = resSix10265.WarnMsg
  6945. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6946. res2.Infcode = infocode
  6947. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6948. result, requestLog := service.FJyb2203(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, doctor_info.UserName, roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  6949. saveLog(result, requestLog, "2203", "上传就诊信息")
  6950. var respJSON2 map[string]interface{}
  6951. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6952. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6954. return
  6955. }
  6956. userJSONBytes2, _ := json.Marshal(respJSON2)
  6957. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  6958. utils.ErrorLog("解析失败:%v", err)
  6959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6960. return
  6961. }
  6962. } else {
  6963. var result string
  6964. var requestLog string
  6965. if miConfig.MdtrtareaAdmvs == "440781" { //
  6966. 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)
  6967. } else {
  6968. if miConfig.Code == "H15049901371" {
  6969. //赤峰地区国家医保医疗类别
  6970. //职工透析:医疗类别选特殊情况门诊990502
  6971. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6972. var med_type string
  6973. if his.Insutype == "390" {
  6974. if reg_type == 14 {
  6975. med_type = "9933"
  6976. } else if reg_type == 11 {
  6977. med_type = "11"
  6978. }
  6979. } else if his.Insutype == "310" {
  6980. if reg_type == 14 {
  6981. med_type = "990502"
  6982. } else if reg_type == 11 {
  6983. med_type = "11"
  6984. }
  6985. }
  6986. 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)
  6987. } else {
  6988. 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)
  6989. }
  6990. saveLog(result, requestLog, "2203", "上传就诊信息")
  6991. var respJSON2 map[string]interface{}
  6992. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6993. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6995. return
  6996. }
  6997. userJSONBytes2, _ := json.Marshal(respJSON2)
  6998. if miConfig.Code == "H15049901371" {
  6999. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  7000. utils.ErrorLog("解析失败:%v", err)
  7001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7002. return
  7003. }
  7004. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7005. res2.Output = resSix10265.Output
  7006. res2.ErrMsg = resSix10265.ErrMsg
  7007. res2.Cainfo = resSix10265.Cainfo
  7008. res2.WarnMsg = resSix10265.WarnMsg
  7009. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7010. res2.Infcode = infocode
  7011. } else {
  7012. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7013. utils.ErrorLog("解析失败:%v", err)
  7014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7015. return
  7016. }
  7017. }
  7018. }
  7019. }
  7020. if res2.Infcode != 0 {
  7021. adminUser := c.GetAdminUserInfo()
  7022. errlog := &models.HisOrderError{
  7023. UserOrgId: adminUser.CurrentOrgId,
  7024. Ctime: time.Now().Unix(),
  7025. Mtime: time.Now().Unix(),
  7026. ErrMsg: res2.ErrMsg,
  7027. Status: 1,
  7028. PatientId: id,
  7029. RecordTime: recordDateTime,
  7030. Stage: 3,
  7031. }
  7032. service.CreateErrMsgLog(errlog)
  7033. c.ServeSuccessJSON(map[string]interface{}{
  7034. "failed_code": -10,
  7035. "msg": res2.ErrMsg,
  7036. })
  7037. return
  7038. } else {
  7039. his.Diagnosis = diagnosis_id
  7040. his.SickType = sickConfig.ID
  7041. his.PType = fmt.Sprintf("%d", reg_type)
  7042. service.UpdateHisPatientThree(&his)
  7043. data := make(map[string]interface{})
  7044. if settle_accounts_type == 1 { //日结
  7045. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  7046. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  7047. } else {
  7048. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  7049. }
  7050. data["pre"] = prescriptions
  7051. } else { //月结
  7052. start_time_str := c.GetString("start_time")
  7053. end_time_str := c.GetString("end_time")
  7054. timeLayout := "2006-01-02"
  7055. loc, _ := time.LoadLocation("Local")
  7056. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7057. if err != nil {
  7058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7059. return
  7060. }
  7061. recordStartTime := theStartTime.Unix()
  7062. start_time = recordStartTime
  7063. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7064. if err != nil {
  7065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7066. return
  7067. }
  7068. recordEndTime := theEndTime.Unix()
  7069. end_time = recordEndTime
  7070. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  7071. data["pre"] = prescriptions
  7072. }
  7073. client := &http.Client{}
  7074. data["psn_no"] = his.PsnNo
  7075. data["mdtrt_id"] = his.Number
  7076. data["chrg_bchno"] = chrg_bchno
  7077. data["org_name"] = miConfig.OrgName
  7078. data["doctor"] = roles.UserName
  7079. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  7080. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  7081. data["fixmedins_code"] = miConfig.Code
  7082. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  7083. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  7084. data["dept_code"] = "15"
  7085. } else {
  7086. data["dept_code"] = department.Number
  7087. }
  7088. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7089. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7090. data["secret_key"] = miConfig.SecretKey
  7091. data["url"] = miConfig.Url
  7092. data["ak"] = miConfig.AccessKey
  7093. data["new_doctor_name"] = patientPrescription.Doctor
  7094. data["diag_code"] = sickConfig.CountryCode
  7095. data["time_stamp"] = time_stamp
  7096. data["cainfo"] = miConfig.Cainfo
  7097. var ids []int64
  7098. for _, item := range prescriptions {
  7099. ids = append(ids, item.ID)
  7100. }
  7101. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7102. if config.IsOpen == 1 { //对接了医保,走医保流程
  7103. var res ResultFour
  7104. var resFour10265 ResultFour10265
  7105. if miConfig.MdtrtareaAdmvs == "421300" {
  7106. bytesData, _ := json.Marshal(data)
  7107. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  7108. resp, _ := client.Do(req)
  7109. defer resp.Body.Close()
  7110. body, ioErr := ioutil.ReadAll(resp.Body)
  7111. if ioErr != nil {
  7112. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7114. return
  7115. }
  7116. var respJSON map[string]interface{}
  7117. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7118. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7120. return
  7121. }
  7122. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7123. userJSONBytes, _ := json.Marshal(respJSON)
  7124. fmt.Println("log")
  7125. fmt.Println(string(userJSONBytes))
  7126. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7127. utils.ErrorLog("解析失败:%v", err)
  7128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7129. return
  7130. }
  7131. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7132. bytesData, _ := json.Marshal(data)
  7133. var req *http.Request
  7134. if miConfig.MdtrtareaAdmvs == "320921" {
  7135. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7136. } else {
  7137. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7138. }
  7139. resp, _ := client.Do(req)
  7140. defer resp.Body.Close()
  7141. body, ioErr := ioutil.ReadAll(resp.Body)
  7142. if ioErr != nil {
  7143. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7145. return
  7146. }
  7147. var respJSON map[string]interface{}
  7148. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7149. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7151. return
  7152. }
  7153. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7154. userJSONBytes, _ := json.Marshal(respJSON)
  7155. fmt.Println("log")
  7156. fmt.Println(string(userJSONBytes))
  7157. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7158. utils.ErrorLog("解析失败:%v", err)
  7159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7160. return
  7161. }
  7162. res.InfRefmsgid = resFour10265.InfRefmsgid
  7163. res.Output = resFour10265.Output
  7164. res.ErrMsg = resFour10265.ErrMsg
  7165. res.Cainfo = resFour10265.Cainfo
  7166. res.WarnMsg = resFour10265.WarnMsg
  7167. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7168. res.Infcode = infocode
  7169. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7170. result, request_log := service.FJyb2204(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), roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  7171. var dat map[string]interface{}
  7172. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7173. fmt.Println(dat)
  7174. } else {
  7175. fmt.Println(err)
  7176. }
  7177. saveLog(result, request_log, "2204", "上传费用明细")
  7178. userJSONBytes, _ := json.Marshal(dat)
  7179. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7180. utils.ErrorLog("解析失败:%v", err)
  7181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7182. return
  7183. }
  7184. } else {
  7185. if miConfig.Code == "H15049901371" {
  7186. 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)
  7187. var dat map[string]interface{}
  7188. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7189. fmt.Println(dat)
  7190. } else {
  7191. fmt.Println(err)
  7192. }
  7193. saveLog(result, request_log, "2204", "上传费用明细")
  7194. userJSONBytes, _ := json.Marshal(dat)
  7195. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7196. utils.ErrorLog("解析失败:%v", err)
  7197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7198. return
  7199. }
  7200. res.InfRefmsgid = resFour10265.InfRefmsgid
  7201. res.Output = resFour10265.Output
  7202. res.ErrMsg = resFour10265.ErrMsg
  7203. res.Cainfo = resFour10265.Cainfo
  7204. res.WarnMsg = resFour10265.WarnMsg
  7205. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7206. res.Infcode = infocode
  7207. } else {
  7208. 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)
  7209. var dat map[string]interface{}
  7210. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7211. fmt.Println(dat)
  7212. } else {
  7213. fmt.Println(err)
  7214. }
  7215. saveLog(result, request_log, "2204", "上传费用明细")
  7216. userJSONBytes, _ := json.Marshal(dat)
  7217. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7218. utils.ErrorLog("解析失败:%v", err)
  7219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7220. return
  7221. }
  7222. }
  7223. }
  7224. if res.Infcode == 0 {
  7225. order := &models.HisOrder{
  7226. UserOrgId: adminUser.CurrentOrgId,
  7227. HisPatientId: his.ID,
  7228. PatientId: his.PatientId,
  7229. SettleAccountsDate: recordDateTime,
  7230. Ctime: time.Now().Unix(),
  7231. Mtime: time.Now().Unix(),
  7232. MdtrtId: his.Number,
  7233. PsnNo: his.PsnNo,
  7234. MedType: strconv.FormatInt(reg_type, 10),
  7235. Status: 1,
  7236. Number: chrg_bchno,
  7237. Infcode: res.Infcode,
  7238. WarnMsg: res.WarnMsg,
  7239. Cainfo: res.Cainfo,
  7240. ErrMsg: res.ErrMsg,
  7241. RespondTime: res.RefmsgTime,
  7242. InfRefmsgid: res.InfRefmsgid,
  7243. OrderStatus: 1,
  7244. IsMedicineInsurance: 1,
  7245. SettleType: settle_accounts_type,
  7246. SettleStartTime: start_time,
  7247. SettleEndTime: end_time,
  7248. Creator: roles.AdminUserId,
  7249. Modify: roles.AdminUserId,
  7250. PType: 2,
  7251. Diagnosis: diagnosis_id,
  7252. }
  7253. err = service.CreateOrder(order)
  7254. if err != nil {
  7255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7256. return
  7257. }
  7258. for _, item := range res.Output.Result {
  7259. temp := strings.Split(item.FeedetlSn, "-")
  7260. var advice_id int64 = 0
  7261. var project_id int64 = 0
  7262. var types int64 = 0
  7263. id, _ := strconv.ParseInt(temp[2], 10, 64)
  7264. types, _ = strconv.ParseInt(temp[1], 10, 64)
  7265. if temp[1] == "1" {
  7266. advice_id = id
  7267. project_id = 0
  7268. } else if temp[1] == "2" {
  7269. advice_id = 0
  7270. project_id = id
  7271. }
  7272. info := &models.HisOrderInfo{
  7273. OrderNumber: order.Number,
  7274. FeedetlSn: item.FeedetlSn,
  7275. UploadDate: time.Now().Unix(),
  7276. AdviceId: advice_id,
  7277. DetItemFeeSumamt: item.DetItemFeeSumamt,
  7278. Cnt: item.Cnt,
  7279. Pric: float64(item.Pric),
  7280. PatientId: his.PatientId,
  7281. PricUplmtAmt: item.PricUplmtAmt,
  7282. SelfpayProp: item.SelfpayProp,
  7283. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7284. OverlmtAmt: item.OverlmtAmt,
  7285. PreselfpayAmt: item.PreselfpayAmt,
  7286. BasMednFlag: item.BasMednFlag,
  7287. MedChrgitmType: item.MedChrgitmType,
  7288. HiNegoDrugFlag: item.HiNegoDrugFlag,
  7289. Status: 1,
  7290. Memo: item.Memo,
  7291. Mtime: time.Now().Unix(),
  7292. InscpScpAmt: item.InscpScpAmt,
  7293. DrtReimFlag: item.DrtReimFlag,
  7294. Ctime: time.Now().Unix(),
  7295. ListSpItemFlag: item.ListSpItemFlag,
  7296. ChldMedcFlag: item.ChldMedcFlag,
  7297. LmtUsedFlag: item.LmtUsedFlag,
  7298. ChrgitmLv: item.ChrgitmLv,
  7299. UserOrgId: adminUser.CurrentOrgId,
  7300. HisPatientId: his.ID,
  7301. OrderId: order.ID,
  7302. ProjectId: project_id,
  7303. Type: types,
  7304. }
  7305. service.CreateOrderInfo(info)
  7306. }
  7307. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7308. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  7309. var total float64
  7310. for _, item := range prescriptions {
  7311. if item.Type == 1 { //药品
  7312. for _, subItem := range item.HisDoctorAdviceInfo {
  7313. total = total + (subItem.Price * subItem.PrescribingNumber)
  7314. }
  7315. }
  7316. if item.Type == 2 { //项目
  7317. for _, subItem := range item.HisPrescriptionProject {
  7318. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7319. total = total + (subItem.Price * cnt)
  7320. }
  7321. }
  7322. }
  7323. for _, item := range prescriptions {
  7324. for _, subItem := range item.HisAdditionalCharge {
  7325. total = total + (subItem.Price * float64(subItem.Count))
  7326. }
  7327. }
  7328. allTotal := fmt.Sprintf("%.4f", total)
  7329. if res.Infcode == 0 {
  7330. var rf []*ResultFive
  7331. json.Unmarshal([]byte(his.Iinfo), &rf)
  7332. chrg_bchno := chrg_bchno
  7333. cert_no := his.Certno
  7334. var insutypes []string
  7335. var insutype string
  7336. var is390 int = 0
  7337. var is310 int = 0
  7338. for _, item := range rf {
  7339. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7340. insutypes = append(insutypes, item.Insutype)
  7341. }
  7342. }
  7343. if len(insutypes) == 1 {
  7344. insutype = insutypes[0]
  7345. } else {
  7346. for _, i := range insutypes {
  7347. if i == "390" {
  7348. is390 = 1
  7349. }
  7350. if i == "310" {
  7351. is310 = 1
  7352. }
  7353. }
  7354. }
  7355. if is390 == 1 {
  7356. insutype = "390"
  7357. }
  7358. if is310 == 1 {
  7359. insutype = "310"
  7360. }
  7361. if len(insutypes) == 0 {
  7362. insutype = "310"
  7363. }
  7364. if len(insutypes) == 2 {
  7365. insutype = strconv.FormatInt(his.SocialType, 64)
  7366. }
  7367. //insutype = "390"
  7368. if his.IdCardType == 1 {
  7369. cert_no = his.MedicalInsuranceNumber
  7370. } else {
  7371. cert_no = his.Certno
  7372. }
  7373. var res ResultSeven
  7374. var resSeven10265 ResultSeven10265
  7375. if miConfig.MdtrtareaAdmvs == "421300" {
  7376. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7377. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7378. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7379. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7380. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7381. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7382. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  7383. resp, requestErr := http.Get(api)
  7384. if requestErr != nil {
  7385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7386. return
  7387. }
  7388. body, ioErr := ioutil.ReadAll(resp.Body)
  7389. if ioErr != nil {
  7390. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7392. return
  7393. }
  7394. var respJSON map[string]interface{}
  7395. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7396. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7398. return
  7399. }
  7400. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7401. result, _ := json.Marshal(respJSON)
  7402. fmt.Println("log")
  7403. fmt.Println(string(result))
  7404. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7405. utils.ErrorLog("解析失败:%v", err)
  7406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7407. return
  7408. }
  7409. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7410. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7411. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7412. bas := strings.Split(psn_info.CardInfo, "|")
  7413. if his.IdCardType == 1 {
  7414. cert_no = bas[2]
  7415. } else {
  7416. cert_no = bas[1]
  7417. }
  7418. //江苏地区国家医保医疗类别
  7419. //职工透析:医疗类别选特殊情况门诊9933
  7420. //居民血透门慢: 医疗类别选门诊慢病1402
  7421. //var med_type string
  7422. //if his.Insutype == "310" {
  7423. // if reg_type == 14 {
  7424. // med_type = "9933"
  7425. // } else if reg_type == 11 {
  7426. // med_type = "11"
  7427. //
  7428. // }
  7429. //} else if his.Insutype == "390" {
  7430. // if reg_type == 14 {
  7431. // med_type = "1402"
  7432. // } else if reg_type == 11 {
  7433. // med_type = "11"
  7434. // }
  7435. //}
  7436. var api string
  7437. if miConfig.MdtrtareaAdmvs == "320921" {
  7438. api = "http://192.168.2.110:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7439. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7440. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7441. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7442. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7443. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7444. "&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
  7445. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7446. } else {
  7447. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7448. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7449. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7450. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7451. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7452. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7453. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7454. "&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
  7455. }
  7456. resp, requestErr := http.Get(api)
  7457. if requestErr != nil {
  7458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7459. return
  7460. }
  7461. body, ioErr := ioutil.ReadAll(resp.Body)
  7462. if ioErr != nil {
  7463. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7465. return
  7466. }
  7467. var respJSON map[string]interface{}
  7468. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7469. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7471. return
  7472. }
  7473. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7474. result, _ := json.Marshal(respJSON)
  7475. fmt.Println("log")
  7476. fmt.Println(string(result))
  7477. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7478. utils.ErrorLog("解析失败:%v", err)
  7479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7480. return
  7481. }
  7482. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7483. res.Output = resSeven10265.Output
  7484. res.ErrMsg = resSeven10265.ErrMsg
  7485. res.Cainfo = resSeven10265.Cainfo
  7486. res.WarnMsg = resSeven10265.WarnMsg
  7487. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7488. res.Infcode = infocode
  7489. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7490. result, request_log := service.FJyb2206(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, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  7491. var dat map[string]interface{}
  7492. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7493. fmt.Println(dat)
  7494. } else {
  7495. fmt.Println(err)
  7496. }
  7497. saveLog(result, request_log, "2206", "预结算")
  7498. userJSONBytes, _ := json.Marshal(dat)
  7499. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7500. utils.ErrorLog("解析失败:%v", err)
  7501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7502. return
  7503. }
  7504. } else {
  7505. var result string
  7506. var request_log string
  7507. if miConfig.Code == "H15049901371" {
  7508. //赤峰地区国家医保医疗类别
  7509. //职工透析:医疗类别选特殊情况门诊990502
  7510. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7511. var med_type string
  7512. if his.Insutype == "390" {
  7513. if reg_type == 14 {
  7514. med_type = "9933"
  7515. } else if reg_type == 11 {
  7516. med_type = "11"
  7517. }
  7518. } else if his.Insutype == "310" {
  7519. if reg_type == 14 {
  7520. med_type = "990502"
  7521. } else if reg_type == 11 {
  7522. med_type = "11"
  7523. }
  7524. }
  7525. 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)
  7526. } else {
  7527. 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)
  7528. }
  7529. var dat map[string]interface{}
  7530. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7531. fmt.Println(dat)
  7532. } else {
  7533. fmt.Println(err)
  7534. }
  7535. saveLog(result, request_log, "2206", "预结算")
  7536. //userJSONBytes, _ := json.Marshal(dat)
  7537. //
  7538. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7539. // utils.ErrorLog("解析失败:%v", err)
  7540. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7541. // return
  7542. //}
  7543. userJSONBytes, _ := json.Marshal(dat)
  7544. if miConfig.Code == "H15049901371" {
  7545. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7546. utils.ErrorLog("解析失败:%v", err)
  7547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7548. return
  7549. }
  7550. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7551. res.Output = resSeven10265.Output
  7552. res.ErrMsg = resSeven10265.ErrMsg
  7553. res.Cainfo = resSeven10265.Cainfo
  7554. res.WarnMsg = resSeven10265.WarnMsg
  7555. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7556. res.Infcode = infocode
  7557. } else {
  7558. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7559. utils.ErrorLog("解析失败:%v", err)
  7560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7561. return
  7562. }
  7563. }
  7564. }
  7565. if res.Infcode != 0 {
  7566. errlog := &models.HisOrderError{
  7567. UserOrgId: adminUser.CurrentOrgId,
  7568. Ctime: time.Now().Unix(),
  7569. Mtime: time.Now().Unix(),
  7570. Number: chrg_bchno,
  7571. ErrMsg: res.ErrMsg,
  7572. Status: 1,
  7573. PatientId: id,
  7574. RecordTime: recordDateTime,
  7575. Stage: 20,
  7576. }
  7577. service.CreateErrMsgLog(errlog)
  7578. c.ServeSuccessJSON(map[string]interface{}{
  7579. "failed_code": -10,
  7580. "msg": res.ErrMsg,
  7581. })
  7582. return
  7583. } else {
  7584. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7585. order.OrderStatus = 1
  7586. order.IsPre = 1
  7587. order.Status = 1
  7588. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7589. order.SetlId = res.Output.Setlinfo.SetlID
  7590. order.PsnNo = res.Output.Setlinfo.PsnNo
  7591. order.PsnName = res.Output.Setlinfo.PsnName
  7592. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7593. order.Certno = res.Output.Setlinfo.Certno
  7594. order.Gend = res.Output.Setlinfo.Gend
  7595. order.Naty = res.Output.Setlinfo.Naty
  7596. order.Age = res.Output.Setlinfo.Age
  7597. order.Insutype = res.Output.Setlinfo.Insutype
  7598. order.PsnType = res.Output.Setlinfo.PsnType
  7599. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7600. order.SetlTime = res.Output.Setlinfo.SetlTime
  7601. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7602. if res.Output.Setlinfo.MedType == "140101" {
  7603. order.MedType = "14"
  7604. } else {
  7605. order.MedType = res.Output.Setlinfo.MedType
  7606. }
  7607. if reg_type == 1112 {
  7608. order.MedType = "1112"
  7609. }
  7610. if reg_type == 1111 {
  7611. order.MedType = "1111"
  7612. }
  7613. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7614. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7615. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7616. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7617. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7618. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7619. order.HifpPay = res.Output.Setlinfo.HifpPay
  7620. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7621. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7622. order.HifesPay = res.Output.Setlinfo.HifesPay
  7623. order.HifobPay = res.Output.Setlinfo.HifobPay
  7624. order.MafPay = res.Output.Setlinfo.MafPay
  7625. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  7626. order.OthPay = res.Output.Setlinfo.OthPay
  7627. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7628. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7629. order.AcctPay = res.Output.Setlinfo.AcctPay
  7630. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7631. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7632. order.Balc = res.Output.Setlinfo.Balc
  7633. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7634. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7635. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7636. order.ClrWay = res.Output.Setlinfo.ClrWay
  7637. order.Creator = order.Creator
  7638. order.Modify = roles.AdminUserId
  7639. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7640. detailStr := string(setlDetail)
  7641. order.SetlDetail = detailStr
  7642. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7643. err = service.UpDateOrder(order)
  7644. if err == nil {
  7645. c.ServeSuccessJSON(map[string]interface{}{
  7646. "msg": "预结算成功",
  7647. })
  7648. } else {
  7649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7650. return
  7651. }
  7652. }
  7653. } else {
  7654. adminUser := c.GetAdminUserInfo()
  7655. errlog := &models.HisOrderError{
  7656. UserOrgId: adminUser.CurrentOrgId,
  7657. Ctime: time.Now().Unix(),
  7658. Mtime: time.Now().Unix(),
  7659. ErrMsg: res.ErrMsg,
  7660. Status: 1,
  7661. PatientId: id,
  7662. RecordTime: recordDateTime,
  7663. Stage: 4,
  7664. }
  7665. service.CreateErrMsgLog(errlog)
  7666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7667. return
  7668. }
  7669. } else {
  7670. adminUser := c.GetAdminUserInfo()
  7671. errlog := &models.HisOrderError{
  7672. UserOrgId: adminUser.CurrentOrgId,
  7673. Ctime: time.Now().Unix(),
  7674. Mtime: time.Now().Unix(),
  7675. ErrMsg: res.ErrMsg,
  7676. Status: 1,
  7677. PatientId: id,
  7678. RecordTime: recordDateTime,
  7679. Stage: 4,
  7680. }
  7681. service.CreateErrMsgLog(errlog)
  7682. c.ServeSuccessJSON(map[string]interface{}{
  7683. "failed_code": -10,
  7684. "msg": res.ErrMsg,
  7685. })
  7686. return
  7687. }
  7688. }
  7689. }
  7690. }
  7691. //退款
  7692. func (c *HisApiController) Refund() {
  7693. order_id, _ := c.GetInt64("order_id")
  7694. admin_user_id, _ := c.GetInt64("admin_user_id")
  7695. adminUser := c.GetAdminUserInfo()
  7696. var order models.HisOrder
  7697. order, _ = service.GetHisOrderByID(order_id)
  7698. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7699. if order.ID == 0 {
  7700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7701. return
  7702. }
  7703. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7704. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7705. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7706. if config.IsOpen == 1 { //对接了医保,走医保流程
  7707. var res ResultSixteen
  7708. var resSixteen10265 ResultSixteen10265
  7709. var src_resquest string
  7710. var result string
  7711. if miConfig.MdtrtareaAdmvs == "421300" {
  7712. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  7713. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7714. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7715. resp3, requestErr3 := http.Get(api3)
  7716. if requestErr3 != nil {
  7717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7718. return
  7719. }
  7720. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7721. if ioErr3 != nil {
  7722. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7724. return
  7725. }
  7726. var respJSON3 map[string]interface{}
  7727. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7728. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7730. return
  7731. }
  7732. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7733. userJSONBytes3, _ := json.Marshal(respJSON3)
  7734. fmt.Println("log")
  7735. fmt.Println(string(userJSONBytes3))
  7736. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  7737. utils.ErrorLog("解析失败:%v", err)
  7738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7739. return
  7740. }
  7741. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7742. var api3 string
  7743. if miConfig.MdtrtareaAdmvs == "320921" {
  7744. api3 = "http://192.168.2.110:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7745. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7746. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7747. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7748. } else {
  7749. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7750. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7751. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7752. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7753. }
  7754. resp3, requestErr3 := http.Get(api3)
  7755. if requestErr3 != nil {
  7756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7757. return
  7758. }
  7759. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7760. if ioErr3 != nil {
  7761. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7763. return
  7764. }
  7765. var respJSON3 map[string]interface{}
  7766. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7767. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7769. return
  7770. }
  7771. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7772. userJSONBytes3, _ := json.Marshal(respJSON3)
  7773. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  7774. utils.ErrorLog("解析失败:%v", err)
  7775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7776. return
  7777. }
  7778. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7779. res.Output = resSixteen10265.Output
  7780. res.ErrMsg = resSixteen10265.ErrMsg
  7781. res.Cainfo = resSixteen10265.Cainfo
  7782. res.WarnMsg = resSixteen10265.WarnMsg
  7783. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7784. res.Infcode = infocode
  7785. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7786. result, src_resquest = service.FJyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  7787. var dat map[string]interface{}
  7788. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7789. fmt.Println(dat)
  7790. } else {
  7791. fmt.Println(err)
  7792. }
  7793. saveLog(result, src_resquest, "2208", "退费")
  7794. userJSONBytes, _ := json.Marshal(dat)
  7795. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7796. utils.ErrorLog("解析失败:%v", err)
  7797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7798. return
  7799. }
  7800. } else {
  7801. if miConfig.Code == "H15049901371" {
  7802. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7803. var dat map[string]interface{}
  7804. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7805. fmt.Println(dat)
  7806. } else {
  7807. fmt.Println(err)
  7808. }
  7809. saveLog(result, src_resquest, "2208", "退费")
  7810. userJSONBytes, _ := json.Marshal(dat)
  7811. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  7812. utils.ErrorLog("解析失败:%v", err)
  7813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7814. return
  7815. }
  7816. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7817. res.Output = resSixteen10265.Output
  7818. res.ErrMsg = resSixteen10265.ErrMsg
  7819. res.Cainfo = resSixteen10265.Cainfo
  7820. res.WarnMsg = resSixteen10265.WarnMsg
  7821. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7822. res.Infcode = infocode
  7823. } else {
  7824. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7825. var dat map[string]interface{}
  7826. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7827. fmt.Println(dat)
  7828. } else {
  7829. fmt.Println(err)
  7830. }
  7831. saveLog(result, src_resquest, "2208", "退费")
  7832. userJSONBytes, _ := json.Marshal(dat)
  7833. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7834. utils.ErrorLog("解析失败:%v", err)
  7835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7836. return
  7837. }
  7838. }
  7839. }
  7840. if res.Infcode == 0 {
  7841. var res2 ResultSix
  7842. var resSix10265 ResultSix10265
  7843. if miConfig.MdtrtareaAdmvs == "421300" {
  7844. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7845. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7846. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7847. resp3, requestErr3 := http.Get(api3)
  7848. if requestErr3 != nil {
  7849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7850. return
  7851. }
  7852. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7853. if ioErr3 != nil {
  7854. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7856. return
  7857. }
  7858. var respJSON3 map[string]interface{}
  7859. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7860. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7862. return
  7863. }
  7864. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7865. userJSONBytes3, _ := json.Marshal(respJSON3)
  7866. fmt.Println("log")
  7867. fmt.Println(string(userJSONBytes3))
  7868. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7869. utils.ErrorLog("解析失败:%v", err)
  7870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7871. return
  7872. }
  7873. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7874. var api3 string
  7875. if miConfig.MdtrtareaAdmvs == "320921" {
  7876. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7877. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7878. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7879. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7880. } else {
  7881. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7882. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7883. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7884. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7885. }
  7886. resp3, requestErr3 := http.Get(api3)
  7887. if requestErr3 != nil {
  7888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7889. return
  7890. }
  7891. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7892. if ioErr3 != nil {
  7893. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7895. return
  7896. }
  7897. var respJSON3 map[string]interface{}
  7898. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7899. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7901. return
  7902. }
  7903. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7904. userJSONBytes3, _ := json.Marshal(respJSON3)
  7905. fmt.Println("log")
  7906. fmt.Println(string(userJSONBytes3))
  7907. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7908. utils.ErrorLog("解析失败:%v", err)
  7909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7910. return
  7911. }
  7912. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7913. res2.Output = resSix10265.Output
  7914. res2.ErrMsg = resSix10265.ErrMsg
  7915. res2.Cainfo = resSix10265.Cainfo
  7916. res2.WarnMsg = resSix10265.WarnMsg
  7917. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7918. res2.Infcode = infocode
  7919. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7920. result2, src_request := service.FJyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  7921. var dat map[string]interface{}
  7922. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7923. fmt.Println(dat)
  7924. } else {
  7925. fmt.Println(err)
  7926. }
  7927. saveLog(result2, src_request, "2205", "撤销明细")
  7928. userJSONBytes, _ := json.Marshal(dat)
  7929. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7930. utils.ErrorLog("解析失败:%v", err)
  7931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7932. return
  7933. }
  7934. } else {
  7935. if miConfig.Code == "H15049901371" {
  7936. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7937. var dat map[string]interface{}
  7938. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7939. fmt.Println(dat)
  7940. } else {
  7941. fmt.Println(err)
  7942. }
  7943. saveLog(result2, src_request, "2205", "撤销明细")
  7944. userJSONBytes, _ := json.Marshal(dat)
  7945. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7946. utils.ErrorLog("解析失败:%v", err)
  7947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7948. return
  7949. }
  7950. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7951. res2.Output = resSix10265.Output
  7952. res2.ErrMsg = resSix10265.ErrMsg
  7953. res2.Cainfo = resSix10265.Cainfo
  7954. res2.WarnMsg = resSix10265.WarnMsg
  7955. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7956. res2.Infcode = infocode
  7957. } else {
  7958. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7959. var dat map[string]interface{}
  7960. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7961. fmt.Println(dat)
  7962. } else {
  7963. fmt.Println(err)
  7964. }
  7965. saveLog(result2, src_request, "2205", "撤销明细")
  7966. userJSONBytes, _ := json.Marshal(dat)
  7967. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7968. utils.ErrorLog("解析失败:%v", err)
  7969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7970. return
  7971. }
  7972. }
  7973. }
  7974. if res2.Infcode == 0 {
  7975. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  7976. if err == nil {
  7977. //当押金不为零时产生退费记录
  7978. if order.Decimal != 0 {
  7979. tmp := strconv.FormatInt(order.ID, 10)
  7980. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  7981. if err != nil {
  7982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7983. return
  7984. }
  7985. }
  7986. c.ServeSuccessJSON(map[string]interface{}{
  7987. "msg": "退费成功",
  7988. })
  7989. } else {
  7990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7991. return
  7992. }
  7993. } else {
  7994. c.ServeSuccessJSON(map[string]interface{}{
  7995. "code": -10,
  7996. "msg": res2.ErrMsg,
  7997. })
  7998. }
  7999. } else {
  8000. c.ServeSuccessJSON(map[string]interface{}{
  8001. "code": -10,
  8002. "msg": res.ErrMsg,
  8003. })
  8004. }
  8005. }
  8006. }
  8007. func (c *HisApiController) RefundNumber() {
  8008. record_time := c.GetString("record_time")
  8009. //patient_id, _ := c.GetInt64("patient_id")
  8010. admin_user_id, _ := c.GetInt64("admin_user_id")
  8011. his_patient_id, _ := c.GetInt64("id")
  8012. timeLayout := "2006-01-02"
  8013. loc, _ := time.LoadLocation("Local")
  8014. adminUser := c.GetAdminUserInfo()
  8015. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8016. fmt.Println(err)
  8017. if err != nil {
  8018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8019. return
  8020. }
  8021. recordDateTime := theTime.Unix()
  8022. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8023. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  8024. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8025. //order, _ := service.GetHisOrderByID(order_id)
  8026. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8027. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8028. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8029. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  8030. if count > 0 {
  8031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  8032. return
  8033. }
  8034. if config.IsOpen == 1 { //对接了医保,走医保流程
  8035. var res2 ResultSix
  8036. var resSix10265 ResultSix10265
  8037. if miConfig.MdtrtareaAdmvs == "421300" {
  8038. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  8039. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8040. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8041. resp3, requestErr3 := http.Get(api3)
  8042. if requestErr3 != nil {
  8043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8044. return
  8045. }
  8046. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8047. if ioErr3 != nil {
  8048. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8050. return
  8051. }
  8052. var respJSON3 map[string]interface{}
  8053. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8054. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8056. return
  8057. }
  8058. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8059. userJSONBytes3, _ := json.Marshal(respJSON3)
  8060. fmt.Println("log")
  8061. fmt.Println(string(userJSONBytes3))
  8062. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8063. utils.ErrorLog("解析失败:%v", err)
  8064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8065. return
  8066. }
  8067. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8068. var api3 string
  8069. if miConfig.MdtrtareaAdmvs == "320921" {
  8070. api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8071. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8072. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8073. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8074. } else {
  8075. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8076. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8077. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8078. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8079. }
  8080. resp3, requestErr3 := http.Get(api3)
  8081. if requestErr3 != nil {
  8082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8083. return
  8084. }
  8085. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8086. if ioErr3 != nil {
  8087. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8089. return
  8090. }
  8091. var respJSON3 map[string]interface{}
  8092. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8093. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8095. return
  8096. }
  8097. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8098. userJSONBytes3, _ := json.Marshal(respJSON3)
  8099. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8100. utils.ErrorLog("解析失败:%v", err)
  8101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8102. return
  8103. }
  8104. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8105. res2.Output = resSix10265.Output
  8106. res2.ErrMsg = resSix10265.ErrMsg
  8107. res2.Cainfo = resSix10265.Cainfo
  8108. res2.WarnMsg = resSix10265.WarnMsg
  8109. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8110. res2.Infcode = infocode
  8111. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8112. result, request := service.FJyb2202(his.PsnNo, his.Number, his.IptOtpNo, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  8113. var dat map[string]interface{}
  8114. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8115. fmt.Println(dat)
  8116. } else {
  8117. fmt.Println(err)
  8118. }
  8119. saveLog(result, request, "2202", "退号")
  8120. userJSONBytes, _ := json.Marshal(dat)
  8121. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8122. utils.ErrorLog("解析失败:%v", err)
  8123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8124. return
  8125. }
  8126. } else {
  8127. var api3 string
  8128. if miConfig.Code == "H15049901371" {
  8129. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8130. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8131. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8132. } else {
  8133. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8134. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8135. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8136. }
  8137. resp3, requestErr3 := http.Get(api3)
  8138. if requestErr3 != nil {
  8139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8140. return
  8141. }
  8142. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8143. if ioErr3 != nil {
  8144. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8146. return
  8147. }
  8148. var respJSON3 map[string]interface{}
  8149. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8150. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8152. return
  8153. }
  8154. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8155. userJSONBytes3, _ := json.Marshal(respJSON3)
  8156. if miConfig.Code == "H15049901371" {
  8157. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8158. utils.ErrorLog("解析失败:%v", err)
  8159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8160. return
  8161. }
  8162. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8163. res2.Output = resSix10265.Output
  8164. res2.ErrMsg = resSix10265.ErrMsg
  8165. res2.Cainfo = resSix10265.Cainfo
  8166. res2.WarnMsg = resSix10265.WarnMsg
  8167. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8168. res2.Infcode = infocode
  8169. } else {
  8170. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8171. utils.ErrorLog("解析失败:%v", err)
  8172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8173. return
  8174. }
  8175. }
  8176. }
  8177. if res2.Infcode == 0 {
  8178. if err == nil {
  8179. c.ServeSuccessJSON(map[string]interface{}{
  8180. "msg": "退号成功",
  8181. })
  8182. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  8183. } else {
  8184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8185. return
  8186. }
  8187. } else {
  8188. c.ServeSuccessJSON(map[string]interface{}{
  8189. "code": -10,
  8190. "msg": res2.ErrMsg,
  8191. })
  8192. }
  8193. } else {
  8194. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  8195. //if err == nil {
  8196. // c.ServeSuccessJSON(map[string]interface{}{
  8197. // "msg": "退费成功",
  8198. // })
  8199. //} else {
  8200. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8201. // return
  8202. //}
  8203. }
  8204. }
  8205. func (c *HisApiController) RefundDetail() {
  8206. order_id, _ := c.GetInt64("order_id")
  8207. admin_user_id, _ := c.GetInt64("admin_user_id")
  8208. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8209. number := c.GetString("number")
  8210. record_time := c.GetString("record_time")
  8211. patient_id, _ := c.GetInt64("patient_id")
  8212. //med_type, _ := c.GetInt64("med_type")
  8213. timeLayout := "2006-01-02"
  8214. loc, _ := time.LoadLocation("Local")
  8215. adminUser := c.GetAdminUserInfo()
  8216. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8217. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8218. fmt.Println(err)
  8219. if err != nil {
  8220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8221. return
  8222. }
  8223. recordDateTime := theTime.Unix()
  8224. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8225. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8226. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8227. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8228. var order models.HisOrder
  8229. order, _ = service.GetHisOrderByID(order_id)
  8230. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8231. if config.IsOpen == 1 { //对接了医保,走医保流程
  8232. var res2 ResultSix
  8233. if miConfig.MdtrtareaAdmvs == "421300" {
  8234. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8235. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8236. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8237. resp3, requestErr3 := http.Get(api3)
  8238. if requestErr3 != nil {
  8239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8240. return
  8241. }
  8242. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8243. if ioErr3 != nil {
  8244. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8246. return
  8247. }
  8248. var respJSON3 map[string]interface{}
  8249. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8250. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8252. return
  8253. }
  8254. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8255. userJSONBytes3, _ := json.Marshal(respJSON3)
  8256. fmt.Println("log")
  8257. fmt.Println(string(userJSONBytes3))
  8258. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8259. utils.ErrorLog("解析失败:%v", err)
  8260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8261. return
  8262. }
  8263. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8264. if err == nil {
  8265. c.ServeSuccessJSON(map[string]interface{}{
  8266. "msg": "撤销明细成功",
  8267. })
  8268. return
  8269. } else {
  8270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8271. return
  8272. }
  8273. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8274. var resSix10265 ResultSix10265
  8275. var api3 string
  8276. if miConfig.MdtrtareaAdmvs == "320921" {
  8277. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8278. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8279. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8280. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8281. } else {
  8282. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8283. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8284. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8285. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8286. }
  8287. resp3, requestErr3 := http.Get(api3)
  8288. if requestErr3 != nil {
  8289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8290. return
  8291. }
  8292. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8293. if ioErr3 != nil {
  8294. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8296. return
  8297. }
  8298. var respJSON3 map[string]interface{}
  8299. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8300. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8302. return
  8303. }
  8304. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8305. userJSONBytes3, _ := json.Marshal(respJSON3)
  8306. fmt.Println("log")
  8307. fmt.Println(string(userJSONBytes3))
  8308. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8309. utils.ErrorLog("解析失败:%v", err)
  8310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8311. return
  8312. }
  8313. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8314. res2.Output = resSix10265.Output
  8315. res2.ErrMsg = resSix10265.ErrMsg
  8316. res2.Cainfo = resSix10265.Cainfo
  8317. res2.WarnMsg = resSix10265.WarnMsg
  8318. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8319. res2.Infcode = infocode
  8320. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8321. if err == nil {
  8322. c.ServeSuccessJSON(map[string]interface{}{
  8323. "msg": "撤销明细成功",
  8324. })
  8325. return
  8326. } else {
  8327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8328. return
  8329. }
  8330. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8331. result2, src_request := service.FJyb2205(his.PsnNo, his.Number, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  8332. var dat map[string]interface{}
  8333. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8334. fmt.Println(dat)
  8335. } else {
  8336. fmt.Println(err)
  8337. }
  8338. saveLog(result2, src_request, "2205", "撤销明细")
  8339. userJSONBytes, _ := json.Marshal(dat)
  8340. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8341. utils.ErrorLog("解析失败:%v", err)
  8342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8343. return
  8344. }
  8345. if res2.Infcode == 0 {
  8346. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8347. if err == nil {
  8348. c.ServeSuccessJSON(map[string]interface{}{
  8349. "msg": "撤销明细成功",
  8350. })
  8351. return
  8352. } else {
  8353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8354. return
  8355. }
  8356. } else {
  8357. c.ServeSuccessJSON(map[string]interface{}{
  8358. "code": -10,
  8359. "msg": res2.ErrMsg,
  8360. })
  8361. }
  8362. } else {
  8363. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  8364. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8365. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8366. resp2, requestErr2 := http.Get(api2)
  8367. if requestErr2 != nil {
  8368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8369. return
  8370. }
  8371. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8372. if ioErr2 != nil {
  8373. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8375. return
  8376. }
  8377. var respJSON2 map[string]interface{}
  8378. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8379. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8381. return
  8382. }
  8383. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8384. if err == nil {
  8385. c.ServeSuccessJSON(map[string]interface{}{
  8386. "msg": "撤销明细成功",
  8387. })
  8388. return
  8389. } else {
  8390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8391. return
  8392. }
  8393. }
  8394. } else {
  8395. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8396. if err == nil {
  8397. c.ServeSuccessJSON(map[string]interface{}{
  8398. "msg": "退费成功",
  8399. })
  8400. } else {
  8401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8402. return
  8403. }
  8404. }
  8405. }
  8406. //对账
  8407. func (c *HisApiController) GetCheckAccount() {
  8408. start_time := c.GetString("start_time")
  8409. end_time := c.GetString("end_time")
  8410. insutype := c.GetString("insutype")
  8411. clr_type := c.GetString("clr_type")
  8412. clr_org := c.GetString("clr_optins")
  8413. admin_user_id, _ := c.GetInt64("admin_user_id")
  8414. adminUser := c.GetAdminUserInfo()
  8415. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8416. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8417. if len(clr_org) == 0 {
  8418. clr_org = miConfig.MdtrtareaAdmvs
  8419. }
  8420. timeLayout := "2006-01-02"
  8421. loc, _ := time.LoadLocation("Local")
  8422. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8423. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8424. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  8425. fixmedins_setl_cnt := int64(len(orders))
  8426. var medfee_sumamt float64
  8427. var acct_pay float64
  8428. var fund_pay_sumamt float64
  8429. for _, item := range orders {
  8430. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8431. acct_pay = acct_pay + item.AcctPay
  8432. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8433. }
  8434. var user_name string
  8435. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8436. if role.ID == 0 {
  8437. user_name = "xxx"
  8438. } else {
  8439. user_name = role.UserName
  8440. }
  8441. var res ResultEight
  8442. var res10188 ResultEightFor10188
  8443. if config.IsOpen == 1 {
  8444. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8445. api := "http://192.168.2.110:9532/" + "jsyb/3201?" +
  8446. "insutype=" + insutype +
  8447. "&clr_type=" + clr_type +
  8448. "&setl_optins=" + clr_org +
  8449. "&stmt_begndate=" + start_time +
  8450. "&stm_enddate=" + end_time +
  8451. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8452. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8453. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8454. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8455. "&fixmedins_code=" + miConfig.Code +
  8456. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8457. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8458. "&secret_key=" + miConfig.SecretKey +
  8459. "&org_name=" + miConfig.OrgName +
  8460. "&doctor=" + user_name +
  8461. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8462. fmt.Println(api)
  8463. resp, requestErr := http.Get(api)
  8464. if requestErr != nil {
  8465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8466. return
  8467. }
  8468. body, ioErr := ioutil.ReadAll(resp.Body)
  8469. fmt.Println(body)
  8470. if ioErr != nil {
  8471. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8473. return
  8474. }
  8475. var respJSON map[string]interface{}
  8476. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8477. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8479. return
  8480. }
  8481. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8482. userJSONBytes, _ := json.Marshal(respJSON)
  8483. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8484. utils.ErrorLog("解析失败:%v", err)
  8485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8486. return
  8487. }
  8488. res.InfRefmsgid = res10188.InfRefmsgid
  8489. res.Output = res10188.Output
  8490. res.ErrMsg = res10188.ErrMsg
  8491. res.Cainfo = res10188.Cainfo
  8492. res.WarnMsg = res10188.WarnMsg
  8493. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8494. res.Infcode = infocode
  8495. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8496. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  8497. "insutype=" + insutype +
  8498. "&clr_type=" + clr_type +
  8499. "&setl_optins=" + clr_org +
  8500. "&stmt_begndate=" + start_time +
  8501. "&stm_enddate=" + end_time +
  8502. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8503. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8504. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8505. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8506. "&fixmedins_code=" + miConfig.Code +
  8507. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8508. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8509. "&secret_key=" + miConfig.SecretKey +
  8510. "&org_name=" + miConfig.OrgName +
  8511. "&doctor=" + user_name
  8512. resp, requestErr := http.Get(api)
  8513. if requestErr != nil {
  8514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8515. return
  8516. }
  8517. body, ioErr := ioutil.ReadAll(resp.Body)
  8518. if ioErr != nil {
  8519. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8521. return
  8522. }
  8523. var respJSON map[string]interface{}
  8524. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8525. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8527. return
  8528. }
  8529. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8530. result, _ := json.Marshal(respJSON)
  8531. fmt.Println("log")
  8532. fmt.Println(string(result))
  8533. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  8534. utils.ErrorLog("解析失败:%v", err)
  8535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8536. return
  8537. }
  8538. res.InfRefmsgid = res10188.InfRefmsgid
  8539. res.Output = res10188.Output
  8540. res.ErrMsg = res10188.ErrMsg
  8541. res.Cainfo = res10188.Cainfo
  8542. res.WarnMsg = res10188.WarnMsg
  8543. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8544. res.Infcode = infocode
  8545. } else {
  8546. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8547. "insutype=" + insutype +
  8548. "&clr_type=" + clr_type +
  8549. "&setl_optins=" + clr_org +
  8550. "&stmt_begndate=" + start_time +
  8551. "&stm_enddate=" + end_time +
  8552. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8553. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8554. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8555. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8556. "&fixmedins_code=" + miConfig.Code +
  8557. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8558. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8559. "&secret_key=" + miConfig.SecretKey +
  8560. "&org_name=" + miConfig.OrgName +
  8561. "&doctor=" + user_name
  8562. fmt.Println(api)
  8563. resp, requestErr := http.Get(api)
  8564. if requestErr != nil {
  8565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8566. return
  8567. }
  8568. body, ioErr := ioutil.ReadAll(resp.Body)
  8569. fmt.Println(body)
  8570. if ioErr != nil {
  8571. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8573. return
  8574. }
  8575. var respJSON map[string]interface{}
  8576. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8577. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8579. return
  8580. }
  8581. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8582. userJSONBytes, _ := json.Marshal(respJSON)
  8583. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8584. utils.ErrorLog("解析失败:%v", err)
  8585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8586. return
  8587. }
  8588. }
  8589. if res.Infcode == 0 {
  8590. if res.Output.Stmtinfo.StmtRslt == "0" {
  8591. micc := &models.MedicalInsuranceCostCompare{
  8592. StartTime: startime.Unix(),
  8593. EndTime: endtime.Unix(),
  8594. Insutype: insutype,
  8595. CheckType: 1,
  8596. Num: fixmedins_setl_cnt,
  8597. Mtime: time.Now().Unix(),
  8598. Status: 1,
  8599. UserOrgId: adminUser.CurrentOrgId,
  8600. CostTotal: medfee_sumamt,
  8601. FuncTotal: fund_pay_sumamt,
  8602. PsnPay: acct_pay,
  8603. Creator: admin_user_id,
  8604. Ctime: time.Now().Unix(),
  8605. ClrType: clr_type,
  8606. }
  8607. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  8608. if err == nil {
  8609. c.ServeSuccessJSON(map[string]interface{}{
  8610. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8611. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8612. })
  8613. } else {
  8614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8615. }
  8616. } else {
  8617. c.ServeSuccessJSON(map[string]interface{}{
  8618. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8619. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8620. })
  8621. }
  8622. } else {
  8623. c.ServeSuccessJSON(map[string]interface{}{
  8624. "code": -10,
  8625. "msg": res.ErrMsg,
  8626. })
  8627. }
  8628. }
  8629. }
  8630. func (c *HisApiController) Check310() {
  8631. adminUser := c.GetAdminUserInfo()
  8632. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8633. var user_name string
  8634. user_name = "高慧裕"
  8635. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8636. "insutype=" + "310" +
  8637. "&clr_type=" + "" +
  8638. "&setl_optins=" + "441202" +
  8639. "&stmt_begndate=" + "2022-03-01" +
  8640. "&stm_enddate=" + "2022-03-31" +
  8641. "&medfee_sumamt=" + "194930.12" +
  8642. "&fund_pay_sumamt=" + "188741.46" +
  8643. "&acct_pay=" + "0" +
  8644. "&fixmedins_setl_cnt=" + "452" +
  8645. "&fixmedins_code=" + miConfig.Code +
  8646. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8647. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8648. "&secret_key=" + miConfig.SecretKey +
  8649. "&org_name=" + miConfig.OrgName +
  8650. "&doctor=" + user_name
  8651. fmt.Println(api)
  8652. resp, requestErr := http.Get(api)
  8653. if requestErr != nil {
  8654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8655. return
  8656. }
  8657. body, ioErr := ioutil.ReadAll(resp.Body)
  8658. fmt.Println(body)
  8659. if ioErr != nil {
  8660. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8662. return
  8663. }
  8664. var respJSON map[string]interface{}
  8665. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8666. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8668. return
  8669. }
  8670. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8671. userJSONBytes, _ := json.Marshal(respJSON)
  8672. var res ResultEight
  8673. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8674. utils.ErrorLog("解析失败:%v", err)
  8675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8676. return
  8677. }
  8678. }
  8679. func (c *HisApiController) Check390() {
  8680. adminUser := c.GetAdminUserInfo()
  8681. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8682. var user_name string
  8683. user_name = "高慧裕"
  8684. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8685. "insutype=" + "390" +
  8686. "&clr_type=" + "" +
  8687. "&setl_optins=" + "441202" +
  8688. "&stmt_begndate=" + "2022-03-01" +
  8689. "&stm_enddate=" + "2022-03-31" +
  8690. "&medfee_sumamt=" + "1068448.89" +
  8691. "&fund_pay_sumamt=" + "1014677.62" +
  8692. "&acct_pay=" + "0" +
  8693. "&fixmedins_setl_cnt=" + "1950" +
  8694. "&fixmedins_code=" + miConfig.Code +
  8695. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8696. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8697. "&secret_key=" + miConfig.SecretKey +
  8698. "&org_name=" + miConfig.OrgName +
  8699. "&doctor=" + user_name
  8700. fmt.Println(api)
  8701. resp, requestErr := http.Get(api)
  8702. if requestErr != nil {
  8703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8704. return
  8705. }
  8706. body, ioErr := ioutil.ReadAll(resp.Body)
  8707. fmt.Println(body)
  8708. if ioErr != nil {
  8709. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8711. return
  8712. }
  8713. var respJSON map[string]interface{}
  8714. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8715. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8717. return
  8718. }
  8719. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8720. userJSONBytes, _ := json.Marshal(respJSON)
  8721. var res ResultEight
  8722. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8723. utils.ErrorLog("解析失败:%v", err)
  8724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8725. return
  8726. }
  8727. }
  8728. //对账明细
  8729. func (c *HisApiController) GetCheckDetailAccount() {
  8730. start_time := c.GetString("start_time")
  8731. end_time := c.GetString("end_time")
  8732. admin_user_id, _ := c.GetInt64("admin_user_id")
  8733. adminUser := c.GetAdminUserInfo()
  8734. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8735. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8736. timeLayout := "2006-01-02"
  8737. loc, _ := time.LoadLocation("Local")
  8738. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8739. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8740. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  8741. rand.Seed(time.Now().UnixNano())
  8742. num := rand.Intn(30000)
  8743. Mkdir(miConfig.OrgName)
  8744. file := strconv.FormatInt(int64(num), 10)
  8745. file_name := file + ".txt"
  8746. zip_name := file + ".zip"
  8747. zip_path := miConfig.OrgName + "/" + zip_name
  8748. file_path := miConfig.OrgName + "/" + file_name
  8749. decimal.DivisionPrecision = 2
  8750. var medfee_sumamt float64
  8751. var psn_cash_pay float64
  8752. var fund_pay_sumamt float64
  8753. fixmedins_setl_cnt := int64(len(orders))
  8754. for _, item := range orders {
  8755. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8756. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  8757. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8758. }
  8759. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  8760. defer f.Close()
  8761. if err != nil {
  8762. fmt.Println(err.Error())
  8763. } else {
  8764. for _, item := range orders {
  8765. var refd_setl_flag string
  8766. if item.OrderStatus == 2 {
  8767. refd_setl_flag = "0"
  8768. var str string
  8769. str = item.SetlId + " " +
  8770. item.MdtrtId + " " +
  8771. item.PsnNo + " " +
  8772. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8773. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8774. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  8775. _, err = f.Write([]byte(str))
  8776. }
  8777. if item.OrderStatus == 3 {
  8778. var str string
  8779. str = item.SetlId + " " +
  8780. item.MdtrtId + " " +
  8781. item.PsnNo + " " +
  8782. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8783. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8784. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  8785. _, err = f.Write([]byte(str))
  8786. var str2 string
  8787. str2 = item.SetlId + " " +
  8788. item.MdtrtId + " " +
  8789. item.PsnNo + " " +
  8790. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  8791. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  8792. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  8793. _, err = f.Write([]byte(str2))
  8794. }
  8795. }
  8796. }
  8797. Zip(file_path, zip_path)
  8798. fmt.Println(ReadFile(zip_path))
  8799. fmt.Println(string(ReadFile(zip_path)))
  8800. if config.IsOpen == 1 {
  8801. var user_name string
  8802. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8803. if role.ID == 0 {
  8804. user_name = "管理员"
  8805. } else {
  8806. user_name = role.UserName
  8807. }
  8808. baseParams := models.BaseParams{
  8809. SecretKey: miConfig.SecretKey,
  8810. FixmedinsCode: miConfig.Code,
  8811. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8812. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8813. OrgName: miConfig.OrgName,
  8814. Doctor: user_name,
  8815. }
  8816. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  8817. var dat map[string]interface{}
  8818. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8819. fmt.Println(dat)
  8820. } else {
  8821. fmt.Println(err)
  8822. }
  8823. userJSONBytes, _ := json.Marshal(dat)
  8824. var res ResultNine
  8825. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8826. utils.ErrorLog("解析失败:%v", err)
  8827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8828. return
  8829. }
  8830. if res.Infcode == 0 {
  8831. fileNo := res.Output.FileQuryNo
  8832. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  8833. "file_qury_no=" + fileNo +
  8834. "&setl_optins=" + "定点医保中心" +
  8835. "&stmt_begndate=" + start_time +
  8836. "&stm_enddate=" + end_time +
  8837. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8838. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8839. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  8840. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8841. "&fixmedins_code=" + miConfig.Code +
  8842. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8843. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8844. "&secret_key=" + miConfig.SecretKey +
  8845. "&org_name=" + miConfig.OrgName +
  8846. "&doctor=" + user_name
  8847. resp, requestErr := http.Get(api)
  8848. if requestErr != nil {
  8849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8850. return
  8851. }
  8852. body, ioErr := ioutil.ReadAll(resp.Body)
  8853. if ioErr != nil {
  8854. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8856. return
  8857. }
  8858. var respJSON map[string]interface{}
  8859. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8860. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8862. return
  8863. }
  8864. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8865. userJSONBytes, _ := json.Marshal(respJSON)
  8866. var res ResultTen
  8867. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8868. utils.ErrorLog("解析失败:%v", err)
  8869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8870. return
  8871. }
  8872. if res.Infcode == 0 {
  8873. service.Gdyb9102(baseParams, zip_name, fileNo)
  8874. micc := &models.MedicalInsuranceCostCompare{
  8875. StartTime: startime.Unix(),
  8876. EndTime: endtime.Unix(),
  8877. Insutype: "0",
  8878. CheckType: 2,
  8879. Num: fixmedins_setl_cnt,
  8880. Mtime: time.Now().Unix(),
  8881. Status: 1,
  8882. UserOrgId: adminUser.CurrentOrgId,
  8883. CostTotal: medfee_sumamt,
  8884. FuncTotal: fund_pay_sumamt,
  8885. PsnPay: psn_cash_pay,
  8886. Creator: admin_user_id,
  8887. Ctime: time.Now().Unix(),
  8888. }
  8889. service.CreateMedicalInsuranceCostCompareRecord(micc)
  8890. c.ServeSuccessJSON(map[string]interface{}{
  8891. "msg": "明细对账成功",
  8892. })
  8893. }
  8894. } else {
  8895. }
  8896. }
  8897. }
  8898. type CustomOrderInfo struct {
  8899. Name string
  8900. Spec string
  8901. Unit string
  8902. Count float64
  8903. Price float64
  8904. Total float64
  8905. }
  8906. func (c *HisApiController) GetSettleAccounts() {
  8907. //id, _ := c.GetInt64("id")
  8908. //record_time := c.GetString("record_time")
  8909. order_id, _ := c.GetInt64("order_id")
  8910. admin_user_id, _ := c.GetInt64("admin_user_id")
  8911. //timeLayout := "2006-01-02"
  8912. //loc, _ := time.LoadLocation("Local")
  8913. //
  8914. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8915. //if err != nil {
  8916. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8917. // return
  8918. //}
  8919. //recordDateTime := theTime.Unix()
  8920. adminUser := c.GetAdminUserInfo()
  8921. order, _ := service.GetHisOrderByID(order_id)
  8922. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8923. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  8924. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8925. orderInfos = append(orderInfos, orderInfos_two...)
  8926. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8927. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  8928. var diagnosis_ids []string
  8929. if his.ID > 0 {
  8930. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  8931. } else {
  8932. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  8933. }
  8934. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  8935. var dia_config []*models.HisXtDiagnoseConfig
  8936. var name string
  8937. for _, item := range diagnosis_ids {
  8938. id, _ := strconv.ParseInt(item, 10, 64)
  8939. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8940. dia_config = append(dia_config, &diagnosisConfig)
  8941. if len(name) == 0 {
  8942. name = diagnosisConfig.ClassName
  8943. } else {
  8944. name = name + "," + diagnosisConfig.ClassName
  8945. }
  8946. }
  8947. var bedCostTotal float64 = 0 //床位总费
  8948. var bedCostSelfTotal float64 = 0 //床位自费
  8949. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  8950. var operationCostTotal float64 = 0 //手术费
  8951. var operationCostSelfTotal float64 = 0 //手术费
  8952. var operationCostPartSelfTotal float64 = 0 //手术费
  8953. var otherCostTotal float64 = 0 //其他费用
  8954. var otherCostSelfTotal float64 = 0 //其他费用
  8955. var otherCostPartSelfTotal float64 = 0 //其他费用
  8956. var materialCostTotal float64 = 0 //材料费
  8957. var materialCostSelfTotal float64 = 0 //材料费
  8958. var materialCostPartSelfTotal float64 = 0 //材料费
  8959. var westernMedicineCostTotal float64 = 0 //西药费
  8960. var westernMedicineCostSelfTotal float64 = 0 //西药费
  8961. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  8962. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  8963. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  8964. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  8965. var checkCostTotal float64 = 0 //检查费
  8966. var checkCostSelfTotal float64 = 0 //检查费
  8967. var checkCostPartSelfTotal float64 = 0 //检查费
  8968. var laboratoryCostTotal float64 = 0 //化验费
  8969. var laboratoryCostSelfTotal float64 = 0 //化验费
  8970. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  8971. var treatCostTotal float64 = 0 //治疗费用
  8972. var treatCostSelfTotal float64 = 0 //治疗费用
  8973. var treatCostPartSelfTotal float64 = 0 //治疗费用
  8974. decimal.DivisionPrecision = 2
  8975. for _, item := range orderInfos {
  8976. if item.MedChrgitmType == "01" { //床位费
  8977. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8978. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8979. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8980. }
  8981. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  8982. if item.MedChrgitmType == "03" { //检查费
  8983. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8984. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8985. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8986. }
  8987. } else {
  8988. if item.MedChrgitmType == "03" { //检查费
  8989. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8990. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8991. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8992. }
  8993. }
  8994. if item.MedChrgitmType == "04" { //化验费
  8995. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8996. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8997. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8998. }
  8999. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  9000. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9001. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9002. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9003. }
  9004. if item.MedChrgitmType == "06" { //手术费
  9005. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9006. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9007. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9008. }
  9009. if item.MedChrgitmType == "08" { //材料费
  9010. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9011. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9012. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9013. }
  9014. if item.MedChrgitmType == "09" { //西药费
  9015. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9016. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9017. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9018. }
  9019. if item.MedChrgitmType == "11" { //中成费
  9020. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9021. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9022. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9023. }
  9024. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  9025. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9026. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9027. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9028. }
  9029. }
  9030. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9031. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9032. var user_name string
  9033. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9034. if role.ID == 0 {
  9035. user_name = "管理员"
  9036. } else {
  9037. user_name = role.UserName
  9038. }
  9039. baseParams := models.BaseParams{
  9040. SecretKey: miConfig.SecretKey,
  9041. FixmedinsCode: miConfig.Code,
  9042. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9043. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9044. OrgName: miConfig.OrgName,
  9045. Doctor: user_name,
  9046. }
  9047. businessParams := models.BusinessParams{
  9048. PsnNo: order.PsnNo,
  9049. MdtrtId: order.MdtrtId,
  9050. SetlId: order.SetlId,
  9051. }
  9052. var res ResultEleven
  9053. var resEleven10265 ResultEleven10265
  9054. if config.IsOpen == 1 {
  9055. if miConfig.MdtrtareaAdmvs == "421300" {
  9056. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9057. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9058. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9059. resp, requestErr := http.Get(api)
  9060. if requestErr != nil {
  9061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9062. return
  9063. }
  9064. body, ioErr := ioutil.ReadAll(resp.Body)
  9065. if ioErr != nil {
  9066. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9068. return
  9069. }
  9070. var respJSON map[string]interface{}
  9071. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9072. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9074. return
  9075. }
  9076. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9077. result, _ := json.Marshal(respJSON)
  9078. fmt.Println("log")
  9079. fmt.Println(string(result))
  9080. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9081. utils.ErrorLog("解析失败:%v", err)
  9082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9083. return
  9084. }
  9085. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9086. var api string
  9087. if miConfig.MdtrtareaAdmvs == "320921" {
  9088. api = "http://192.168.2.110:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9089. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9090. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9091. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9092. } else {
  9093. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9094. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9095. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9096. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9097. }
  9098. resp, requestErr := http.Get(api)
  9099. if requestErr != nil {
  9100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9101. return
  9102. }
  9103. body, ioErr := ioutil.ReadAll(resp.Body)
  9104. if ioErr != nil {
  9105. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9107. return
  9108. }
  9109. var respJSON map[string]interface{}
  9110. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9111. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9113. return
  9114. }
  9115. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9116. result, _ := json.Marshal(respJSON)
  9117. fmt.Println("log")
  9118. fmt.Println(string(result))
  9119. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9120. utils.ErrorLog("解析失败:%v", err)
  9121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9122. return
  9123. }
  9124. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9125. res.Output = resEleven10265.Output
  9126. res.ErrMsg = resEleven10265.ErrMsg
  9127. res.Cainfo = resEleven10265.Cainfo
  9128. res.WarnMsg = resEleven10265.WarnMsg
  9129. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9130. res.Infcode = infocode
  9131. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9132. result := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  9133. var dat map[string]interface{}
  9134. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9135. fmt.Println(dat)
  9136. } else {
  9137. fmt.Println(err)
  9138. }
  9139. userJSONBytes, _ := json.Marshal(dat)
  9140. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9141. utils.ErrorLog("解析失败:%v", err)
  9142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9143. return
  9144. }
  9145. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9146. fmt.Println("~~~~~~~")
  9147. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9148. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9149. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9150. resp, requestErr := http.Get(api)
  9151. if requestErr != nil {
  9152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9153. return
  9154. }
  9155. body, ioErr := ioutil.ReadAll(resp.Body)
  9156. if ioErr != nil {
  9157. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9159. return
  9160. }
  9161. var respJSON map[string]interface{}
  9162. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9163. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9165. return
  9166. }
  9167. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9168. result, _ := json.Marshal(respJSON)
  9169. fmt.Println("log")
  9170. fmt.Println(string(result))
  9171. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9172. utils.ErrorLog("解析失败:%v", err)
  9173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9174. return
  9175. }
  9176. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9177. res.Output = resEleven10265.Output
  9178. res.ErrMsg = resEleven10265.ErrMsg
  9179. res.Cainfo = resEleven10265.Cainfo
  9180. res.WarnMsg = resEleven10265.WarnMsg
  9181. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9182. res.Infcode = infocode
  9183. } else {
  9184. result := service.Gdyb5203(baseParams, businessParams)
  9185. //service.Gdyb5204(baseParams, businessParams)
  9186. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  9187. var dat map[string]interface{}
  9188. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9189. fmt.Println(dat)
  9190. } else {
  9191. fmt.Println(err)
  9192. }
  9193. userJSONBytes, _ := json.Marshal(dat)
  9194. if miConfig.Code == "H15049901371" {
  9195. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  9196. utils.ErrorLog("解析失败:%v", err)
  9197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9198. return
  9199. }
  9200. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9201. res.Output = resEleven10265.Output
  9202. res.ErrMsg = resEleven10265.ErrMsg
  9203. res.Cainfo = resEleven10265.Cainfo
  9204. res.WarnMsg = resEleven10265.WarnMsg
  9205. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9206. res.Infcode = infocode
  9207. } else {
  9208. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9209. utils.ErrorLog("解析失败:%v", err)
  9210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9211. return
  9212. }
  9213. }
  9214. }
  9215. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9216. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  9217. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  9218. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9219. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  9220. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9221. var doctor_name string
  9222. if roles.ID == 0 {
  9223. doctor_name = "管理员"
  9224. } else {
  9225. doctor_name = roles.UserName
  9226. }
  9227. yiliao_leibie := ""
  9228. switch order.MedType {
  9229. case "11":
  9230. yiliao_leibie = "普通门诊"
  9231. break
  9232. case "12":
  9233. yiliao_leibie = "门诊挂号"
  9234. break
  9235. case "13":
  9236. yiliao_leibie = "急诊"
  9237. break
  9238. case "14":
  9239. yiliao_leibie = "门诊特殊病"
  9240. break
  9241. case "15":
  9242. yiliao_leibie = "门诊统筹"
  9243. break
  9244. case "16":
  9245. yiliao_leibie = "门诊慢性病"
  9246. break
  9247. case "21":
  9248. yiliao_leibie = "普通住院"
  9249. break
  9250. }
  9251. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9252. if res.Infcode == 0 {
  9253. c.ServeSuccessJSON(map[string]interface{}{
  9254. "diagnosis": name,
  9255. "order_infos": orderInfos,
  9256. "number": order.MdtrtId,
  9257. "date": order.SettleAccountsDate,
  9258. "charge_admin": charge_admin,
  9259. "printor_admin": printor_admin,
  9260. "info": res.Output.Setlinfo,
  9261. "order": order,
  9262. "bedCostTotal": bedCostTotal,
  9263. "bedCostSelfTotal": bedCostSelfTotal,
  9264. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  9265. "operationCostTotal": operationCostTotal,
  9266. "operationCostSelfTotal": operationCostSelfTotal,
  9267. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  9268. "otherCostTotal": otherCostTotal,
  9269. "otherCostSelfTotal": otherCostSelfTotal,
  9270. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  9271. "materialCostTotal": materialCostTotal,
  9272. "materialCostSelfTotal": materialCostSelfTotal,
  9273. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  9274. "westernMedicineCostTotal": westernMedicineCostTotal,
  9275. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  9276. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  9277. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  9278. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  9279. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  9280. "checkCostTotal": checkCostTotal,
  9281. "checkCostSelfTotal": checkCostSelfTotal,
  9282. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  9283. "laboratoryCostTotal": laboratoryCostTotal,
  9284. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  9285. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  9286. "treatCostTotal": treatCostTotal,
  9287. "treatCostSelfTotal": treatCostSelfTotal,
  9288. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  9289. "doctor_info": doctor_info,
  9290. "doctor_code": adminRole_two.DoctorCode,
  9291. "doctor_name": doctor_name,
  9292. "health_card_no": order.PsnNo,
  9293. "department": departments.Name,
  9294. "yiliao_leibie": yiliao_leibie,
  9295. "after_money": order.AccountPrice,
  9296. "patient": patient,
  9297. "org_name": miConfig.OrgName,
  9298. "org_code": miConfig.Code,
  9299. "order_number": order.Number,
  9300. "his_hospital": his_hospital,
  9301. "his": his,
  9302. "dia_config": dia_config,
  9303. //"check_order_info": cus_slice,
  9304. })
  9305. }
  9306. }
  9307. }
  9308. func (c *HisApiController) CheckTreatment() {
  9309. patient_id, _ := c.GetInt64("patient_id")
  9310. id_card_no := c.GetString("id_card_no")
  9311. insutype := c.GetString("insutype")
  9312. med_type := c.GetString("med_type")
  9313. admin_user_id, _ := c.GetInt64("admin_user_id")
  9314. adminUser := c.GetAdminUserInfo()
  9315. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9316. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9317. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9318. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9319. if miConfig.MdtrtareaAdmvs == "421300" {
  9320. var res ResultTwo
  9321. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  9322. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9323. "&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)
  9324. resp, requestErr := http.Get(api)
  9325. if requestErr != nil {
  9326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9327. return
  9328. }
  9329. body, ioErr := ioutil.ReadAll(resp.Body)
  9330. if ioErr != nil {
  9331. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9333. return
  9334. }
  9335. var respJSON map[string]interface{}
  9336. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9337. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9339. return
  9340. }
  9341. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9342. result, _ := json.Marshal(respJSON)
  9343. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9344. utils.ErrorLog("解析失败:%v", err)
  9345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9346. return
  9347. }
  9348. if res.Infcode == 0 {
  9349. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  9350. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9351. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  9352. resp, requestErr := http.Get(api)
  9353. if requestErr != nil {
  9354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9355. return
  9356. }
  9357. body, ioErr := ioutil.ReadAll(resp.Body)
  9358. if ioErr != nil {
  9359. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9361. return
  9362. }
  9363. var respJSON map[string]interface{}
  9364. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9365. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9367. return
  9368. }
  9369. var res Result2001
  9370. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9371. result2, _ := json.Marshal(respJSON)
  9372. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9373. utils.ErrorLog("解析失败:%v", err)
  9374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9375. return
  9376. }
  9377. if res.Infcode == 0 {
  9378. c.ServeSuccessJSON(map[string]interface{}{
  9379. "msg": res.Output.Trtinfo,
  9380. })
  9381. }
  9382. } else {
  9383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9384. return
  9385. }
  9386. } else {
  9387. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9388. var dat map[string]interface{}
  9389. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9390. fmt.Println(dat)
  9391. } else {
  9392. fmt.Println(err)
  9393. }
  9394. userJSONBytes, _ := json.Marshal(dat)
  9395. var res ResultTwo
  9396. var res10265 ResultTwo10265
  9397. if miConfig.Code == "H15049901371" {
  9398. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9399. utils.ErrorLog("解析失败:%v", err)
  9400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9401. return
  9402. }
  9403. res.ErrMsg = res10265.ErrMsg
  9404. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9405. res.Infcode = infocode
  9406. res.Output = res10265.Output
  9407. res.InfRefmsgid = res10265.InfRefmsgid
  9408. } else {
  9409. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9410. utils.ErrorLog("解析失败:%v", err)
  9411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9412. return
  9413. }
  9414. }
  9415. var user_name string
  9416. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  9417. if role.ID == 0 {
  9418. user_name = "xxx"
  9419. } else {
  9420. user_name = role.UserName
  9421. }
  9422. baseParams := models.BaseParams{
  9423. SecretKey: miConfig.SecretKey,
  9424. FixmedinsCode: miConfig.Code,
  9425. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9426. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9427. OrgName: miConfig.OrgName,
  9428. Doctor: user_name,
  9429. }
  9430. if config.IsOpen == 1 {
  9431. if miConfig.Code == "H15049901371" {
  9432. if med_type == "14" {
  9433. if insutype == "390" {
  9434. med_type = "9933"
  9435. } else if insutype == "310" {
  9436. med_type = "990502"
  9437. }
  9438. } else if med_type == "11" {
  9439. med_type = "11"
  9440. }
  9441. }
  9442. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  9443. var dat map[string]interface{}
  9444. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9445. fmt.Println(dat)
  9446. } else {
  9447. fmt.Println(err)
  9448. }
  9449. var res Result2001
  9450. var res10265 Result2001Org10265
  9451. if miConfig.Code == "H15049901371" {
  9452. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9453. utils.ErrorLog("解析失败:%v", err)
  9454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9455. return
  9456. }
  9457. res.ErrMsg = res10265.ErrMsg
  9458. res.Output = res10265.Output
  9459. res.InfRefmsgid = res10265.InfRefmsgid
  9460. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9461. res.Infcode = infocode
  9462. } else {
  9463. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9464. utils.ErrorLog("解析失败:%v", err)
  9465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9466. return
  9467. }
  9468. }
  9469. if res.Infcode == 0 {
  9470. c.ServeSuccessJSON(map[string]interface{}{
  9471. "msg": res.Output.Trtinfo,
  9472. })
  9473. }
  9474. }
  9475. }
  9476. }
  9477. //func (c *HisApiController) PutRecord() {
  9478. // id, _ := c.GetInt64("id")
  9479. // record_time := c.GetString("record_time")
  9480. // timeLayout := "2006-01-02"
  9481. // loc, _ := time.LoadLocation("Local")
  9482. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9483. // if err != nil {
  9484. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9485. // return
  9486. // }
  9487. // recordDateTime := theTime.Unix()
  9488. //
  9489. // adminInfo := c.GetAdminUserInfo()
  9490. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  9491. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9492. //
  9493. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9494. //
  9495. // fmt.Println(miConfig.SecretKey)
  9496. //
  9497. // if patient == nil {
  9498. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9499. // return
  9500. // }
  9501. // if len(patient.IdCardNo) == 0 {
  9502. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  9503. // return
  9504. // }
  9505. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  9506. // if config.IsOpen == 1 {
  9507. // 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
  9508. // resp, requestErr := http.Get(api)
  9509. // if requestErr != nil {
  9510. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9511. // return
  9512. // }
  9513. // defer resp.Body.Close()
  9514. // body, ioErr := ioutil.ReadAll(resp.Body)
  9515. // if ioErr != nil {
  9516. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9517. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9518. // return
  9519. // }
  9520. // var respJSON map[string]interface{}
  9521. //
  9522. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9523. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9524. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9525. // return
  9526. // }
  9527. //
  9528. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9529. // userJSONBytes, _ := json.Marshal(userJSON)
  9530. // var res ResultTwo
  9531. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9532. // utils.ErrorLog("解析失败:%v", err)
  9533. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9534. // return
  9535. // }
  9536. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9537. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9538. // infoStr := string(Iinfos)
  9539. // idetinfoStr := string(Idetinfos)
  9540. //
  9541. // if res.Infcode == 0 {
  9542. // his := models.VMHisPatient{
  9543. // Status: 1,
  9544. // Ctime: time.Now().Unix(),
  9545. // Mtime: time.Now().Unix(),
  9546. // PsnNo: res.Output.Baseinfo.PsnNo,
  9547. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  9548. // Certno: res.Output.Baseinfo.Certno,
  9549. // PsnName: res.Output.Baseinfo.PsnName,
  9550. // Gend: res.Output.Baseinfo.Gend,
  9551. // Naty: res.Output.Baseinfo.Naty,
  9552. // Brdy: res.Output.Baseinfo.Brdy,
  9553. // Age: res.Output.Baseinfo.Age,
  9554. // Iinfo: infoStr,
  9555. // Idetinfo: idetinfoStr,
  9556. // PatientId: patient.ID,
  9557. // RecordDate: theTime.Unix(),
  9558. // UserOrgId: adminInfo.CurrentOrgId,
  9559. // AdminUserId: adminInfo.AdminUser.Id,
  9560. // IsReturn: 1,
  9561. // }
  9562. //
  9563. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  9564. // //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")
  9565. // //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")
  9566. //
  9567. // //var dat map[string]interface{}
  9568. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9569. // // fmt.Println(dat)
  9570. // //} else {
  9571. // // fmt.Println(err)
  9572. // //}
  9573. //
  9574. // var dat2 map[string]interface{}
  9575. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9576. // fmt.Println(dat2)
  9577. // } else {
  9578. // fmt.Println(err)
  9579. // }
  9580. //
  9581. // } else {
  9582. // adminUser := c.GetAdminUserInfo()
  9583. // errlog := &models.HisOrderError{
  9584. // UserOrgId: adminUser.CurrentOrgId,
  9585. // Ctime: time.Now().Unix(),
  9586. // Mtime: time.Now().Unix(),
  9587. // ErrMsg: res.ErrMsg,
  9588. // Status: 1,
  9589. // PatientId: id,
  9590. // RecordTime: recordDateTime,
  9591. // Stage: 1,
  9592. // }
  9593. // service.CreateErrMsgLog(errlog)
  9594. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  9595. // return
  9596. // }
  9597. // }
  9598. //
  9599. //}
  9600. //func (c *HisApiController) GetUploadDiag() {
  9601. // id, _ := c.GetInt64("id")
  9602. // record_time := c.GetString("record_time")
  9603. //
  9604. // diagnosis_id, _ := c.GetInt64("diagnosis")
  9605. // sick_type, _ := c.GetInt64("sick_type")
  9606. // reg_type, _ := c.GetInt64("reg_type")
  9607. //
  9608. // timeLayout := "2006-01-02"
  9609. // loc, _ := time.LoadLocation("Local")
  9610. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9611. // if err != nil {
  9612. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9613. // return
  9614. // }
  9615. //
  9616. // var patientPrescription models.HisPrescriptionInfo
  9617. // recordDateTime := theTime.Unix()
  9618. // adminInfo := c.GetAdminUserInfo()
  9619. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9620. //
  9621. // if patientPrescription.ID == 0 {
  9622. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9623. // }
  9624. //
  9625. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9626. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9627. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9628. // sickConfig, _ := service.FindSickById(sick_type)
  9629. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9630. //
  9631. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  9632. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  9633. // "&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 +
  9634. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  9635. // resp2, requestErr2 := http.Get(api2)
  9636. // if requestErr2 != nil {
  9637. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9638. // return
  9639. // }
  9640. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  9641. // if ioErr2 != nil {
  9642. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  9643. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9644. // return
  9645. // }
  9646. // var respJSON2 map[string]interface{}
  9647. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  9648. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9649. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9650. // return
  9651. // }
  9652. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9653. // userJSONBytes2, _ := json.Marshal(respJSON2)
  9654. //
  9655. // var res2 ResultSix
  9656. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9657. // utils.ErrorLog("解析失败:%v", err)
  9658. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9659. // return
  9660. // }
  9661. // if res2.Infcode != 0 {
  9662. // adminUser := c.GetAdminUserInfo()
  9663. // errlog := &models.HisOrderError{
  9664. // UserOrgId: adminUser.CurrentOrgId,
  9665. // Ctime: time.Now().Unix(),
  9666. // Mtime: time.Now().Unix(),
  9667. // ErrMsg: res2.ErrMsg,
  9668. // Status: 1,
  9669. // PatientId: id,
  9670. // RecordTime: recordDateTime,
  9671. // Stage: 3,
  9672. // }
  9673. // service.CreateErrMsgLog(errlog)
  9674. //
  9675. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  9676. // return
  9677. // }
  9678. //
  9679. // c.ServeSuccessJSON(map[string]interface{}{
  9680. // "msg": "上传成功",
  9681. // })
  9682. //
  9683. //}
  9684. type QueryResult struct {
  9685. ID int64
  9686. Name string
  9687. Code string
  9688. List_type_code string
  9689. }
  9690. func (c *HisApiController) GetCheckCode() {
  9691. ids_str := c.GetString("ids")
  9692. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9693. ids_arr := strings.Split(ids_str, ",")
  9694. var queryResult []QueryResult
  9695. ids := make([]int64, 0)
  9696. for _, item := range ids_arr {
  9697. id, _ := strconv.ParseInt(item, 10, 64)
  9698. ids = append(ids, id)
  9699. }
  9700. if record_type == 1 {
  9701. drugs, _ := service.GetBatchDrugList(ids)
  9702. for _, item := range drugs {
  9703. result := QueryResult{
  9704. ID: item.ID,
  9705. Name: item.DrugName,
  9706. Code: item.MedicalInsuranceNumber,
  9707. List_type_code: "101",
  9708. }
  9709. queryResult = append(queryResult, result)
  9710. }
  9711. } else if record_type == 2 {
  9712. goods, _ := service.GetBatchGoodInformationList(ids)
  9713. for _, item := range goods {
  9714. result := QueryResult{
  9715. ID: item.ID,
  9716. Name: item.GoodName,
  9717. Code: item.MedicalInsuranceNumber,
  9718. List_type_code: "301",
  9719. }
  9720. queryResult = append(queryResult, result)
  9721. }
  9722. } else if record_type == 3 {
  9723. projects, _ := service.GetBathchMyPorjecgList(ids)
  9724. for _, item := range projects {
  9725. result := QueryResult{
  9726. ID: item.ID,
  9727. Name: item.ProjectName,
  9728. Code: item.MedicalCode,
  9729. List_type_code: "201",
  9730. }
  9731. queryResult = append(queryResult, result)
  9732. }
  9733. }
  9734. admin_user_id, _ := c.GetInt64("admin_user_id")
  9735. adminUser := c.GetAdminUserInfo()
  9736. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9737. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9738. var user_name string
  9739. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9740. if role.ID == 0 {
  9741. user_name = "xxx"
  9742. } else {
  9743. user_name = role.UserName
  9744. }
  9745. baseParams := &models.BaseParams{
  9746. SecretKey: miConfig.SecretKey,
  9747. FixmedinsCode: miConfig.Code,
  9748. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9749. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9750. OrgName: miConfig.OrgName,
  9751. Doctor: user_name,
  9752. }
  9753. if config.IsOpen == 1 {
  9754. for _, item := range queryResult {
  9755. var result string
  9756. if record_type == 1 {
  9757. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9758. } else if record_type == 2 {
  9759. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9760. } else if record_type == 3 {
  9761. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9762. }
  9763. var dat map[string]interface{}
  9764. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9765. fmt.Println(dat)
  9766. } else {
  9767. fmt.Println(err)
  9768. }
  9769. userJSONBytes, _ := json.Marshal(dat)
  9770. var res ResultSix
  9771. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9772. utils.ErrorLog("解析失败:%v", err)
  9773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9774. return
  9775. }
  9776. if res.Infcode == 0 {
  9777. if record_type == 1 {
  9778. service.UpdateBaseDrugById(item.ID)
  9779. } else if record_type == 2 {
  9780. service.UpdateGoodInformaitonByDetail(item.ID)
  9781. } else if record_type == 3 {
  9782. service.UpdateProjectById(item.ID)
  9783. }
  9784. c.ServeSuccessJSON(map[string]interface{}{
  9785. "failed_code": 0,
  9786. "msg": "目录对照成功",
  9787. })
  9788. } else {
  9789. c.ServeSuccessJSON(map[string]interface{}{
  9790. "failed_code": -10,
  9791. "msg": res.ErrMsg,
  9792. })
  9793. }
  9794. }
  9795. }
  9796. }
  9797. func (c *HisApiController) UnCheckCode() {
  9798. ids_str := c.GetString("ids")
  9799. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9800. admin_user_id, _ := c.GetInt64("admin_user_id")
  9801. ids_arr := strings.Split(ids_str, ",")
  9802. var queryResult []QueryResult
  9803. ids := make([]int64, 0)
  9804. for _, item := range ids_arr {
  9805. id, _ := strconv.ParseInt(item, 10, 64)
  9806. ids = append(ids, id)
  9807. }
  9808. if record_type == 1 {
  9809. drugs, _ := service.GetBatchDrugList(ids)
  9810. for _, item := range drugs {
  9811. result := QueryResult{
  9812. ID: item.ID,
  9813. Name: item.DrugName,
  9814. Code: item.MedicalInsuranceNumber,
  9815. List_type_code: "101",
  9816. }
  9817. queryResult = append(queryResult, result)
  9818. }
  9819. } else if record_type == 2 {
  9820. goods, _ := service.GetBatchGoodInformationList(ids)
  9821. for _, item := range goods {
  9822. result := QueryResult{
  9823. ID: item.ID,
  9824. Name: item.GoodName,
  9825. Code: item.MedicalInsuranceNumber,
  9826. List_type_code: "301",
  9827. }
  9828. queryResult = append(queryResult, result)
  9829. }
  9830. } else if record_type == 3 {
  9831. projects, _ := service.GetBathchMyPorjecgList(ids)
  9832. for _, item := range projects {
  9833. result := QueryResult{
  9834. ID: item.ID,
  9835. Name: item.ProjectName,
  9836. Code: item.MedicalCode,
  9837. List_type_code: "201",
  9838. }
  9839. queryResult = append(queryResult, result)
  9840. }
  9841. }
  9842. adminUser := c.GetAdminUserInfo()
  9843. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9844. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9845. var user_name string
  9846. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9847. if role.ID == 0 {
  9848. user_name = "xxx"
  9849. } else {
  9850. user_name = role.UserName
  9851. }
  9852. baseParams := &models.BaseParams{
  9853. SecretKey: miConfig.SecretKey,
  9854. FixmedinsCode: miConfig.Code,
  9855. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9856. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9857. OrgName: miConfig.OrgName,
  9858. Doctor: user_name,
  9859. }
  9860. if config.IsOpen == 1 {
  9861. for _, item := range queryResult {
  9862. var result string
  9863. if record_type == 1 {
  9864. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9865. } else if record_type == 2 {
  9866. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9867. } else if record_type == 3 {
  9868. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9869. }
  9870. var dat2 map[string]interface{}
  9871. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  9872. fmt.Println(dat2)
  9873. } else {
  9874. fmt.Println(err)
  9875. }
  9876. userJSONBytes, _ := json.Marshal(dat2)
  9877. var res ResultSix
  9878. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9879. utils.ErrorLog("解析失败:%v", err)
  9880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9881. return
  9882. }
  9883. if res.Infcode == 0 {
  9884. if record_type == 1 {
  9885. service.UpdateDrugByIdDetail(item.ID)
  9886. } else if record_type == 2 {
  9887. service.UpdateGoodInfoById(item.ID)
  9888. } else if record_type == 3 {
  9889. service.UpdateMyProjectById(item.ID)
  9890. }
  9891. c.ServeSuccessJSON(map[string]interface{}{
  9892. "failed_code": 0,
  9893. "msg": "撤销目录对照成功",
  9894. })
  9895. } else {
  9896. c.ServeSuccessJSON(map[string]interface{}{
  9897. "failed_code": -10,
  9898. "msg": res.ErrMsg,
  9899. })
  9900. }
  9901. }
  9902. }
  9903. }
  9904. func (c *HisApiController) GetPatientInfo() {
  9905. id_card_no := c.GetString("id_card_no")
  9906. admin_user_id, _ := c.GetInt64("admin_user_id")
  9907. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  9908. if patient.ID == 0 {
  9909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9910. return
  9911. }
  9912. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9913. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9914. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  9915. if config.IsOpen == 1 {
  9916. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9917. var dat map[string]interface{}
  9918. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9919. fmt.Println(dat)
  9920. } else {
  9921. fmt.Println(err)
  9922. }
  9923. userJSONBytes, _ := json.Marshal(dat)
  9924. var res ResultTwo
  9925. var res10265 ResultTwo10265
  9926. if miConfig.Code == "H15049901371" {
  9927. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9928. utils.ErrorLog("解析失败:%v", err)
  9929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9930. return
  9931. }
  9932. res.ErrMsg = res10265.ErrMsg
  9933. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9934. res.Infcode = infocode
  9935. res.Output = res10265.Output
  9936. res.InfRefmsgid = res10265.InfRefmsgid
  9937. } else {
  9938. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9939. utils.ErrorLog("解析失败:%v", err)
  9940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9941. return
  9942. }
  9943. }
  9944. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9945. // utils.ErrorLog("解析失败:%v", err)
  9946. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9947. // return
  9948. //}
  9949. if res.Infcode != 0 {
  9950. c.ServeSuccessJSON(map[string]interface{}{
  9951. "failed_code": -10,
  9952. "msg": res.ErrMsg,
  9953. })
  9954. } else {
  9955. c.ServeSuccessJSON(map[string]interface{}{
  9956. "failed_code": 0,
  9957. "info": res,
  9958. })
  9959. }
  9960. }
  9961. }
  9962. func (c *HisApiController) PsnPutOnRecord() {
  9963. record_type, _ := c.GetInt64("type")
  9964. patient_id, _ := c.GetInt64("patient_id")
  9965. admin_user_id, _ := c.GetInt64("admin_user_id")
  9966. start_time := c.GetString("start_time")
  9967. end_time := c.GetString("end_time")
  9968. adminUser := c.GetAdminUserInfo()
  9969. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9970. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9971. var patients []*models.Patients
  9972. if record_type == 1 { //全部备案
  9973. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  9974. patients = append(patients, patient...)
  9975. } else { //单个备案
  9976. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9977. patients = append(patients, patient)
  9978. }
  9979. var user_name string
  9980. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9981. if role.ID == 0 {
  9982. user_name = "xxx"
  9983. } else {
  9984. user_name = role.UserName
  9985. }
  9986. if config.IsOpen == 1 {
  9987. for _, item := range patients {
  9988. 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
  9989. resp, requestErr := http.Get(api)
  9990. if requestErr != nil {
  9991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9992. return
  9993. }
  9994. defer resp.Body.Close()
  9995. body, ioErr := ioutil.ReadAll(resp.Body)
  9996. if ioErr != nil {
  9997. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9999. return
  10000. }
  10001. var respJSON map[string]interface{}
  10002. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10003. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10005. return
  10006. }
  10007. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10008. userJSONBytes, _ := json.Marshal(userJSON)
  10009. var res ResultTwo
  10010. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10011. utils.ErrorLog("解析失败:%v", err)
  10012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10013. return
  10014. }
  10015. if res.Infcode == 0 {
  10016. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  10017. var dat map[string]interface{}
  10018. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10019. fmt.Println(dat)
  10020. } else {
  10021. fmt.Println(err)
  10022. }
  10023. userJSONBytes, _ := json.Marshal(dat)
  10024. var res2 ResultThirteen
  10025. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10026. utils.ErrorLog("解析失败:%v", err)
  10027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10028. return
  10029. }
  10030. if res2.Infcode == 0 {
  10031. psnResult := &models.GdybPsnRecord{
  10032. UserOrgId: adminUser.CurrentOrgId,
  10033. PatientId: item.ID,
  10034. PsnNo: res.Output.Baseinfo.PsnNo,
  10035. Ctime: time.Now().Unix(),
  10036. Mtime: time.Now().Unix(),
  10037. Status: 1,
  10038. IsCancel: 1,
  10039. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10040. }
  10041. service.CreatePsnRecord(psnResult)
  10042. } else {
  10043. c.ServeSuccessJSON(map[string]interface{}{
  10044. "failed_code": -10,
  10045. "msg": res2.ErrMsg,
  10046. })
  10047. return
  10048. }
  10049. }
  10050. }
  10051. }
  10052. }
  10053. func (c *HisApiController) PsnUnPutOnRecord() {
  10054. id, _ := c.GetInt64("id")
  10055. //record_type, _ := c.GetInt64("type")
  10056. admin_user_id, _ := c.GetInt64("admin_user_id")
  10057. adminUser := c.GetAdminUserInfo()
  10058. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10059. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10060. var user_name string
  10061. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10062. if role.ID == 0 {
  10063. user_name = "xxx"
  10064. } else {
  10065. user_name = role.UserName
  10066. }
  10067. psn_record, _ := service.GetPsnRecordById(id)
  10068. if psn_record.ID == 0 {
  10069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10070. return
  10071. }
  10072. if config.IsOpen == 1 {
  10073. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10074. var dat map[string]interface{}
  10075. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10076. fmt.Println(dat)
  10077. } else {
  10078. fmt.Println(err)
  10079. }
  10080. userJSONBytes, _ := json.Marshal(dat)
  10081. var res ResultFourteen
  10082. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10083. utils.ErrorLog("解析失败:%v", err)
  10084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10085. return
  10086. }
  10087. if res.Infcode == 0 {
  10088. psn_record.IsCancel = 2
  10089. service.CreatePsnRecord(&psn_record)
  10090. } else {
  10091. c.ServeSuccessJSON(map[string]interface{}{
  10092. "failed_code": -10,
  10093. "msg": res.ErrMsg,
  10094. })
  10095. return
  10096. }
  10097. }
  10098. }
  10099. func (c *HisApiController) PsnPutNCDSOnRecord() {
  10100. patient_id, _ := c.GetInt64("patient_id")
  10101. insutype_two := c.GetString("insutype")
  10102. psn_no := c.GetString("psn_no")
  10103. doctor_id, _ := c.GetInt64("doctor_id")
  10104. sick_id, _ := c.GetInt64("sick_id")
  10105. department_id, _ := c.GetInt64("department_id")
  10106. start_time := c.GetString("start_time")
  10107. end_time := c.GetString("end_time")
  10108. check_time := c.GetString("check_time")
  10109. adminUser := c.GetAdminUserInfo()
  10110. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10111. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10112. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10113. sick, _ := service.FindSickById(sick_id)
  10114. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10115. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10116. var res ResultTwo
  10117. var res10265 ResultTwo10265
  10118. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10119. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  10120. api := "http://192.168.2.110:9532/" + "hbyb/1101?cert_no=" + "" +
  10121. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  10122. "&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
  10123. resp, requestErr := http.Get(api)
  10124. if requestErr != nil {
  10125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10126. return
  10127. }
  10128. body, ioErr := ioutil.ReadAll(resp.Body)
  10129. if ioErr != nil {
  10130. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10132. return
  10133. }
  10134. var respJSON map[string]interface{}
  10135. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10136. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10138. return
  10139. }
  10140. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10141. result, _ := json.Marshal(respJSON)
  10142. fmt.Println("log")
  10143. fmt.Println(string(result))
  10144. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10145. utils.ErrorLog("解析失败:%v", err)
  10146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10147. return
  10148. }
  10149. res.ErrMsg = res10265.ErrMsg
  10150. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10151. res.Infcode = infocode
  10152. res.Output = res10265.Output
  10153. res.InfRefmsgid = res10265.InfRefmsgid
  10154. } else {
  10155. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10156. if miConfig.Code == "H15049901371" {
  10157. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10158. utils.ErrorLog("解析失败:%v", err)
  10159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10160. return
  10161. }
  10162. res.ErrMsg = res10265.ErrMsg
  10163. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10164. res.Infcode = infocode
  10165. res.Output = res10265.Output
  10166. res.InfRefmsgid = res10265.InfRefmsgid
  10167. } else {
  10168. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10169. utils.ErrorLog("解析失败:%v", err)
  10170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10171. return
  10172. }
  10173. }
  10174. }
  10175. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10176. infoStr := string(Iinfos)
  10177. var rf []*ResultFive
  10178. json.Unmarshal([]byte(infoStr), &rf)
  10179. var insuplc_admdvs string
  10180. var insutype string
  10181. var is390 int = 0
  10182. var is310 int = 0
  10183. var insutypes []*ResultFive
  10184. for _, item := range rf {
  10185. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10186. insutypes = append(insutypes, item)
  10187. }
  10188. }
  10189. if len(insutypes) == 1 {
  10190. insutype = insutypes[0].Insutype
  10191. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10192. } else {
  10193. for _, i := range insutypes {
  10194. if i.Insutype == "390" {
  10195. is390 = 1
  10196. }
  10197. if i.Insutype == "310" {
  10198. is310 = 1
  10199. }
  10200. }
  10201. }
  10202. if is390 == 1 {
  10203. insutype = "390"
  10204. }
  10205. if is310 == 1 {
  10206. insutype = "310"
  10207. }
  10208. if len(insutypes) == 2 {
  10209. insutype = insutype_two
  10210. }
  10211. if len(insutypes) == 0 {
  10212. insutype = "310"
  10213. }
  10214. insutype = insutype_two
  10215. fmt.Println(insutype)
  10216. for _, item := range rf {
  10217. fmt.Println(item.Insutype)
  10218. fmt.Println(insutype)
  10219. if item.Insutype == insutype {
  10220. fmt.Println(item.Insutype)
  10221. fmt.Println(insutype)
  10222. insuplc_admdvs = item.InsuplcAdmdvs
  10223. }
  10224. }
  10225. fmt.Println(insuplc_admdvs)
  10226. var res2 ResultThirteen
  10227. var res10265_2 ResultThirteen10265
  10228. if config.IsOpen == 1 {
  10229. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10230. } else {
  10231. 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)
  10232. var dat map[string]interface{}
  10233. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10234. fmt.Println(dat)
  10235. } else {
  10236. fmt.Println(err)
  10237. }
  10238. userJSONBytes, _ := json.Marshal(dat)
  10239. if miConfig.Code == "H15049901371" {
  10240. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  10241. utils.ErrorLog("解析失败:%v", err)
  10242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10243. return
  10244. }
  10245. res2.ErrMsg = res10265_2.ErrMsg
  10246. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  10247. res2.Infcode = infocode
  10248. res2.Output = res10265_2.Output
  10249. res2.InfRefmsgid = res10265_2.InfRefmsgid
  10250. } else {
  10251. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10252. utils.ErrorLog("解析失败:%v", err)
  10253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10254. return
  10255. }
  10256. }
  10257. }
  10258. if res2.Infcode == 0 {
  10259. psnResult := &models.GdybPsnNcdsRecord{
  10260. UserOrgId: adminUser.CurrentOrgId,
  10261. PatientId: patient.ID,
  10262. PsnNo: psn_no,
  10263. DoctorId: doctor.AdminUserId,
  10264. DepartmentId: department_id,
  10265. SickType: sick_id,
  10266. Insutype: insutype,
  10267. Ctime: time.Now().Unix(),
  10268. Mtime: time.Now().Unix(),
  10269. Status: 1,
  10270. IsCancel: 1,
  10271. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10272. }
  10273. service.CreatePsnNCDSRecord(psnResult)
  10274. c.ServeSuccessJSON(map[string]interface{}{
  10275. "failed_code": 0,
  10276. "msg": "备案成功",
  10277. "result": psnResult,
  10278. })
  10279. } else {
  10280. c.ServeSuccessJSON(map[string]interface{}{
  10281. "failed_code": -10,
  10282. "msg": res2.ErrMsg,
  10283. })
  10284. return
  10285. }
  10286. }
  10287. }
  10288. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  10289. id, _ := c.GetInt64("id")
  10290. admin_user_id, _ := c.GetInt64("admin_user_id")
  10291. adminUser := c.GetAdminUserInfo()
  10292. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10293. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10294. //config, _ := service.Ge(adminUser.CurrentOrgId)
  10295. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  10296. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10297. //var user_name string
  10298. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10299. //if role.ID == 0 {
  10300. // user_name = "xxx"
  10301. //} else {
  10302. // user_name = role.UserName
  10303. //}
  10304. psn_record, _ := service.GetPsnNCDSRecordById(id)
  10305. if psn_record.ID == 0 {
  10306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10307. return
  10308. }
  10309. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10310. var res ResultTwo
  10311. var res10265 ResultTwo10265
  10312. if miConfig.Code == "H15049901371" {
  10313. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10314. utils.ErrorLog("解析失败:%v", err)
  10315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10316. return
  10317. }
  10318. res.ErrMsg = res10265.ErrMsg
  10319. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10320. res.Infcode = infocode
  10321. res.Output = res10265.Output
  10322. res.InfRefmsgid = res10265.InfRefmsgid
  10323. } else {
  10324. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10325. utils.ErrorLog("解析失败:%v", err)
  10326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10327. return
  10328. }
  10329. }
  10330. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10331. infoStr := string(Iinfos)
  10332. var rf []*ResultFive
  10333. json.Unmarshal([]byte(infoStr), &rf)
  10334. var insuplc_admdvs string
  10335. var insutype string
  10336. var is390 int = 0
  10337. var is310 int = 0
  10338. var insutypes []*ResultFive
  10339. for _, item := range rf {
  10340. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10341. insutypes = append(insutypes, item)
  10342. }
  10343. }
  10344. if len(insutypes) == 1 {
  10345. insutype = insutypes[0].Insutype
  10346. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10347. } else {
  10348. for _, i := range insutypes {
  10349. if i.Insutype == "390" {
  10350. is390 = 1
  10351. }
  10352. if i.Insutype == "310" {
  10353. is310 = 1
  10354. }
  10355. }
  10356. }
  10357. if is390 == 1 {
  10358. insutype = "390"
  10359. }
  10360. if is310 == 1 {
  10361. insutype = "310"
  10362. }
  10363. if len(insutypes) == 0 {
  10364. insutype = "310"
  10365. }
  10366. insutype = psn_record.Insutype
  10367. for _, item := range rf {
  10368. if item.Insutype == insutype {
  10369. insuplc_admdvs = item.InsuplcAdmdvs
  10370. }
  10371. }
  10372. if config.IsOpen == 1 {
  10373. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10374. var dat map[string]interface{}
  10375. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10376. fmt.Println(dat)
  10377. } else {
  10378. fmt.Println(err)
  10379. }
  10380. userJSONBytes, _ := json.Marshal(dat)
  10381. var res ResultFourteen
  10382. var res10265 ResultFourteen10265
  10383. if miConfig.Code == "H15049901371" {
  10384. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10385. utils.ErrorLog("解析失败:%v", err)
  10386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10387. return
  10388. }
  10389. res.ErrMsg = res10265.ErrMsg
  10390. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10391. res.Infcode = infocode
  10392. res.Output = res10265.Output
  10393. res.InfRefmsgid = res10265.InfRefmsgid
  10394. } else {
  10395. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10396. utils.ErrorLog("解析失败:%v", err)
  10397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10398. return
  10399. }
  10400. }
  10401. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10402. // utils.ErrorLog("解析失败:%v", err)
  10403. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10404. // return
  10405. //}
  10406. if res.Infcode == 0 {
  10407. psn_record.IsCancel = 2
  10408. service.CreatePsnNCDSRecord(&psn_record)
  10409. c.ServeSuccessJSON(map[string]interface{}{
  10410. "failed_code": 0,
  10411. "msg": "撤销备案成功",
  10412. })
  10413. } else {
  10414. c.ServeSuccessJSON(map[string]interface{}{
  10415. "failed_code": -10,
  10416. "msg": res.ErrMsg,
  10417. })
  10418. return
  10419. }
  10420. }
  10421. }
  10422. func (c *HisApiController) TestTest() {
  10423. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  10424. fmt.Println(patient.Iinfo)
  10425. }
  10426. type CustomData struct {
  10427. MsgId string
  10428. PsnNo string
  10429. Info string
  10430. }
  10431. func (c *HisApiController) ReversalData() {
  10432. var customData []*CustomData
  10433. custom := &CustomData{
  10434. MsgId: "H44022900158202103301714472004",
  10435. PsnNo: "44020000001101329945",
  10436. Info: "2207",
  10437. }
  10438. customData = append(customData, custom)
  10439. custom1 := &CustomData{
  10440. MsgId: "H4402290015820210330172057803",
  10441. PsnNo: "44020000001101161813",
  10442. Info: "2207",
  10443. }
  10444. customData = append(customData, custom1)
  10445. custom2 := &CustomData{
  10446. MsgId: "H44022900158202103301705198813",
  10447. PsnNo: "44190000133097375417",
  10448. Info: "2207",
  10449. }
  10450. customData = append(customData, custom2)
  10451. custom3 := &CustomData{
  10452. MsgId: "H44022900158202103301715524756",
  10453. PsnNo: "44020000001100187221",
  10454. Info: "2207",
  10455. }
  10456. customData = append(customData, custom3)
  10457. custom4 := &CustomData{
  10458. MsgId: "H44022900158202103301730376224",
  10459. PsnNo: "44020000001101959155",
  10460. Info: "2207",
  10461. }
  10462. customData = append(customData, custom4)
  10463. custom5 := &CustomData{
  10464. MsgId: "H44022900158202103301748008725",
  10465. PsnNo: "44020000001104246641",
  10466. Info: "2207",
  10467. }
  10468. customData = append(customData, custom5)
  10469. custom6 := &CustomData{
  10470. MsgId: "H44022900158202103301718096755",
  10471. PsnNo: "44020000001102211860",
  10472. Info: "2207",
  10473. }
  10474. customData = append(customData, custom6)
  10475. custom7 := &CustomData{
  10476. MsgId: "H44022900158202103301736551640",
  10477. PsnNo: "44020000001102687718",
  10478. Info: "2207",
  10479. }
  10480. customData = append(customData, custom7)
  10481. custom8 := &CustomData{
  10482. MsgId: "H44022900158202103301743097676",
  10483. PsnNo: "44020000001102127785",
  10484. Info: "2207",
  10485. }
  10486. customData = append(customData, custom8)
  10487. custom9 := &CustomData{
  10488. MsgId: "H44022900158202103301712304203",
  10489. PsnNo: "44020000001101518097",
  10490. Info: "2207",
  10491. }
  10492. customData = append(customData, custom9)
  10493. custom10 := &CustomData{
  10494. MsgId: "H44022900158202103301738448785",
  10495. PsnNo: "44020000001100500813",
  10496. Info: "2207",
  10497. }
  10498. customData = append(customData, custom10)
  10499. custom11 := &CustomData{
  10500. MsgId: "H44022900158202103301732455843",
  10501. PsnNo: "44020000001102690557",
  10502. Info: "2207",
  10503. }
  10504. customData = append(customData, custom11)
  10505. custom12 := &CustomData{
  10506. MsgId: "H44022900158202103301745421708",
  10507. PsnNo: "44020000001102211928",
  10508. Info: "2207",
  10509. }
  10510. customData = append(customData, custom12)
  10511. custom1212 := &CustomData{
  10512. MsgId: "H440229001582021033017351627",
  10513. PsnNo: "44020000001102481733",
  10514. Info: "2207",
  10515. }
  10516. customData = append(customData, custom1212)
  10517. custom13 := &CustomData{
  10518. MsgId: "H44022900158202103301740327951",
  10519. PsnNo: "44020000001103174866",
  10520. Info: "2207",
  10521. }
  10522. customData = append(customData, custom13)
  10523. custom14 := &CustomData{
  10524. MsgId: "H4402290015820210330174922668",
  10525. PsnNo: "44020000001102927272",
  10526. Info: "2207",
  10527. }
  10528. customData = append(customData, custom14)
  10529. custom15 := &CustomData{
  10530. MsgId: "H44022900158202103301752362273",
  10531. PsnNo: "44020000001102942890",
  10532. Info: "2207",
  10533. }
  10534. customData = append(customData, custom15)
  10535. custom16 := &CustomData{
  10536. MsgId: "H44022900158202103301751082917",
  10537. PsnNo: "44020000001101662162",
  10538. Info: "2207",
  10539. }
  10540. customData = append(customData, custom16)
  10541. custom17 := &CustomData{
  10542. MsgId: "H44022900158202103301754147728",
  10543. PsnNo: "44020000000229014511",
  10544. Info: "2207",
  10545. }
  10546. customData = append(customData, custom17)
  10547. adminUser := c.GetAdminUserInfo()
  10548. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10549. for _, item := range customData {
  10550. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10551. fmt.Println(result)
  10552. }
  10553. }
  10554. //func (c *HisApiController) GetAllopatry() {
  10555. // year := c.GetString("year")
  10556. // month := c.GetString("month")
  10557. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10558. // adminUser := c.GetAdminUserInfo()
  10559. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10560. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10561. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10562. //
  10563. // var dat map[string]interface{}
  10564. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10565. // fmt.Println(dat)
  10566. // } else {
  10567. // fmt.Println(err)
  10568. // }
  10569. // userJSONBytes, _ := json.Marshal(dat)
  10570. // var res models.Result9001
  10571. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10572. // utils.ErrorLog("解析失败:%v", err)
  10573. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10574. // return
  10575. // }
  10576. //
  10577. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10578. // var dat2 map[string]interface{}
  10579. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10580. // fmt.Println(dat)
  10581. // } else {
  10582. // fmt.Println(err)
  10583. // }
  10584. // userJSONBytes2, _ := json.Marshal(dat2)
  10585. // var res2 models.Result3260
  10586. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10587. // utils.ErrorLog("解析失败:%v", err)
  10588. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10589. // return
  10590. // }
  10591. // if res2.Infcode == 0 {
  10592. // c.ServeSuccessJSON(map[string]interface{}{
  10593. // "list": res2.Output.Data,
  10594. // })
  10595. // return
  10596. // } else {
  10597. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10598. // return
  10599. // }
  10600. //
  10601. //}
  10602. //func (c *HisApiController) ComfirmAllopatry() {
  10603. // year := c.GetString("year")
  10604. // month := c.GetString("month")
  10605. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10606. // adminUser := c.GetAdminUserInfo()
  10607. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10608. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10609. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10610. // var dat map[string]interface{}
  10611. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10612. // fmt.Println(dat)
  10613. // } else {
  10614. // fmt.Println(err)
  10615. // }
  10616. // userJSONBytes, _ := json.Marshal(dat)
  10617. // var res models.Result9001
  10618. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10619. // utils.ErrorLog("解析失败:%v", err)
  10620. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10621. // return
  10622. // }
  10623. //
  10624. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10625. // var dat2 map[string]interface{}
  10626. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10627. // fmt.Println(dat)
  10628. // } else {
  10629. // fmt.Println(err)
  10630. // }
  10631. // userJSONBytes2, _ := json.Marshal(dat2)
  10632. // var res2 models.Result3260
  10633. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10634. // utils.ErrorLog("解析失败:%v", err)
  10635. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10636. // return
  10637. // }
  10638. //
  10639. // if res2.Infcode == 0 {
  10640. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  10641. // var dat map[string]interface{}
  10642. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10643. // fmt.Println(dat)
  10644. // } else {
  10645. // fmt.Println(err)
  10646. // }
  10647. // userJSONBytes, _ := json.Marshal(dat)
  10648. // var res3 models.Result3261
  10649. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  10650. // utils.ErrorLog("解析失败:%v", err)
  10651. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10652. // return
  10653. // }
  10654. //
  10655. // if res3.Infcode == 0 {
  10656. // record := &models.HisYidiClearRecord{
  10657. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10658. // Ctime: time.Now().Unix(),
  10659. // Mtime: time.Now().Unix(),
  10660. // Status: 1,
  10661. // MsgId: msgId,
  10662. // }
  10663. // service.SaveClearRecord(record)
  10664. // c.ServeSuccessJSON(map[string]interface{}{
  10665. // "msg": "提取成功",
  10666. // })
  10667. // }
  10668. // }
  10669. //}
  10670. func (c *HisApiController) RefundAllopatry() {
  10671. year := c.GetString("year")
  10672. month := c.GetString("month")
  10673. id, _ := c.GetInt64("id")
  10674. admin_user_id, _ := c.GetInt64("admin_user_id")
  10675. adminUser := c.GetAdminUserInfo()
  10676. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10677. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10678. record, _ := service.GetClearRecordById(id)
  10679. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  10680. var dat map[string]interface{}
  10681. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10682. fmt.Println(dat)
  10683. } else {
  10684. fmt.Println(err)
  10685. }
  10686. userJSONBytes, _ := json.Marshal(dat)
  10687. var empty ResultFourteen
  10688. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  10689. utils.ErrorLog("解析失败:%v", err)
  10690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10691. return
  10692. }
  10693. if empty.Infcode == 0 {
  10694. c.ServeSuccessJSON(map[string]interface{}{
  10695. "msg": "撤销成功",
  10696. })
  10697. return
  10698. }
  10699. }
  10700. func (c *HisApiController) ReversalOtherData() {
  10701. var customData []*CustomData
  10702. custom := &CustomData{
  10703. MsgId: "H44022900158202103301714472004",
  10704. PsnNo: "44020000001101329945",
  10705. Info: "2208",
  10706. }
  10707. customData = append(customData, custom)
  10708. custom1 := &CustomData{
  10709. MsgId: "H4402290015820210330172057803",
  10710. PsnNo: "44020000001101161813",
  10711. Info: "2208",
  10712. }
  10713. customData = append(customData, custom1)
  10714. custom2 := &CustomData{
  10715. MsgId: "H44022900158202103301705198813",
  10716. PsnNo: "44190000133097375417",
  10717. Info: "2208",
  10718. }
  10719. customData = append(customData, custom2)
  10720. custom3 := &CustomData{
  10721. MsgId: "H44022900158202103301715524756",
  10722. PsnNo: "44020000001100187221",
  10723. Info: "2208",
  10724. }
  10725. customData = append(customData, custom3)
  10726. custom4 := &CustomData{
  10727. MsgId: "H44022900158202103301730376224",
  10728. PsnNo: "44020000001101959155",
  10729. Info: "2208",
  10730. }
  10731. customData = append(customData, custom4)
  10732. custom5 := &CustomData{
  10733. MsgId: "H44022900158202103301748008725",
  10734. PsnNo: "44020000001104246641",
  10735. Info: "2208",
  10736. }
  10737. customData = append(customData, custom5)
  10738. custom6 := &CustomData{
  10739. MsgId: "H44022900158202103301718096755",
  10740. PsnNo: "44020000001102211860",
  10741. Info: "2208",
  10742. }
  10743. customData = append(customData, custom6)
  10744. custom7 := &CustomData{
  10745. MsgId: "H44022900158202103301736551640",
  10746. PsnNo: "44020000001102687718",
  10747. Info: "2208",
  10748. }
  10749. customData = append(customData, custom7)
  10750. custom8 := &CustomData{
  10751. MsgId: "H44022900158202103301743097676",
  10752. PsnNo: "44020000001102127785",
  10753. Info: "2208",
  10754. }
  10755. customData = append(customData, custom8)
  10756. custom9 := &CustomData{
  10757. MsgId: "H44022900158202103301712304203",
  10758. PsnNo: "44020000001101518097",
  10759. Info: "2208",
  10760. }
  10761. customData = append(customData, custom9)
  10762. custom10 := &CustomData{
  10763. MsgId: "H44022900158202103301738448785",
  10764. PsnNo: "44020000001100500813",
  10765. Info: "2208",
  10766. }
  10767. customData = append(customData, custom10)
  10768. custom11 := &CustomData{
  10769. MsgId: "H44022900158202103301732455843",
  10770. PsnNo: "44020000001102690557",
  10771. Info: "2208",
  10772. }
  10773. customData = append(customData, custom11)
  10774. custom12 := &CustomData{
  10775. MsgId: "H44022900158202103301745421708",
  10776. PsnNo: "44020000001102211928",
  10777. Info: "2208",
  10778. }
  10779. customData = append(customData, custom12)
  10780. custom1212 := &CustomData{
  10781. MsgId: "H440229001582021033017351627",
  10782. PsnNo: "44020000001102481733",
  10783. Info: "2208",
  10784. }
  10785. customData = append(customData, custom1212)
  10786. custom13 := &CustomData{
  10787. MsgId: "H44022900158202103301740327951",
  10788. PsnNo: "44020000001103174866",
  10789. Info: "2208",
  10790. }
  10791. customData = append(customData, custom13)
  10792. custom14 := &CustomData{
  10793. MsgId: "H4402290015820210330174922668",
  10794. PsnNo: "44020000001102927272",
  10795. Info: "2208",
  10796. }
  10797. customData = append(customData, custom14)
  10798. custom15 := &CustomData{
  10799. MsgId: "H44022900158202103301752362273",
  10800. PsnNo: "44020000001102942890",
  10801. Info: "2208",
  10802. }
  10803. customData = append(customData, custom15)
  10804. custom16 := &CustomData{
  10805. MsgId: "H44022900158202103301751082917",
  10806. PsnNo: "44020000001101662162",
  10807. Info: "2208",
  10808. }
  10809. customData = append(customData, custom16)
  10810. custom17 := &CustomData{
  10811. MsgId: "H44022900158202103301754147728",
  10812. PsnNo: "44020000000229014511",
  10813. Info: "2208",
  10814. }
  10815. customData = append(customData, custom17)
  10816. adminUser := c.GetAdminUserInfo()
  10817. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10818. for _, item := range customData {
  10819. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10820. fmt.Println(result)
  10821. }
  10822. }
  10823. func PathExists(path string) (bool, error) {
  10824. _, err := os.Stat(path)
  10825. if err == nil {
  10826. return true, nil
  10827. }
  10828. if os.IsNotExist(err) {
  10829. return false, nil
  10830. }
  10831. return false, err
  10832. }
  10833. //创建文件夹
  10834. func Mkdir(dir string) {
  10835. // 创建文件夹
  10836. exist, err := PathExists(dir)
  10837. if err != nil {
  10838. fmt.Println(err.Error())
  10839. } else {
  10840. if exist {
  10841. fmt.Println(dir + "文件夹已存在!")
  10842. } else {
  10843. // 文件夹名称,权限
  10844. err := os.Mkdir(dir, os.ModePerm)
  10845. if err != nil {
  10846. fmt.Println(dir+"文件夹创建失败:", err.Error())
  10847. } else {
  10848. fmt.Println(dir + "文件夹创建成功!")
  10849. }
  10850. }
  10851. }
  10852. }
  10853. //压缩文件
  10854. func Zip(srcFile string, destZip string) error {
  10855. zipfile, err := os.Create(destZip)
  10856. if err != nil {
  10857. return err
  10858. }
  10859. defer zipfile.Close()
  10860. archive := zip.NewWriter(zipfile)
  10861. defer archive.Close()
  10862. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  10863. if err != nil {
  10864. return err
  10865. }
  10866. header, err := zip.FileInfoHeader(info)
  10867. if err != nil {
  10868. return err
  10869. }
  10870. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  10871. // header.Name = path
  10872. if info.IsDir() {
  10873. header.Name += "/"
  10874. } else {
  10875. header.Method = zip.Deflate
  10876. }
  10877. writer, err := archive.CreateHeader(header)
  10878. if err != nil {
  10879. return err
  10880. }
  10881. if !info.IsDir() {
  10882. file, err := os.Open(path)
  10883. if err != nil {
  10884. return err
  10885. }
  10886. defer file.Close()
  10887. _, err = io.Copy(writer, file)
  10888. }
  10889. return err
  10890. })
  10891. return err
  10892. }
  10893. func ReadFile(filePath string) []byte {
  10894. f, err := os.Open(filePath)
  10895. if err != nil {
  10896. fmt.Println("read file fail", err)
  10897. return nil
  10898. }
  10899. defer f.Close()
  10900. fd, err := ioutil.ReadAll(f)
  10901. if err != nil {
  10902. fmt.Println("read to fd fail", err)
  10903. return nil
  10904. }
  10905. return fd
  10906. }
  10907. func saveLog(result string, request string, infno string, desc string) {
  10908. org_id, _ := beego.AppConfig.Int64("org_id")
  10909. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  10910. dir := miConfig.OrgName + "日志"
  10911. utils.Mkdir(dir)
  10912. month := time.Unix(1557042972, 0).Format("1")
  10913. year := time.Now().Format("2006")
  10914. month = time.Now().Format("01")
  10915. day := time.Now().Format("02")
  10916. hour := time.Now().Format("15")
  10917. min := time.Now().Format("04")
  10918. sec := time.Now().Format("05")
  10919. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  10920. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  10921. file_name := file + ".txt"
  10922. file_path := miConfig.OrgName + "日志" + "/" + file_name
  10923. exist, _ := utils.PathExists(file_path)
  10924. if exist { //存在
  10925. fmt.Println("存在")
  10926. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  10927. if err != nil {
  10928. fmt.Println("read fail")
  10929. }
  10930. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  10931. n, _ := f.Seek(0, 2)
  10932. _, err = f.WriteAt([]byte(content), n)
  10933. } else { //不存在
  10934. fmt.Println("文件不存在,创建文件")
  10935. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  10936. defer f.Close()
  10937. if err != nil {
  10938. } else {
  10939. _, err = f.Write([]byte("记录日志"))
  10940. }
  10941. }
  10942. }
  10943. type Charset string
  10944. const (
  10945. UTF8 = Charset("UTF-8")
  10946. GB18030 = Charset("GB18030")
  10947. )
  10948. func ConvertToString(src string, srcCode string, tagCode string) string {
  10949. srcCoder := mahonia.NewDecoder(srcCode)
  10950. srcResult := srcCoder.ConvertString(src)
  10951. tagCoder := mahonia.NewDecoder(tagCode)
  10952. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  10953. result := string(cdata)
  10954. return result
  10955. }
  10956. func (c *HisApiController) ReadEleCard() {
  10957. id_card_type, _ := c.GetInt64("id_card_type")
  10958. admin_user_id, _ := c.GetInt64("admin_user_id")
  10959. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  10960. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10961. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10962. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10963. var api string
  10964. if miConfig.MdtrtareaAdmvs == "320921" {
  10965. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  10966. "&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
  10967. fmt.Println(api)
  10968. } else {
  10969. 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 +
  10970. "&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)
  10971. }
  10972. resp, requestErr := http.Get(api)
  10973. if requestErr != nil {
  10974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10975. return
  10976. }
  10977. body, ioErr := ioutil.ReadAll(resp.Body)
  10978. if ioErr != nil {
  10979. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10981. return
  10982. }
  10983. var respJSON map[string]interface{}
  10984. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10985. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10987. return
  10988. }
  10989. var status string
  10990. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10991. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10992. var token string
  10993. var res ResultTwo //1101结果
  10994. var res10265 ResultTwo10265 //1101结果
  10995. if status == "0" { //读卡成功
  10996. var card_info string //卡信息
  10997. var busi_card_info string
  10998. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10999. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  11000. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  11001. fmt.Println(card_info)
  11002. fmt.Println(busi_card_info)
  11003. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  11004. result, _ := json.Marshal(respJSON)
  11005. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11006. utils.ErrorLog("解析失败:%v", err)
  11007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11008. return
  11009. }
  11010. res.ErrMsg = res10265.ErrMsg
  11011. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11012. res.Infcode = infocode
  11013. res.Output = res10265.Output
  11014. res.InfRefmsgid = res10265.InfRefmsgid
  11015. if res.Infcode == 0 {
  11016. c.ServeSuccessJSON(map[string]interface{}{
  11017. "number": token,
  11018. })
  11019. }
  11020. } else {
  11021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11022. return
  11023. }
  11024. } else { //读卡失败
  11025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11026. return
  11027. }
  11028. }
  11029. func DeleteExtraSpaceTwo(s string) string {
  11030. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11031. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11032. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11033. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11034. s2 := make([]byte, len(s1)) //定义字符数组切片
  11035. copy(s2, s1) //将字符串复制到切片
  11036. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11037. for len(spc_index) > 0 { //找到适配项
  11038. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11039. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11040. }
  11041. return string(s2)
  11042. }
  11043. func Remove0000(s string) string {
  11044. str := make([]rune, 0, len(s))
  11045. for _, v := range []rune(s) {
  11046. if v == 0 {
  11047. continue
  11048. }
  11049. str = append(str, v)
  11050. }
  11051. return string(str)
  11052. }
  11053. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  11054. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  11055. readCard := DllDef.MustFindProc("EcQuery")
  11056. pCardInfo := make([]byte, 8192)
  11057. pBusiCardInfo := make([]byte, 8192)
  11058. data := make(map[string]interface{})
  11059. //pData := make(map[string]interface{})
  11060. inputData := make(map[string]interface{})
  11061. inputData["orgId"] = code
  11062. inputData["businessType"] = "01101"
  11063. inputData["operatorId"] = operator_id
  11064. inputData["operatorName"] = operator_name
  11065. inputData["officeId"] = "001"
  11066. inputData["officeName"] = "血透室"
  11067. //
  11068. data["data"] = inputData
  11069. data["transType"] = "ec.query"
  11070. data["orgId"] = code
  11071. bytesData, _ := json.Marshal(data)
  11072. pCardInfo = bytesData
  11073. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  11074. fmt.Println(ret2)
  11075. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  11076. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11077. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  11078. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11079. if ret2 != 0 {
  11080. return "", ""
  11081. }
  11082. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  11083. }
  11084. func DeleteExtraSpace(s string) string {
  11085. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11086. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11087. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11088. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11089. s2 := make([]byte, len(s1)) //定义字符数组切片
  11090. copy(s2, s1) //将字符串复制到切片
  11091. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11092. for len(spc_index) > 0 { //找到适配项
  11093. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11094. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11095. }
  11096. return string(s2)
  11097. }