his_api_controller.go 460KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548
  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. service.GetFjAuthorizationInfo(miConfig.Code)
  85. } else {
  86. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  87. var dat map[string]interface{}
  88. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  89. fmt.Println(dat)
  90. } else {
  91. fmt.Println(err)
  92. }
  93. userJSONBytes, _ := json.Marshal(dat)
  94. var res models.Result9001
  95. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  96. utils.ErrorLog("解析失败:%v", err)
  97. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  98. return
  99. }
  100. }
  101. }
  102. func (c *HisApiController) Check3101(patient_id int64, his_patient_id int64, admin_user_id int64) {
  103. adminUser := c.GetAdminUserInfo()
  104. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  105. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  106. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  107. record_time := c.GetString("record_time")
  108. trig_scen := c.GetString("trig_scen")
  109. timeLayout := "2006-01-02"
  110. loc, _ := time.LoadLocation("Local")
  111. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  112. if err != nil {
  113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  114. return
  115. }
  116. recordDateTime := theTime.Unix()
  117. var patientPrescription models.HisPrescriptionInfo
  118. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  119. if patientPrescription.ID == 0 {
  120. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  121. }
  122. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  123. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  124. //
  125. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  126. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  127. var pp models.PublicParams
  128. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  129. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  130. pp.FixmedinsName = miConfig.OrgName
  131. pp.FixmedinsCode = miConfig.Code
  132. pp.RequestUrl = miConfig.Url
  133. pp.Cainfo = miConfig.Cainfo
  134. pp.SecretKey = miConfig.SecretKey
  135. pp.AccessKey = miConfig.AccessKey
  136. pp.OpterName = roles.UserName
  137. var config []*models.HisXtDiagnoseConfig
  138. for _, item := range diagnosis_ids {
  139. id, _ := strconv.ParseInt(item, 10, 64)
  140. diagnosisConfig, _ := service.FindDiagnoseById(id)
  141. config = append(config, &diagnosisConfig)
  142. }
  143. var pd models.PatientDtos
  144. pd.PatnID = his.PsnNo
  145. pd.PatnName = his.Name
  146. pd.Gend = his.Gend
  147. pd.Brdy = his.Brdy
  148. pd.Poolarea = his.InsuplcAdmdvs
  149. pd.CurrMdtrtID = his.Number
  150. var fed models.FsiEncounterDtos
  151. fed.MdtrtID = his.Number
  152. fed.MedinsID = miConfig.Code
  153. fed.MedinsName = miConfig.OrgName
  154. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  155. fed.MedMdtrtType = "1"
  156. fed.MedinsType = "1"
  157. fed.MedinsLv = "11"
  158. tm := time.Unix(his.RecordDate, 0)
  159. s_tm := tm.Format("2006-01-02 15:04:05")
  160. fed.AdmDate = s_tm
  161. fed.DscgDate = s_tm
  162. fed.DscgMainDiseCodg = config[0].CountryCode
  163. fed.DscgMainDiseName = config[0].CountryContentName
  164. //诊断信息
  165. var fdds []*models.FsiDiagnoseDtos
  166. for index, item := range config {
  167. if index == 0 {
  168. var fdd models.FsiDiagnoseDtos
  169. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  170. fdd.InoutDiseType = "1"
  171. fdd.MaindiseFlag = "1"
  172. fdd.DiseDate = s_tm
  173. fdd.DiasSrtNo = "1"
  174. fdd.DiseName = item.CountryContentName
  175. fdd.DiseCodg = item.CountryCode
  176. fdds = append(fdds, &fdd)
  177. } else {
  178. var fdd models.FsiDiagnoseDtos
  179. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  180. fdd.InoutDiseType = "1"
  181. fdd.MaindiseFlag = "1"
  182. fdd.DiseDate = s_tm
  183. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  184. fdd.DiseName = item.CountryContentName
  185. fdd.DiseCodg = item.CountryCode
  186. fdds = append(fdds, &fdd)
  187. }
  188. }
  189. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  190. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  191. fed.AdmDeptName = department.Name
  192. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  193. fed.DscgDeptName = department.Name
  194. fed.MedMdtrtType = "1"
  195. fed.MedType = "11"
  196. //if his.Insutype == "390" {
  197. // fed.MedType = "1402"
  198. //} else {
  199. // fed.MedType = "9933"
  200. //}
  201. var orders []*models.FsiOrderDtos
  202. if trig_scen == "2" {
  203. //处方医嘱信息
  204. for _, item := range prescriptions {
  205. for _, subItem := range item.HisDoctorAdviceInfo {
  206. var order models.FsiOrderDtos
  207. order.RxID = strconv.FormatInt(item.ID, 10)
  208. order.Rxno = strconv.FormatInt(item.ID, 10)
  209. order.LongDrordFlag = "0"
  210. order.HilistType = "1"
  211. order.ChrgType = "1"
  212. order.DrordBhvr = "-"
  213. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  214. order.HosplistName = subItem.BaseDrugLib.DrugName
  215. order.HilistLv = "1"
  216. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  217. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  218. order.HosplistName = subItem.BaseDrugLib.DrugName
  219. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  220. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  221. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  222. order.OwnpayAmt = ""
  223. order.SelfpayAmt = ""
  224. order.Spec = ""
  225. order.SpecUnt = ""
  226. order.DrordBegnDate = s_tm
  227. order.DrordStopDate = ""
  228. order.DrordDrCodg = "1"
  229. order.DrordDeptName = department.Name
  230. order.DrordDrCodg = "1"
  231. order.DrordDrName = doctor_info.UserName
  232. order.DrordDrProfttl = ""
  233. order.CurrDrordFlag = "1"
  234. orders = append(orders, &order)
  235. }
  236. for _, subItem := range item.HisPrescriptionProject {
  237. if subItem.Type == 2 {
  238. var order models.FsiOrderDtos
  239. order.RxID = strconv.FormatInt(item.ID, 10)
  240. order.Rxno = strconv.FormatInt(item.ID, 10)
  241. order.LongDrordFlag = "0"
  242. order.HilistType = "1"
  243. order.ChrgType = "1"
  244. order.DrordBhvr = "-"
  245. order.HilistCode = subItem.HisProject.MedicalCode
  246. order.HosplistName = subItem.HisProject.ProjectName
  247. order.HilistLv = "1"
  248. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  249. order.HosplistCode = subItem.HisProject.MedicalCode
  250. order.HosplistName = subItem.HisProject.ProjectName
  251. order.Cnt = subItem.Count
  252. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  253. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  254. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  255. order.OwnpayAmt = ""
  256. order.SelfpayAmt = ""
  257. order.Spec = ""
  258. order.SpecUnt = ""
  259. order.DrordBegnDate = s_tm
  260. order.DrordStopDate = ""
  261. order.DrordDrCodg = "1"
  262. order.DrordDeptName = department.Name
  263. order.DrordDrCodg = "1"
  264. order.DrordDrName = doctor_info.UserName
  265. order.DrordDrProfttl = ""
  266. order.CurrDrordFlag = "1"
  267. orders = append(orders, &order)
  268. }
  269. if subItem.Type == 3 {
  270. var order models.FsiOrderDtos
  271. order.RxID = strconv.FormatInt(item.ID, 10)
  272. order.Rxno = strconv.FormatInt(item.ID, 10)
  273. order.LongDrordFlag = "0"
  274. order.HilistType = "1"
  275. order.ChrgType = "1"
  276. order.DrordBhvr = "-"
  277. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  278. order.HosplistName = subItem.GoodInfo.GoodName
  279. order.HilistLv = "1"
  280. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  281. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  282. order.HosplistName = subItem.GoodInfo.GoodName
  283. order.Cnt = subItem.Count
  284. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  285. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  286. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  287. order.OwnpayAmt = ""
  288. order.SelfpayAmt = ""
  289. order.Spec = ""
  290. order.SpecUnt = ""
  291. order.DrordBegnDate = s_tm
  292. order.DrordStopDate = ""
  293. order.DrordDrCodg = "1"
  294. order.DrordDeptName = department.Name
  295. order.DrordDrCodg = "1"
  296. order.DrordDrName = doctor_info.UserName
  297. order.DrordDrProfttl = ""
  298. order.CurrDrordFlag = "1"
  299. orders = append(orders, &order)
  300. }
  301. }
  302. }
  303. //处方医嘱信息
  304. }
  305. fed.MatnStas = "0"
  306. fed.MedfeeSumamt = "0"
  307. fed.OwnpayAmt = "0"
  308. fed.SelfpayAmt = "0"
  309. fed.AcctPayamt = "0"
  310. fed.MaAmt = "0"
  311. fed.HifpPayamt = "0"
  312. fed.SetlTotlnum = "1"
  313. fed.Insutype = his.Insutype
  314. fed.ReimFlag = "0"
  315. fed.OutSetlFlag = "0"
  316. var fopd []*models.FsiOperationDtosData
  317. data := make(map[string]interface{})
  318. data["fed"] = fed
  319. data["fdd"] = fdds
  320. data["fod"] = orders
  321. data["pd"] = pd
  322. data["pp"] = pp
  323. data["fopd"] = fopd
  324. data["trig_scen"] = trig_scen
  325. fmt.Println(data)
  326. fmt.Println(fed)
  327. fmt.Println(fdds)
  328. fmt.Println(orders)
  329. fmt.Println(pd)
  330. fmt.Println(pp)
  331. fmt.Println(fopd)
  332. client := &http.Client{}
  333. bytesData, _ := json.Marshal(data)
  334. var req *http.Request
  335. if miConfig.MdtrtareaAdmvs == "320921" {
  336. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  337. } else {
  338. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  339. }
  340. resp, _ := client.Do(req)
  341. defer resp.Body.Close()
  342. body, ioErr := ioutil.ReadAll(resp.Body)
  343. if ioErr != nil {
  344. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  346. return
  347. }
  348. var respJSON map[string]interface{}
  349. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  350. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  352. return
  353. }
  354. //手术操作集合
  355. //手术操作集合
  356. }
  357. func (c *HisApiController) Check3102() {
  358. patient_id, _ := c.GetInt64("patient_id")
  359. order_id, _ := c.GetInt64("order_id")
  360. his_patient_id, _ := c.GetInt64("his_patient_id")
  361. admin_user_id, _ := c.GetInt64("admin_user_id")
  362. trig_scen := c.GetString("trig_scen")
  363. adminUser := c.GetAdminUserInfo()
  364. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  365. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  366. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  367. record_time := c.GetString("record_time")
  368. order, _ := service.GetHisOrderByID(order_id)
  369. timeLayout := "2006-01-02"
  370. loc, _ := time.LoadLocation("Local")
  371. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  372. if err != nil {
  373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  374. return
  375. }
  376. recordDateTime := theTime.Unix()
  377. var patientPrescription models.HisPrescriptionInfo
  378. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  379. if patientPrescription.ID == 0 {
  380. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  381. }
  382. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  383. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  384. //
  385. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  386. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  387. var pp models.PublicParams
  388. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  389. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  390. pp.FixmedinsName = miConfig.OrgName
  391. pp.FixmedinsCode = miConfig.Code
  392. pp.RequestUrl = miConfig.Url
  393. pp.Cainfo = miConfig.Cainfo
  394. pp.SecretKey = miConfig.SecretKey
  395. pp.AccessKey = miConfig.AccessKey
  396. pp.OpterName = roles.UserName
  397. var config []*models.HisXtDiagnoseConfig
  398. for _, item := range diagnosis_ids {
  399. id, _ := strconv.ParseInt(item, 10, 64)
  400. diagnosisConfig, _ := service.FindDiagnoseById(id)
  401. config = append(config, &diagnosisConfig)
  402. }
  403. var pd models.PatientDtos
  404. pd.PatnID = his.PsnNo
  405. pd.PatnName = his.Name
  406. pd.Gend = his.Gend
  407. pd.Brdy = his.Brdy
  408. pd.Poolarea = his.InsuplcAdmdvs
  409. pd.CurrMdtrtID = his.Number
  410. var fed models.FsiEncounterDtos
  411. fed.MdtrtID = his.Number
  412. fed.MedinsID = miConfig.Code
  413. fed.MedinsName = miConfig.OrgName
  414. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  415. fed.MedMdtrtType = "1"
  416. fed.MedinsType = "1"
  417. fed.MedinsLv = "11"
  418. tm := time.Unix(his.RecordDate, 0)
  419. s_tm := tm.Format("2006-01-02 15:04:05")
  420. fed.AdmDate = s_tm
  421. fed.DscgDate = s_tm
  422. fed.DscgMainDiseCodg = config[0].CountryCode
  423. fed.DscgMainDiseName = config[0].CountryContentName
  424. //诊断信息
  425. var fdds []*models.FsiDiagnoseDtos
  426. for index, item := range config {
  427. if index == 0 {
  428. var fdd models.FsiDiagnoseDtos
  429. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  430. fdd.InoutDiseType = "1"
  431. fdd.MaindiseFlag = "1"
  432. fdd.DiseDate = s_tm
  433. fdd.DiasSrtNo = "1"
  434. fdd.DiseName = item.CountryContentName
  435. fdd.DiseCodg = item.CountryCode
  436. fdds = append(fdds, &fdd)
  437. } else {
  438. var fdd models.FsiDiagnoseDtos
  439. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  440. fdd.InoutDiseType = "1"
  441. fdd.MaindiseFlag = "1"
  442. fdd.DiseDate = s_tm
  443. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  444. fdd.DiseName = item.CountryContentName
  445. fdd.DiseCodg = item.CountryCode
  446. fdds = append(fdds, &fdd)
  447. }
  448. }
  449. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  450. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  451. fed.AdmDeptName = department.Name
  452. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  453. fed.DscgDeptName = department.Name
  454. fed.MedType = order.MedType
  455. //处方医嘱信息
  456. var orders []*models.FsiOrderDtos
  457. //for _, item := range prescriptions {
  458. // for _, subItem := range item.HisDoctorAdviceInfo {
  459. // var order models.FsiOrderDtos
  460. // order.RxID = strconv.FormatInt(item.ID, 10)
  461. // order.Rxno = strconv.FormatInt(item.ID, 10)
  462. // order.LongDrordFlag = "0"
  463. // order.HilistType = "1"
  464. // order.ChrgType = "1"
  465. // order.DrordBhvr = "-"
  466. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  467. // order.HosplistName = subItem.BaseDrugLib.DrugName
  468. // order.HilistLv = "1"
  469. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  470. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  471. // order.HosplistName = subItem.BaseDrugLib.DrugName
  472. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  473. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  474. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  475. // order.OwnpayAmt = ""
  476. // order.SelfpayAmt = ""
  477. // order.Spec = ""
  478. // order.SpecUnt = ""
  479. // order.DrordBegnDate = s_tm
  480. // order.DrordStopDate = ""
  481. // order.DrordDrCodg = "1"
  482. // order.DrordDeptName = department.Name
  483. // order.DrordDrCodg = "1"
  484. // order.DrordDrName = doctor_info.UserName
  485. // order.DrordDrProfttl = ""
  486. // order.CurrDrordFlag = "1"
  487. // orders = append(orders, &order)
  488. // }
  489. // for _, subItem := range item.HisPrescriptionProject {
  490. // if subItem.Type == 2 {
  491. // var order models.FsiOrderDtos
  492. // order.RxID = strconv.FormatInt(item.ID, 10)
  493. // order.Rxno = strconv.FormatInt(item.ID, 10)
  494. // order.LongDrordFlag = "0"
  495. // order.HilistType = "1"
  496. // order.ChrgType = "1"
  497. // order.DrordBhvr = "-"
  498. // order.HilistCode = subItem.HisProject.MedicalCode
  499. // order.HosplistName = subItem.HisProject.ProjectName
  500. // order.HilistLv = "1"
  501. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  502. // order.HosplistCode = subItem.HisProject.MedicalCode
  503. // order.HosplistName = subItem.HisProject.ProjectName
  504. // order.Cnt = subItem.Count
  505. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  506. //
  507. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  508. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  509. // order.OwnpayAmt = ""
  510. // order.SelfpayAmt = ""
  511. // order.Spec = ""
  512. // order.SpecUnt = ""
  513. // order.DrordBegnDate = s_tm
  514. // order.DrordStopDate = ""
  515. // order.DrordDrCodg = "1"
  516. // order.DrordDeptName = department.Name
  517. // order.DrordDrCodg = "1"
  518. // order.DrordDrName = doctor_info.UserName
  519. // order.DrordDrProfttl = ""
  520. // order.CurrDrordFlag = "1"
  521. // orders = append(orders, &order)
  522. //
  523. // }
  524. // if subItem.Type == 3 {
  525. //
  526. // var order models.FsiOrderDtos
  527. // order.RxID = strconv.FormatInt(item.ID, 10)
  528. // order.Rxno = strconv.FormatInt(item.ID, 10)
  529. // order.LongDrordFlag = "0"
  530. // order.HilistType = "1"
  531. // order.ChrgType = "1"
  532. // order.DrordBhvr = "-"
  533. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  534. // order.HosplistName = subItem.GoodInfo.GoodName
  535. // order.HilistLv = "1"
  536. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  537. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  538. // order.HosplistName = subItem.GoodInfo.GoodName
  539. // order.Cnt = subItem.Count
  540. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  541. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  542. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  543. // order.OwnpayAmt = ""
  544. // order.SelfpayAmt = ""
  545. // order.Spec = ""
  546. // order.SpecUnt = ""
  547. // order.DrordBegnDate = s_tm
  548. // order.DrordStopDate = ""
  549. // order.DrordDrCodg = "1"
  550. // order.DrordDeptName = department.Name
  551. // order.DrordDrCodg = "1"
  552. // order.DrordDrName = doctor_info.UserName
  553. // order.DrordDrProfttl = ""
  554. // order.CurrDrordFlag = "1"
  555. // orders = append(orders, &order)
  556. //
  557. // }
  558. // }
  559. //}
  560. for _, item := range prescriptions {
  561. for _, subItem := range item.HisDoctorAdviceInfo {
  562. var order models.FsiOrderDtos
  563. order.RxID = strconv.FormatInt(item.ID, 10)
  564. order.Rxno = strconv.FormatInt(item.ID, 10)
  565. order.LongDrordFlag = "0"
  566. order.HilistType = "1"
  567. order.ChrgType = "1"
  568. order.DrordBhvr = "-"
  569. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  570. order.HosplistName = subItem.BaseDrugLib.DrugName
  571. order.HilistLv = "1"
  572. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  573. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  574. order.HosplistName = subItem.BaseDrugLib.DrugName
  575. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  576. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  577. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  578. order.OwnpayAmt = ""
  579. order.SelfpayAmt = ""
  580. order.Spec = ""
  581. order.SpecUnt = ""
  582. order.DrordBegnDate = s_tm
  583. order.DrordStopDate = ""
  584. order.DrordDrCodg = "1"
  585. order.DrordDeptName = department.Name
  586. order.DrordDrCodg = "1"
  587. order.DrordDrName = doctor_info.UserName
  588. order.DrordDrProfttl = ""
  589. order.CurrDrordFlag = "1"
  590. orders = append(orders, &order)
  591. }
  592. for _, subItem := range item.HisPrescriptionProject {
  593. if subItem.Type == 2 {
  594. var order models.FsiOrderDtos
  595. order.RxID = strconv.FormatInt(item.ID, 10)
  596. order.Rxno = strconv.FormatInt(item.ID, 10)
  597. order.LongDrordFlag = "0"
  598. order.HilistType = "1"
  599. order.ChrgType = "1"
  600. order.DrordBhvr = "-"
  601. order.HilistCode = subItem.HisProject.MedicalCode
  602. order.HosplistName = subItem.HisProject.ProjectName
  603. order.HilistLv = "1"
  604. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  605. order.HosplistCode = subItem.HisProject.MedicalCode
  606. order.HosplistName = subItem.HisProject.ProjectName
  607. order.Cnt = subItem.Count
  608. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  609. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  610. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  611. order.OwnpayAmt = ""
  612. order.SelfpayAmt = ""
  613. order.Spec = ""
  614. order.SpecUnt = ""
  615. order.DrordBegnDate = s_tm
  616. order.DrordStopDate = ""
  617. order.DrordDrCodg = "1"
  618. order.DrordDeptName = department.Name
  619. order.DrordDrCodg = "1"
  620. order.DrordDrName = doctor_info.UserName
  621. order.DrordDrProfttl = ""
  622. order.CurrDrordFlag = "1"
  623. orders = append(orders, &order)
  624. }
  625. if subItem.Type == 3 {
  626. var order models.FsiOrderDtos
  627. order.RxID = strconv.FormatInt(item.ID, 10)
  628. order.Rxno = strconv.FormatInt(item.ID, 10)
  629. order.LongDrordFlag = "0"
  630. order.HilistType = "1"
  631. order.ChrgType = "1"
  632. order.DrordBhvr = "-"
  633. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  634. order.HosplistName = subItem.GoodInfo.GoodName
  635. order.HilistLv = "1"
  636. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  637. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  638. order.HosplistName = subItem.GoodInfo.GoodName
  639. order.Cnt = subItem.Count
  640. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  641. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  642. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  643. order.OwnpayAmt = ""
  644. order.SelfpayAmt = ""
  645. order.Spec = ""
  646. order.SpecUnt = ""
  647. order.DrordBegnDate = s_tm
  648. order.DrordStopDate = ""
  649. order.DrordDrCodg = "1"
  650. order.DrordDeptName = department.Name
  651. order.DrordDrCodg = "1"
  652. order.DrordDrName = doctor_info.UserName
  653. order.DrordDrProfttl = ""
  654. order.CurrDrordFlag = "1"
  655. orders = append(orders, &order)
  656. }
  657. }
  658. }
  659. //处方医嘱信息
  660. fed.MatnStas = "0"
  661. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  662. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  663. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  664. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  665. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  666. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  667. fed.SetlTotlnum = "1"
  668. fed.Insutype = his.Insutype
  669. fed.ReimFlag = "0"
  670. fed.OutSetlFlag = "0"
  671. var fopd []*models.FsiOperationDtosData
  672. data := make(map[string]interface{})
  673. data["fed"] = fed
  674. data["fdd"] = fdds
  675. data["fod"] = orders
  676. data["pd"] = pd
  677. data["pp"] = pp
  678. data["fopd"] = fopd
  679. data["trig_scen"] = trig_scen
  680. client := &http.Client{}
  681. bytesData, _ := json.Marshal(data)
  682. var req *http.Request
  683. if miConfig.MdtrtareaAdmvs == "320921" {
  684. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  685. } else {
  686. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  687. }
  688. resp, _ := client.Do(req)
  689. defer resp.Body.Close()
  690. body, ioErr := ioutil.ReadAll(resp.Body)
  691. if ioErr != nil {
  692. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  694. return
  695. }
  696. var respJSON map[string]interface{}
  697. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  698. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  700. return
  701. }
  702. //手术操作集合
  703. //手术操作集合
  704. }
  705. func (c *HisApiController) Check() {
  706. psn_no := c.GetString("psn_no")
  707. in := c.GetString("in")
  708. mt := c.GetString("mt")
  709. baseParams := models.BaseParams{
  710. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  711. FixmedinsCode: "H15049901371",
  712. InsuplcAdmdvs: "150499",
  713. MdtrtareaAdmvs: "150499",
  714. OrgName: "赤峰费森血液透析中心",
  715. Doctor: "1111",
  716. }
  717. service.Gdyb2001(baseParams, psn_no, in, mt)
  718. }
  719. func (c *HisApiController) GetPsnNcdsInfo() {
  720. admin_user_id, _ := c.GetInt64("admin_user_id")
  721. patient_id, _ := c.GetInt64("patient_id")
  722. id, _ := c.GetInt64("id")
  723. adminUser := c.GetAdminUserInfo()
  724. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  725. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  726. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  727. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  728. psn_record, _ := service.GetPsnNCDSRecordById(id)
  729. //
  730. //if psn_record.ID == 0 {
  731. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  732. // return
  733. //}
  734. var res Result5301
  735. var res10265 Result5301For10265
  736. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  737. psn_info, _ := service.GetPsnByPatientId(patient_id)
  738. var api string
  739. if miConfig.MdtrtareaAdmvs == "320921" {
  740. 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 +
  741. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  742. } else {
  743. 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 +
  744. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  745. }
  746. resp, requestErr := http.Get(api)
  747. if requestErr != nil {
  748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  749. return
  750. }
  751. body, ioErr := ioutil.ReadAll(resp.Body)
  752. if ioErr != nil {
  753. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  755. return
  756. }
  757. var respJSON map[string]interface{}
  758. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  759. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  761. return
  762. }
  763. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  764. result, _ := json.Marshal(respJSON)
  765. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  766. utils.ErrorLog("解析失败:%v", err)
  767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  768. return
  769. }
  770. res.ErrMsg = res10265.ErrMsg
  771. res.Output = res10265.Output
  772. res.InfRefmsgid = res10265.InfRefmsgid
  773. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  774. res.Infcode = infocode
  775. } else {
  776. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  777. var dat map[string]interface{}
  778. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  779. fmt.Println(dat)
  780. } else {
  781. fmt.Println(err)
  782. }
  783. userJSONBytes, _ := json.Marshal(dat)
  784. if miConfig.Code == "H15049901371" {
  785. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  786. utils.ErrorLog("解析失败:%v", err)
  787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  788. return
  789. }
  790. res.InfRefmsgid = res10265.InfRefmsgid
  791. res.Output = res10265.Output
  792. res.ErrMsg = res10265.ErrMsg
  793. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  794. res.Infcode = infocode
  795. } else {
  796. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  797. utils.ErrorLog("解析失败:%v", err)
  798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  799. return
  800. }
  801. }
  802. }
  803. if res.Infcode == 0 {
  804. c.ServeSuccessJSON(map[string]interface{}{
  805. "result": res.Output.Result,
  806. })
  807. }
  808. }
  809. func (c *HisApiController) CheckInsutype() {
  810. his_patient_id, _ := c.GetInt64("his_patient_id")
  811. admin_user_id, _ := c.GetInt64("admin_user_id")
  812. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  813. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  814. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  815. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  816. var dat map[string]interface{}
  817. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  818. fmt.Println(dat)
  819. } else {
  820. fmt.Println(err)
  821. }
  822. userJSONBytes, _ := json.Marshal(dat)
  823. var res Result90100
  824. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  825. utils.ErrorLog("解析失败:%v", err)
  826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  827. return
  828. }
  829. if res.Infcode != 0 {
  830. c.ServeSuccessJSON(map[string]interface{}{
  831. "failed_code": -10,
  832. "msg": res.ErrMsg,
  833. })
  834. return
  835. } else {
  836. fmt.Println(res)
  837. }
  838. }
  839. func (c *HisApiController) CheckCardPWD() {
  840. card_pwd := c.GetString("card_pwd")
  841. his_patient_id, _ := c.GetInt64("his_patient_id")
  842. admin_user_id, _ := c.GetInt64("admin_user_id")
  843. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  844. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  845. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  846. psn, _ := service.GetPsnByPatientId(his.PatientId)
  847. bas := strings.Split(psn.CardInfo, "|")
  848. basNumber := bas[2]
  849. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  850. var dat map[string]interface{}
  851. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  852. fmt.Println(dat)
  853. } else {
  854. fmt.Println(err)
  855. }
  856. userJSONBytes, _ := json.Marshal(dat)
  857. var res Result90991
  858. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  859. utils.ErrorLog("解析失败:%v", err)
  860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  861. return
  862. }
  863. if res.Infcode != 0 {
  864. c.ServeSuccessJSON(map[string]interface{}{
  865. "failed_code": -10,
  866. "msg": res.ErrMsg,
  867. })
  868. return
  869. } else {
  870. if res.Output.Result.SscnoCheckStat == "0" {
  871. var msg string
  872. switch res.Output.Result.CardStat {
  873. case "00":
  874. msg = "未激活"
  875. break
  876. case "10":
  877. msg = "激活"
  878. break
  879. case "20":
  880. msg = "窗口挂失"
  881. break
  882. case "21":
  883. msg = "电话挂失"
  884. break
  885. case "22":
  886. msg = "单位网上申报挂失"
  887. break
  888. case "23":
  889. msg = "保健办挂失"
  890. break
  891. case "24":
  892. msg = "个人网上挂失"
  893. break
  894. case "25":
  895. msg = "网上服务大厅挂失"
  896. break
  897. case "30":
  898. msg = "注销"
  899. break
  900. case "40":
  901. msg = "回收"
  902. break
  903. case "99":
  904. msg = "制卡中(无效卡)"
  905. break
  906. }
  907. c.ServeSuccessJSON(map[string]interface{}{
  908. "failed_code": -10,
  909. "msg": msg,
  910. })
  911. return
  912. } else {
  913. c.ServeSuccessJSON(map[string]interface{}{
  914. "msg": "校验成功",
  915. })
  916. return
  917. }
  918. }
  919. }
  920. func (c *HisApiController) CheckCardPWDTwo() {
  921. //card_pwd := c.GetString("card_pwd")
  922. //his_patient_id, _ := c.GetInt64("his_patient_id")
  923. admin_user_id, _ := c.GetInt64("admin_user_id")
  924. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  925. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  926. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  927. var dat map[string]interface{}
  928. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  929. fmt.Println(dat)
  930. } else {
  931. fmt.Println(err)
  932. }
  933. userJSONBytes, _ := json.Marshal(dat)
  934. var res Result90991
  935. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  936. utils.ErrorLog("解析失败:%v", err)
  937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  938. return
  939. }
  940. if res.Infcode != 0 {
  941. c.ServeSuccessJSON(map[string]interface{}{
  942. "failed_code": -10,
  943. "msg": res.ErrMsg,
  944. })
  945. return
  946. } else {
  947. if res.Output.Result.SscnoCheckStat == "0" {
  948. var msg string
  949. switch res.Output.Result.CardStat {
  950. case "00":
  951. msg = "未激活"
  952. break
  953. case "10":
  954. msg = "激活"
  955. break
  956. case "20":
  957. msg = "窗口挂失"
  958. break
  959. case "21":
  960. msg = "电话挂失"
  961. break
  962. case "22":
  963. msg = "单位网上申报挂失"
  964. break
  965. case "23":
  966. msg = "保健办挂失"
  967. break
  968. case "24":
  969. msg = "个人网上挂失"
  970. break
  971. case "25":
  972. msg = "网上服务大厅挂失"
  973. break
  974. case "30":
  975. msg = "注销"
  976. break
  977. case "40":
  978. msg = "回收"
  979. break
  980. case "99":
  981. msg = "制卡中(无效卡)"
  982. break
  983. }
  984. c.ServeSuccessJSON(map[string]interface{}{
  985. "failed_code": -10,
  986. "msg": msg,
  987. })
  988. return
  989. } else {
  990. c.ServeSuccessJSON(map[string]interface{}{
  991. "msg": "校验成功",
  992. })
  993. return
  994. }
  995. }
  996. }
  997. type ELeCertData struct {
  998. Data struct {
  999. Extra string `json:"extra"`
  1000. IDNo string `json:"idNo"`
  1001. IDType string `json:"idType"`
  1002. EcToken string `json:"ecToken"`
  1003. InsuOrg string `json:"insuOrg"`
  1004. UserName string `json:"userName"`
  1005. EcIndexNo string `json:"ecIndexNo"`
  1006. Gender string `json:"gender"`
  1007. Birthday string `json:"birthday"`
  1008. Nationality string `json:"nationality"`
  1009. Email string `json:"email"`
  1010. } `json:"OutData"`
  1011. }
  1012. func (c *HisApiController) ReadCard() {
  1013. id_card_type, _ := c.GetInt64("id_card_type")
  1014. admin_user_id, _ := c.GetInt64("admin_user_id")
  1015. certificates, _ := c.GetInt64("certificates")
  1016. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  1017. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1018. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1019. switch id_card_type {
  1020. case 1:
  1021. if miConfig.MdtrtareaAdmvs == "421300" {
  1022. var res ResultTwo
  1023. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  1024. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  1025. "&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)
  1026. resp, requestErr := http.Get(api)
  1027. if requestErr != nil {
  1028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1029. return
  1030. }
  1031. body, ioErr := ioutil.ReadAll(resp.Body)
  1032. if ioErr != nil {
  1033. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1035. return
  1036. }
  1037. var respJSON map[string]interface{}
  1038. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1039. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1041. return
  1042. }
  1043. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1044. result, _ := json.Marshal(respJSON)
  1045. fmt.Println("log")
  1046. fmt.Println(string(result))
  1047. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1048. utils.ErrorLog("解析失败:%v", err)
  1049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1050. return
  1051. }
  1052. if res.Infcode == 0 {
  1053. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1054. if err == gorm.ErrRecordNotFound {
  1055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1056. return
  1057. } else if err != nil {
  1058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1059. return
  1060. } else {
  1061. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1062. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1063. infoStr := string(Iinfos)
  1064. idetinfoStr := string(Idetinfos)
  1065. psn := &models.HisPsn{
  1066. PsnNo: res.Output.Baseinfo.PsnNo,
  1067. Age: res.Output.Baseinfo.Age,
  1068. PatientId: patient.ID,
  1069. Certno: res.Output.Baseinfo.Certno,
  1070. Brdy: res.Output.Baseinfo.Brdy,
  1071. Gend: res.Output.Baseinfo.Gend,
  1072. Naty: res.Output.Baseinfo.Naty,
  1073. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1074. PsnName: res.Output.Baseinfo.PsnName,
  1075. Idetinfo: idetinfoStr,
  1076. Insuinfo: infoStr,
  1077. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1078. }
  1079. service.CreateHisPsn(psn)
  1080. c.ServeSuccessJSON(map[string]interface{}{
  1081. "patient": patient,
  1082. "number": res.Output.Baseinfo.Certno,
  1083. })
  1084. }
  1085. } else {
  1086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1087. return
  1088. }
  1089. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1090. var api string
  1091. if miConfig.MdtrtareaAdmvs == "320921" {
  1092. 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 +
  1093. "&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
  1094. fmt.Println(api)
  1095. } else {
  1096. 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 +
  1097. "&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)
  1098. }
  1099. resp, requestErr := http.Get(api)
  1100. if requestErr != nil {
  1101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1102. return
  1103. }
  1104. body, ioErr := ioutil.ReadAll(resp.Body)
  1105. if ioErr != nil {
  1106. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1108. return
  1109. }
  1110. var respJSON map[string]interface{}
  1111. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1112. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1114. return
  1115. }
  1116. var status string
  1117. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1118. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1119. //console.log()
  1120. fmt.Println("type===")
  1121. fmt.Println(card_type)
  1122. var token string
  1123. var res ResultTwo //1101结果
  1124. var res10265 ResultTwo10265 //1101结果
  1125. var card_info string //卡信息
  1126. var busi_card_info string
  1127. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1128. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1129. if status == "0" { //读卡成功
  1130. if card_type == "1" {
  1131. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1132. result, _ := json.Marshal(respJSON)
  1133. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1134. utils.ErrorLog("解析失败:%v", err)
  1135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1136. return
  1137. }
  1138. res.ErrMsg = res10265.ErrMsg
  1139. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1140. res.Infcode = infocode
  1141. res.Output = res10265.Output
  1142. res.InfRefmsgid = res10265.InfRefmsgid
  1143. } else {
  1144. //var card_info string //卡信息
  1145. //var busi_card_info string
  1146. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1147. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1148. //fmt.Println(card_info)
  1149. //fmt.Println(busi_card_info)
  1150. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1151. result, _ := json.Marshal(respJSON)
  1152. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1153. utils.ErrorLog("解析失败:%v", err)
  1154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1155. return
  1156. }
  1157. res.ErrMsg = res10265.ErrMsg
  1158. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1159. res.Infcode = infocode
  1160. res.Output = res10265.Output
  1161. res.InfRefmsgid = res10265.InfRefmsgid
  1162. }
  1163. if res.Infcode == 0 {
  1164. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1165. if err == gorm.ErrRecordNotFound {
  1166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1167. return
  1168. } else if err != nil {
  1169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1170. return
  1171. } else {
  1172. if card_type == "1" {
  1173. bas := strings.Split(card_info, "|")
  1174. basNumber := bas[2]
  1175. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1176. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1177. infoStr := string(Iinfos)
  1178. idetinfoStr := string(Idetinfos)
  1179. psn := &models.HisPsn{
  1180. PsnNo: res.Output.Baseinfo.PsnNo,
  1181. Age: res.Output.Baseinfo.Age,
  1182. PatientId: patient.ID,
  1183. Certno: res.Output.Baseinfo.Certno,
  1184. Brdy: res.Output.Baseinfo.Brdy,
  1185. Gend: res.Output.Baseinfo.Gend,
  1186. Naty: res.Output.Baseinfo.Naty,
  1187. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1188. PsnName: res.Output.Baseinfo.PsnName,
  1189. Idetinfo: idetinfoStr,
  1190. Insuinfo: infoStr,
  1191. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1192. CardInfo: card_info,
  1193. VerifyNumber: busi_card_info,
  1194. }
  1195. service.CreateHisPsn(psn)
  1196. var rf []*ResultFive
  1197. json.Unmarshal([]byte(infoStr), &rf)
  1198. var insutypes []*ResultFive
  1199. var insutype string
  1200. var is390 int = 0
  1201. var is310 int = 0
  1202. for _, item := range rf {
  1203. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1204. insutypes = append(insutypes, item)
  1205. }
  1206. }
  1207. if len(insutypes) == 1 {
  1208. insutype = insutypes[0].Insutype
  1209. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1210. } else {
  1211. for _, i := range insutypes {
  1212. if i.Insutype == "390" {
  1213. is390 = 1
  1214. }
  1215. if i.Insutype == "310" {
  1216. is310 = 1
  1217. }
  1218. }
  1219. }
  1220. if is390 == 1 {
  1221. insutype = "390"
  1222. }
  1223. if is310 == 1 {
  1224. insutype = "310"
  1225. }
  1226. if len(insutypes) == 0 {
  1227. insutype = "310"
  1228. }
  1229. c.ServeSuccessJSON(map[string]interface{}{
  1230. "patient": patient,
  1231. "number": basNumber,
  1232. "insutype": insutype,
  1233. })
  1234. } else {
  1235. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1236. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1237. infoStr := string(Iinfos)
  1238. idetinfoStr := string(Idetinfos)
  1239. psn := &models.HisPsn{
  1240. PsnNo: res.Output.Baseinfo.PsnNo,
  1241. Age: res.Output.Baseinfo.Age,
  1242. PatientId: patient.ID,
  1243. Certno: res.Output.Baseinfo.Certno,
  1244. Brdy: res.Output.Baseinfo.Brdy,
  1245. Gend: res.Output.Baseinfo.Gend,
  1246. Naty: res.Output.Baseinfo.Naty,
  1247. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1248. PsnName: res.Output.Baseinfo.PsnName,
  1249. Idetinfo: idetinfoStr,
  1250. Insuinfo: infoStr,
  1251. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1252. CardInfo: card_info,
  1253. VerifyNumber: token,
  1254. }
  1255. service.CreateHisPsn(psn)
  1256. c.ServeSuccessJSON(map[string]interface{}{
  1257. "patient": patient,
  1258. "number": token,
  1259. })
  1260. }
  1261. }
  1262. } else {
  1263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1264. return
  1265. }
  1266. } else { //读卡失败
  1267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1268. return
  1269. }
  1270. } else if miConfig.MdtrtareaAdmvs == "350500" {
  1271. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  1272. cardnum = DeleteExtraSpaceTwo(cardnum)
  1273. cardCode = DeleteExtraSpaceTwo(cardCode)
  1274. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  1275. name = DeleteExtraSpaceTwo(name)
  1276. errmsg = DeleteExtraSpaceTwo(errmsg)
  1277. cardnum = Remove0000(cardnum)
  1278. cardCode = Remove0000(cardCode)
  1279. id_card_no = Remove0000(id_card_no)
  1280. name = Remove0000(name)
  1281. errmsg = Remove0000(errmsg)
  1282. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  1283. result, requestLog, errMsgLog := 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)
  1284. saveLog(result, requestLog, "1101", "获取人员信息")
  1285. fmt.Println(errMsgLog)
  1286. if len(errMsgLog) > 0 {
  1287. } else {
  1288. var dat map[string]interface{}
  1289. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1290. fmt.Println(dat)
  1291. } else {
  1292. fmt.Println(err)
  1293. }
  1294. userJSONBytes, _ := json.Marshal(dat)
  1295. var res ResultTwo
  1296. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1297. utils.ErrorLog("解析失败:%v", err)
  1298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1299. return
  1300. }
  1301. res.ErrMsg = errMsgLog
  1302. if res.Infcode == 0 {
  1303. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  1304. if err == gorm.ErrRecordNotFound {
  1305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1306. return
  1307. } else if err != nil {
  1308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1309. return
  1310. } else {
  1311. fmt.Println(res)
  1312. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1313. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1314. infoStr := string(Iinfos)
  1315. idetinfoStr := string(Idetinfos)
  1316. psn := &models.HisPsn{
  1317. PsnNo: res.Output.Baseinfo.PsnNo,
  1318. Age: res.Output.Baseinfo.Age,
  1319. PatientId: patient.ID,
  1320. Certno: res.Output.Baseinfo.Certno,
  1321. Brdy: res.Output.Baseinfo.Brdy,
  1322. Gend: res.Output.Baseinfo.Gend,
  1323. Naty: res.Output.Baseinfo.Naty,
  1324. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1325. PsnName: res.Output.Baseinfo.PsnName,
  1326. Idetinfo: idetinfoStr,
  1327. Insuinfo: infoStr,
  1328. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1329. CardInfo: basStr,
  1330. VerifyNumber: "",
  1331. }
  1332. service.CreateHisPsn(psn)
  1333. var rf []*ResultFive
  1334. json.Unmarshal([]byte(infoStr), &rf)
  1335. var insutypes []*ResultFive
  1336. var insutype string
  1337. var is390 int = 0
  1338. var is310 int = 0
  1339. for _, item := range rf {
  1340. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1341. insutypes = append(insutypes, item)
  1342. }
  1343. }
  1344. if len(insutypes) == 1 {
  1345. insutype = insutypes[0].Insutype
  1346. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1347. } else {
  1348. for _, i := range insutypes {
  1349. if i.Insutype == "390" {
  1350. is390 = 1
  1351. }
  1352. if i.Insutype == "310" {
  1353. is310 = 1
  1354. }
  1355. }
  1356. }
  1357. if is390 == 1 {
  1358. insutype = "390"
  1359. }
  1360. if is310 == 1 {
  1361. insutype = "310"
  1362. }
  1363. if len(insutypes) == 0 {
  1364. insutype = "310"
  1365. }
  1366. c.ServeSuccessJSON(map[string]interface{}{
  1367. "patient": patient,
  1368. "number": cardnum,
  1369. "insutype": insutype,
  1370. })
  1371. }
  1372. } else {
  1373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1374. return
  1375. }
  1376. }
  1377. } else {
  1378. if initFlag == 0 {
  1379. c.TestGetBasBaseInit()
  1380. }
  1381. basStr := c.GetBasBaseInfo()
  1382. if len(basStr) == 0 {
  1383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1384. return
  1385. }
  1386. fmt.Println(basStr)
  1387. bas := strings.Split(basStr, "|")
  1388. basNumber := bas[1]
  1389. fmt.Println(basNumber)
  1390. card_sn := bas[3]
  1391. fmt.Println(card_sn)
  1392. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1393. var dat map[string]interface{}
  1394. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1395. fmt.Println(dat)
  1396. } else {
  1397. fmt.Println(err)
  1398. }
  1399. userJSONBytes, _ := json.Marshal(dat)
  1400. var res ResultTwo
  1401. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1402. utils.ErrorLog("解析失败:%v", err)
  1403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1404. return
  1405. }
  1406. if res.Infcode == 0 {
  1407. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1408. if err == gorm.ErrRecordNotFound {
  1409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1410. return
  1411. } else if err != nil {
  1412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1413. return
  1414. } else {
  1415. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1416. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1417. infoStr := string(Iinfos)
  1418. idetinfoStr := string(Idetinfos)
  1419. psn := &models.HisPsn{
  1420. PsnNo: res.Output.Baseinfo.PsnNo,
  1421. Age: res.Output.Baseinfo.Age,
  1422. PatientId: patient.ID,
  1423. Certno: res.Output.Baseinfo.Certno,
  1424. Brdy: res.Output.Baseinfo.Brdy,
  1425. Gend: res.Output.Baseinfo.Gend,
  1426. Naty: res.Output.Baseinfo.Naty,
  1427. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1428. PsnName: res.Output.Baseinfo.PsnName,
  1429. Idetinfo: idetinfoStr,
  1430. Insuinfo: infoStr,
  1431. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1432. CardInfo: basStr,
  1433. VerifyNumber: "",
  1434. }
  1435. service.CreateHisPsn(psn)
  1436. c.ServeSuccessJSON(map[string]interface{}{
  1437. "patient": patient,
  1438. "number": basNumber,
  1439. })
  1440. }
  1441. } else {
  1442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1443. return
  1444. }
  1445. break
  1446. }
  1447. case 2:
  1448. SFZStr := c.GetSFZBaseInfo()
  1449. id_card_str := strings.Split(SFZStr, "^")
  1450. id_card_number := id_card_str[0]
  1451. card_sn := ""
  1452. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1453. var dat map[string]interface{}
  1454. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1455. fmt.Println(dat)
  1456. } else {
  1457. fmt.Println(err)
  1458. }
  1459. userJSONBytes, _ := json.Marshal(dat)
  1460. var res ResultTwo
  1461. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1462. utils.ErrorLog("解析失败:%v", err)
  1463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1464. return
  1465. }
  1466. if res.Infcode == 0 {
  1467. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1468. if err == gorm.ErrRecordNotFound {
  1469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1470. return
  1471. } else if err != nil {
  1472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1473. return
  1474. } else {
  1475. c.ServeSuccessJSON(map[string]interface{}{
  1476. "patient": patient,
  1477. "number": id_card_number,
  1478. })
  1479. }
  1480. } else {
  1481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1482. return
  1483. }
  1484. break
  1485. case 3:
  1486. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1487. var api string
  1488. if miConfig.MdtrtareaAdmvs == "320921" {
  1489. 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 +
  1490. "&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
  1491. fmt.Println(api)
  1492. } else {
  1493. 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 +
  1494. "&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)
  1495. }
  1496. resp, requestErr := http.Get(api)
  1497. if requestErr != nil {
  1498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1499. return
  1500. }
  1501. body, ioErr := ioutil.ReadAll(resp.Body)
  1502. if ioErr != nil {
  1503. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1505. return
  1506. }
  1507. var respJSON map[string]interface{}
  1508. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1509. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1511. return
  1512. }
  1513. var status string
  1514. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1515. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1516. var token string
  1517. var res ResultTwo //1101结果
  1518. var res10265 ResultTwo10265 //1101结果
  1519. var card_info string //卡信息
  1520. var busi_card_info string
  1521. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1522. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1523. if status == "0" { //读卡成功
  1524. if card_type == "1" {
  1525. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1526. result, _ := json.Marshal(respJSON)
  1527. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1528. utils.ErrorLog("解析失败:%v", err)
  1529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1530. return
  1531. }
  1532. res.ErrMsg = res10265.ErrMsg
  1533. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1534. res.Infcode = infocode
  1535. res.Output = res10265.Output
  1536. res.InfRefmsgid = res10265.InfRefmsgid
  1537. } else {
  1538. //var card_info string //卡信息
  1539. //var busi_card_info string
  1540. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1541. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1542. //fmt.Println(card_info)
  1543. //fmt.Println(busi_card_info)
  1544. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1545. result, _ := json.Marshal(respJSON)
  1546. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1547. utils.ErrorLog("解析失败:%v", err)
  1548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1549. return
  1550. }
  1551. res.ErrMsg = res10265.ErrMsg
  1552. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1553. res.Infcode = infocode
  1554. res.Output = res10265.Output
  1555. res.InfRefmsgid = res10265.InfRefmsgid
  1556. }
  1557. if res.Infcode == 0 {
  1558. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1559. if err == gorm.ErrRecordNotFound {
  1560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1561. return
  1562. } else if err != nil {
  1563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1564. return
  1565. } else {
  1566. if card_type == "1" {
  1567. bas := strings.Split(card_info, "|")
  1568. basNumber := bas[2]
  1569. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1570. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1571. infoStr := string(Iinfos)
  1572. idetinfoStr := string(Idetinfos)
  1573. psn := &models.HisPsn{
  1574. PsnNo: res.Output.Baseinfo.PsnNo,
  1575. Age: res.Output.Baseinfo.Age,
  1576. PatientId: patient.ID,
  1577. Certno: res.Output.Baseinfo.Certno,
  1578. Brdy: res.Output.Baseinfo.Brdy,
  1579. Gend: res.Output.Baseinfo.Gend,
  1580. Naty: res.Output.Baseinfo.Naty,
  1581. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1582. PsnName: res.Output.Baseinfo.PsnName,
  1583. Idetinfo: idetinfoStr,
  1584. Insuinfo: infoStr,
  1585. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1586. CardInfo: card_info,
  1587. VerifyNumber: busi_card_info,
  1588. }
  1589. service.CreateHisPsn(psn)
  1590. c.ServeSuccessJSON(map[string]interface{}{
  1591. "patient": patient,
  1592. "number": basNumber,
  1593. })
  1594. } else {
  1595. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1596. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1597. infoStr := string(Iinfos)
  1598. idetinfoStr := string(Idetinfos)
  1599. psn := &models.HisPsn{
  1600. PsnNo: res.Output.Baseinfo.PsnNo,
  1601. Age: res.Output.Baseinfo.Age,
  1602. PatientId: patient.ID,
  1603. Certno: res.Output.Baseinfo.Certno,
  1604. Brdy: res.Output.Baseinfo.Brdy,
  1605. Gend: res.Output.Baseinfo.Gend,
  1606. Naty: res.Output.Baseinfo.Naty,
  1607. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1608. PsnName: res.Output.Baseinfo.PsnName,
  1609. Idetinfo: idetinfoStr,
  1610. Insuinfo: infoStr,
  1611. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1612. CardInfo: card_info,
  1613. VerifyNumber: token,
  1614. }
  1615. service.CreateHisPsn(psn)
  1616. var rf []*ResultFive
  1617. json.Unmarshal([]byte(infoStr), &rf)
  1618. var insutypes []*ResultFive
  1619. var insutype string
  1620. var is390 int = 0
  1621. var is310 int = 0
  1622. for _, item := range rf {
  1623. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1624. insutypes = append(insutypes, item)
  1625. }
  1626. }
  1627. if len(insutypes) == 1 {
  1628. insutype = insutypes[0].Insutype
  1629. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1630. } else {
  1631. for _, i := range insutypes {
  1632. if i.Insutype == "390" {
  1633. is390 = 1
  1634. }
  1635. if i.Insutype == "310" {
  1636. is310 = 1
  1637. }
  1638. }
  1639. }
  1640. if is390 == 1 {
  1641. insutype = "390"
  1642. }
  1643. if is310 == 1 {
  1644. insutype = "310"
  1645. }
  1646. if len(insutypes) == 0 {
  1647. insutype = "310"
  1648. }
  1649. c.ServeSuccessJSON(map[string]interface{}{
  1650. "patient": patient,
  1651. "number": token,
  1652. "insutype": insutype,
  1653. })
  1654. }
  1655. }
  1656. } else {
  1657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1658. return
  1659. }
  1660. } else { //读卡失败
  1661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1662. return
  1663. }
  1664. }
  1665. break
  1666. case 4:
  1667. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1668. var api string
  1669. if miConfig.MdtrtareaAdmvs == "320921" {
  1670. 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 +
  1671. "&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
  1672. fmt.Println(api)
  1673. } else {
  1674. 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 +
  1675. "&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)
  1676. }
  1677. resp, requestErr := http.Get(api)
  1678. if requestErr != nil {
  1679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1680. return
  1681. }
  1682. body, ioErr := ioutil.ReadAll(resp.Body)
  1683. if ioErr != nil {
  1684. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1686. return
  1687. }
  1688. var respJSON map[string]interface{}
  1689. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1690. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1692. return
  1693. }
  1694. var status string
  1695. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1696. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1697. var token string
  1698. var res ResultTwo //1101结果
  1699. var res10265 ResultTwo10265 //1101结果
  1700. if status == "0" { //读卡成功
  1701. var card_info string //卡信息
  1702. var busi_card_info string
  1703. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1704. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1705. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1706. fmt.Println(card_info)
  1707. fmt.Println(busi_card_info)
  1708. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1709. result, _ := json.Marshal(respJSON)
  1710. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1711. utils.ErrorLog("解析失败:%v", err)
  1712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1713. return
  1714. }
  1715. res.ErrMsg = res10265.ErrMsg
  1716. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1717. res.Infcode = infocode
  1718. res.Output = res10265.Output
  1719. res.InfRefmsgid = res10265.InfRefmsgid
  1720. if res.Infcode == 0 {
  1721. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1722. if err == gorm.ErrRecordNotFound {
  1723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1724. return
  1725. } else if err != nil {
  1726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1727. return
  1728. } else {
  1729. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1730. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1731. infoStr := string(Iinfos)
  1732. idetinfoStr := string(Idetinfos)
  1733. psn := &models.HisPsn{
  1734. PsnNo: res.Output.Baseinfo.PsnNo,
  1735. Age: res.Output.Baseinfo.Age,
  1736. PatientId: patient.ID,
  1737. Certno: res.Output.Baseinfo.Certno,
  1738. Brdy: res.Output.Baseinfo.Brdy,
  1739. Gend: res.Output.Baseinfo.Gend,
  1740. Naty: res.Output.Baseinfo.Naty,
  1741. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1742. PsnName: res.Output.Baseinfo.PsnName,
  1743. Idetinfo: idetinfoStr,
  1744. Insuinfo: infoStr,
  1745. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1746. CardInfo: card_info,
  1747. VerifyNumber: token,
  1748. }
  1749. service.CreateHisPsn(psn)
  1750. c.ServeSuccessJSON(map[string]interface{}{
  1751. "patient": patient,
  1752. "number": token,
  1753. })
  1754. }
  1755. } else {
  1756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1757. return
  1758. }
  1759. } else { //读卡失败
  1760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1761. return
  1762. }
  1763. } else if miConfig.MdtrtareaAdmvs == "440300" || miConfig.MdtrtareaAdmvs == "440305" {
  1764. result, requestLog := service.Gdyb6101(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  1765. saveLog(result, requestLog, "6101", "电子凭证")
  1766. var ele ELeCertData
  1767. err := json.Unmarshal([]byte(result), &ele)
  1768. if err != nil {
  1769. utils.ErrorLog("解析失败:%v", err)
  1770. }
  1771. result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, ele.Data.EcToken)
  1772. saveLog(result2, requestLog2, "1101", "获取人员信息")
  1773. var res ResultTwo
  1774. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  1775. utils.ErrorLog("解析失败:%v", err)
  1776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1777. return
  1778. }
  1779. if res.Infcode == 0 {
  1780. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  1781. if err == gorm.ErrRecordNotFound {
  1782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1783. return
  1784. } else if err != nil {
  1785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1786. return
  1787. } else {
  1788. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1789. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1790. infoStr := string(Iinfos)
  1791. idetinfoStr := string(Idetinfos)
  1792. psn := &models.HisPsn{
  1793. PsnNo: res.Output.Baseinfo.PsnNo,
  1794. Age: res.Output.Baseinfo.Age,
  1795. PatientId: patient.ID,
  1796. Certno: res.Output.Baseinfo.Certno,
  1797. Brdy: res.Output.Baseinfo.Brdy,
  1798. Gend: res.Output.Baseinfo.Gend,
  1799. Naty: res.Output.Baseinfo.Naty,
  1800. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1801. PsnName: res.Output.Baseinfo.PsnName,
  1802. Idetinfo: idetinfoStr,
  1803. Insuinfo: infoStr,
  1804. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1805. CardInfo: "",
  1806. VerifyNumber: ele.Data.EcToken,
  1807. }
  1808. service.CreateHisPsn(psn)
  1809. c.ServeSuccessJSON(map[string]interface{}{
  1810. "patient": patient,
  1811. "number": ele.Data.EcToken,
  1812. })
  1813. }
  1814. } else {
  1815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1816. return
  1817. }
  1818. }
  1819. break
  1820. }
  1821. }
  1822. var initFlag int64 = 0
  1823. func (c *HisApiController) TestGetBasBaseInit() {
  1824. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1825. Iinit := DllDef.MustFindProc("Init")
  1826. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1827. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  1828. if ret != 0 {
  1829. fmt.Println("SSCard的报错原因:", err)
  1830. fmt.Println("SSCard的运算结果为:", ret)
  1831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1832. return
  1833. }
  1834. result := int(ret)
  1835. fmt.Println("SSCard的运算结果为1:", result)
  1836. initFlag = 1
  1837. return
  1838. }
  1839. func (c *HisApiController) GetSFZBaseInfo() string {
  1840. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1841. readCard := DllDef.MustFindProc("ReadSFZ")
  1842. if readCard == nil {
  1843. fmt.Println("readcard is nil")
  1844. readCard = DllDef.MustFindProc("ReadSFZ")
  1845. }
  1846. str := make([]byte, 256)
  1847. str1 := make([]byte, 256)
  1848. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1849. fmt.Println(r)
  1850. return string(str)
  1851. }
  1852. func (c *HisApiController) GetBasBaseInfo() string {
  1853. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1854. readCard := DllDef.MustFindProc("ReadCardBas")
  1855. if readCard == nil {
  1856. fmt.Println("readcard is nil")
  1857. readCard = DllDef.MustFindProc("ReadCardBas")
  1858. }
  1859. str := make([]byte, 1024)
  1860. str1 := make([]byte, 1024)
  1861. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  1862. fmt.Println(string(str1))
  1863. fmt.Println(string(str))
  1864. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1865. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1866. if ret2 != 0 {
  1867. return ""
  1868. }
  1869. return string(str)
  1870. }
  1871. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  1872. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  1873. readCard := DllDef.MustFindProc("read_cardinfo")
  1874. if readCard == nil {
  1875. fmt.Println("readcard is nil")
  1876. readCard = DllDef.MustFindProc("read_cardinfo")
  1877. }
  1878. str := make([]byte, 1024) //卡号
  1879. str1 := make([]byte, 1024) //卡识别码
  1880. str2 := make([]byte, 1024) //身份证号
  1881. str3 := make([]byte, 1024) //姓名
  1882. str4 := make([]byte, 1024) //错误信息
  1883. 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])))
  1884. fmt.Println(string(str1))
  1885. fmt.Println(string(str))
  1886. fmt.Println(string(str2))
  1887. fmt.Println(string(str3))
  1888. fmt.Println(string(str4))
  1889. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1890. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1891. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  1892. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  1893. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  1894. if ret2 != 0 {
  1895. return "", "", "", "", ""
  1896. }
  1897. return string(str), string(str1), string(str2), string(str3), string(str4)
  1898. }
  1899. type CustomFundPay struct {
  1900. FundPayType string `json:"fund_pay_type"`
  1901. FundPayamt float64 `json:"fund_payamt"`
  1902. }
  1903. func (c *HisApiController) GetSettleList() {
  1904. order_id, _ := c.GetInt64("order_id")
  1905. admin_user_id, _ := c.GetInt64("admin_user_id")
  1906. order, _ := service.GetHisOrderByIDTwo(order_id)
  1907. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1908. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1909. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1910. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1911. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1912. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1913. if order.ID == 0 {
  1914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1915. return
  1916. }
  1917. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1918. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1919. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1920. fmt.Println(count)
  1921. var zero string
  1922. number := count + 1
  1923. if number >= 1000 {
  1924. zero = "0000" + strconv.FormatInt(number, 10)
  1925. } else if number >= 10000 {
  1926. zero = "000" + strconv.FormatInt(number, 10)
  1927. } else if number >= 100000 {
  1928. zero = "00" + strconv.FormatInt(number, 10)
  1929. } else if number >= 1000000 {
  1930. zero = "0" + strconv.FormatInt(number, 10)
  1931. } else {
  1932. zero = strconv.FormatInt(number, 10)
  1933. }
  1934. fmt.Println(zero)
  1935. struct4101 := service.Struct4101{
  1936. PsnNo: order.PsnNo,
  1937. MdtrtId: order.MdtrtId,
  1938. SetlId: order.SetlId,
  1939. PsnName: order.PsnName,
  1940. Gend: order.Gend,
  1941. Brdy: his.Brdy,
  1942. Age: his.Age,
  1943. Naty: order.Naty,
  1944. PatnCertType: "01",
  1945. Certno: order.Certno,
  1946. Prfs: "90",
  1947. ConerName: roles[0].UserName,
  1948. PatnRlts: "99",
  1949. ConerAddr: miConfig.OrgName,
  1950. ConerTel: admin.Mobile,
  1951. HiType: order.Insutype,
  1952. Insuplc: miConfig.InsuplcAdmdvs,
  1953. MaindiagFlag: "1",
  1954. BillCode: last_order.FaPiaoCode,
  1955. BillNo: zero,
  1956. BizSn: order.Number,
  1957. PsnSelfPay: order.PsnPartAmt,
  1958. PsnOwnPay: order.PsnPartAmt,
  1959. AcctPay: order.AcctPay,
  1960. PsnCashpay: order.PsnCashPay,
  1961. HiPaymtd: "1",
  1962. Hsorg: miConfig.InsuplcAdmdvs,
  1963. HsorgOpter: miConfig.InsuplcAdmdvs,
  1964. MedinsFillPsn: curRoles.UserName,
  1965. MedinsFillDept: depart.Name,
  1966. IptMedType: "2",
  1967. }
  1968. struct4101.SetlBegnDate = order.SetlTime
  1969. struct4101.SetlEndDate = order.SetlTime
  1970. time_arr := strings.Split(order.SetlTime, " ")
  1971. struct4101.AdmTime = time_arr[0]
  1972. struct4101.AdmEndTime = time_arr[0]
  1973. var rf []CustomFundPay
  1974. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1975. var tempFunPays []service.CustomStruct
  1976. for _, item := range rf {
  1977. var tempFunPay service.CustomStruct
  1978. tempFunPay.FundPayamt = item.FundPayamt
  1979. tempFunPay.FundPayType = item.FundPayType
  1980. tempFunPays = append(tempFunPays, tempFunPay)
  1981. }
  1982. struct4101.CustomStruct = tempFunPays
  1983. var tempDiaginfos []service.DiaginfoStructTwo
  1984. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1985. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1986. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  1987. var config []*models.HisXtDiagnoseConfig
  1988. for _, item := range diagnosis_ids {
  1989. id, _ := strconv.ParseInt(item, 10, 64)
  1990. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1991. config = append(config, &diagnosisConfig)
  1992. }
  1993. for index, item := range config {
  1994. if index == 0 {
  1995. var tempDiaginfo service.DiaginfoStructTwo
  1996. tempDiaginfo.DiagCode = item.CountryCode
  1997. tempDiaginfo.DiagName = item.CountryContentName
  1998. tempDiaginfo.DiagType = "1"
  1999. tempDiaginfo.MaindiagFlag = "1"
  2000. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2001. } else {
  2002. var tempDiaginfo service.DiaginfoStructTwo
  2003. tempDiaginfo.DiagCode = item.CountryCode
  2004. tempDiaginfo.DiagName = item.CountryContentName
  2005. tempDiaginfo.DiagType = "2"
  2006. tempDiaginfo.MaindiagFlag = "0"
  2007. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2008. }
  2009. }
  2010. struct4101.Diseinfo = tempDiaginfos
  2011. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2012. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2013. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2014. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  2015. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  2016. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2017. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2018. var iteminfo service.IteminfoStruct
  2019. var bedCostTotal float64 = 0 //床位总费
  2020. var bedCostSelfTotal float64 = 0 //床位自费
  2021. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2022. var operationCostTotal float64 = 0 //手术费
  2023. var operationCostSelfTotal float64 = 0 //手术费
  2024. var operationCostPartSelfTotal float64 = 0 //手术费
  2025. var otherCostTotal float64 = 0 //其他费用
  2026. var otherCostSelfTotal float64 = 0 //其他费用
  2027. var otherCostPartSelfTotal float64 = 0 //其他费用
  2028. var materialCostTotal float64 = 0 //材料费
  2029. var materialCostSelfTotal float64 = 0 //材料费
  2030. var materialCostPartSelfTotal float64 = 0 //材料费
  2031. var westernMedicineCostTotal float64 = 0 //西药费
  2032. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2033. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2034. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2035. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2036. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2037. var checkCostTotal float64 = 0 //检查费
  2038. var checkCostSelfTotal float64 = 0 //检查费
  2039. var checkCostPartSelfTotal float64 = 0 //检查费
  2040. var laboratoryCostTotal float64 = 0 //化验费
  2041. var laboratoryCostSelfTotal float64 = 0 //化验费
  2042. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2043. var treatCostTotal float64 = 0 //治疗费用
  2044. var treatCostSelfTotal float64 = 0 //治疗费用
  2045. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2046. decimal.DivisionPrecision = 2
  2047. var bed_fulamt_ownpay_amt float64 = 0
  2048. var operation_fulamt_ownpay_amt float64 = 0
  2049. var other_fulamt_ownpay_amt float64 = 0
  2050. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2051. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2052. var check_fulamt_ownpay_amt float64 = 0
  2053. var material_fulamt_ownpay_amt float64 = 0
  2054. var laboratory_fulamt_ownpay_amt float64 = 0
  2055. var treat_fulamt_ownpay_amt float64 = 0
  2056. var bed_claa_sunmfee float64 = 0
  2057. var bed_clab_amt float64 = 0
  2058. var bed_other_amt float64 = 0
  2059. var operation_claa_sunmfee float64 = 0
  2060. var operation_clab_amt float64 = 0
  2061. var operation_other_amt float64 = 0
  2062. var other_claa_sunmfee float64 = 0
  2063. var other_clab_amt float64 = 0
  2064. var other_other_amt float64 = 0
  2065. var westernMedicine_claa_sunmfee float64 = 0
  2066. var westernMedicine_clab_amt float64 = 0
  2067. var westernMedicine_other_amt float64 = 0
  2068. var chineseTraditional_claa_sunmfee float64 = 0
  2069. var chineseTraditional_clab_amt float64 = 0
  2070. var chineseTraditional_other_amt float64 = 0
  2071. var check_claa_sunmfee float64 = 0
  2072. var check_clab_amt float64 = 0
  2073. var check_other_amt float64 = 0
  2074. var material_claa_sunmfee float64 = 0
  2075. var material_clab_amt float64 = 0
  2076. var material_other_amt float64 = 0
  2077. var laboratory_claa_sunmfee float64 = 0
  2078. var laboratory_clab_amt float64 = 0
  2079. var laboratory_other_amt float64 = 0
  2080. var treat_claa_sunmfee float64 = 0
  2081. var treat_clab_amt float64 = 0
  2082. var treat_other_amt float64 = 0
  2083. for _, item := range order.HisOrderInfo {
  2084. if item.MedChrgitmType == "01" { //床位费
  2085. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2086. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2087. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2088. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2089. if item.ChrgitmLv == "1" {
  2090. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2091. }
  2092. if item.ChrgitmLv == "2" {
  2093. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2094. }
  2095. if item.ChrgitmLv == "3" {
  2096. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2097. }
  2098. }
  2099. if item.MedChrgitmType == "03" { //检查费
  2100. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2101. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2102. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2103. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2104. if item.ChrgitmLv == "1" {
  2105. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2106. }
  2107. if item.ChrgitmLv == "2" {
  2108. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2109. }
  2110. if item.ChrgitmLv == "3" {
  2111. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2112. }
  2113. }
  2114. if item.MedChrgitmType == "04" { //化验费
  2115. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2116. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2117. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2118. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2119. if item.ChrgitmLv == "1" {
  2120. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2121. }
  2122. if item.ChrgitmLv == "2" {
  2123. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2124. }
  2125. if item.ChrgitmLv == "3" {
  2126. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2127. }
  2128. }
  2129. if item.MedChrgitmType == "05" { //治疗费
  2130. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2131. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2132. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2133. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2134. if item.ChrgitmLv == "1" {
  2135. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2136. }
  2137. if item.ChrgitmLv == "2" {
  2138. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2139. }
  2140. if item.ChrgitmLv == "3" {
  2141. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2142. }
  2143. }
  2144. if item.MedChrgitmType == "06" { //手术费
  2145. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2146. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2147. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2148. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2149. if item.ChrgitmLv == "1" {
  2150. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2151. }
  2152. if item.ChrgitmLv == "2" {
  2153. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2154. }
  2155. if item.ChrgitmLv == "3" {
  2156. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2157. }
  2158. }
  2159. if item.MedChrgitmType == "08" { //材料费
  2160. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2161. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2162. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2163. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2164. if item.ChrgitmLv == "1" {
  2165. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2166. }
  2167. if item.ChrgitmLv == "2" {
  2168. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2169. }
  2170. if item.ChrgitmLv == "3" {
  2171. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2172. }
  2173. }
  2174. if item.MedChrgitmType == "09" { //西药费
  2175. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2176. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2177. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2178. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2179. if item.ChrgitmLv == "1" {
  2180. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2181. }
  2182. if item.ChrgitmLv == "2" {
  2183. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2184. }
  2185. if item.ChrgitmLv == "3" {
  2186. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2187. }
  2188. }
  2189. if item.MedChrgitmType == "11" { //中成费
  2190. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2191. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2192. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2193. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2194. if item.ChrgitmLv == "1" {
  2195. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2196. }
  2197. if item.ChrgitmLv == "2" {
  2198. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2199. }
  2200. if item.ChrgitmLv == "3" {
  2201. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2202. }
  2203. }
  2204. if item.MedChrgitmType == "14" { //其他费
  2205. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2206. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2207. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2208. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2209. if item.ChrgitmLv == "1" {
  2210. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2211. }
  2212. if item.ChrgitmLv == "2" {
  2213. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2214. }
  2215. if item.ChrgitmLv == "3" {
  2216. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2217. }
  2218. }
  2219. }
  2220. var iteminfoStructs []service.IteminfoStruct
  2221. if bedCostTotal != 0 {
  2222. iteminfo.MedChrgitm = "01"
  2223. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2224. iteminfo.Amt = bedCostTotal
  2225. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2226. iteminfo.ClabAmt = bed_clab_amt
  2227. iteminfo.OthAmt = bed_other_amt
  2228. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2229. }
  2230. if checkCostTotal != 0 {
  2231. iteminfo.MedChrgitm = "03"
  2232. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2233. iteminfo.Amt = checkCostTotal
  2234. iteminfo.ClaaSumfee = check_claa_sunmfee
  2235. iteminfo.ClabAmt = check_clab_amt
  2236. iteminfo.OthAmt = check_other_amt
  2237. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2238. }
  2239. if laboratoryCostTotal != 0 {
  2240. iteminfo.MedChrgitm = "04"
  2241. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2242. iteminfo.Amt = laboratoryCostTotal
  2243. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2244. iteminfo.ClabAmt = laboratory_clab_amt
  2245. iteminfo.OthAmt = laboratory_other_amt
  2246. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2247. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2248. }
  2249. if treatCostTotal != 0 {
  2250. iteminfo.MedChrgitm = "05"
  2251. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2252. iteminfo.Amt = treatCostTotal
  2253. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2254. iteminfo.ClabAmt = treat_clab_amt
  2255. iteminfo.OthAmt = treat_other_amt
  2256. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2257. //(struct4101.IteminfoStruct, iteminfo)
  2258. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2259. }
  2260. if operationCostTotal != 0 {
  2261. iteminfo.MedChrgitm = "06"
  2262. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2263. iteminfo.Amt = operationCostTotal
  2264. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2265. iteminfo.ClabAmt = operation_clab_amt
  2266. iteminfo.OthAmt = operation_other_amt
  2267. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2268. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2269. }
  2270. if materialCostTotal != 0 {
  2271. iteminfo.MedChrgitm = "08"
  2272. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2273. iteminfo.Amt = materialCostTotal
  2274. iteminfo.ClaaSumfee = material_claa_sunmfee
  2275. iteminfo.ClabAmt = material_clab_amt
  2276. iteminfo.OthAmt = material_other_amt
  2277. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2278. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2279. }
  2280. if westernMedicineCostTotal != 0 {
  2281. iteminfo.MedChrgitm = "09"
  2282. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2283. iteminfo.Amt = westernMedicineCostTotal
  2284. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2285. iteminfo.ClabAmt = westernMedicine_clab_amt
  2286. iteminfo.OthAmt = westernMedicine_other_amt
  2287. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2288. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2289. }
  2290. if chineseTraditionalMedicineCostTotal != 0 {
  2291. iteminfo.MedChrgitm = "11"
  2292. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2293. iteminfo.Amt = westernMedicineCostTotal
  2294. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2295. iteminfo.ClabAmt = westernMedicine_clab_amt
  2296. iteminfo.OthAmt = westernMedicine_other_amt
  2297. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2298. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2299. }
  2300. if otherCostTotal != 0 {
  2301. iteminfo.MedChrgitm = "14"
  2302. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2303. iteminfo.Amt = otherCostTotal
  2304. iteminfo.ClaaSumfee = other_claa_sunmfee
  2305. iteminfo.ClabAmt = other_clab_amt
  2306. iteminfo.OthAmt = other_other_amt
  2307. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2308. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2309. }
  2310. struct4101.IteminfoStruct = iteminfoStructs
  2311. struct4101.Ntly = "中国"
  2312. struct4101.AdmCaty = "A03.06"
  2313. var res ResultSeventeen
  2314. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2315. var resOther ResultSeventeenOther
  2316. var pp models.PublicParams
  2317. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2318. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2319. pp.FixmedinsName = miConfig.OrgName
  2320. pp.FixmedinsCode = miConfig.Code
  2321. pp.RequestUrl = miConfig.Url
  2322. pp.Cainfo = miConfig.Cainfo
  2323. pp.SecretKey = miConfig.SecretKey
  2324. pp.AccessKey = miConfig.AccessKey
  2325. pp.OpterName = curRoles.UserName
  2326. client := &http.Client{}
  2327. var req *http.Request
  2328. data := make(map[string]interface{})
  2329. data["struct4101"] = struct4101
  2330. data["pp"] = pp
  2331. bytesData, _ := json.Marshal(data)
  2332. if miConfig.MdtrtareaAdmvs == "320921" {
  2333. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2334. } else {
  2335. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2336. }
  2337. resp, _ := client.Do(req)
  2338. defer resp.Body.Close()
  2339. body, ioErr := ioutil.ReadAll(resp.Body)
  2340. if ioErr != nil {
  2341. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2343. return
  2344. }
  2345. var respJSON map[string]interface{}
  2346. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2347. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2349. return
  2350. }
  2351. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2352. userJSONBytes, _ := json.Marshal(respJSON)
  2353. fmt.Println("log")
  2354. fmt.Println(string(userJSONBytes))
  2355. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  2356. utils.ErrorLog("解析失败:%v", err)
  2357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2358. return
  2359. }
  2360. res.InfRefmsgid = resOther.InfRefmsgid
  2361. res.Output = resOther.Output
  2362. res.ErrMsg = resOther.ErrMsg
  2363. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  2364. res.Infcode = infocode
  2365. } else {
  2366. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2367. var dat map[string]interface{}
  2368. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2369. fmt.Println(dat)
  2370. } else {
  2371. fmt.Println(err)
  2372. }
  2373. userJSONBytes, _ := json.Marshal(dat)
  2374. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2375. utils.ErrorLog("解析失败:%v", err)
  2376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2377. return
  2378. }
  2379. }
  2380. if res.Infcode != 0 {
  2381. c.ServeSuccessJSON(map[string]interface{}{
  2382. "failed_code": -10,
  2383. "msg": res.ErrMsg,
  2384. })
  2385. return
  2386. } else {
  2387. order.FaPiaoNumber = zero
  2388. order.FaPiaoCode = last_order.FaPiaoCode
  2389. service.UpdateOrder(order)
  2390. hisFundSettleListResult := &models.HisFundSettleListResult{
  2391. Number: res.Output.SetlListId,
  2392. Status: 1,
  2393. Ctime: time.Now().Unix(),
  2394. Mtime: time.Now().Unix(),
  2395. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2396. IsUpload: 1,
  2397. OrderId: order_id,
  2398. }
  2399. service.CreateUploadRecord(hisFundSettleListResult)
  2400. c.ServeSuccessJSON(map[string]interface{}{
  2401. "msg": "上传成功",
  2402. "result": hisFundSettleListResult,
  2403. })
  2404. return
  2405. }
  2406. }
  2407. func (c *HisApiController) GetSettleListHospital() {
  2408. order_id, _ := c.GetInt64("order_id")
  2409. admin_user_id, _ := c.GetInt64("admin_user_id")
  2410. order, _ := service.GetHisOrderByIDTwo(order_id)
  2411. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2412. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2413. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2414. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2415. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2416. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2417. if order.ID == 0 {
  2418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2419. return
  2420. }
  2421. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  2422. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  2423. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  2424. fmt.Println(count)
  2425. var zero string
  2426. number := count + 1
  2427. if number >= 1000 {
  2428. zero = "0000" + strconv.FormatInt(number, 10)
  2429. } else if number >= 10000 {
  2430. zero = "000" + strconv.FormatInt(number, 10)
  2431. } else if number >= 100000 {
  2432. zero = "00" + strconv.FormatInt(number, 10)
  2433. } else if number >= 1000000 {
  2434. zero = "0" + strconv.FormatInt(number, 10)
  2435. } else {
  2436. zero = strconv.FormatInt(number, 10)
  2437. }
  2438. fmt.Println(zero)
  2439. struct4101 := service.Struct4101{
  2440. PsnNo: order.PsnNo,
  2441. MdtrtId: order.MdtrtId,
  2442. SetlId: order.SetlId,
  2443. PsnName: order.PsnName,
  2444. Gend: order.Gend,
  2445. Brdy: his.Brdy,
  2446. Age: int64(order.Age),
  2447. Naty: order.Naty,
  2448. PatnCertType: "01",
  2449. Certno: order.Certno,
  2450. Prfs: "90",
  2451. ConerName: roles[0].UserName,
  2452. PatnRlts: "99",
  2453. ConerAddr: miConfig.OrgName,
  2454. ConerTel: admin.Mobile,
  2455. HiType: order.Insutype,
  2456. Insuplc: miConfig.InsuplcAdmdvs,
  2457. MaindiagFlag: "1",
  2458. BillCode: last_order.FaPiaoCode,
  2459. BillNo: zero,
  2460. BizSn: order.Number,
  2461. PsnSelfPay: order.PsnPartAmt,
  2462. PsnOwnPay: order.PsnPartAmt,
  2463. AcctPay: order.AcctPay,
  2464. PsnCashpay: order.PsnCashPay,
  2465. HiPaymtd: "1",
  2466. Hsorg: miConfig.InsuplcAdmdvs,
  2467. HsorgOpter: miConfig.InsuplcAdmdvs,
  2468. MedinsFillPsn: curRoles.UserName,
  2469. MedinsFillDept: depart.Name,
  2470. IptMedType: "2",
  2471. AdmTime: his.InHosptialTime,
  2472. AdmEndTime: his.OutHosptialTime,
  2473. }
  2474. struct4101.SetlBegnDate = order.SetlTime
  2475. struct4101.SetlEndDate = order.SetlTime
  2476. var rf []CustomFundPay
  2477. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2478. var tempFunPays []service.CustomStruct
  2479. for _, item := range rf {
  2480. var tempFunPay service.CustomStruct
  2481. tempFunPay.FundPayamt = item.FundPayamt
  2482. tempFunPay.FundPayType = item.FundPayType
  2483. tempFunPays = append(tempFunPays, tempFunPay)
  2484. }
  2485. struct4101.CustomStruct = tempFunPays
  2486. var tempDiaginfos []service.DiaginfoStructTwo
  2487. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2488. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2489. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2490. var config []*models.HisXtDiagnoseConfig
  2491. for _, item := range diagnosis_ids {
  2492. id, _ := strconv.ParseInt(item, 10, 64)
  2493. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2494. config = append(config, &diagnosisConfig)
  2495. }
  2496. for index, item := range config {
  2497. if index == 0 {
  2498. var tempDiaginfo service.DiaginfoStructTwo
  2499. tempDiaginfo.DiagCode = item.CountryCode
  2500. tempDiaginfo.DiagName = item.CountryContentName
  2501. tempDiaginfo.DiagType = "1"
  2502. tempDiaginfo.MaindiagFlag = "1"
  2503. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2504. } else {
  2505. var tempDiaginfo service.DiaginfoStructTwo
  2506. tempDiaginfo.DiagCode = item.CountryCode
  2507. tempDiaginfo.DiagName = item.CountryContentName
  2508. tempDiaginfo.DiagType = "2"
  2509. tempDiaginfo.MaindiagFlag = "0"
  2510. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2511. }
  2512. }
  2513. struct4101.Diseinfo = tempDiaginfos
  2514. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2515. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2516. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2517. tempOpspdiseinfo2.OprnOprtCode = ""
  2518. tempOpspdiseinfo2.OprnOprtName = ""
  2519. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2520. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2521. var iteminfo service.IteminfoStruct
  2522. var bedCostTotal float64 = 0 //床位总费
  2523. var bedCostSelfTotal float64 = 0 //床位自费
  2524. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2525. var operationCostTotal float64 = 0 //手术费
  2526. var operationCostSelfTotal float64 = 0 //手术费
  2527. var operationCostPartSelfTotal float64 = 0 //手术费
  2528. var otherCostTotal float64 = 0 //其他费用
  2529. var otherCostSelfTotal float64 = 0 //其他费用
  2530. var otherCostPartSelfTotal float64 = 0 //其他费用
  2531. var materialCostTotal float64 = 0 //材料费
  2532. var materialCostSelfTotal float64 = 0 //材料费
  2533. var materialCostPartSelfTotal float64 = 0 //材料费
  2534. var westernMedicineCostTotal float64 = 0 //西药费
  2535. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2536. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2537. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2538. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2539. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2540. var checkCostTotal float64 = 0 //检查费
  2541. var checkCostSelfTotal float64 = 0 //检查费
  2542. var checkCostPartSelfTotal float64 = 0 //检查费
  2543. var laboratoryCostTotal float64 = 0 //化验费
  2544. var laboratoryCostSelfTotal float64 = 0 //化验费
  2545. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2546. var treatCostTotal float64 = 0 //治疗费用
  2547. var treatCostSelfTotal float64 = 0 //治疗费用
  2548. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2549. decimal.DivisionPrecision = 2
  2550. var bed_fulamt_ownpay_amt float64 = 0
  2551. var operation_fulamt_ownpay_amt float64 = 0
  2552. var other_fulamt_ownpay_amt float64 = 0
  2553. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2554. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2555. var check_fulamt_ownpay_amt float64 = 0
  2556. var material_fulamt_ownpay_amt float64 = 0
  2557. var laboratory_fulamt_ownpay_amt float64 = 0
  2558. var treat_fulamt_ownpay_amt float64 = 0
  2559. var bed_claa_sunmfee float64 = 0
  2560. var bed_clab_amt float64 = 0
  2561. var bed_other_amt float64 = 0
  2562. var operation_claa_sunmfee float64 = 0
  2563. var operation_clab_amt float64 = 0
  2564. var operation_other_amt float64 = 0
  2565. var other_claa_sunmfee float64 = 0
  2566. var other_clab_amt float64 = 0
  2567. var other_other_amt float64 = 0
  2568. var westernMedicine_claa_sunmfee float64 = 0
  2569. var westernMedicine_clab_amt float64 = 0
  2570. var westernMedicine_other_amt float64 = 0
  2571. var chineseTraditional_claa_sunmfee float64 = 0
  2572. var chineseTraditional_clab_amt float64 = 0
  2573. var chineseTraditional_other_amt float64 = 0
  2574. var check_claa_sunmfee float64 = 0
  2575. var check_clab_amt float64 = 0
  2576. var check_other_amt float64 = 0
  2577. var material_claa_sunmfee float64 = 0
  2578. var material_clab_amt float64 = 0
  2579. var material_other_amt float64 = 0
  2580. var laboratory_claa_sunmfee float64 = 0
  2581. var laboratory_clab_amt float64 = 0
  2582. var laboratory_other_amt float64 = 0
  2583. var treat_claa_sunmfee float64 = 0
  2584. var treat_clab_amt float64 = 0
  2585. var treat_other_amt float64 = 0
  2586. for _, item := range order.HisOrderInfo {
  2587. if item.MedChrgitmType == "01" { //床位费
  2588. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2589. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2590. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2591. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2592. if item.ChrgitmLv == "1" {
  2593. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2594. }
  2595. if item.ChrgitmLv == "2" {
  2596. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2597. }
  2598. if item.ChrgitmLv == "3" {
  2599. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2600. }
  2601. }
  2602. if item.MedChrgitmType == "03" { //检查费
  2603. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2604. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2605. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2606. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2607. if item.ChrgitmLv == "1" {
  2608. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2609. }
  2610. if item.ChrgitmLv == "2" {
  2611. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2612. }
  2613. if item.ChrgitmLv == "3" {
  2614. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2615. }
  2616. }
  2617. if item.MedChrgitmType == "04" { //化验费
  2618. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2619. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2620. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2621. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2622. if item.ChrgitmLv == "1" {
  2623. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2624. }
  2625. if item.ChrgitmLv == "2" {
  2626. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2627. }
  2628. if item.ChrgitmLv == "3" {
  2629. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2630. }
  2631. }
  2632. if item.MedChrgitmType == "05" { //治疗费
  2633. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2634. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2635. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2636. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2637. if item.ChrgitmLv == "1" {
  2638. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2639. }
  2640. if item.ChrgitmLv == "2" {
  2641. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2642. }
  2643. if item.ChrgitmLv == "3" {
  2644. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2645. }
  2646. }
  2647. if item.MedChrgitmType == "06" { //手术费
  2648. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2649. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2650. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2651. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2652. if item.ChrgitmLv == "1" {
  2653. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2654. }
  2655. if item.ChrgitmLv == "2" {
  2656. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2657. }
  2658. if item.ChrgitmLv == "3" {
  2659. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2660. }
  2661. }
  2662. if item.MedChrgitmType == "08" { //材料费
  2663. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2664. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2665. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2666. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2667. if item.ChrgitmLv == "1" {
  2668. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2669. }
  2670. if item.ChrgitmLv == "2" {
  2671. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2672. }
  2673. if item.ChrgitmLv == "3" {
  2674. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2675. }
  2676. }
  2677. if item.MedChrgitmType == "09" { //西药费
  2678. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2679. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2680. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2681. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2682. if item.ChrgitmLv == "1" {
  2683. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2684. }
  2685. if item.ChrgitmLv == "2" {
  2686. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2687. }
  2688. if item.ChrgitmLv == "3" {
  2689. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2690. }
  2691. }
  2692. if item.MedChrgitmType == "11" { //中成费
  2693. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2694. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2695. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2696. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2697. if item.ChrgitmLv == "1" {
  2698. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2699. }
  2700. if item.ChrgitmLv == "2" {
  2701. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2702. }
  2703. if item.ChrgitmLv == "3" {
  2704. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2705. }
  2706. }
  2707. if item.MedChrgitmType == "14" { //其他费
  2708. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2709. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2710. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2711. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2712. if item.ChrgitmLv == "1" {
  2713. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2714. }
  2715. if item.ChrgitmLv == "2" {
  2716. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2717. }
  2718. if item.ChrgitmLv == "3" {
  2719. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2720. }
  2721. }
  2722. }
  2723. var iteminfoStructs []service.IteminfoStruct
  2724. if bedCostTotal != 0 {
  2725. iteminfo.MedChrgitm = "01"
  2726. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2727. iteminfo.Amt = bedCostTotal
  2728. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2729. iteminfo.ClabAmt = bed_clab_amt
  2730. iteminfo.OthAmt = bed_other_amt
  2731. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2732. }
  2733. if checkCostTotal != 0 {
  2734. iteminfo.MedChrgitm = "03"
  2735. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2736. iteminfo.Amt = checkCostTotal
  2737. iteminfo.ClaaSumfee = check_claa_sunmfee
  2738. iteminfo.ClabAmt = check_clab_amt
  2739. iteminfo.OthAmt = check_other_amt
  2740. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2741. }
  2742. if laboratoryCostTotal != 0 {
  2743. iteminfo.MedChrgitm = "04"
  2744. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2745. iteminfo.Amt = laboratoryCostTotal
  2746. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2747. iteminfo.ClabAmt = laboratory_clab_amt
  2748. iteminfo.OthAmt = laboratory_other_amt
  2749. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2750. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2751. }
  2752. if treatCostTotal != 0 {
  2753. iteminfo.MedChrgitm = "05"
  2754. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2755. iteminfo.Amt = treatCostTotal
  2756. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2757. iteminfo.ClabAmt = treat_clab_amt
  2758. iteminfo.OthAmt = treat_other_amt
  2759. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2760. //(struct4101.IteminfoStruct, iteminfo)
  2761. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2762. }
  2763. if operationCostTotal != 0 {
  2764. iteminfo.MedChrgitm = "06"
  2765. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2766. iteminfo.Amt = operationCostTotal
  2767. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2768. iteminfo.ClabAmt = operation_clab_amt
  2769. iteminfo.OthAmt = operation_other_amt
  2770. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2771. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2772. }
  2773. if materialCostTotal != 0 {
  2774. iteminfo.MedChrgitm = "08"
  2775. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2776. iteminfo.Amt = materialCostTotal
  2777. iteminfo.ClaaSumfee = material_claa_sunmfee
  2778. iteminfo.ClabAmt = material_clab_amt
  2779. iteminfo.OthAmt = material_other_amt
  2780. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2781. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2782. }
  2783. if westernMedicineCostTotal != 0 {
  2784. iteminfo.MedChrgitm = "09"
  2785. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2786. iteminfo.Amt = westernMedicineCostTotal
  2787. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2788. iteminfo.ClabAmt = westernMedicine_clab_amt
  2789. iteminfo.OthAmt = westernMedicine_other_amt
  2790. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2791. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2792. }
  2793. if chineseTraditionalMedicineCostTotal != 0 {
  2794. iteminfo.MedChrgitm = "11"
  2795. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2796. iteminfo.Amt = westernMedicineCostTotal
  2797. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2798. iteminfo.ClabAmt = westernMedicine_clab_amt
  2799. iteminfo.OthAmt = westernMedicine_other_amt
  2800. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2801. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2802. }
  2803. if otherCostTotal != 0 {
  2804. iteminfo.MedChrgitm = "14"
  2805. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2806. iteminfo.Amt = otherCostTotal
  2807. iteminfo.ClaaSumfee = other_claa_sunmfee
  2808. iteminfo.ClabAmt = other_clab_amt
  2809. iteminfo.OthAmt = other_other_amt
  2810. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2811. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2812. }
  2813. struct4101.IteminfoStruct = iteminfoStructs
  2814. struct4101.Ntly = "中国"
  2815. struct4101.AdmCaty = "A03.06"
  2816. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2817. fmt.Println(result)
  2818. var dat map[string]interface{}
  2819. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2820. fmt.Println(dat)
  2821. } else {
  2822. fmt.Println(err)
  2823. }
  2824. userJSONBytes, _ := json.Marshal(dat)
  2825. var res ResultSeventeen
  2826. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2827. utils.ErrorLog("解析失败:%v", err)
  2828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2829. return
  2830. }
  2831. if res.Infcode != 0 {
  2832. c.ServeSuccessJSON(map[string]interface{}{
  2833. "failed_code": -10,
  2834. "msg": res.ErrMsg,
  2835. })
  2836. return
  2837. } else {
  2838. order.FaPiaoNumber = zero
  2839. order.FaPiaoCode = last_order.FaPiaoCode
  2840. service.UpdateOrder(order)
  2841. hisFundSettleListResult := &models.HisFundSettleListResult{
  2842. Number: res.Output.SetlListId,
  2843. Status: 1,
  2844. Ctime: time.Now().Unix(),
  2845. Mtime: time.Now().Unix(),
  2846. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2847. IsUpload: 1,
  2848. OrderId: order_id,
  2849. }
  2850. service.CreateUploadRecord(hisFundSettleListResult)
  2851. c.ServeSuccessJSON(map[string]interface{}{
  2852. "msg": "上传成功",
  2853. "result": hisFundSettleListResult,
  2854. })
  2855. return
  2856. }
  2857. }
  2858. func (c *HisApiController) GetBatchSettleList() {
  2859. orders, _ := service.GetAllHisOrder(10106)
  2860. for _, item := range orders {
  2861. order_id := item.ID
  2862. order, _ := service.GetHisOrderByIDTwo(order_id)
  2863. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2864. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2865. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2866. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  2867. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2868. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2869. if order.ID == 0 {
  2870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2871. return
  2872. }
  2873. if his.BalanceAccountsType == 2 {
  2874. continue
  2875. }
  2876. struct4101 := service.Struct4101{
  2877. PsnNo: order.PsnNo,
  2878. MdtrtId: order.MdtrtId,
  2879. SetlId: order.SetlId,
  2880. PsnName: order.PsnName,
  2881. Gend: order.Gend,
  2882. Brdy: his.Brdy,
  2883. Age: his.Age,
  2884. Naty: order.Naty,
  2885. PatnCertType: "01",
  2886. Certno: order.Certno,
  2887. Prfs: "90",
  2888. ConerName: roles[0].UserName,
  2889. PatnRlts: "99",
  2890. ConerAddr: miConfig.OrgName,
  2891. ConerTel: admin.Mobile,
  2892. HiType: order.Insutype,
  2893. Insuplc: his.InsuplcAdmdvs,
  2894. MaindiagFlag: "1",
  2895. BillCode: order.FaPiaoCode,
  2896. BillNo: order.FaPiaoNumber,
  2897. BizSn: order.Number,
  2898. PsnSelfPay: order.PsnPartAmt,
  2899. PsnOwnPay: order.PsnPartAmt,
  2900. AcctPay: order.AcctPay,
  2901. PsnCashpay: order.PsnCashPay,
  2902. HiPaymtd: "1",
  2903. Hsorg: his.InsuplcAdmdvs,
  2904. HsorgOpter: his.InsuplcAdmdvs,
  2905. MedinsFillPsn: curRoles.UserName,
  2906. MedinsFillDept: depart.Name,
  2907. IptMedType: "2",
  2908. }
  2909. struct4101.SetlBegnDate = order.SetlTime
  2910. struct4101.SetlEndDate = order.SetlTime
  2911. //if order.SettleType == 1 {
  2912. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  2913. // dateStr := t.Format("2006-01-02")
  2914. // struct4101.SetlBegnDate = dateStr
  2915. // struct4101.SetlEndDate = dateStr
  2916. //} else {
  2917. // t := time.Unix(int64(order.SettleStartTime), 0)
  2918. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  2919. // dateStartStr := t.Format("2006-01-02")
  2920. // dateEndStr := t2.Format("2006-01-02")
  2921. // struct4101.SetlBegnDate = dateStartStr
  2922. // struct4101.SetlEndDate = dateEndStr
  2923. //}
  2924. var rf []CustomFundPay
  2925. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2926. var tempFunPays []service.CustomStruct
  2927. var tempFunPay610100 service.CustomStruct
  2928. for _, item := range rf {
  2929. if item.FundPayType == "610100" {
  2930. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  2931. tempFunPay610100.FundPayType = item.FundPayType
  2932. } else {
  2933. var tempFunPay service.CustomStruct
  2934. tempFunPay.FundPayamt = item.FundPayamt
  2935. tempFunPay.FundPayType = item.FundPayType
  2936. tempFunPays = append(tempFunPays, tempFunPay)
  2937. }
  2938. }
  2939. tempFunPays = append(tempFunPays, tempFunPay610100)
  2940. struct4101.CustomStruct = tempFunPays
  2941. var tempDiaginfos []service.DiaginfoStructTwo
  2942. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2943. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2944. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2945. var config []*models.HisXtDiagnoseConfig
  2946. for _, item := range diagnosis_ids {
  2947. id, _ := strconv.ParseInt(item, 10, 64)
  2948. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2949. config = append(config, &diagnosisConfig)
  2950. }
  2951. for index, item := range config {
  2952. if index == 0 {
  2953. var tempDiaginfo service.DiaginfoStructTwo
  2954. tempDiaginfo.DiagCode = item.CountryCode
  2955. tempDiaginfo.DiagName = item.CountryContentName
  2956. tempDiaginfo.DiagType = "1"
  2957. tempDiaginfo.MaindiagFlag = "1"
  2958. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2959. } else {
  2960. var tempDiaginfo service.DiaginfoStructTwo
  2961. tempDiaginfo.DiagCode = item.CountryCode
  2962. tempDiaginfo.DiagName = item.CountryContentName
  2963. tempDiaginfo.DiagType = "2"
  2964. tempDiaginfo.MaindiagFlag = "0"
  2965. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2966. }
  2967. }
  2968. struct4101.Diseinfo = tempDiaginfos
  2969. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2970. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2971. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2972. tempOpspdiseinfo2.OprnOprtCode = ""
  2973. tempOpspdiseinfo2.OprnOprtName = ""
  2974. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2975. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2976. var iteminfo service.IteminfoStruct
  2977. var bedCostTotal float64 = 0 //床位总费
  2978. var bedCostSelfTotal float64 = 0 //床位自费
  2979. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2980. var examineCostTotal float64 = 0 //诊查总费
  2981. var examineCostSelfTotal float64 = 0 //诊查自费
  2982. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  2983. var nursingCostTotal float64 = 0 //护理总费
  2984. var nursingCostSelfTotal float64 = 0 //护理自费
  2985. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  2986. var chineseMedicineCostTotal float64 = 0 //中成药
  2987. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  2988. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  2989. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  2990. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  2991. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  2992. var registerCostTotal float64 = 0 //一般诊疗费
  2993. var registerCostSelfTotal float64 = 0 //一般诊疗费
  2994. var registerPartSelfTotal float64 = 0 //一般诊疗费
  2995. var operationCostTotal float64 = 0 //手术费
  2996. var operationCostSelfTotal float64 = 0 //手术费
  2997. var operationCostPartSelfTotal float64 = 0 //手术费
  2998. var otherCostTotal float64 = 0 //其他费用
  2999. var otherCostSelfTotal float64 = 0 //其他费用
  3000. var otherCostPartSelfTotal float64 = 0 //其他费用
  3001. var materialCostTotal float64 = 0 //材料费
  3002. var materialCostSelfTotal float64 = 0 //材料费
  3003. var materialCostPartSelfTotal float64 = 0 //材料费
  3004. var westernMedicineCostTotal float64 = 0 //西药费
  3005. var westernMedicineCostSelfTotal float64 = 0 //西药费
  3006. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  3007. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  3008. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  3009. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  3010. var checkCostTotal float64 = 0 //检查费
  3011. var checkCostSelfTotal float64 = 0 //检查费
  3012. var checkCostPartSelfTotal float64 = 0 //检查费
  3013. var laboratoryCostTotal float64 = 0 //化验费
  3014. var laboratoryCostSelfTotal float64 = 0 //化验费
  3015. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  3016. var treatCostTotal float64 = 0 //治疗费用
  3017. var treatCostSelfTotal float64 = 0 //治疗费用
  3018. var treatCostPartSelfTotal float64 = 0 //治疗费用
  3019. decimal.DivisionPrecision = 2
  3020. var bed_fulamt_ownpay_amt float64 = 0
  3021. var examine_fulamt_ownpay_amt float64 = 0
  3022. var nursing_fulamt_ownpay_amt float64 = 0
  3023. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  3024. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  3025. var register_fulamt_ownpay_amt float64 = 0
  3026. var operation_fulamt_ownpay_amt float64 = 0
  3027. var other_fulamt_ownpay_amt float64 = 0
  3028. var westernMedicine_fulamt_ownpay_amt float64 = 0
  3029. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  3030. var check_fulamt_ownpay_amt float64 = 0
  3031. var material_fulamt_ownpay_amt float64 = 0
  3032. var laboratory_fulamt_ownpay_amt float64 = 0
  3033. var treat_fulamt_ownpay_amt float64 = 0
  3034. var bed_claa_sunmfee float64 = 0
  3035. var bed_clab_amt float64 = 0
  3036. var bed_other_amt float64 = 0
  3037. var examine_claa_sunmfee float64 = 0
  3038. var examine_clab_amt float64 = 0
  3039. var examine_other_amt float64 = 0
  3040. var nursing_claa_sunmfee float64 = 0
  3041. var nursing_clab_amt float64 = 0
  3042. var nursing_other_amt float64 = 0
  3043. var chinese_medicine_claa_sunmfee float64 = 0
  3044. var chinese_medicine_clab_amt float64 = 0
  3045. var chinese_medicine_other_amt float64 = 0
  3046. var commonly_treatment_claa_sunmfee float64 = 0
  3047. var commonly_treatment_clab_amt float64 = 0
  3048. var commonly_treatment_other_amt float64 = 0
  3049. var operation_claa_sunmfee float64 = 0
  3050. var operation_clab_amt float64 = 0
  3051. var operation_other_amt float64 = 0
  3052. var other_claa_sunmfee float64 = 0
  3053. var other_clab_amt float64 = 0
  3054. var other_other_amt float64 = 0
  3055. var westernMedicine_claa_sunmfee float64 = 0
  3056. var westernMedicine_clab_amt float64 = 0
  3057. var westernMedicine_other_amt float64 = 0
  3058. var chineseTraditional_claa_sunmfee float64 = 0
  3059. var chineseTraditional_clab_amt float64 = 0
  3060. var chineseTraditional_other_amt float64 = 0
  3061. var check_claa_sunmfee float64 = 0
  3062. var check_clab_amt float64 = 0
  3063. var check_other_amt float64 = 0
  3064. var material_claa_sunmfee float64 = 0
  3065. var material_clab_amt float64 = 0
  3066. var material_other_amt float64 = 0
  3067. var laboratory_claa_sunmfee float64 = 0
  3068. var laboratory_clab_amt float64 = 0
  3069. var laboratory_other_amt float64 = 0
  3070. var treat_claa_sunmfee float64 = 0
  3071. var treat_clab_amt float64 = 0
  3072. var treat_other_amt float64 = 0
  3073. var register_claa_sunmfee float64 = 0
  3074. var register_clab_amt float64 = 0
  3075. var register_other_amt float64 = 0
  3076. for _, item := range order.HisOrderInfo {
  3077. if item.MedChrgitmType == "01" { //床位费
  3078. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3079. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3080. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3081. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3082. if item.ChrgitmLv == "1" {
  3083. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3084. }
  3085. if item.ChrgitmLv == "2" {
  3086. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3087. }
  3088. if item.ChrgitmLv == "3" {
  3089. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3090. }
  3091. }
  3092. if item.MedChrgitmType == "02" { //诊查
  3093. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3094. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3095. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3096. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3097. if item.ChrgitmLv == "1" {
  3098. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3099. }
  3100. if item.ChrgitmLv == "2" {
  3101. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3102. }
  3103. if item.ChrgitmLv == "3" {
  3104. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3105. }
  3106. }
  3107. if item.MedChrgitmType == "03" { //检查费
  3108. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3109. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3110. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3111. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3112. if item.ChrgitmLv == "1" {
  3113. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3114. }
  3115. if item.ChrgitmLv == "2" {
  3116. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3117. }
  3118. if item.ChrgitmLv == "3" {
  3119. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3120. }
  3121. }
  3122. if item.MedChrgitmType == "04" { //化验费
  3123. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3124. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3125. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3126. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3127. if item.ChrgitmLv == "1" {
  3128. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3129. }
  3130. if item.ChrgitmLv == "2" {
  3131. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3132. }
  3133. if item.ChrgitmLv == "3" {
  3134. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3135. }
  3136. }
  3137. if item.MedChrgitmType == "05" { //治疗费
  3138. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3139. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3140. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3141. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3142. if item.ChrgitmLv == "1" {
  3143. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3144. }
  3145. if item.ChrgitmLv == "2" {
  3146. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3147. }
  3148. if item.ChrgitmLv == "3" {
  3149. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3150. }
  3151. }
  3152. if item.MedChrgitmType == "06" { //手术费
  3153. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3154. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3155. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3156. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3157. if item.ChrgitmLv == "1" {
  3158. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3159. }
  3160. if item.ChrgitmLv == "2" {
  3161. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3162. }
  3163. if item.ChrgitmLv == "3" {
  3164. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3165. }
  3166. }
  3167. if item.MedChrgitmType == "07" { //手术费
  3168. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3169. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3170. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3171. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3172. if item.ChrgitmLv == "1" {
  3173. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3174. }
  3175. if item.ChrgitmLv == "2" {
  3176. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3177. }
  3178. if item.ChrgitmLv == "3" {
  3179. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3180. }
  3181. }
  3182. if item.MedChrgitmType == "08" { //材料费
  3183. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3184. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3185. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3186. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3187. if item.ChrgitmLv == "1" {
  3188. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3189. }
  3190. if item.ChrgitmLv == "2" {
  3191. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3192. }
  3193. if item.ChrgitmLv == "3" {
  3194. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3195. }
  3196. }
  3197. if item.MedChrgitmType == "09" { //西药费
  3198. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3199. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3200. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3201. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3202. if item.ChrgitmLv == "1" {
  3203. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3204. }
  3205. if item.ChrgitmLv == "2" {
  3206. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3207. }
  3208. if item.ChrgitmLv == "3" {
  3209. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3210. }
  3211. }
  3212. if item.MedChrgitmType == "10" { //中药饮片
  3213. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3214. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3215. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3216. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3217. if item.ChrgitmLv == "1" {
  3218. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3219. }
  3220. if item.ChrgitmLv == "2" {
  3221. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3222. }
  3223. if item.ChrgitmLv == "3" {
  3224. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3225. }
  3226. }
  3227. if item.MedChrgitmType == "11" { //中成费
  3228. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3229. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3230. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3231. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3232. if item.ChrgitmLv == "1" {
  3233. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3234. }
  3235. if item.ChrgitmLv == "2" {
  3236. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3237. }
  3238. if item.ChrgitmLv == "3" {
  3239. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3240. }
  3241. }
  3242. if item.MedChrgitmType == "12" { //中成费
  3243. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3244. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3245. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3246. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3247. if item.ChrgitmLv == "1" {
  3248. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3249. }
  3250. if item.ChrgitmLv == "2" {
  3251. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3252. }
  3253. if item.ChrgitmLv == "3" {
  3254. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3255. }
  3256. }
  3257. if item.MedChrgitmType == "13" { //中成费
  3258. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3259. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3260. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3261. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3262. if item.ChrgitmLv == "1" {
  3263. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3264. }
  3265. if item.ChrgitmLv == "2" {
  3266. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3267. }
  3268. if item.ChrgitmLv == "3" {
  3269. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3270. }
  3271. }
  3272. if item.MedChrgitmType == "14" { //其他费
  3273. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3274. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3275. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3276. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3277. if item.ChrgitmLv == "1" {
  3278. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3279. }
  3280. if item.ChrgitmLv == "2" {
  3281. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3282. }
  3283. if item.ChrgitmLv == "3" {
  3284. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3285. }
  3286. }
  3287. }
  3288. var iteminfoStructs []service.IteminfoStruct
  3289. if bedCostTotal != 0 {
  3290. iteminfo.MedChrgitm = "01"
  3291. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3292. iteminfo.Amt = bedCostTotal
  3293. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3294. iteminfo.ClabAmt = bed_clab_amt
  3295. iteminfo.OthAmt = bed_other_amt
  3296. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3297. }
  3298. if examineCostTotal != 0 {
  3299. iteminfo.MedChrgitm = "02"
  3300. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  3301. iteminfo.Amt = examineCostTotal
  3302. iteminfo.ClaaSumfee = examine_claa_sunmfee
  3303. iteminfo.ClabAmt = examine_clab_amt
  3304. iteminfo.OthAmt = examine_other_amt
  3305. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3306. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3307. }
  3308. if checkCostTotal != 0 {
  3309. iteminfo.MedChrgitm = "03"
  3310. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3311. iteminfo.Amt = checkCostTotal
  3312. iteminfo.ClaaSumfee = check_claa_sunmfee
  3313. iteminfo.ClabAmt = check_clab_amt
  3314. iteminfo.OthAmt = check_other_amt
  3315. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3316. }
  3317. if laboratoryCostTotal != 0 {
  3318. iteminfo.MedChrgitm = "04"
  3319. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3320. iteminfo.Amt = laboratoryCostTotal
  3321. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3322. iteminfo.ClabAmt = laboratory_clab_amt
  3323. iteminfo.OthAmt = laboratory_other_amt
  3324. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3325. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3326. }
  3327. if treatCostTotal != 0 {
  3328. iteminfo.MedChrgitm = "05"
  3329. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3330. iteminfo.Amt = treatCostTotal
  3331. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3332. iteminfo.ClabAmt = treat_clab_amt
  3333. iteminfo.OthAmt = treat_other_amt
  3334. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3335. //(struct4101.IteminfoStruct, iteminfo)
  3336. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3337. }
  3338. if operationCostTotal != 0 {
  3339. iteminfo.MedChrgitm = "06"
  3340. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3341. iteminfo.Amt = operationCostTotal
  3342. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3343. iteminfo.ClabAmt = operation_clab_amt
  3344. iteminfo.OthAmt = operation_other_amt
  3345. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3346. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3347. }
  3348. if nursingCostTotal != 0 {
  3349. iteminfo.MedChrgitm = "07"
  3350. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  3351. iteminfo.Amt = nursingCostTotal
  3352. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  3353. iteminfo.ClabAmt = nursing_clab_amt
  3354. iteminfo.OthAmt = nursing_other_amt
  3355. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3356. }
  3357. if materialCostTotal != 0 {
  3358. iteminfo.MedChrgitm = "08"
  3359. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3360. iteminfo.Amt = materialCostTotal
  3361. iteminfo.ClaaSumfee = material_claa_sunmfee
  3362. iteminfo.ClabAmt = material_clab_amt
  3363. iteminfo.OthAmt = material_other_amt
  3364. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3365. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3366. }
  3367. if westernMedicineCostTotal != 0 {
  3368. iteminfo.MedChrgitm = "09"
  3369. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3370. iteminfo.Amt = westernMedicineCostTotal
  3371. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3372. iteminfo.ClabAmt = westernMedicine_clab_amt
  3373. iteminfo.OthAmt = westernMedicine_other_amt
  3374. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3375. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3376. }
  3377. if chineseMedicineCostTotal != 0 {
  3378. iteminfo.MedChrgitm = "10"
  3379. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  3380. iteminfo.Amt = chineseMedicineCostTotal
  3381. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  3382. iteminfo.ClabAmt = chinese_medicine_clab_amt
  3383. iteminfo.OthAmt = chinese_medicine_other_amt
  3384. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3385. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3386. }
  3387. if chineseTraditionalMedicineCostTotal != 0 {
  3388. iteminfo.MedChrgitm = "11"
  3389. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3390. iteminfo.Amt = westernMedicineCostTotal
  3391. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3392. iteminfo.ClabAmt = westernMedicine_clab_amt
  3393. iteminfo.OthAmt = westernMedicine_other_amt
  3394. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3395. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3396. }
  3397. if commonlyTreatmentCostTotal != 0 {
  3398. iteminfo.MedChrgitm = "12"
  3399. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  3400. iteminfo.Amt = commonlyTreatmentCostTotal
  3401. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  3402. iteminfo.ClabAmt = commonly_treatment_clab_amt
  3403. iteminfo.OthAmt = commonly_treatment_other_amt
  3404. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3405. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3406. }
  3407. if registerCostTotal != 0 {
  3408. iteminfo.MedChrgitm = "13"
  3409. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  3410. iteminfo.Amt = registerCostTotal
  3411. iteminfo.ClaaSumfee = register_claa_sunmfee
  3412. iteminfo.ClabAmt = register_clab_amt
  3413. iteminfo.OthAmt = register_other_amt
  3414. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3415. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3416. }
  3417. if otherCostTotal != 0 {
  3418. iteminfo.MedChrgitm = "14"
  3419. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3420. iteminfo.Amt = otherCostTotal
  3421. iteminfo.ClaaSumfee = other_claa_sunmfee
  3422. iteminfo.ClabAmt = other_clab_amt
  3423. iteminfo.OthAmt = other_other_amt
  3424. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3425. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3426. }
  3427. struct4101.IteminfoStruct = iteminfoStructs
  3428. struct4101.Ntly = "中国"
  3429. struct4101.AdmCaty = "A03.06"
  3430. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  3431. fmt.Println(result)
  3432. var dat map[string]interface{}
  3433. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3434. fmt.Println(dat)
  3435. } else {
  3436. fmt.Println(err)
  3437. }
  3438. userJSONBytes, _ := json.Marshal(dat)
  3439. var res ResultSeventeen
  3440. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3441. utils.ErrorLog("解析失败:%v", err)
  3442. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3443. adminUser := c.GetAdminUserInfo()
  3444. errlog := &models.HisOrderError{
  3445. UserOrgId: adminUser.CurrentOrgId,
  3446. Ctime: time.Now().Unix(),
  3447. Mtime: time.Now().Unix(),
  3448. ErrMsg: res.ErrMsg + "解析失败",
  3449. Status: 1,
  3450. PatientId: order_id,
  3451. Stage: 10106,
  3452. }
  3453. service.CreateErrMsgLog(errlog)
  3454. continue
  3455. }
  3456. if res.Infcode != 0 {
  3457. adminUser := c.GetAdminUserInfo()
  3458. errlog := &models.HisOrderError{
  3459. UserOrgId: adminUser.CurrentOrgId,
  3460. Ctime: time.Now().Unix(),
  3461. Mtime: time.Now().Unix(),
  3462. ErrMsg: res.ErrMsg,
  3463. Status: 1,
  3464. PatientId: order_id,
  3465. Stage: 10106,
  3466. }
  3467. service.CreateErrMsgLog(errlog)
  3468. continue
  3469. } else {
  3470. hisFundSettleListResult := &models.HisFundSettleListResult{
  3471. Number: res.Output.SetlListId,
  3472. Status: 1,
  3473. Ctime: time.Now().Unix(),
  3474. Mtime: time.Now().Unix(),
  3475. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3476. IsUpload: 1,
  3477. OrderId: order_id,
  3478. }
  3479. service.CreateUploadRecord(hisFundSettleListResult)
  3480. continue
  3481. }
  3482. }
  3483. }
  3484. func (c *HisApiController) GetOrgInfo() {
  3485. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  3486. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  3487. }
  3488. func (c *HisApiController) GetHisPatientInfo() {
  3489. medical_insurance_card := c.GetString("medical_insurance_card")
  3490. id_card_type, _ := c.GetInt64("id_card_type")
  3491. id_card := c.GetString("id_card")
  3492. adminInfo := c.GetAdminUserInfo()
  3493. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3494. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3495. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  3496. IdCardNo := ""
  3497. if id_card_type == 1 {
  3498. IdCardNo = medical_insurance_card
  3499. } else if id_card_type == 2 {
  3500. IdCardNo = id_card
  3501. }
  3502. if config.IsOpen == 1 {
  3503. 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
  3504. resp, requestErr := http.Get(api)
  3505. if requestErr != nil {
  3506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3507. return
  3508. }
  3509. defer resp.Body.Close()
  3510. body, ioErr := ioutil.ReadAll(resp.Body)
  3511. if ioErr != nil {
  3512. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3514. return
  3515. }
  3516. var respJSON map[string]interface{}
  3517. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3518. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3520. return
  3521. }
  3522. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3523. userJSONBytes, _ := json.Marshal(userJSON)
  3524. var res ResultTwo
  3525. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3526. utils.ErrorLog("解析失败:%v", err)
  3527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3528. return
  3529. }
  3530. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3531. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3532. infoStr := string(Iinfos)
  3533. idetinfoStr := string(Idetinfos)
  3534. if res.Infcode == 0 {
  3535. his := models.VMHisPatient{
  3536. Status: 1,
  3537. Ctime: time.Now().Unix(),
  3538. Mtime: time.Now().Unix(),
  3539. PsnNo: res.Output.Baseinfo.PsnNo,
  3540. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3541. Certno: res.Output.Baseinfo.Certno,
  3542. PsnName: res.Output.Baseinfo.PsnName,
  3543. Gend: res.Output.Baseinfo.Gend,
  3544. Naty: res.Output.Baseinfo.Naty,
  3545. Brdy: res.Output.Baseinfo.Brdy,
  3546. Age: res.Output.Baseinfo.Age,
  3547. Iinfo: infoStr,
  3548. Idetinfo: idetinfoStr,
  3549. UserOrgId: adminInfo.CurrentOrgId,
  3550. IsReturn: 1,
  3551. IdCardType: id_card_type,
  3552. }
  3553. c.ServeSuccessJSON(map[string]interface{}{
  3554. "info": his,
  3555. })
  3556. } else {
  3557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3558. return
  3559. }
  3560. }
  3561. }
  3562. //func GetBasBaseInfo() (jsonStr string, err error) {
  3563. //
  3564. // handle := syscall.NewLazyDLL("SSCard.dll")
  3565. // add := handle.NewProc("ReadCardBas")
  3566. // str := make([]byte, 1024)
  3567. // str1 := make([]byte, 1024)
  3568. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3569. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3570. //
  3571. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3572. //
  3573. // fmt.Println("> Add(4,5)的结果为:", ret)
  3574. // handle.Release()
  3575. //
  3576. // return "", nil
  3577. //
  3578. //}
  3579. //func GetQRBaseInfo() (jsonStr string, err error) {
  3580. // handle := syscall.LoadDLL("SSCard.dll")
  3581. // ReadCardBas := handle.FindProc("GetQRBase")
  3582. //
  3583. // str := make([]byte, 256)
  3584. // str1 := make([]byte, 256)
  3585. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3586. //
  3587. // fmt.Println(string(str))
  3588. // fmt.Println(r)
  3589. // return string(str), nil
  3590. //}
  3591. //func CardInit() int {
  3592. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  3593. // add := DllTestDef.MustFindProc("Init")
  3594. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3595. // if err != nil {
  3596. // fmt.Println("SSCard的运算结果为:", ret)
  3597. // }
  3598. // result := int(ret)
  3599. // return result
  3600. //}
  3601. //func CardInit() int {
  3602. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3603. // if err != nil {
  3604. // fmt.Println("SSCard的运算结果为:", ret)
  3605. // }
  3606. // fmt.Println(err)
  3607. // result := int(ret)
  3608. // return result
  3609. //}
  3610. func IntPtr(n int) uintptr {
  3611. return uintptr(n)
  3612. }
  3613. func StrPtr(s string) uintptr {
  3614. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3615. }
  3616. type Result2001 struct {
  3617. Cainfo interface{} `json:"cainfo"`
  3618. ErrMsg string `json:"err_msg"`
  3619. InfRefmsgid string `json:"inf_refmsgid"`
  3620. Infcode int64 `json:"infcode"`
  3621. Output struct {
  3622. Trtinfo struct {
  3623. PsnNo string `json:"psn_no"`
  3624. TrtChkType string `json:"trt_chk_type"`
  3625. FundPayType string `json:"fund_pay_type"`
  3626. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3627. Begndate string `json:"begndate"`
  3628. Enddate string `json:"enddate"`
  3629. TrtChkRslt string `json:"trt_chk_rslt"`
  3630. } `json:"trtinfo"`
  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 Result2001Org10265 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. Trtinfo struct {
  3644. PsnNo string `json:"psn_no"`
  3645. TrtChkType string `json:"trt_chk_type"`
  3646. FundPayType string `json:"fund_pay_type"`
  3647. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3648. Begndate string `json:"begndate"`
  3649. Enddate string `json:"enddate"`
  3650. TrtChkRslt string `json:"trt_chk_rslt"`
  3651. } `json:"trtinfo"`
  3652. } `json:"output"`
  3653. RefmsgTime string `json:"refmsg_time"`
  3654. RespondTime string `json:"respond_time"`
  3655. Signtype interface{} `json:"signtype"`
  3656. WarnMsg interface{} `json:"warn_msg"`
  3657. }
  3658. type ResultTwo struct {
  3659. ErrMsg string `json:"err_msg"`
  3660. InfRefmsgid string `json:"inf_refmsgid"`
  3661. Infcode int64 `json:"infcode"`
  3662. Output struct {
  3663. Baseinfo struct {
  3664. Age float64 `json:"age"`
  3665. Brdy string `json:"brdy"`
  3666. Certno string `json:"certno"`
  3667. Gend string `json:"gend"`
  3668. Naty string `json:"naty"`
  3669. PsnCertType string `json:"psn_cert_type"`
  3670. PsnName string `json:"psn_name"`
  3671. PsnNo string `json:"psn_no"`
  3672. } `json:"baseinfo"`
  3673. Idetinfo []interface{} `json:"idetinfo"`
  3674. Iinfo []struct {
  3675. Balc float64 `json:"balc"`
  3676. CvlservFlag string `json:"cvlserv_flag"`
  3677. EmpName string `json:"emp_name"`
  3678. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3679. Insutype string `json:"insutype"`
  3680. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3681. PausInsuDate string `json:"paus_insu_date"`
  3682. PsnInsuDate string `json:"psn_insu_date"`
  3683. PsnInsuStas string `json:"psn_insu_stas"`
  3684. PsnType string `json:"psn_type"`
  3685. } `json:"insuinfo"`
  3686. } `json:"output"`
  3687. RefmsgTime string `json:"refmsg_time"`
  3688. RespondTime string `json:"respond_time"`
  3689. Signtype interface{} `json:"signtype"`
  3690. WarnInfo interface{} `json:"warn_info"`
  3691. }
  3692. type ResultTwo10265 struct {
  3693. ErrMsg string `json:"err_msg"`
  3694. InfRefmsgid string `json:"inf_refmsgid"`
  3695. Infcode string `json:"infcode"`
  3696. Output struct {
  3697. Baseinfo struct {
  3698. Age float64 `json:"age"`
  3699. Brdy string `json:"brdy"`
  3700. Certno string `json:"certno"`
  3701. Gend string `json:"gend"`
  3702. Naty string `json:"naty"`
  3703. PsnCertType string `json:"psn_cert_type"`
  3704. PsnName string `json:"psn_name"`
  3705. PsnNo string `json:"psn_no"`
  3706. } `json:"baseinfo"`
  3707. Idetinfo []interface{} `json:"idetinfo"`
  3708. Iinfo []struct {
  3709. Balc float64 `json:"balc"`
  3710. CvlservFlag string `json:"cvlserv_flag"`
  3711. EmpName string `json:"emp_name"`
  3712. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3713. Insutype string `json:"insutype"`
  3714. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3715. PausInsuDate string `json:"paus_insu_date"`
  3716. PsnInsuDate string `json:"psn_insu_date"`
  3717. PsnInsuStas string `json:"psn_insu_stas"`
  3718. PsnType string `json:"psn_type"`
  3719. } `json:"insuinfo"`
  3720. } `json:"output"`
  3721. RefmsgTime string `json:"refmsg_time"`
  3722. RespondTime string `json:"respond_time"`
  3723. Signtype interface{} `json:"signtype"`
  3724. WarnInfo interface{} `json:"warn_info"`
  3725. }
  3726. type ResultThree struct {
  3727. Cainfo interface{} `json:"cainfo"`
  3728. ErrMsg string `json:"err_msg"`
  3729. InfRefmsgid string `json:"inf_refmsgid"`
  3730. Infcode int64 `json:"infcode"`
  3731. Output struct {
  3732. Data struct {
  3733. IptOtpNo string `json:"ipt_otp_no"`
  3734. MdtrtID string `json:"mdtrt_id"`
  3735. PsnNo string `json:"psn_no"`
  3736. } `json:"data"`
  3737. } `json:"output"`
  3738. RefmsgTime string `json:"refmsg_time"`
  3739. RespondTime string `json:"respond_time"`
  3740. Signtype interface{} `json:"signtype"`
  3741. WarnMsg interface{} `json:"warn_msg"`
  3742. }
  3743. type ResultThree10265 struct {
  3744. Cainfo interface{} `json:"cainfo"`
  3745. ErrMsg string `json:"err_msg"`
  3746. InfRefmsgid string `json:"inf_refmsgid"`
  3747. Infcode string `json:"infcode"`
  3748. Output struct {
  3749. Data struct {
  3750. IptOtpNo string `json:"ipt_otp_no"`
  3751. MdtrtID string `json:"mdtrt_id"`
  3752. PsnNo string `json:"psn_no"`
  3753. } `json:"data"`
  3754. } `json:"output"`
  3755. RefmsgTime string `json:"refmsg_time"`
  3756. RespondTime string `json:"respond_time"`
  3757. Signtype interface{} `json:"signtype"`
  3758. WarnMsg interface{} `json:"warn_msg"`
  3759. }
  3760. type ResultFour struct {
  3761. Cainfo string `json:"cainfo"`
  3762. ErrMsg string `json:"err_msg"`
  3763. InfRefmsgid string `json:"inf_refmsgid"`
  3764. Infcode int64 `json:"infcode"`
  3765. Output struct {
  3766. Result []struct {
  3767. BasMednFlag string `json:"bas_medn_flag"`
  3768. ChldMedcFlag string `json:"chld_medc_flag"`
  3769. ChrgitmLv string `json:"chrgitm_lv"`
  3770. Cnt float64 `json:"cnt"`
  3771. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3772. DrtReimFlag string `json:"drt_reim_flag"`
  3773. FeedetlSn string `json:"feedetl_sn"`
  3774. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3775. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3776. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3777. ListSpItemFlag string `json:"list_sp_item_flag"`
  3778. LmtUsedFlag string `json:"lmt_used_flag"`
  3779. MedChrgitmType string `json:"med_chrgitm_type"`
  3780. Memo string `json:"memo"`
  3781. OverlmtAmt float64 `json:"overlmt_amt"`
  3782. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3783. Pric float64 `json:"pric"`
  3784. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3785. SelfpayProp float64 `json:"selfpay_prop"`
  3786. } `json:"result"`
  3787. } `json:"output"`
  3788. RefmsgTime string `json:"refmsg_time"`
  3789. RespondTime string `json:"respond_time"`
  3790. Signtype string `json:"signtype"`
  3791. WarnMsg string `json:"warn_msg"`
  3792. }
  3793. type ResultFour10265 struct {
  3794. Cainfo string `json:"cainfo"`
  3795. ErrMsg string `json:"err_msg"`
  3796. InfRefmsgid string `json:"inf_refmsgid"`
  3797. Infcode string `json:"infcode"`
  3798. Output struct {
  3799. Result []struct {
  3800. BasMednFlag string `json:"bas_medn_flag"`
  3801. ChldMedcFlag string `json:"chld_medc_flag"`
  3802. ChrgitmLv string `json:"chrgitm_lv"`
  3803. Cnt float64 `json:"cnt"`
  3804. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3805. DrtReimFlag string `json:"drt_reim_flag"`
  3806. FeedetlSn string `json:"feedetl_sn"`
  3807. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3808. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3809. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3810. ListSpItemFlag string `json:"list_sp_item_flag"`
  3811. LmtUsedFlag string `json:"lmt_used_flag"`
  3812. MedChrgitmType string `json:"med_chrgitm_type"`
  3813. Memo string `json:"memo"`
  3814. OverlmtAmt float64 `json:"overlmt_amt"`
  3815. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3816. Pric float64 `json:"pric"`
  3817. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3818. SelfpayProp float64 `json:"selfpay_prop"`
  3819. } `json:"result"`
  3820. } `json:"output"`
  3821. RefmsgTime string `json:"refmsg_time"`
  3822. RespondTime string `json:"respond_time"`
  3823. Signtype string `json:"signtype"`
  3824. WarnMsg string `json:"warn_msg"`
  3825. }
  3826. type ResultFive struct {
  3827. Balc float64 `json:"balc"`
  3828. CvlservFlag string `json:"cvlserv_flag"`
  3829. EmpName string `json:"emp_name"`
  3830. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3831. Insutype string `json:"insutype"`
  3832. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3833. PausInsuDate string `json:"paus_insu_date"`
  3834. PsnInsuDate string `json:"psn_insu_date"`
  3835. PsnInsuStas string `json:"psn_insu_stas"`
  3836. PsnType string `json:"psn_type"`
  3837. }
  3838. type ResultSix struct {
  3839. Cainfo interface{} `json:"cainfo"`
  3840. ErrMsg string `json:"err_msg"`
  3841. InfRefmsgid string `json:"inf_refmsgid"`
  3842. Infcode int64 `json:"infcode"`
  3843. Output struct {
  3844. } `json:"output"`
  3845. RefmsgTime string `json:"refmsg_time"`
  3846. RespondTime string `json:"respond_time"`
  3847. Signtype interface{} `json:"signtype"`
  3848. WarnMsg interface{} `json:"warn_msg"`
  3849. }
  3850. type ResultSix10265 struct {
  3851. Cainfo interface{} `json:"cainfo"`
  3852. ErrMsg string `json:"err_msg"`
  3853. InfRefmsgid string `json:"inf_refmsgid"`
  3854. Infcode string `json:"infcode"`
  3855. Output struct {
  3856. } `json:"output"`
  3857. RefmsgTime string `json:"refmsg_time"`
  3858. RespondTime string `json:"respond_time"`
  3859. Signtype interface{} `json:"signtype"`
  3860. WarnMsg interface{} `json:"warn_msg"`
  3861. }
  3862. type ResultSeven struct {
  3863. Cainfo string `json:"cainfo"`
  3864. ErrMsg string `json:"err_msg"`
  3865. InfRefmsgid string `json:"inf_refmsgid"`
  3866. Infcode int64 `json:"infcode"`
  3867. Output struct {
  3868. Setldetail []interface{} `json:"setldetail"`
  3869. Setlinfo struct {
  3870. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3871. AcctPay float64 `json:"acct_pay"`
  3872. ActPayDedc float64 `json:"act_pay_dedc"`
  3873. Age float64 `json:"age"`
  3874. Balc float64 `json:"balc"`
  3875. Brdy string `json:"brdy"`
  3876. Certno string `json:"certno"`
  3877. ClrOptins string `json:"clr_optins"`
  3878. ClrType string `json:"clr_type"`
  3879. ClrWay string `json:"clr_way"`
  3880. CvlservFlag string `json:"cvlserv_flag"`
  3881. CvlservPay float64 `json:"cvlserv_pay"`
  3882. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3883. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3884. Gend string `json:"gend"`
  3885. HifesPay float64 `json:"hifes_pay"`
  3886. HifmiPay float64 `json:"hifmi_pay"`
  3887. HifpPay float64 `json:"hifp_pay"`
  3888. HospPartAmt float64 `json:"hosp_part_amt"`
  3889. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3890. Insutype string `json:"insutype"`
  3891. MafPay float64 `json:"maf_pay"`
  3892. MdtrtCertType string `json:"mdtrt_cert_type"`
  3893. HifobPay float64 `json:"hifob_pay"`
  3894. MdtrtID string `json:"mdtrt_id"`
  3895. MedType string `json:"med_type"`
  3896. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3897. MedinsSetlID string `json:"medins_setl_id"`
  3898. Naty string `json:"naty"`
  3899. OthPay float64 `json:"oth_pay"`
  3900. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3901. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3902. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3903. PsnCashPay float64 `json:"psn_cash_pay"`
  3904. PsnCertType string `json:"psn_cert_type"`
  3905. PsnName string `json:"psn_name"`
  3906. PsnNo string `json:"psn_no"`
  3907. PsnPartAmt float64 `json:"psn_part_amt"`
  3908. PsnType string `json:"psn_type"`
  3909. SetlID string `json:"setl_id"`
  3910. SetlTime string `json:"setl_time"`
  3911. } `json:"setlinfo"`
  3912. } `json:"output"`
  3913. RefmsgTime string `json:"refmsg_time"`
  3914. RespondTime string `json:"respond_time"`
  3915. Signtype interface{} `json:"signtype"`
  3916. WarnMsg interface{} `json:"warn_msg"`
  3917. }
  3918. type ResultSeven10265 struct {
  3919. Cainfo string `json:"cainfo"`
  3920. ErrMsg string `json:"err_msg"`
  3921. InfRefmsgid string `json:"inf_refmsgid"`
  3922. Infcode string `json:"infcode"`
  3923. Output struct {
  3924. Setldetail []interface{} `json:"setldetail"`
  3925. Setlinfo struct {
  3926. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3927. AcctPay float64 `json:"acct_pay"`
  3928. ActPayDedc float64 `json:"act_pay_dedc"`
  3929. Age float64 `json:"age"`
  3930. Balc float64 `json:"balc"`
  3931. Brdy string `json:"brdy"`
  3932. Certno string `json:"certno"`
  3933. ClrOptins string `json:"clr_optins"`
  3934. ClrType string `json:"clr_type"`
  3935. ClrWay string `json:"clr_way"`
  3936. CvlservFlag string `json:"cvlserv_flag"`
  3937. CvlservPay float64 `json:"cvlserv_pay"`
  3938. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3939. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3940. Gend string `json:"gend"`
  3941. HifesPay float64 `json:"hifes_pay"`
  3942. HifmiPay float64 `json:"hifmi_pay"`
  3943. HifpPay float64 `json:"hifp_pay"`
  3944. HospPartAmt float64 `json:"hosp_part_amt"`
  3945. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3946. Insutype string `json:"insutype"`
  3947. MafPay float64 `json:"maf_pay"`
  3948. MdtrtCertType string `json:"mdtrt_cert_type"`
  3949. HifobPay float64 `json:"hifob_pay"`
  3950. MdtrtID string `json:"mdtrt_id"`
  3951. MedType string `json:"med_type"`
  3952. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3953. MedinsSetlID string `json:"medins_setl_id"`
  3954. Naty string `json:"naty"`
  3955. OthPay float64 `json:"oth_pay"`
  3956. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3957. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3958. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3959. PsnCashPay float64 `json:"psn_cash_pay"`
  3960. PsnCertType string `json:"psn_cert_type"`
  3961. PsnName string `json:"psn_name"`
  3962. PsnNo string `json:"psn_no"`
  3963. PsnPartAmt float64 `json:"psn_part_amt"`
  3964. PsnType string `json:"psn_type"`
  3965. SetlID string `json:"setl_id"`
  3966. SetlTime string `json:"setl_time"`
  3967. } `json:"setlinfo"`
  3968. } `json:"output"`
  3969. RefmsgTime string `json:"refmsg_time"`
  3970. RespondTime string `json:"respond_time"`
  3971. Signtype interface{} `json:"signtype"`
  3972. WarnMsg interface{} `json:"warn_msg"`
  3973. }
  3974. type ResultEight struct {
  3975. Cainfo string `json:"cainfo"`
  3976. ErrMsg string `json:"err_msg"`
  3977. InfRefmsgid string `json:"inf_refmsgid"`
  3978. Infcode int64 `json:"infcode"`
  3979. Output struct {
  3980. Stmtinfo struct {
  3981. SetlOptins string `json:"setl_optins"`
  3982. StmtRslt string `json:"stmt_rslt"`
  3983. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3984. } `json:"stmtinfo"`
  3985. } `json:"output"`
  3986. RefmsgTime string `json:"refmsg_time"`
  3987. RespondTime string `json:"respond_time"`
  3988. Signtype interface{} `json:"signtype"`
  3989. WarnMsg interface{} `json:"warn_msg"`
  3990. }
  3991. type ResultEightFor10188 struct {
  3992. Cainfo string `json:"cainfo"`
  3993. ErrMsg string `json:"err_msg"`
  3994. InfRefmsgid string `json:"inf_refmsgid"`
  3995. Infcode string `json:"infcode"`
  3996. Output struct {
  3997. Stmtinfo struct {
  3998. SetlOptins string `json:"setl_optins"`
  3999. StmtRslt string `json:"stmt_rslt"`
  4000. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  4001. } `json:"stmtinfo"`
  4002. } `json:"output"`
  4003. RefmsgTime string `json:"refmsg_time"`
  4004. RespondTime string `json:"respond_time"`
  4005. Signtype interface{} `json:"signtype"`
  4006. WarnMsg interface{} `json:"warn_msg"`
  4007. }
  4008. type ResultNine struct {
  4009. Cainfo string `json:"cainfo"`
  4010. ErrMsg string `json:"err_msg"`
  4011. InfRefmsgid string `json:"inf_refmsgid"`
  4012. Infcode int64 `json:"infcode"`
  4013. Output struct {
  4014. FileQuryNo string `json:"file_qury_no"`
  4015. } `json:"output"`
  4016. RefmsgTime string `json:"refmsg_time"`
  4017. RespondTime string `json:"respond_time"`
  4018. Signtype interface{} `json:"signtype"`
  4019. WarnMsg interface{} `json:"warn_msg"`
  4020. }
  4021. type ResultTen struct {
  4022. Cainfo string `json:"cainfo"`
  4023. ErrMsg string `json:"err_msg"`
  4024. InfRefmsgid string `json:"inf_refmsgid"`
  4025. Infcode int64 `json:"infcode"`
  4026. Output struct {
  4027. DldEndtime string `json:"dld_endtime"`
  4028. FileQuryNo string `json:"file_qury_no"`
  4029. Filename string `json:"filename"`
  4030. } `json:"output"`
  4031. RefmsgTime string `json:"refmsg_time"`
  4032. RespondTime string `json:"respond_time"`
  4033. Signtype interface{} `json:"signtype"`
  4034. WarnMsg interface{} `json:"warn_msg"`
  4035. }
  4036. //type Autogenerated struct {
  4037. // Output struct {
  4038. // Setlinfo struct {
  4039. // SetlTime string `json:"setl_time"`
  4040. // CvlservPay float64 `json:"cvlserv_pay"`
  4041. // Year string `json:"year"`
  4042. // MedType string `json:"med_type"`
  4043. // PsnPay float64 `json:"psn_pay"`
  4044. // OpterID string `json:"opter_id"`
  4045. // Begndate string `json:"begndate"`
  4046. // FlxempeFlag string `json:"flxempe_flag"`
  4047. // HifmiPay float64 `json:"hifmi_pay"`
  4048. // PsnNo string `json:"psn_no"`
  4049. // ActPayDedc float64 `json:"act_pay_dedc"`
  4050. // MedinsSetlID interface{} `json:"medins_setl_id"`
  4051. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4052. // ClrWay string `json:"clr_way"`
  4053. // OthPay float64 `json:"oth_pay"`
  4054. // Gend string `json:"gend"`
  4055. // MdtrtID string `json:"mdtrt_id"`
  4056. // AcctPay float64 `json:"acct_pay"`
  4057. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  4058. // Insutype string `json:"insutype"`
  4059. // Invono interface{} `json:"invono"`
  4060. // Enddate string `json:"enddate"`
  4061. // CashPayamt float64 `json:"cash_payamt"`
  4062. // PsnType string `json:"psn_type"`
  4063. // FixmedinsName string `json:"fixmedins_name"`
  4064. // HifpPay float64 `json:"hifp_pay"`
  4065. // NewFlag interface{} `json:"new_flag"`
  4066. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4067. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  4068. // PayLoc string `json:"pay_loc"`
  4069. // ClrType string `json:"clr_type"`
  4070. // RefdSetlFlag string `json:"refd_setl_flag"`
  4071. // CvlservFlag string `json:"cvlserv_flag"`
  4072. // EmpName string `json:"emp_name"`
  4073. // Brdy string `json:"brdy"`
  4074. // Naty string `json:"naty"`
  4075. // Certno string `json:"certno"`
  4076. // DiseCode string `json:"dise_code"`
  4077. // FixmedinsCode string `json:"fixmedins_code"`
  4078. // DedcHospLv string `json:"dedc_hosp_lv"`
  4079. // OpterName string `json:"opter_name"`
  4080. // Balc float64 `json:"balc"`
  4081. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4082. // PsnCertType string `json:"psn_cert_type"`
  4083. // HifobPay float64 `json:"hifob_pay"`
  4084. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  4085. // HifesPay float64 `json:"hifes_pay"`
  4086. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4087. // OptTime string `json:"opt_time"`
  4088. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4089. // SetlID string `json:"setl_id"`
  4090. // MafPay float64 `json:"maf_pay"`
  4091. // PsnName string `json:"psn_name"`
  4092. // InsuOptins interface{} `json:"insu_optins"`
  4093. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4094. // ClrOptins string `json:"clr_optins"`
  4095. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4096. // DiseName string `json:"dise_name"`
  4097. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4098. // Age float64 `json:"age"`
  4099. // DtrtCertType string `json:"dtrt_cert_type"`
  4100. // HospLv string `json:"hosp_lv"`
  4101. // } `json:"setlinfo"`
  4102. // Setldetail []struct {
  4103. // FundPayType string `json:"fund_pay_type"`
  4104. // FundPayamt float64 `json:"fund_payamt"`
  4105. // SetlProcInfo interface{} `json:"setl_proc_info"`
  4106. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  4107. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  4108. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  4109. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4110. // } `json:"setldetail"`
  4111. // } `json:"output"`
  4112. // Infcode int `json:"infcode"`
  4113. // WarnMsg interface{} `json:"warn_msg"`
  4114. // Cainfo interface{} `json:"cainfo"`
  4115. // ErrMsg interface{} `json:"err_msg"`
  4116. // RefmsgTime string `json:"refmsg_time"`
  4117. // Signtype interface{} `json:"signtype"`
  4118. // RespondTime string `json:"respond_time"`
  4119. // InfRefmsgid string `json:"inf_refmsgid"`
  4120. //}
  4121. type ResultEleven struct {
  4122. Cainfo string `json:"cainfo"`
  4123. ErrMsg string `json:"err_msg"`
  4124. InfRefmsgid string `json:"inf_refmsgid"`
  4125. Infcode int64 `json:"infcode"`
  4126. Output struct {
  4127. Setlinfo struct {
  4128. SetlTime string `json:"setl_time"`
  4129. CvlservPay float64 `json:"cvlserv_pay"`
  4130. Year string `json:"year"`
  4131. MedType string `json:"med_type"`
  4132. PsnPay float64 `json:"psn_pay"`
  4133. OpterID string `json:"opter_id"`
  4134. Begndate string `json:"begndate"`
  4135. FlxempeFlag string `json:"flxempe_flag"`
  4136. HifmiPay float64 `json:"hifmi_pay"`
  4137. PsnNo string `json:"psn_no"`
  4138. ActPayDedc float64 `json:"act_pay_dedc"`
  4139. MedinsSetlID interface{} `json:"medins_setl_id"`
  4140. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4141. ClrWay string `json:"clr_way"`
  4142. OthPay float64 `json:"oth_pay"`
  4143. Gend string `json:"gend"`
  4144. MdtrtID string `json:"mdtrt_id"`
  4145. AcctPay float64 `json:"acct_pay"`
  4146. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4147. Insutype string `json:"insutype"`
  4148. Invono interface{} `json:"invono"`
  4149. Enddate string `json:"enddate"`
  4150. CashPayamt float64 `json:"cash_payamt"`
  4151. PsnType string `json:"psn_type"`
  4152. FixmedinsName string `json:"fixmedins_name"`
  4153. HifpPay float64 `json:"hifp_pay"`
  4154. NewFlag interface{} `json:"new_flag"`
  4155. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4156. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4157. PayLoc string `json:"pay_loc"`
  4158. ClrType string `json:"clr_type"`
  4159. RefdSetlFlag string `json:"refd_setl_flag"`
  4160. CvlservFlag string `json:"cvlserv_flag"`
  4161. EmpName string `json:"emp_name"`
  4162. Brdy string `json:"brdy"`
  4163. Naty string `json:"naty"`
  4164. Certno string `json:"certno"`
  4165. DiseCode string `json:"dise_code"`
  4166. FixmedinsCode string `json:"fixmedins_code"`
  4167. DedcHospLv string `json:"dedc_hosp_lv"`
  4168. OpterName string `json:"opter_name"`
  4169. Balc float64 `json:"balc"`
  4170. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4171. PsnCertType string `json:"psn_cert_type"`
  4172. HifobPay float64 `json:"hifob_pay"`
  4173. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4174. HifesPay float64 `json:"hifes_pay"`
  4175. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4176. OptTime string `json:"opt_time"`
  4177. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4178. SetlID string `json:"setl_id"`
  4179. MafPay float64 `json:"maf_pay"`
  4180. PsnName string `json:"psn_name"`
  4181. InsuOptins interface{} `json:"insu_optins"`
  4182. PrefFundPay interface{} `json:"pref_fund_pay"`
  4183. ClrOptins string `json:"clr_optins"`
  4184. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4185. DiseName string `json:"dise_name"`
  4186. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4187. Age float64 `json:"age"`
  4188. DtrtCertType string `json:"dtrt_cert_type"`
  4189. HospLv string `json:"hosp_lv"`
  4190. } `json:"setlinfo"`
  4191. } `json:"output"`
  4192. RefmsgTime string `json:"refmsg_time"`
  4193. RespondTime string `json:"respond_time"`
  4194. Signtype interface{} `json:"signtype"`
  4195. WarnMsg interface{} `json:"warn_msg"`
  4196. }
  4197. type ResultEleven10265 struct {
  4198. Cainfo string `json:"cainfo"`
  4199. ErrMsg string `json:"err_msg"`
  4200. InfRefmsgid string `json:"inf_refmsgid"`
  4201. Infcode string `json:"infcode"`
  4202. Output struct {
  4203. Setlinfo struct {
  4204. SetlTime string `json:"setl_time"`
  4205. CvlservPay float64 `json:"cvlserv_pay"`
  4206. Year string `json:"year"`
  4207. MedType string `json:"med_type"`
  4208. PsnPay float64 `json:"psn_pay"`
  4209. OpterID string `json:"opter_id"`
  4210. Begndate string `json:"begndate"`
  4211. FlxempeFlag string `json:"flxempe_flag"`
  4212. HifmiPay float64 `json:"hifmi_pay"`
  4213. PsnNo string `json:"psn_no"`
  4214. ActPayDedc float64 `json:"act_pay_dedc"`
  4215. MedinsSetlID interface{} `json:"medins_setl_id"`
  4216. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4217. ClrWay string `json:"clr_way"`
  4218. OthPay float64 `json:"oth_pay"`
  4219. Gend string `json:"gend"`
  4220. MdtrtID string `json:"mdtrt_id"`
  4221. AcctPay float64 `json:"acct_pay"`
  4222. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4223. Insutype string `json:"insutype"`
  4224. Invono interface{} `json:"invono"`
  4225. Enddate string `json:"enddate"`
  4226. CashPayamt float64 `json:"cash_payamt"`
  4227. PsnType string `json:"psn_type"`
  4228. FixmedinsName string `json:"fixmedins_name"`
  4229. HifpPay float64 `json:"hifp_pay"`
  4230. NewFlag interface{} `json:"new_flag"`
  4231. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4232. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4233. PayLoc string `json:"pay_loc"`
  4234. ClrType string `json:"clr_type"`
  4235. RefdSetlFlag string `json:"refd_setl_flag"`
  4236. CvlservFlag string `json:"cvlserv_flag"`
  4237. EmpName string `json:"emp_name"`
  4238. Brdy string `json:"brdy"`
  4239. Naty string `json:"naty"`
  4240. Certno string `json:"certno"`
  4241. DiseCode string `json:"dise_code"`
  4242. FixmedinsCode string `json:"fixmedins_code"`
  4243. DedcHospLv string `json:"dedc_hosp_lv"`
  4244. OpterName string `json:"opter_name"`
  4245. Balc float64 `json:"balc"`
  4246. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4247. PsnCertType string `json:"psn_cert_type"`
  4248. HifobPay float64 `json:"hifob_pay"`
  4249. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4250. HifesPay float64 `json:"hifes_pay"`
  4251. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4252. OptTime string `json:"opt_time"`
  4253. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4254. SetlID string `json:"setl_id"`
  4255. MafPay float64 `json:"maf_pay"`
  4256. PsnName string `json:"psn_name"`
  4257. InsuOptins interface{} `json:"insu_optins"`
  4258. PrefFundPay interface{} `json:"pref_fund_pay"`
  4259. ClrOptins string `json:"clr_optins"`
  4260. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4261. DiseName string `json:"dise_name"`
  4262. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4263. Age float64 `json:"age"`
  4264. DtrtCertType string `json:"dtrt_cert_type"`
  4265. HospLv string `json:"hosp_lv"`
  4266. } `json:"setlinfo"`
  4267. } `json:"output"`
  4268. RefmsgTime string `json:"refmsg_time"`
  4269. RespondTime string `json:"respond_time"`
  4270. Signtype interface{} `json:"signtype"`
  4271. WarnMsg interface{} `json:"warn_msg"`
  4272. }
  4273. type ResultTwelve struct {
  4274. Cainfo string `json:"cainfo"`
  4275. ErrMsg string `json:"err_msg"`
  4276. InfRefmsgid string `json:"inf_refmsgid"`
  4277. Infcode int64 `json:"infcode"`
  4278. Output struct {
  4279. MdtrtId string `json:"mdtrt_id"`
  4280. ChrgBchno string `json:"chrg_bchno"`
  4281. PsnNo string `json:"psn_no"`
  4282. } `json:"output"`
  4283. RefmsgTime string `json:"refmsg_time"`
  4284. RespondTime string `json:"respond_time"`
  4285. Signtype interface{} `json:"signtype"`
  4286. WarnMsg interface{} `json:"warn_msg"`
  4287. }
  4288. type ResultThirteen struct {
  4289. ErrMsg string `json:"err_msg"`
  4290. InfRefmsgid string `json:"inf_refmsgid"`
  4291. Infcode int64 `json:"infcode"`
  4292. Output struct {
  4293. Result struct {
  4294. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4295. } `json:"result"`
  4296. } `json:"output"`
  4297. RefmsgTime string `json:"refmsg_time"`
  4298. RespondTime string `json:"respond_time"`
  4299. Signtype interface{} `json:"signtype"`
  4300. WarnInfo interface{} `json:"warn_info"`
  4301. }
  4302. type ResultThirteen10265 struct {
  4303. ErrMsg string `json:"err_msg"`
  4304. InfRefmsgid string `json:"inf_refmsgid"`
  4305. Infcode string `json:"infcode"`
  4306. Output struct {
  4307. Result struct {
  4308. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4309. } `json:"result"`
  4310. } `json:"output"`
  4311. RefmsgTime string `json:"refmsg_time"`
  4312. RespondTime string `json:"respond_time"`
  4313. Signtype interface{} `json:"signtype"`
  4314. WarnInfo interface{} `json:"warn_info"`
  4315. }
  4316. type ResultFourteen struct {
  4317. ErrMsg string `json:"err_msg"`
  4318. InfRefmsgid string `json:"inf_refmsgid"`
  4319. Infcode int64 `json:"infcode"`
  4320. Output struct {
  4321. } `json:"output"`
  4322. RefmsgTime string `json:"refmsg_time"`
  4323. RespondTime string `json:"respond_time"`
  4324. Signtype interface{} `json:"signtype"`
  4325. WarnInfo interface{} `json:"warn_info"`
  4326. }
  4327. type ResultFourteen10265 struct {
  4328. ErrMsg string `json:"err_msg"`
  4329. InfRefmsgid string `json:"inf_refmsgid"`
  4330. Infcode string `json:"infcode"`
  4331. Output struct {
  4332. } `json:"output"`
  4333. RefmsgTime string `json:"refmsg_time"`
  4334. RespondTime string `json:"respond_time"`
  4335. Signtype interface{} `json:"signtype"`
  4336. WarnInfo interface{} `json:"warn_info"`
  4337. }
  4338. type ResultSixteen struct {
  4339. Cainfo string `json:"cainfo"`
  4340. ErrMsg string `json:"err_msg"`
  4341. InfRefmsgid string `json:"inf_refmsgid"`
  4342. Infcode int64 `json:"infcode"`
  4343. Output struct {
  4344. Setldetail []interface{} `json:"setldetail"`
  4345. Setlinfo struct {
  4346. MdtrtID string `json:"mdtrt_id"`
  4347. SetlID string `json:"setl_id"`
  4348. ClrOptins string `json:"clr_optins"`
  4349. SetlTime string `json:"setl_time"`
  4350. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4351. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4352. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4353. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4354. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4355. ActPayDedc float64 `json:"act_pay_dedc"`
  4356. HifpPay float64 `json:"hifp_pay"`
  4357. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4358. Lfpay float64 `json:"selfpay"`
  4359. CvlservPay float64 `json:"cvlserv_pay"`
  4360. HifesPay float64 `json:"hifes_pay"`
  4361. HifmiPay float64 `json:"hifmi_pay"`
  4362. HifobPay float64 `json:"hifob_pay"`
  4363. MafPay float64 `json:"maf_pay"`
  4364. OthPay float64 `json:"oth_pay"`
  4365. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4366. PsnPartAmt float64 `json:"psn_part_amt"`
  4367. AcctPay float64 `json:"acct_pay"`
  4368. Balc float64 `json:"balc"`
  4369. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4370. HospPartAmt float64 `json:"hosp_part_amt"`
  4371. MedinsSetlID string `json:"medins_setl_id"`
  4372. PdnCashPay string `json:"pdn_cash_pay"`
  4373. } `json:"setlinfo"`
  4374. } `json:"output"`
  4375. RefmsgTime string `json:"refmsg_time"`
  4376. RespondTime string `json:"respond_time"`
  4377. Signtype interface{} `json:"signtype"`
  4378. WarnMsg interface{} `json:"warn_msg"`
  4379. }
  4380. type ResultSixteen10265 struct {
  4381. Cainfo string `json:"cainfo"`
  4382. ErrMsg string `json:"err_msg"`
  4383. InfRefmsgid string `json:"inf_refmsgid"`
  4384. Infcode string `json:"infcode"`
  4385. Output struct {
  4386. Setldetail []interface{} `json:"setldetail"`
  4387. Setlinfo struct {
  4388. MdtrtID string `json:"mdtrt_id"`
  4389. SetlID string `json:"setl_id"`
  4390. ClrOptins string `json:"clr_optins"`
  4391. SetlTime string `json:"setl_time"`
  4392. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4393. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4394. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4395. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4396. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4397. ActPayDedc float64 `json:"act_pay_dedc"`
  4398. HifpPay float64 `json:"hifp_pay"`
  4399. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4400. Lfpay float64 `json:"selfpay"`
  4401. CvlservPay float64 `json:"cvlserv_pay"`
  4402. HifesPay float64 `json:"hifes_pay"`
  4403. HifmiPay float64 `json:"hifmi_pay"`
  4404. HifobPay float64 `json:"hifob_pay"`
  4405. MafPay float64 `json:"maf_pay"`
  4406. OthPay float64 `json:"oth_pay"`
  4407. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4408. PsnPartAmt float64 `json:"psn_part_amt"`
  4409. AcctPay float64 `json:"acct_pay"`
  4410. Balc float64 `json:"balc"`
  4411. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4412. HospPartAmt float64 `json:"hosp_part_amt"`
  4413. MedinsSetlID string `json:"medins_setl_id"`
  4414. PdnCashPay string `json:"pdn_cash_pay"`
  4415. } `json:"setlinfo"`
  4416. } `json:"output"`
  4417. RefmsgTime string `json:"refmsg_time"`
  4418. RespondTime string `json:"respond_time"`
  4419. Signtype interface{} `json:"signtype"`
  4420. WarnMsg interface{} `json:"warn_msg"`
  4421. }
  4422. type ResultSeventeen struct {
  4423. ErrMsg string `json:"err_msg"`
  4424. InfRefmsgid string `json:"inf_refmsgid"`
  4425. Infcode int64 `json:"infcode"`
  4426. Output struct {
  4427. SetlListId string `json:"setl_list_id"`
  4428. } `json:"output"`
  4429. RefmsgTime string `json:"refmsg_time"`
  4430. RespondTime string `json:"respond_time"`
  4431. Signtype string `json:"signtype"`
  4432. WarnInfo string `json:"warn_info"`
  4433. }
  4434. type ResultSeventeenOther struct {
  4435. ErrMsg string `json:"err_msg"`
  4436. InfRefmsgid string `json:"inf_refmsgid"`
  4437. Infcode string `json:"infcode"`
  4438. Output struct {
  4439. SetlListId string `json:"setl_list_id"`
  4440. } `json:"output"`
  4441. RefmsgTime string `json:"refmsg_time"`
  4442. RespondTime string `json:"respond_time"`
  4443. Signtype string `json:"signtype"`
  4444. WarnInfo string `json:"warn_info"`
  4445. }
  4446. type Result90991 struct {
  4447. ErrMsg string `json:"err_msg"`
  4448. InfRefmsgid string `json:"inf_refmsgid"`
  4449. Infcode int64 `json:"infcode"`
  4450. Output struct {
  4451. Result struct {
  4452. PsnNo string `json:"psn_no"`
  4453. CardStat string `json:"card_stat"`
  4454. Certno string `json:"certno"`
  4455. PsnName string `json:"psn_name"`
  4456. CheckStat string `json:"check_stat"`
  4457. SscnoCheckStat string `json:"sscno_check_stat"`
  4458. } `json:"result"`
  4459. } `json:"output"`
  4460. RefmsgTime string `json:"refmsg_time"`
  4461. RespondTime string `json:"respond_time"`
  4462. Signtype interface{} `json:"signtype"`
  4463. WarnInfo interface{} `json:"warn_info"`
  4464. }
  4465. type Result90100 struct {
  4466. ErrMsg string `json:"err_msg"`
  4467. InfRefmsgid string `json:"inf_refmsgid"`
  4468. Infcode int64 `json:"infcode"`
  4469. Output struct {
  4470. PoolareaNo string `json:"poolarea_no"`
  4471. PoolareaNoName string `json:"poolarea_no_name"`
  4472. Insutype string `json:"insutype"`
  4473. InsutypeName string `json:"insutype_name"`
  4474. ClctType string `json:"clct_type"`
  4475. ClctTypeName string `json:"clct_type_name"`
  4476. ClctFlag string `json:"clct_flag"`
  4477. ClctFlagName string `json:"clct_flag_name"`
  4478. AccrymBegn string `json:"accrym_begn"`
  4479. AccrymEnd string `json:"accrym_end"`
  4480. ClctTime string `json:"clct_time"`
  4481. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  4482. } `json:"output"`
  4483. RefmsgTime string `json:"refmsg_time"`
  4484. RespondTime string `json:"respond_time"`
  4485. Signtype interface{} `json:"signtype"`
  4486. WarnInfo interface{} `json:"warn_info"`
  4487. }
  4488. type Custom struct {
  4489. DetItemFeeSumamt string
  4490. Cut string
  4491. FeedetlSn string
  4492. Price string
  4493. MedListCodg string
  4494. Type int64
  4495. AdviceId int64
  4496. ProjectId int64
  4497. ItemId int64
  4498. }
  4499. type Result5301 struct {
  4500. ErrMsg string `json:"err_msg"`
  4501. InfRefmsgid string `json:"inf_refmsgid"`
  4502. Infcode int64 `json:"infcode"`
  4503. Output struct {
  4504. Result []struct {
  4505. OpspDiseCode string `json:"opsp_dise_code"`
  4506. OpspDiseName string `json:"opsp_dise_name"`
  4507. Begndate string `json:"begndate"`
  4508. Enddate string `json:"enddate"`
  4509. } `json:"feedetail"`
  4510. } `json:"output"`
  4511. RefmsgTime string `json:"refmsg_time"`
  4512. RespondTime string `json:"respond_time"`
  4513. Signtype interface{} `json:"signtype"`
  4514. WarnInfo interface{} `json:"warn_info"`
  4515. }
  4516. type Result5301For10265 struct {
  4517. ErrMsg string `json:"err_msg"`
  4518. InfRefmsgid string `json:"inf_refmsgid"`
  4519. Infcode string `json:"infcode"`
  4520. Output struct {
  4521. Result []struct {
  4522. OpspDiseCode string `json:"opsp_dise_code"`
  4523. OpspDiseName string `json:"opsp_dise_name"`
  4524. Begndate string `json:"begndate"`
  4525. Enddate string `json:"enddate"`
  4526. } `json:"feedetail"`
  4527. } `json:"output"`
  4528. RefmsgTime string `json:"refmsg_time"`
  4529. RespondTime string `json:"respond_time"`
  4530. Signtype interface{} `json:"signtype"`
  4531. WarnInfo interface{} `json:"warn_info"`
  4532. }
  4533. //获取个人信息----挂号-----上传就诊信息
  4534. func (c *HisApiController) GetRegisterInfo() {
  4535. id, _ := c.GetInt64("id")
  4536. record_time := c.GetString("record_time")
  4537. settlementValue, _ := c.GetInt64("settlement_value")
  4538. medical_insurance_card := c.GetString("medical_insurance_card")
  4539. name := c.GetString("name")
  4540. id_card_type, _ := c.GetInt64("id_card_type")
  4541. certificates, _ := c.GetInt64("certificates")
  4542. medical_care, _ := c.GetInt64("medical_care")
  4543. birthday := c.GetString("birthday")
  4544. id_card := c.GetString("id_card")
  4545. register_type, _ := c.GetInt64("register")
  4546. doctor, _ := c.GetInt64("doctor")
  4547. department, _ := c.GetInt64("department")
  4548. gender, _ := c.GetInt64("sex")
  4549. registration_fee, _ := c.GetFloat("registration_fee")
  4550. medical_expenses, _ := c.GetFloat("medical_expenses")
  4551. social_type, _ := c.GetInt64("social_type")
  4552. med_type := c.GetString("social_type")
  4553. admin_user_id, _ := c.GetInt64("admin_user_id")
  4554. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4555. timeLayout := "2006-01-02"
  4556. loc, _ := time.LoadLocation("Local")
  4557. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4558. birthUnix := birthdays.Unix()
  4559. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4560. if err != nil {
  4561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4562. return
  4563. }
  4564. recordDateTime := theTime.Unix()
  4565. adminInfo := c.GetAdminUserInfo()
  4566. var patient service.Patients
  4567. if id == 0 {
  4568. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4569. } else {
  4570. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4571. }
  4572. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4573. if patientPrescription.ID == 0 {
  4574. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4575. }
  4576. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4577. if patient.ID == 0 {
  4578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4579. return
  4580. }
  4581. if len(patient.IdCardNo) == 0 {
  4582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4583. return
  4584. }
  4585. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4586. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4587. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4588. //就诊结算未完成,不能进行二次挂号
  4589. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4590. if len(his) >= 1 {
  4591. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  4592. if len(his) >= 1 && order.ID == 0 {
  4593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  4594. return
  4595. }
  4596. }
  4597. //var register_log string
  4598. if config.IsOpen == 1 {
  4599. var res ResultTwo
  4600. var res10265 ResultTwo10265
  4601. var PsnNo string
  4602. var PsnCertType string
  4603. var Certno string
  4604. var PsnName string
  4605. var Gend string
  4606. var Naty string
  4607. var Brdy string
  4608. var Age float64
  4609. var infoStr string
  4610. var idetinfoStr string
  4611. var infocode int64
  4612. var verify_number string
  4613. fmt.Println(verify_number)
  4614. if miConfig.MdtrtareaAdmvs == "421300" {
  4615. psn_info, _ := service.GetPsnByPatientId(id)
  4616. PsnNo = psn_info.PsnNo
  4617. PsnCertType = psn_info.PsnCertType
  4618. Certno = psn_info.Certno
  4619. PsnName = psn_info.PsnName
  4620. Gend = psn_info.Gend
  4621. Naty = psn_info.Naty
  4622. Brdy = psn_info.Brdy
  4623. Age = psn_info.Age
  4624. infoStr = psn_info.Insuinfo
  4625. idetinfoStr = psn_info.Idetinfo
  4626. infocode = 0
  4627. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4628. psn_info, _ := service.GetPsnByPatientId(id)
  4629. PsnNo = psn_info.PsnNo
  4630. PsnCertType = psn_info.PsnCertType
  4631. Certno = psn_info.Certno
  4632. PsnName = psn_info.PsnName
  4633. Gend = psn_info.Gend
  4634. Naty = psn_info.Naty
  4635. Brdy = psn_info.Brdy
  4636. Age = psn_info.Age
  4637. infoStr = psn_info.Insuinfo
  4638. idetinfoStr = psn_info.Idetinfo
  4639. infocode = 0
  4640. verify_number = psn_info.VerifyNumber
  4641. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4642. if id_card_type == 1 {
  4643. psn_info, _ := service.GetPsnByPatientId(id)
  4644. PsnNo = psn_info.PsnNo
  4645. PsnCertType = psn_info.PsnCertType
  4646. Certno = psn_info.Certno
  4647. PsnName = psn_info.PsnName
  4648. Gend = psn_info.Gend
  4649. Naty = psn_info.Naty
  4650. Brdy = psn_info.Brdy
  4651. Age = psn_info.Age
  4652. infoStr = psn_info.Insuinfo
  4653. idetinfoStr = psn_info.Idetinfo
  4654. infocode = 0
  4655. verify_number = psn_info.VerifyNumber
  4656. } else if id_card_type == 2 {
  4657. result, requestLog, errMsgLog := service.FJyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, patient.IdCardNo, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  4658. fmt.Println(errMsgLog)
  4659. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4660. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4661. utils.ErrorLog("解析失败:%v", err)
  4662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4663. return
  4664. }
  4665. PsnNo = res.Output.Baseinfo.PsnNo
  4666. PsnCertType = res.Output.Baseinfo.PsnCertType
  4667. Certno = res.Output.Baseinfo.Certno
  4668. PsnName = res.Output.Baseinfo.PsnName
  4669. Gend = res.Output.Baseinfo.Gend
  4670. Naty = res.Output.Baseinfo.Naty
  4671. Brdy = res.Output.Baseinfo.Brdy
  4672. Age = res.Output.Baseinfo.Age
  4673. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4674. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4675. infoStr = string(Iinfos)
  4676. idetinfoStr = string(Idetinfos)
  4677. infocode = res.Infcode
  4678. }
  4679. } else {
  4680. var result string
  4681. var requestLog string
  4682. if miConfig.UserOrgId == 10138 {
  4683. if id_card_type == 4 {
  4684. psn_info, _ := service.GetPsnByPatientId(id)
  4685. result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  4686. } else {
  4687. 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)
  4688. }
  4689. } else {
  4690. 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)
  4691. }
  4692. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4693. if miConfig.Code == "H15049901371" {
  4694. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4695. utils.ErrorLog("解析失败:%v", err)
  4696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4697. return
  4698. }
  4699. res.ErrMsg = res10265.ErrMsg
  4700. res.Output = res10265.Output
  4701. res.InfRefmsgid = res10265.InfRefmsgid
  4702. } else {
  4703. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4704. utils.ErrorLog("解析失败:%v", err)
  4705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4706. return
  4707. }
  4708. }
  4709. PsnNo = res.Output.Baseinfo.PsnNo
  4710. PsnCertType = res.Output.Baseinfo.PsnCertType
  4711. Certno = res.Output.Baseinfo.Certno
  4712. PsnName = res.Output.Baseinfo.PsnName
  4713. Gend = res.Output.Baseinfo.Gend
  4714. Naty = res.Output.Baseinfo.Naty
  4715. Brdy = res.Output.Baseinfo.Brdy
  4716. Age = res.Output.Baseinfo.Age
  4717. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4718. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4719. infoStr = string(Iinfos)
  4720. idetinfoStr = string(Idetinfos)
  4721. if miConfig.Code == "H15049901371" {
  4722. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  4723. } else {
  4724. infocode = res.Infcode
  4725. }
  4726. }
  4727. if infocode == 0 {
  4728. his := models.VMHisPatient{
  4729. Name: name,
  4730. Gender: gender,
  4731. Birthday: birthUnix,
  4732. MedicalTreatmentType: medical_care,
  4733. IdType: certificates,
  4734. IdCardNo: id_card,
  4735. BalanceAccountsType: settlementValue,
  4736. SocialType: social_type,
  4737. MedicalInsuranceNumber: medical_insurance_card,
  4738. RegisterType: register_type,
  4739. RegisterCost: registration_fee,
  4740. TreatmentCost: medical_expenses,
  4741. Status: 1,
  4742. Ctime: time.Now().Unix(),
  4743. Mtime: time.Now().Unix(),
  4744. PsnNo: PsnNo,
  4745. PsnCertType: PsnCertType,
  4746. Certno: Certno,
  4747. PsnName: PsnName,
  4748. Gend: Gend,
  4749. Naty: Naty,
  4750. Brdy: Brdy,
  4751. Age: Age,
  4752. Iinfo: infoStr,
  4753. Idetinfo: idetinfoStr,
  4754. PatientId: patient.ID,
  4755. RecordDate: theTime.Unix(),
  4756. UserOrgId: adminInfo.CurrentOrgId,
  4757. AdminUserId: admin_user_id,
  4758. IsReturn: 1,
  4759. IdCardType: id_card_type,
  4760. Doctor: doctor,
  4761. Departments: department,
  4762. }
  4763. timestamp := time.Now().Unix()
  4764. tempTime := time.Unix(timestamp, 0)
  4765. timeFormat := tempTime.Format("20060102150405")
  4766. chrgBchno := rand.Intn(100000) + 10000
  4767. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4768. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  4769. department, _ := service.GetDepartMentDetail(department)
  4770. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  4771. IdCardNo := ""
  4772. if id_card_type == 1 {
  4773. // IdCardNo = medical_insurance_card
  4774. IdCardNo = patient.IdCardNo
  4775. } else {
  4776. IdCardNo = patient.IdCardNo
  4777. }
  4778. var rf []*ResultFive
  4779. json.Unmarshal([]byte(his.Iinfo), &rf)
  4780. var insutypes []*ResultFive
  4781. var insutype string
  4782. var insuplc_admdvs_temp string
  4783. var is390 int = 0
  4784. var is310 int = 0
  4785. for _, item := range rf {
  4786. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4787. insutypes = append(insutypes, item)
  4788. }
  4789. }
  4790. if len(insutypes) == 1 {
  4791. insutype = insutypes[0].Insutype
  4792. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4793. } else {
  4794. for _, i := range insutypes {
  4795. if i.Insutype == "390" {
  4796. is390 = 1
  4797. }
  4798. if i.Insutype == "310" {
  4799. is310 = 1
  4800. }
  4801. }
  4802. }
  4803. if is390 == 1 {
  4804. insutype = "390"
  4805. }
  4806. if is310 == 1 {
  4807. insutype = "310"
  4808. }
  4809. if len(insutypes) == 0 {
  4810. insutype = "310"
  4811. }
  4812. if len(insutypes) == 2 {
  4813. insutype = med_type
  4814. }
  4815. if len(med_type) > 0 {
  4816. insutype = med_type
  4817. }
  4818. //for _, item := range rf {
  4819. // if item.Insutype == insutype {
  4820. // insuplc_admdvs = item.InsuplcAdmdvs
  4821. // }
  4822. //}
  4823. var infocode int64
  4824. var resThree ResultThree
  4825. var resThree10265 ResultThree10265
  4826. if len(insuplc_admdvs) == 0 {
  4827. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  4828. } else {
  4829. insuplc_admdvs_temp = insuplc_admdvs
  4830. }
  4831. if miConfig.MdtrtareaAdmvs == "421300" {
  4832. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  4833. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  4834. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4835. "&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
  4836. resp, requestErr := http.Get(api)
  4837. if requestErr != nil {
  4838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4839. return
  4840. }
  4841. body, ioErr := ioutil.ReadAll(resp.Body)
  4842. if ioErr != nil {
  4843. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4845. return
  4846. }
  4847. var respJSON map[string]interface{}
  4848. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4849. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4851. return
  4852. }
  4853. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4854. result, _ := json.Marshal(respJSON)
  4855. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4856. utils.ErrorLog("解析失败:%v", err)
  4857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4858. return
  4859. }
  4860. infocode = resThree.Infcode
  4861. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4862. psn_info, _ := service.GetPsnByPatientId(id)
  4863. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4864. var cert_no string
  4865. if id_card_type == 3 {
  4866. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  4867. cert_no = IdCardNo
  4868. } else if id_card_type == 4 {
  4869. cert_no = IdCardNo
  4870. psn_info.VerifyNumber = psn_info.VerifyNumber
  4871. } else {
  4872. bas := strings.Split(psn_info.CardInfo, "|")
  4873. cert_no = bas[2]
  4874. }
  4875. var api string
  4876. if miConfig.MdtrtareaAdmvs == "320921" {
  4877. api = "http://192.168.2.110:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4878. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4879. "&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_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4880. } else {
  4881. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4882. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4883. "&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_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4884. }
  4885. resp, requestErr := http.Get(api)
  4886. if requestErr != nil {
  4887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4888. return
  4889. }
  4890. body, ioErr := ioutil.ReadAll(resp.Body)
  4891. if ioErr != nil {
  4892. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4894. return
  4895. }
  4896. var respJSON map[string]interface{}
  4897. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4898. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4900. return
  4901. }
  4902. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4903. result, _ := json.Marshal(respJSON)
  4904. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4905. utils.ErrorLog("解析失败:%v", err)
  4906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4907. return
  4908. }
  4909. resThree.ErrMsg = resThree10265.ErrMsg
  4910. resThree.Output = resThree10265.Output
  4911. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4912. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4913. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4914. psn_info, _ := service.GetPsnByPatientId(id)
  4915. var cert_no string
  4916. if id_card_type == 1 {
  4917. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  4918. } else {
  4919. cert_no = strings.Split(psn_info.CardInfo, "|")[1]
  4920. }
  4921. fmt.Println(cert_no)
  4922. result, requestLog, _ := service.FJyb2201(psn_info.PsnNo, insutype, IdCardNo, miConfig.OrgName, doctor_info.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, 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)
  4923. saveLog(result, requestLog, "2201", "挂号")
  4924. if miConfig.Code == "H15049901371" {
  4925. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4926. utils.ErrorLog("解析失败:%v", err)
  4927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4928. return
  4929. }
  4930. resThree.ErrMsg = resThree10265.ErrMsg
  4931. resThree.Output = resThree10265.Output
  4932. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4933. } else {
  4934. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4935. utils.ErrorLog("解析失败:%v", err)
  4936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4937. return
  4938. }
  4939. }
  4940. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4941. } else {
  4942. psn_info, _ := service.GetPsnByPatientId(id)
  4943. result, requestLog := service.Gdyb2201A(res.Output.Baseinfo.PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, record_time, psn_info.VerifyNumber)
  4944. saveLog(result, requestLog, "2201A", "挂号")
  4945. if miConfig.Code == "H15049901371" {
  4946. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4947. utils.ErrorLog("解析失败:%v", err)
  4948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4949. return
  4950. }
  4951. resThree.ErrMsg = resThree10265.ErrMsg
  4952. resThree.Output = resThree10265.Output
  4953. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4954. } else {
  4955. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4956. utils.ErrorLog("解析失败:%v", err)
  4957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4958. return
  4959. }
  4960. }
  4961. if miConfig.Code == "H15049901371" {
  4962. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4963. } else {
  4964. infocode = resThree.Infcode
  4965. }
  4966. }
  4967. if infocode != 0 {
  4968. adminUser := c.GetAdminUserInfo()
  4969. errlog := &models.HisOrderError{
  4970. UserOrgId: adminUser.CurrentOrgId,
  4971. Ctime: time.Now().Unix(),
  4972. Mtime: time.Now().Unix(),
  4973. ErrMsg: resThree.ErrMsg,
  4974. Status: 1,
  4975. PatientId: id,
  4976. RecordTime: recordDateTime,
  4977. Stage: 2,
  4978. }
  4979. service.CreateErrMsgLog(errlog)
  4980. c.ServeSuccessJSON(map[string]interface{}{
  4981. "failed_code": -10,
  4982. "msg": resThree.ErrMsg,
  4983. })
  4984. return
  4985. }
  4986. his.Number = resThree.Output.Data.MdtrtID
  4987. his.PsnNo = resThree.Output.Data.PsnNo
  4988. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  4989. his.IdCardNo = patient.IdCardNo
  4990. his.PhoneNumber = patient.Phone
  4991. his.UserOrgId = adminInfo.CurrentOrgId
  4992. his.Insutype = insutype
  4993. his.Ctime = time.Now().Unix()
  4994. his.Mtime = time.Now().Unix()
  4995. his.InsuplcAdmdvs = insuplc_admdvs_temp
  4996. his.Status = 1
  4997. service.UpdateHisPatientStatus(&his)
  4998. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  4999. c.ServeSuccessJSON(map[string]interface{}{
  5000. "his_info": his,
  5001. })
  5002. } else {
  5003. adminUser := c.GetAdminUserInfo()
  5004. errlog := &models.HisOrderError{
  5005. UserOrgId: adminUser.CurrentOrgId,
  5006. Ctime: time.Now().Unix(),
  5007. Mtime: time.Now().Unix(),
  5008. ErrMsg: res.ErrMsg,
  5009. Status: 1,
  5010. PatientId: id,
  5011. RecordTime: recordDateTime,
  5012. Stage: 1,
  5013. }
  5014. service.CreateErrMsgLog(errlog)
  5015. c.ServeSuccessJSON(map[string]interface{}{
  5016. "failed_code": -10,
  5017. "msg": res.ErrMsg,
  5018. })
  5019. return
  5020. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  5021. }
  5022. }
  5023. }
  5024. //上传明细----预结算----确认订单
  5025. func (c *HisApiController) GetUploadInfo() {
  5026. id, _ := c.GetInt64("id")
  5027. record_time := c.GetString("record_time")
  5028. his_patient_id, _ := c.GetInt64("his_patient_id")
  5029. order_id, _ := c.GetInt64("order_id")
  5030. pay_way, _ := c.GetInt64("pay_way")
  5031. pay_price, _ := c.GetFloat("pay_price")
  5032. pay_card_no := c.GetString("pay_card_no")
  5033. token := c.GetString("token")
  5034. discount_price, _ := c.GetFloat("discount_price")
  5035. preferential_price, _ := c.GetFloat("preferential_price")
  5036. reality_price, _ := c.GetFloat("reality_price")
  5037. found_price, _ := c.GetFloat("found_price")
  5038. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  5039. private_price, _ := c.GetFloat("private_price")
  5040. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5041. admin_user_id, _ := c.GetInt64("admin_user_id")
  5042. fapiao_code := c.GetString("fapiao_code")
  5043. fapiao_number := c.GetString("fapiao_number")
  5044. diagnosis_id := c.GetString("diagnosis")
  5045. sick_type, _ := c.GetInt64("sick_type")
  5046. reg_type, _ := c.GetInt64("p_type")
  5047. begin_time := c.GetString("begin_time")
  5048. id_str := c.GetString("ids")
  5049. ids_arr := strings.Split(id_str, ",")
  5050. timeLayout := "2006-01-02"
  5051. loc, _ := time.LoadLocation("Local")
  5052. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5053. if err != nil {
  5054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5055. return
  5056. }
  5057. recordDateTime := theTime.Unix()
  5058. adminUser := c.GetAdminUserInfo()
  5059. var tempOrder models.HisOrder
  5060. tempOrder, _ = service.GetHisOrderByID(order_id)
  5061. var prescriptions []*models.HisPrescription
  5062. var start_time int64
  5063. var end_time int64
  5064. //押金模块
  5065. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  5066. tmp_decimal := c.GetString("tmp_decimal")
  5067. var decimal float64 //本次使用的押金
  5068. var errmsg error
  5069. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  5070. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  5071. return
  5072. }
  5073. if len(tmp_decimal) > 0 {
  5074. if tmp_decimal[0] == 45 {
  5075. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  5076. return
  5077. }
  5078. }
  5079. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  5080. fmt.Println(errs)
  5081. decimal = tt
  5082. //if adminUser.CurrentOrgId == 10106{
  5083. // if len(fapiao_code) == 0{
  5084. // fapiao_code = "144072080589"
  5085. // }
  5086. // if len(fapiao_number) == 0{
  5087. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  5088. // if order.ID == 0{
  5089. // fapiao_number = "00001520"
  5090. // }else{
  5091. // //fapiao_code = "00001520"
  5092. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  5093. // var zero string
  5094. // if fpNumber >= 1000{
  5095. // zero = "0000" + strconv.Itoa(fpNumber)
  5096. // }else if fpNumber >= 10000{
  5097. // zero = "000" + strconv.Itoa(fpNumber)
  5098. // } else if fpNumber >= 100000{
  5099. // zero = "00" + strconv.Itoa(fpNumber)
  5100. // } else if fpNumber >= 1000000{
  5101. // zero = "0" + strconv.Itoa(fpNumber)
  5102. // }else {
  5103. // zero = strconv.Itoa(fpNumber)
  5104. // }
  5105. // fapiao_number = zero
  5106. // }
  5107. // }
  5108. //}
  5109. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5110. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5111. var patientPrescription models.HisPrescriptionInfo
  5112. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5113. if patientPrescription.ID == 0 {
  5114. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5115. }
  5116. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5117. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5118. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5119. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5120. var config []*models.HisXtDiagnoseConfig
  5121. for _, item := range diagnosis_ids {
  5122. id, _ := strconv.ParseInt(item, 10, 64)
  5123. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5124. config = append(config, &diagnosisConfig)
  5125. }
  5126. sickConfig, _ := service.FindSickById(sick_type)
  5127. //if tempOrder.ID == 0 {
  5128. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  5129. //}
  5130. if tempOrder.ID == 0 {
  5131. var result string
  5132. var requestLog string
  5133. var res2 ResultSix
  5134. var ressix10265 ResultSix10265
  5135. if miConfig.MdtrtareaAdmvs == "421300" {
  5136. data := make(map[string]interface{})
  5137. client := &http.Client{}
  5138. data["psn_no"] = his.PsnNo
  5139. data["mdtrt_id"] = his.Number
  5140. data["opter"] = roles.UserName
  5141. data["org_name"] = miConfig.OrgName
  5142. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5143. data["doctor_id"] = doctor_info.DoctorNumber
  5144. data["doctor_name"] = doctor_info.UserName
  5145. data["department"] = department.Name
  5146. data["fixmedins_code"] = miConfig.Code
  5147. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5148. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5149. data["secret_key"] = miConfig.SecretKey
  5150. data["sick_code"] = sickConfig.CountryCode
  5151. data["sick_name"] = sickConfig.ClassName
  5152. data["dept"] = strconv.FormatInt(department.ID, 10)
  5153. data["config"] = config
  5154. data["begin_time"] = begin_time
  5155. bytesData, _ := json.Marshal(data)
  5156. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5157. resp, _ := client.Do(req)
  5158. defer resp.Body.Close()
  5159. body, ioErr := ioutil.ReadAll(resp.Body)
  5160. if ioErr != nil {
  5161. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5163. return
  5164. }
  5165. var respJSON map[string]interface{}
  5166. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5167. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5169. return
  5170. }
  5171. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5172. userJSONBytes, _ := json.Marshal(respJSON)
  5173. fmt.Println("log")
  5174. fmt.Println(string(userJSONBytes))
  5175. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5176. utils.ErrorLog("解析失败:%v", err)
  5177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5178. return
  5179. }
  5180. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5181. //江苏地区国家医保医疗类别
  5182. //职工透析:医疗类别选特殊情况门诊9933
  5183. //居民血透门慢: 医疗类别选门诊慢病1402
  5184. //var med_type string
  5185. //if his.Insutype == "310" {
  5186. // if reg_type == 14 {
  5187. // med_type = "9933"
  5188. // } else if reg_type == 11 {
  5189. // med_type = "11"
  5190. //
  5191. // }
  5192. //} else if his.Insutype == "390" {
  5193. // if reg_type == 14 {
  5194. // med_type = "1402"
  5195. // } else if reg_type == 11 {
  5196. // med_type = "11"
  5197. // }
  5198. //}
  5199. data := make(map[string]interface{})
  5200. client := &http.Client{}
  5201. data["psn_no"] = his.PsnNo
  5202. data["mdtrt_id"] = his.Number
  5203. data["doctor"] = roles.UserName
  5204. data["department"] = department.Name
  5205. data["org_name"] = miConfig.OrgName
  5206. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5207. data["doctor_id"] = doctor_info.DoctorNumber
  5208. data["new_doctor_name"] = doctor_info.UserName
  5209. data["fixmedins_code"] = miConfig.Code
  5210. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5211. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5212. data["secret_key"] = miConfig.SecretKey
  5213. data["sick_code"] = sickConfig.CountryCode
  5214. data["sick_name"] = sickConfig.ClassName
  5215. data["url"] = miConfig.Url
  5216. data["ak"] = miConfig.AccessKey
  5217. data["begin_time"] = begin_time
  5218. data["cainfo"] = miConfig.Cainfo
  5219. data["dept"] = strconv.FormatInt(department.ID, 10)
  5220. data["config"] = config
  5221. bytesData, _ := json.Marshal(data)
  5222. var req *http.Request
  5223. if miConfig.MdtrtareaAdmvs == "320921" {
  5224. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5225. //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 +
  5226. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  5227. } else {
  5228. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5229. }
  5230. resp, _ := client.Do(req)
  5231. defer resp.Body.Close()
  5232. body, ioErr := ioutil.ReadAll(resp.Body)
  5233. if ioErr != nil {
  5234. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5236. return
  5237. }
  5238. var respJSON map[string]interface{}
  5239. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5240. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5242. return
  5243. }
  5244. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5245. userJSONBytes, _ := json.Marshal(respJSON)
  5246. fmt.Println("log")
  5247. fmt.Println(string(userJSONBytes))
  5248. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5249. utils.ErrorLog("解析失败:%v", err)
  5250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5251. return
  5252. }
  5253. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5254. res2.Output = ressix10265.Output
  5255. res2.ErrMsg = ressix10265.ErrMsg
  5256. res2.Cainfo = ressix10265.Cainfo
  5257. res2.WarnMsg = ressix10265.WarnMsg
  5258. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5259. res2.Infcode = infocode
  5260. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5261. 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)
  5262. saveLog(result, requestLog, "2203", "上传就诊信息")
  5263. var respJSON2 map[string]interface{}
  5264. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5265. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5267. return
  5268. }
  5269. userJSONBytes2, _ := json.Marshal(respJSON2)
  5270. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5271. utils.ErrorLog("解析失败:%v", err)
  5272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5273. return
  5274. }
  5275. } else {
  5276. if miConfig.MdtrtareaAdmvs == "440781" { //
  5277. 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)
  5278. } else {
  5279. if miConfig.Code == "H15049901371" {
  5280. //赤峰地区国家医保医疗类别
  5281. //职工透析:医疗类别选特殊情况门诊990502
  5282. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5283. var med_type string
  5284. if his.Insutype == "390" {
  5285. if reg_type == 14 {
  5286. med_type = "9933"
  5287. } else if reg_type == 11 {
  5288. med_type = "11"
  5289. }
  5290. } else if his.Insutype == "310" {
  5291. if reg_type == 14 {
  5292. med_type = "990502"
  5293. } else if reg_type == 11 {
  5294. med_type = "11"
  5295. }
  5296. }
  5297. 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)
  5298. } else {
  5299. 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)
  5300. }
  5301. }
  5302. saveLog(result, requestLog, "2203", "上传就诊信息")
  5303. var respJSON2 map[string]interface{}
  5304. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5305. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5307. return
  5308. }
  5309. userJSONBytes2, _ := json.Marshal(respJSON2)
  5310. if miConfig.Code == "H15049901371" {
  5311. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  5312. utils.ErrorLog("解析失败:%v", err)
  5313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5314. return
  5315. }
  5316. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5317. res2.Output = ressix10265.Output
  5318. res2.ErrMsg = ressix10265.ErrMsg
  5319. res2.Cainfo = ressix10265.Cainfo
  5320. res2.WarnMsg = ressix10265.WarnMsg
  5321. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5322. res2.Infcode = infocode
  5323. } else {
  5324. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5325. utils.ErrorLog("解析失败:%v", err)
  5326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5327. return
  5328. }
  5329. }
  5330. }
  5331. if res2.Infcode != 0 {
  5332. adminUser := c.GetAdminUserInfo()
  5333. errlog := &models.HisOrderError{
  5334. UserOrgId: adminUser.CurrentOrgId,
  5335. Ctime: time.Now().Unix(),
  5336. Mtime: time.Now().Unix(),
  5337. ErrMsg: res2.ErrMsg,
  5338. Status: 1,
  5339. PatientId: id,
  5340. RecordTime: recordDateTime,
  5341. Stage: 3,
  5342. }
  5343. service.CreateErrMsgLog(errlog)
  5344. c.ServeSuccessJSON(map[string]interface{}{
  5345. "failed_code": -10,
  5346. "msg": res2.ErrMsg,
  5347. })
  5348. return
  5349. } else {
  5350. his.Diagnosis = diagnosis_id
  5351. his.SickType = sickConfig.ID
  5352. //var p_type int64
  5353. //if reg_type == 1111 || reg_type == 1112 {
  5354. // p_type = 11
  5355. //
  5356. //}
  5357. his.PType = fmt.Sprintf("%d", reg_type)
  5358. service.UpdateHisPatientThree(&his)
  5359. data := make(map[string]interface{})
  5360. if settle_accounts_type == 1 { //日结
  5361. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5362. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5363. } else {
  5364. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5365. }
  5366. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  5367. data["pre"] = prescriptions
  5368. } else { //月结
  5369. start_time_str := c.GetString("start_time")
  5370. end_time_str := c.GetString("end_time")
  5371. timeLayout := "2006-01-02"
  5372. loc, _ := time.LoadLocation("Local")
  5373. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5374. if err != nil {
  5375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5376. return
  5377. }
  5378. recordStartTime := theStartTime.Unix()
  5379. start_time = recordStartTime
  5380. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5381. if err != nil {
  5382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5383. return
  5384. }
  5385. recordEndTime := theEndTime.Unix()
  5386. end_time = recordEndTime
  5387. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5388. data["pre"] = prescriptions
  5389. }
  5390. timestamp := time.Now().Unix()
  5391. tempTime := time.Unix(timestamp, 0)
  5392. timeFormat := tempTime.Format("20060102150405")
  5393. chrgBchno := rand.Intn(100000) + 10000
  5394. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5395. strconv.FormatInt(his.PatientId, 10)
  5396. client := &http.Client{}
  5397. data["psn_no"] = his.PsnNo
  5398. data["mdtrt_id"] = his.Number
  5399. data["chrg_bchno"] = chrg_bchno
  5400. data["org_name"] = miConfig.OrgName
  5401. data["doctor"] = doctor_info.UserName
  5402. data["doctor_id"] = doctor_info.DoctorNumber
  5403. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5404. data["fixmedins_code"] = miConfig.Code
  5405. data["opter"] = roles.UserName
  5406. data["dept_code"] = department.Number
  5407. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5408. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5409. data["secret_key"] = miConfig.SecretKey
  5410. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5411. data["url"] = miConfig.Url
  5412. data["ak"] = miConfig.AccessKey
  5413. data["new_doctor_name"] = patientPrescription.Doctor
  5414. data["diag_code"] = sickConfig.CountryCode
  5415. data["cainfo"] = miConfig.Cainfo
  5416. var ids []int64
  5417. for _, item := range prescriptions {
  5418. ids = append(ids, item.ID)
  5419. }
  5420. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5421. if config.IsOpen == 1 { //对接了医保,走医保流程
  5422. var res ResultFour
  5423. var resFour10265 ResultFour10265
  5424. if miConfig.MdtrtareaAdmvs == "421300" {
  5425. bytesData, _ := json.Marshal(data)
  5426. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5427. resp, _ := client.Do(req)
  5428. defer resp.Body.Close()
  5429. body, ioErr := ioutil.ReadAll(resp.Body)
  5430. if ioErr != nil {
  5431. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5433. return
  5434. }
  5435. var respJSON map[string]interface{}
  5436. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5437. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5439. return
  5440. }
  5441. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5442. userJSONBytes, _ := json.Marshal(respJSON)
  5443. fmt.Println("log")
  5444. fmt.Println(string(userJSONBytes))
  5445. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5446. utils.ErrorLog("解析失败:%v", err)
  5447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5448. return
  5449. }
  5450. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5451. bytesData, _ := json.Marshal(data)
  5452. var req *http.Request
  5453. if miConfig.MdtrtareaAdmvs == "320921" {
  5454. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5455. } else {
  5456. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5457. }
  5458. resp, _ := client.Do(req)
  5459. defer resp.Body.Close()
  5460. body, ioErr := ioutil.ReadAll(resp.Body)
  5461. if ioErr != nil {
  5462. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5464. return
  5465. }
  5466. var respJSON map[string]interface{}
  5467. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5468. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5470. return
  5471. }
  5472. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5473. userJSONBytes, _ := json.Marshal(respJSON)
  5474. fmt.Println("log")
  5475. fmt.Println(string(userJSONBytes))
  5476. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5477. utils.ErrorLog("解析失败:%v", err)
  5478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5479. return
  5480. }
  5481. res.InfRefmsgid = resFour10265.InfRefmsgid
  5482. res.Output = resFour10265.Output
  5483. res.ErrMsg = resFour10265.ErrMsg
  5484. res.Cainfo = resFour10265.Cainfo
  5485. res.WarnMsg = resFour10265.WarnMsg
  5486. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5487. res.Infcode = infocode
  5488. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5489. 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)
  5490. var dat map[string]interface{}
  5491. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5492. fmt.Println(dat)
  5493. } else {
  5494. fmt.Println(err)
  5495. }
  5496. saveLog(result, request_log, "2204", "上传费用明细")
  5497. userJSONBytes, _ := json.Marshal(dat)
  5498. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5499. utils.ErrorLog("解析失败:%v", err)
  5500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5501. return
  5502. }
  5503. res.InfRefmsgid = resFour10265.InfRefmsgid
  5504. res.Output = resFour10265.Output
  5505. res.ErrMsg = resFour10265.ErrMsg
  5506. res.Cainfo = resFour10265.Cainfo
  5507. res.WarnMsg = resFour10265.WarnMsg
  5508. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5509. res.Infcode = infocode
  5510. } else {
  5511. if miConfig.Code == "H15049901371" {
  5512. 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)
  5513. var dat map[string]interface{}
  5514. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5515. fmt.Println(dat)
  5516. } else {
  5517. fmt.Println(err)
  5518. }
  5519. saveLog(result, request_log, "2204", "上传费用明细")
  5520. userJSONBytes, _ := json.Marshal(dat)
  5521. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5522. utils.ErrorLog("解析失败:%v", err)
  5523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5524. return
  5525. }
  5526. res.InfRefmsgid = resFour10265.InfRefmsgid
  5527. res.Output = resFour10265.Output
  5528. res.ErrMsg = resFour10265.ErrMsg
  5529. res.Cainfo = resFour10265.Cainfo
  5530. res.WarnMsg = resFour10265.WarnMsg
  5531. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5532. res.Infcode = infocode
  5533. } else {
  5534. 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)
  5535. var dat map[string]interface{}
  5536. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5537. fmt.Println(dat)
  5538. } else {
  5539. fmt.Println(err)
  5540. }
  5541. saveLog(result, request_log, "2204", "上传费用明细")
  5542. userJSONBytes, _ := json.Marshal(dat)
  5543. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5544. utils.ErrorLog("解析失败:%v", err)
  5545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5546. return
  5547. }
  5548. }
  5549. }
  5550. if res.Infcode == 0 {
  5551. order := &models.HisOrder{
  5552. UserOrgId: adminUser.CurrentOrgId,
  5553. HisPatientId: his.ID,
  5554. PatientId: his.PatientId,
  5555. SettleAccountsDate: recordDateTime,
  5556. MdtrtId: his.Number,
  5557. PsnNo: his.PsnNo,
  5558. MedType: strconv.FormatInt(reg_type, 10),
  5559. Ctime: time.Now().Unix(),
  5560. Mtime: time.Now().Unix(),
  5561. Status: 1,
  5562. Number: chrg_bchno,
  5563. Infcode: res.Infcode,
  5564. WarnMsg: res.WarnMsg,
  5565. Cainfo: res.Cainfo,
  5566. ErrMsg: res.ErrMsg,
  5567. RespondTime: res.RefmsgTime,
  5568. InfRefmsgid: res.InfRefmsgid,
  5569. OrderStatus: 1,
  5570. PayWay: pay_way,
  5571. PayPrice: pay_price,
  5572. PayCardNo: pay_card_no,
  5573. DiscountPrice: discount_price,
  5574. PreferentialPrice: preferential_price,
  5575. RealityPrice: reality_price,
  5576. FoundPrice: found_price,
  5577. MedicalInsurancePrice: medical_insurance_price,
  5578. PrivatePrice: private_price,
  5579. IsMedicineInsurance: 1,
  5580. SettleType: settle_accounts_type,
  5581. SettleStartTime: start_time,
  5582. SettleEndTime: end_time,
  5583. Creator: roles.AdminUserId,
  5584. Modify: roles.AdminUserId,
  5585. FaPiaoNumber: fapiao_number,
  5586. FaPiaoCode: fapiao_code,
  5587. PType: 2,
  5588. Diagnosis: diagnosis_id,
  5589. }
  5590. err = service.CreateOrder(order)
  5591. if err != nil {
  5592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5593. return
  5594. }
  5595. for _, item := range res.Output.Result {
  5596. temp := strings.Split(item.FeedetlSn, "-")
  5597. var advice_id int64 = 0
  5598. var project_id int64 = 0
  5599. var types int64 = 0
  5600. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5601. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5602. if temp[1] == "1" {
  5603. advice_id = id
  5604. project_id = 0
  5605. } else if temp[1] == "2" {
  5606. advice_id = 0
  5607. project_id = id
  5608. }
  5609. info := &models.HisOrderInfo{
  5610. OrderNumber: order.Number,
  5611. FeedetlSn: item.FeedetlSn,
  5612. UploadDate: time.Now().Unix(),
  5613. AdviceId: advice_id,
  5614. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5615. Cnt: item.Cnt,
  5616. Pric: float64(item.Pric),
  5617. PatientId: his.PatientId,
  5618. PricUplmtAmt: item.PricUplmtAmt,
  5619. SelfpayProp: item.SelfpayProp,
  5620. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5621. OverlmtAmt: item.OverlmtAmt,
  5622. PreselfpayAmt: item.PreselfpayAmt,
  5623. BasMednFlag: item.BasMednFlag,
  5624. MedChrgitmType: item.MedChrgitmType,
  5625. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5626. Status: 1,
  5627. Memo: item.Memo,
  5628. Mtime: time.Now().Unix(),
  5629. InscpScpAmt: item.InscpScpAmt,
  5630. DrtReimFlag: item.DrtReimFlag,
  5631. Ctime: time.Now().Unix(),
  5632. ListSpItemFlag: item.ListSpItemFlag,
  5633. ChldMedcFlag: item.ChldMedcFlag,
  5634. LmtUsedFlag: item.LmtUsedFlag,
  5635. ChrgitmLv: item.ChrgitmLv,
  5636. UserOrgId: adminUser.CurrentOrgId,
  5637. HisPatientId: his.ID,
  5638. OrderId: order.ID,
  5639. ProjectId: project_id,
  5640. Type: types,
  5641. }
  5642. service.CreateOrderInfo(info)
  5643. }
  5644. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5645. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5646. var total float64
  5647. for _, item := range prescriptions {
  5648. if item.Type == 1 { //药品
  5649. for _, subItem := range item.HisDoctorAdviceInfo {
  5650. total = total + (subItem.Price * subItem.PrescribingNumber)
  5651. }
  5652. }
  5653. if item.Type == 2 { //项目
  5654. for _, subItem := range item.HisPrescriptionProject {
  5655. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5656. total = total + (subItem.Price * cnt)
  5657. }
  5658. }
  5659. }
  5660. for _, item := range prescriptions {
  5661. for _, subItem := range item.HisAdditionalCharge {
  5662. total = total + (subItem.Price * float64(subItem.Count))
  5663. }
  5664. }
  5665. var allTotal string
  5666. if adminUser.CurrentOrgId == 9919 {
  5667. allTotal = fmt.Sprintf("%.4f", total)
  5668. } else {
  5669. allTotal = fmt.Sprintf("%.4f", total)
  5670. }
  5671. if res.Infcode == 0 {
  5672. var rf []*ResultFive
  5673. json.Unmarshal([]byte(his.Iinfo), &rf)
  5674. chrg_bchno := chrg_bchno
  5675. cert_no := his.Certno
  5676. var insutypes []string
  5677. var insutype string
  5678. var is390 int = 0
  5679. var is310 int = 0
  5680. for _, item := range rf {
  5681. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5682. insutypes = append(insutypes, item.Insutype)
  5683. }
  5684. }
  5685. if len(insutypes) == 1 {
  5686. insutype = insutypes[0]
  5687. } else {
  5688. for _, i := range insutypes {
  5689. if i == "390" {
  5690. is390 = 1
  5691. }
  5692. if i == "310" {
  5693. is310 = 1
  5694. }
  5695. }
  5696. }
  5697. if is390 == 1 {
  5698. insutype = "390"
  5699. }
  5700. if is310 == 1 {
  5701. insutype = "310"
  5702. }
  5703. if len(insutypes) == 0 {
  5704. insutype = "310"
  5705. }
  5706. if len(insutypes) == 2 {
  5707. insutype = strconv.FormatInt(his.SocialType, 10)
  5708. }
  5709. insutype = strconv.FormatInt(his.SocialType, 10)
  5710. //insutype = "390"
  5711. if his.IdCardType == 1 {
  5712. // cert_no = his.MedicalInsuranceNumber
  5713. cert_no = his.Certno
  5714. } else {
  5715. cert_no = his.Certno
  5716. }
  5717. var res ResultSeven
  5718. var resSeven10265 ResultSeven10265
  5719. var src_resquest string
  5720. var result2 string
  5721. var acct_used_flag string
  5722. fmt.Println("pay_way")
  5723. fmt.Println(pay_way)
  5724. fmt.Println("pay_way")
  5725. if pay_way == 4 {
  5726. acct_used_flag = "1"
  5727. } else {
  5728. acct_used_flag = "0"
  5729. }
  5730. if miConfig.MdtrtareaAdmvs == "421300" {
  5731. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5732. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5733. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5734. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5735. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5736. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5737. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5738. resp, requestErr := http.Get(api)
  5739. if requestErr != nil {
  5740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5741. return
  5742. }
  5743. body, ioErr := ioutil.ReadAll(resp.Body)
  5744. if ioErr != nil {
  5745. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5747. return
  5748. }
  5749. var respJSON map[string]interface{}
  5750. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5751. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5753. return
  5754. }
  5755. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5756. result, _ := json.Marshal(respJSON)
  5757. if miConfig.Code == "H15049901371" {
  5758. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5759. utils.ErrorLog("解析失败:%v", err)
  5760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5761. return
  5762. }
  5763. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5764. res.Output = resSeven10265.Output
  5765. res.ErrMsg = resSeven10265.ErrMsg
  5766. res.Cainfo = resSeven10265.Cainfo
  5767. res.WarnMsg = resSeven10265.WarnMsg
  5768. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5769. res.Infcode = infocode
  5770. } else {
  5771. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5772. utils.ErrorLog("解析失败:%v", err)
  5773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5774. return
  5775. }
  5776. }
  5777. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5778. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5779. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5780. bas := strings.Split(psn_info.CardInfo, "|")
  5781. if his.IdCardType == 1 {
  5782. cert_no = bas[2]
  5783. } else if his.IdCardType == 3 {
  5784. cert_no = his.Certno
  5785. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  5786. } else if his.IdCardType == 4 {
  5787. cert_no = his.Certno
  5788. psn_info.VerifyNumber = token
  5789. }
  5790. var api string
  5791. if miConfig.MdtrtareaAdmvs == "320921" {
  5792. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5793. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5794. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5795. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5796. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5797. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5798. "&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
  5799. } else {
  5800. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5801. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5802. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5803. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5804. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5805. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5806. "&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
  5807. }
  5808. resp, requestErr := http.Get(api)
  5809. if requestErr != nil {
  5810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5811. return
  5812. }
  5813. body, ioErr := ioutil.ReadAll(resp.Body)
  5814. if ioErr != nil {
  5815. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5817. return
  5818. }
  5819. var respJSON map[string]interface{}
  5820. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5821. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5823. return
  5824. }
  5825. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5826. result, _ := json.Marshal(respJSON)
  5827. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5828. utils.ErrorLog("解析失败:%v", err)
  5829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5830. return
  5831. }
  5832. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5833. res.Output = resSeven10265.Output
  5834. res.ErrMsg = resSeven10265.ErrMsg
  5835. res.Cainfo = resSeven10265.Cainfo
  5836. res.WarnMsg = resSeven10265.WarnMsg
  5837. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5838. res.Infcode = infocode
  5839. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5840. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5841. var cert_no string
  5842. if his.IdCardType == 1 {
  5843. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  5844. }
  5845. fmt.Println(cert_no)
  5846. 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)
  5847. //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)
  5848. var dat map[string]interface{}
  5849. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5850. fmt.Println(dat)
  5851. } else {
  5852. fmt.Println(err)
  5853. }
  5854. saveLog(result2, src_resquest, "2207", "结算")
  5855. userJSONBytes, _ := json.Marshal(dat)
  5856. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5857. utils.ErrorLog("解析失败:%v", err)
  5858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5859. return
  5860. }
  5861. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5862. res.Output = resSeven10265.Output
  5863. res.ErrMsg = resSeven10265.ErrMsg
  5864. res.Cainfo = resSeven10265.Cainfo
  5865. res.WarnMsg = resSeven10265.WarnMsg
  5866. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5867. res.Infcode = infocode
  5868. } else {
  5869. if miConfig.Code == "H15049901371" {
  5870. //赤峰地区国家医保医疗类别
  5871. //职工透析:医疗类别选特殊情况门诊990502
  5872. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5873. var med_type string
  5874. if his.Insutype == "390" {
  5875. if reg_type == 14 {
  5876. med_type = "9933"
  5877. } else if reg_type == 11 {
  5878. med_type = "11"
  5879. }
  5880. } else if his.Insutype == "310" {
  5881. if reg_type == 14 {
  5882. med_type = "990502"
  5883. } else if reg_type == 11 {
  5884. med_type = "11"
  5885. }
  5886. }
  5887. 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)
  5888. } else {
  5889. 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)
  5890. }
  5891. //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)
  5892. var dat map[string]interface{}
  5893. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5894. fmt.Println(dat)
  5895. } else {
  5896. fmt.Println(err)
  5897. }
  5898. saveLog(result2, src_resquest, "2207", "结算")
  5899. userJSONBytes, _ := json.Marshal(dat)
  5900. if miConfig.Code == "H15049901371" {
  5901. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5902. utils.ErrorLog("解析失败:%v", err)
  5903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5904. return
  5905. }
  5906. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5907. res.Output = resSeven10265.Output
  5908. res.ErrMsg = resSeven10265.ErrMsg
  5909. res.Cainfo = resSeven10265.Cainfo
  5910. res.WarnMsg = resSeven10265.WarnMsg
  5911. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5912. res.Infcode = infocode
  5913. } else {
  5914. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5915. utils.ErrorLog("解析失败:%v", err)
  5916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5917. return
  5918. }
  5919. }
  5920. }
  5921. if res.Infcode != 0 {
  5922. errlog := &models.HisOrderError{
  5923. UserOrgId: adminUser.CurrentOrgId,
  5924. Ctime: time.Now().Unix(),
  5925. Mtime: time.Now().Unix(),
  5926. Number: chrg_bchno,
  5927. ErrMsg: res.ErrMsg,
  5928. Status: 1,
  5929. PatientId: id,
  5930. RecordTime: recordDateTime,
  5931. Stage: 6,
  5932. }
  5933. service.CreateErrMsgLog(errlog)
  5934. c.ServeSuccessJSON(map[string]interface{}{
  5935. "failed_code": -10,
  5936. "msg": res.ErrMsg,
  5937. })
  5938. return
  5939. } else {
  5940. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5941. order.OrderStatus = 2
  5942. order.Status = 1
  5943. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5944. order.SetlId = res.Output.Setlinfo.SetlID
  5945. order.PsnNo = res.Output.Setlinfo.PsnNo
  5946. order.PsnName = res.Output.Setlinfo.PsnName
  5947. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5948. order.Certno = res.Output.Setlinfo.Certno
  5949. order.Gend = res.Output.Setlinfo.Gend
  5950. order.Naty = res.Output.Setlinfo.Naty
  5951. order.Age = res.Output.Setlinfo.Age
  5952. order.Insutype = res.Output.Setlinfo.Insutype
  5953. order.PsnType = res.Output.Setlinfo.PsnType
  5954. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5955. order.SetlTime = res.Output.Setlinfo.SetlTime
  5956. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5957. if res.Output.Setlinfo.MedType == "140101" {
  5958. order.MedType = "14"
  5959. } else {
  5960. order.MedType = res.Output.Setlinfo.MedType
  5961. }
  5962. if reg_type == 1112 {
  5963. order.MedType = "1112"
  5964. }
  5965. if reg_type == 1111 {
  5966. order.MedType = "1111"
  5967. }
  5968. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5969. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5970. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5971. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5972. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5973. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5974. order.HifpPay = res.Output.Setlinfo.HifpPay
  5975. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5976. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5977. order.HifesPay = res.Output.Setlinfo.HifesPay
  5978. order.HifobPay = res.Output.Setlinfo.HifobPay
  5979. order.MafPay = res.Output.Setlinfo.MafPay
  5980. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5981. order.OthPay = res.Output.Setlinfo.OthPay
  5982. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5983. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5984. order.AcctPay = res.Output.Setlinfo.AcctPay
  5985. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5986. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5987. order.Balc = res.Output.Setlinfo.Balc
  5988. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5989. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5990. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5991. order.ClrType = res.Output.Setlinfo.ClrType
  5992. order.ClrWay = res.Output.Setlinfo.ClrWay
  5993. order.Creator = order.Creator
  5994. order.Modify = roles.AdminUserId
  5995. order.RequestLog = src_resquest
  5996. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5997. detailStr := string(setlDetail)
  5998. order.SetlDetail = detailStr
  5999. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6000. err = service.UpDateOrder(order)
  6001. if err == nil {
  6002. //判断是否使用了押金
  6003. if dec_way == "true" {
  6004. tmpstring := strconv.FormatInt(order.ID, 10)
  6005. order.Decimal = decimal
  6006. service.UpDateOrder(order)
  6007. //扣押金
  6008. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6009. if errmsg != nil {
  6010. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6011. return
  6012. }
  6013. }
  6014. c.ServeSuccessJSON(map[string]interface{}{
  6015. "msg": "结算成功",
  6016. })
  6017. } else {
  6018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6019. return
  6020. }
  6021. }
  6022. } else {
  6023. adminUser := c.GetAdminUserInfo()
  6024. errlog := &models.HisOrderError{
  6025. UserOrgId: adminUser.CurrentOrgId,
  6026. Ctime: time.Now().Unix(),
  6027. Mtime: time.Now().Unix(),
  6028. ErrMsg: res.ErrMsg,
  6029. Status: 1,
  6030. PatientId: id,
  6031. RecordTime: recordDateTime,
  6032. Stage: 4,
  6033. }
  6034. service.CreateErrMsgLog(errlog)
  6035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6036. return
  6037. }
  6038. } else {
  6039. adminUser := c.GetAdminUserInfo()
  6040. errlog := &models.HisOrderError{
  6041. UserOrgId: adminUser.CurrentOrgId,
  6042. Ctime: time.Now().Unix(),
  6043. Mtime: time.Now().Unix(),
  6044. ErrMsg: res.ErrMsg,
  6045. Status: 1,
  6046. PatientId: id,
  6047. RecordTime: recordDateTime,
  6048. Stage: 4,
  6049. }
  6050. service.CreateErrMsgLog(errlog)
  6051. c.ServeSuccessJSON(map[string]interface{}{
  6052. "failed_code": -10,
  6053. "msg": res.ErrMsg,
  6054. })
  6055. return
  6056. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6057. //return
  6058. }
  6059. }
  6060. }
  6061. } else if tempOrder.ID > 0 {
  6062. if tempOrder.IsPre == 1 {
  6063. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  6064. var rf []*ResultFive
  6065. json.Unmarshal([]byte(his.Iinfo), &rf)
  6066. chrg_bchno := tempOrder.Number
  6067. cert_no := his.Certno
  6068. var insutypes []string
  6069. var insutype string
  6070. var is390 int = 0
  6071. var is310 int = 0
  6072. for _, item := range rf {
  6073. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6074. insutypes = append(insutypes, item.Insutype)
  6075. }
  6076. }
  6077. if len(insutypes) == 1 {
  6078. insutype = insutypes[0]
  6079. } else {
  6080. for _, i := range insutypes {
  6081. if i == "390" {
  6082. is390 = 1
  6083. }
  6084. if i == "310" {
  6085. is310 = 1
  6086. }
  6087. }
  6088. }
  6089. if is390 == 1 {
  6090. insutype = "390"
  6091. }
  6092. if is310 == 1 {
  6093. insutype = "310"
  6094. }
  6095. if len(insutypes) == 0 {
  6096. insutype = "310"
  6097. }
  6098. if len(insutypes) == 2 {
  6099. insutype = strconv.FormatInt(his.SocialType, 64)
  6100. }
  6101. //insutype = "390"
  6102. if his.IdCardType == 1 {
  6103. // cert_no = his.MedicalInsuranceNumber
  6104. cert_no = his.Certno
  6105. } else {
  6106. cert_no = his.Certno
  6107. }
  6108. var res ResultSeven
  6109. var resSeven10265 ResultSeven10265
  6110. var src_resquest string
  6111. var result2 string
  6112. var acct_used_flag string
  6113. fmt.Println("pay_way")
  6114. fmt.Println(pay_way)
  6115. fmt.Println("pay_way")
  6116. if pay_way == 4 {
  6117. acct_used_flag = "1"
  6118. } else {
  6119. acct_used_flag = "0"
  6120. }
  6121. if miConfig.MdtrtareaAdmvs == "421300" {
  6122. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6123. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6124. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6125. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6126. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6127. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6128. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  6129. resp, requestErr := http.Get(api)
  6130. if requestErr != nil {
  6131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6132. return
  6133. }
  6134. body, ioErr := ioutil.ReadAll(resp.Body)
  6135. if ioErr != nil {
  6136. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6138. return
  6139. }
  6140. var respJSON map[string]interface{}
  6141. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6142. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6144. return
  6145. }
  6146. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6147. result, _ := json.Marshal(respJSON)
  6148. fmt.Println("log")
  6149. fmt.Println(string(result))
  6150. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6151. utils.ErrorLog("解析失败:%v", err)
  6152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6153. return
  6154. }
  6155. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6156. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6157. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6158. //psn_info, _ := service.GetPsnByPatientId(id)
  6159. bas := strings.Split(psn_info.CardInfo, "|")
  6160. if his.IdCardType == 1 {
  6161. cert_no = bas[2]
  6162. } else {
  6163. cert_no = bas[1]
  6164. }
  6165. //江苏地区国家医保医疗类别
  6166. //职工透析:医疗类别选特殊情况门诊9933
  6167. //居民血透门慢: 医疗类别选门诊慢病1402
  6168. //var med_type string
  6169. //if his.Insutype == "310" {
  6170. // if reg_type == 14 {
  6171. // med_type = "9933"
  6172. // } else if reg_type == 11 {
  6173. // med_type = "11"
  6174. //
  6175. // }
  6176. //} else if his.Insutype == "390" {
  6177. // if reg_type == 14 {
  6178. // med_type = "1402"
  6179. // } else if reg_type == 11 {
  6180. // med_type = "11"
  6181. // }
  6182. //}
  6183. var api string
  6184. if miConfig.MdtrtareaAdmvs == "320921" {
  6185. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6186. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6187. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6188. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6189. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6190. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6191. "&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
  6192. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6193. } else {
  6194. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6195. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6196. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6197. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6198. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6199. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6200. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6201. "&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
  6202. }
  6203. resp, requestErr := http.Get(api)
  6204. if requestErr != nil {
  6205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6206. return
  6207. }
  6208. body, ioErr := ioutil.ReadAll(resp.Body)
  6209. if ioErr != nil {
  6210. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6212. return
  6213. }
  6214. var respJSON map[string]interface{}
  6215. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6216. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6218. return
  6219. }
  6220. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6221. result, _ := json.Marshal(respJSON)
  6222. fmt.Println("log")
  6223. fmt.Println(string(result))
  6224. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6225. utils.ErrorLog("解析失败:%v", err)
  6226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6227. return
  6228. }
  6229. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6230. res.Output = resSeven10265.Output
  6231. res.ErrMsg = resSeven10265.ErrMsg
  6232. res.Cainfo = resSeven10265.Cainfo
  6233. res.WarnMsg = resSeven10265.WarnMsg
  6234. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6235. res.Infcode = infocode
  6236. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6237. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6238. var cert_no string
  6239. if his.IdCardType == 1 {
  6240. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  6241. }
  6242. fmt.Println(cert_no)
  6243. 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)
  6244. var dat map[string]interface{}
  6245. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6246. fmt.Println(dat)
  6247. } else {
  6248. fmt.Println(err)
  6249. }
  6250. saveLog(result2, src_resquest, "2207", "结算")
  6251. userJSONBytes, _ := json.Marshal(dat)
  6252. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6253. utils.ErrorLog("解析失败:%v", err)
  6254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6255. return
  6256. }
  6257. } else {
  6258. var src_resquest string
  6259. if miConfig.Code == "H15049901371" {
  6260. //赤峰地区国家医保医疗类别
  6261. //职工透析:医疗类别选特殊情况门诊990502
  6262. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6263. var med_type string
  6264. if his.Insutype == "390" {
  6265. if reg_type == 14 {
  6266. med_type = "9933"
  6267. } else if reg_type == 11 {
  6268. med_type = "11"
  6269. }
  6270. } else if his.Insutype == "310" {
  6271. if reg_type == 14 {
  6272. med_type = "990502"
  6273. } else if reg_type == 11 {
  6274. med_type = "11"
  6275. }
  6276. }
  6277. 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)
  6278. } else {
  6279. 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)
  6280. }
  6281. var dat map[string]interface{}
  6282. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6283. fmt.Println(dat)
  6284. } else {
  6285. fmt.Println(err)
  6286. }
  6287. saveLog(result2, src_resquest, "2207", "结算")
  6288. userJSONBytes, _ := json.Marshal(dat)
  6289. if miConfig.Code == "H15049901371" {
  6290. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6291. utils.ErrorLog("解析失败:%v", err)
  6292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6293. return
  6294. }
  6295. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6296. res.Output = resSeven10265.Output
  6297. res.ErrMsg = resSeven10265.ErrMsg
  6298. res.Cainfo = resSeven10265.Cainfo
  6299. res.WarnMsg = resSeven10265.WarnMsg
  6300. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6301. res.Infcode = infocode
  6302. } else {
  6303. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6304. utils.ErrorLog("解析失败:%v", err)
  6305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6306. return
  6307. }
  6308. }
  6309. }
  6310. if res.Infcode != 0 {
  6311. errlog := &models.HisOrderError{
  6312. UserOrgId: adminUser.CurrentOrgId,
  6313. Ctime: time.Now().Unix(),
  6314. Mtime: time.Now().Unix(),
  6315. Number: chrg_bchno,
  6316. ErrMsg: res.ErrMsg,
  6317. Status: 1,
  6318. PatientId: id,
  6319. RecordTime: recordDateTime,
  6320. Stage: 6,
  6321. }
  6322. service.CreateErrMsgLog(errlog)
  6323. c.ServeSuccessJSON(map[string]interface{}{
  6324. "failed_code": -10,
  6325. "msg": res.ErrMsg,
  6326. })
  6327. return
  6328. } else {
  6329. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6330. order.OrderStatus = 2
  6331. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6332. order.SetlId = res.Output.Setlinfo.SetlID
  6333. order.PsnNo = res.Output.Setlinfo.PsnNo
  6334. order.PsnName = res.Output.Setlinfo.PsnName
  6335. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6336. order.Certno = res.Output.Setlinfo.Certno
  6337. order.Gend = res.Output.Setlinfo.Gend
  6338. order.Naty = res.Output.Setlinfo.Naty
  6339. order.Age = res.Output.Setlinfo.Age
  6340. order.Insutype = res.Output.Setlinfo.Insutype
  6341. order.PsnType = res.Output.Setlinfo.PsnType
  6342. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6343. order.SetlTime = res.Output.Setlinfo.SetlTime
  6344. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6345. //order.MedType = res.Output.Setlinfo.MedType
  6346. if reg_type == 1112 {
  6347. order.MedType = "1112"
  6348. }
  6349. if reg_type == 1111 {
  6350. order.MedType = "1111"
  6351. }
  6352. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6353. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6354. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6355. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6356. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6357. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6358. order.HifpPay = res.Output.Setlinfo.HifpPay
  6359. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6360. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6361. order.HifesPay = res.Output.Setlinfo.HifesPay
  6362. order.HifobPay = res.Output.Setlinfo.HifobPay
  6363. order.MafPay = res.Output.Setlinfo.MafPay
  6364. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6365. order.OthPay = res.Output.Setlinfo.OthPay
  6366. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6367. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6368. order.AcctPay = res.Output.Setlinfo.AcctPay
  6369. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6370. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6371. order.Balc = res.Output.Setlinfo.Balc
  6372. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6373. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6374. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6375. order.ClrWay = res.Output.Setlinfo.ClrWay
  6376. order.Creator = order.Creator
  6377. order.Modify = roles.AdminUserId
  6378. order.RequestLog = src_resquest
  6379. order.Diagnosis = diagnosis_id
  6380. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6381. detailStr := string(setlDetail)
  6382. order.SetlDetail = detailStr
  6383. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6384. err = service.UpDateOrder(order)
  6385. if err == nil {
  6386. //判断是否使用了押金
  6387. if dec_way == "true" {
  6388. tmpstring := strconv.FormatInt(order.ID, 10)
  6389. //扣押金
  6390. order.Decimal = decimal
  6391. service.UpDateOrder(order)
  6392. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6393. if errmsg != nil {
  6394. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6395. return
  6396. }
  6397. }
  6398. c.ServeSuccessJSON(map[string]interface{}{
  6399. "msg": "结算成功",
  6400. })
  6401. } else {
  6402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6403. return
  6404. }
  6405. }
  6406. }
  6407. }
  6408. }
  6409. //func (c *HisApiController) GetPreUploadInfo() {
  6410. // id, _ := c.GetInt64("id")
  6411. // record_time := c.GetString("record_time")
  6412. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6413. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6414. //
  6415. // timeLayout := "2006-01-02"
  6416. // loc, _ := time.LoadLocation("Local")
  6417. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6418. // if err != nil {
  6419. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6420. // return
  6421. // }
  6422. // recordDateTime := theTime.Unix()
  6423. // adminUser := c.GetAdminUserInfo()
  6424. //
  6425. // var prescriptions []*models.HisPrescription
  6426. //
  6427. // var start_time int64
  6428. // var end_time int64
  6429. //
  6430. // data := make(map[string]interface{})
  6431. // if settle_accounts_type == 1 { //日结
  6432. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6433. // data["pre"] = prescriptions
  6434. //
  6435. // } else { //月结
  6436. // start_time_str := c.GetString("start_time")
  6437. // end_time_str := c.GetString("end_time")
  6438. // timeLayout := "2006-01-02"
  6439. // loc, _ := time.LoadLocation("Local")
  6440. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6441. // if err != nil {
  6442. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6443. // return
  6444. // }
  6445. // recordStartTime := theStartTime.Unix()
  6446. // start_time = recordStartTime
  6447. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6448. // if err != nil {
  6449. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6450. // return
  6451. // }
  6452. // recordEndTime := theEndTime.Unix()
  6453. // end_time = recordEndTime
  6454. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6455. // data["pre"] = prescriptions
  6456. //
  6457. // }
  6458. //
  6459. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6460. //
  6461. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6462. // timestamp := time.Now().Unix()
  6463. // tempTime := time.Unix(timestamp, 0)
  6464. // timeFormat := tempTime.Format("20060102150405")
  6465. // chrgBchno := rand.Intn(100000) + 10000
  6466. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6467. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6468. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6469. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6470. // strconv.FormatInt(his.PatientId, 10)
  6471. // client := &http.Client{}
  6472. // data["psn_no"] = his.PsnNo
  6473. // data["mdtrt_id"] = his.Number
  6474. // data["chrg_bchno"] = chrg_bchno
  6475. // data["org_name"] = miConfig.OrgName
  6476. // data["doctor"] = roles.UserName
  6477. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6478. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6479. // data["fixmedins_code"] = miConfig.Code
  6480. // data["dept_code"] = department.Number
  6481. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6482. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6483. // data["secret_key"] = miConfig.SecretKey
  6484. // var ids []int64
  6485. //
  6486. // for _, item := range prescriptions {
  6487. // ids = append(ids, item.ID)
  6488. // }
  6489. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6490. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6491. // bytesData, _ := json.Marshal(data)
  6492. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  6493. // resp, _ := client.Do(req)
  6494. // defer resp.Body.Close()
  6495. // body, ioErr := ioutil.ReadAll(resp.Body)
  6496. // if ioErr != nil {
  6497. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6498. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6499. // return
  6500. // }
  6501. // var respJSON map[string]interface{}
  6502. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6503. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6504. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6505. // return
  6506. // }
  6507. //
  6508. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6509. // userJSONBytes, _ := json.Marshal(respJSON)
  6510. // var res ResultFour
  6511. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6512. // utils.ErrorLog("解析失败:%v", err)
  6513. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6514. // return
  6515. // }
  6516. //
  6517. // if res.Infcode == 0 {
  6518. // order := &models.HisOrder{
  6519. // UserOrgId: adminUser.CurrentOrgId,
  6520. // HisPatientId: his.ID,
  6521. // PatientId: his.PatientId,
  6522. // SettleAccountsDate: recordDateTime,
  6523. // Ctime: time.Now().Unix(),
  6524. // Mtime: time.Now().Unix(),
  6525. // Status: 1,
  6526. // Number: chrg_bchno,
  6527. // Infcode: res.Infcode,
  6528. // WarnMsg: res.WarnMsg,
  6529. // Cainfo: res.Cainfo,
  6530. // ErrMsg: res.ErrMsg,
  6531. // RespondTime: res.RefmsgTime,
  6532. // InfRefmsgid: res.InfRefmsgid,
  6533. // OrderStatus: 1,
  6534. // IsMedicineInsurance: 1,
  6535. // SettleType: settle_accounts_type,
  6536. // SettleStartTime: start_time,
  6537. // SettleEndTime: end_time,
  6538. // Creator: roles.ID,
  6539. // Modify: roles.ID,
  6540. // PType: 2,
  6541. // }
  6542. // err = service.CreateOrder(order)
  6543. // if err != nil {
  6544. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6545. // return
  6546. // }
  6547. //
  6548. // for _, item := range res.Output.Result {
  6549. // temp := strings.Split(item.FeedetlSn, "-")
  6550. // var advice_id int64 = 0
  6551. // var project_id int64 = 0
  6552. // var types int64 = 0
  6553. //
  6554. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  6555. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  6556. //
  6557. // if temp[1] == "1" {
  6558. // advice_id = id
  6559. // project_id = 0
  6560. // } else if temp[1] == "2" {
  6561. // advice_id = 0
  6562. // project_id = id
  6563. // }
  6564. //
  6565. // info := &models.HisOrderInfo{
  6566. // OrderNumber: order.Number,
  6567. // FeedetlSn: item.FeedetlSn,
  6568. // UploadDate: time.Now().Unix(),
  6569. // AdviceId: advice_id,
  6570. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  6571. // Cnt: item.Cnt,
  6572. // Pric: float64(item.Pric),
  6573. // PatientId: his.PatientId,
  6574. // PricUplmtAmt: item.PricUplmtAmt,
  6575. // SelfpayProp: item.SelfpayProp,
  6576. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6577. // OverlmtAmt: item.OverlmtAmt,
  6578. // PreselfpayAmt: item.PreselfpayAmt,
  6579. // BasMednFlag: item.BasMednFlag,
  6580. // MedChrgitmType: item.MedChrgitmType,
  6581. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  6582. // Status: 1,
  6583. // Memo: item.Memo,
  6584. // Mtime: time.Now().Unix(),
  6585. // InscpScpAmt: item.InscpScpAmt,
  6586. // DrtReimFlag: item.DrtReimFlag,
  6587. // Ctime: time.Now().Unix(),
  6588. // ListSpItemFlag: item.ListSpItemFlag,
  6589. // ChldMedcFlag: item.ChldMedcFlag,
  6590. // LmtUsedFlag: item.LmtUsedFlag,
  6591. // ChrgitmLv: item.ChrgitmLv,
  6592. // UserOrgId: adminUser.CurrentOrgId,
  6593. // HisPatientId: his.ID,
  6594. // OrderId: order.ID,
  6595. // ProjectId: project_id,
  6596. // Type: types,
  6597. // }
  6598. // service.CreateOrderInfo(info)
  6599. //
  6600. // }
  6601. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6602. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  6603. //
  6604. // var total float64
  6605. // for _, item := range prescriptions {
  6606. // if item.Type == 1 { //药品
  6607. // for _, subItem := range item.HisDoctorAdviceInfo {
  6608. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6609. // }
  6610. // }
  6611. // if item.Type == 2 { //项目
  6612. // for _, subItem := range item.HisPrescriptionProject {
  6613. // total = total + (subItem.Price * float64(subItem.Count))
  6614. // }
  6615. // }
  6616. // }
  6617. //
  6618. // for _, item := range prescriptions {
  6619. // for _, subItem := range item.HisAdditionalCharge {
  6620. // total = total + (subItem.Price * float64(subItem.Count))
  6621. // }
  6622. // }
  6623. //
  6624. // allTotal := fmt.Sprintf("%.2f", total)
  6625. // if res.Infcode == 0 {
  6626. // var rf []*ResultFive
  6627. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6628. // psn_no := his.PsnNo
  6629. // mdtrt_id := his.Number
  6630. // chrg_bchno := chrg_bchno
  6631. // cert_no := his.Certno
  6632. // insutype := rf[0].Insutype
  6633. //
  6634. // if his.IdCardType == 1 {
  6635. // cert_no = his.MedicalInsuranceNumber
  6636. //
  6637. // } else {
  6638. //
  6639. // cert_no = his.Certno
  6640. //
  6641. // }
  6642. //
  6643. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  6644. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  6645. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  6646. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  6647. // resp, requestErr := http.Get(api)
  6648. // if requestErr != nil {
  6649. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6650. // return
  6651. // }
  6652. // defer resp.Body.Close()
  6653. // body, ioErr := ioutil.ReadAll(resp.Body)
  6654. // if ioErr != nil {
  6655. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6656. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6657. // return
  6658. // }
  6659. // var respJSON map[string]interface{}
  6660. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6661. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6662. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6663. // return
  6664. // }
  6665. // fmt.Println(respJSON)
  6666. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6667. // userJSONBytes, _ := json.Marshal(respJSON)
  6668. // var res ResultSeven
  6669. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6670. // utils.ErrorLog("解析失败:%v", err)
  6671. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6672. // return
  6673. // }
  6674. // if res.Infcode != 0 {
  6675. // errlog := &models.HisOrderError{
  6676. // UserOrgId: adminUser.CurrentOrgId,
  6677. // Ctime: time.Now().Unix(),
  6678. // Mtime: time.Now().Unix(),
  6679. // Number: chrg_bchno,
  6680. // ErrMsg: res.ErrMsg,
  6681. // Status: 1,
  6682. // PatientId: id,
  6683. // RecordTime: recordDateTime,
  6684. // Stage: 7,
  6685. // }
  6686. // service.CreateErrMsgLog(errlog)
  6687. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6688. // return
  6689. // } else {
  6690. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6691. // order.OrderStatus = 1
  6692. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6693. // order.SetlId = res.Output.Setlinfo.SetlID
  6694. // order.PsnNo = res.Output.Setlinfo.PsnNo
  6695. // order.PsnName = res.Output.Setlinfo.PsnName
  6696. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6697. // order.Certno = res.Output.Setlinfo.Certno
  6698. // order.Gend = res.Output.Setlinfo.Gend
  6699. // order.Naty = res.Output.Setlinfo.Naty
  6700. // order.Age = res.Output.Setlinfo.Age
  6701. // order.Insutype = res.Output.Setlinfo.Insutype
  6702. // order.PsnType = res.Output.Setlinfo.PsnType
  6703. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6704. // order.SetlTime = res.Output.Setlinfo.SetlTime
  6705. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6706. // order.MedType = res.Output.Setlinfo.MedType
  6707. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6708. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6709. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6710. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6711. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6712. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6713. // order.HifpPay = res.Output.Setlinfo.HifpPay
  6714. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6715. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6716. // order.HifesPay = res.Output.Setlinfo.HifesPay
  6717. // order.HifobPay = res.Output.Setlinfo.HifobPay
  6718. // order.MafPay = res.Output.Setlinfo.MafPay
  6719. // order.OthPay = res.Output.Setlinfo.OthPay
  6720. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6721. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6722. // order.AcctPay = res.Output.Setlinfo.AcctPay
  6723. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6724. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6725. // order.Balc = res.Output.Setlinfo.Balc
  6726. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6727. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6728. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6729. // order.ClrWay = res.Output.Setlinfo.ClrWay
  6730. // order.Creator = order.Creator
  6731. // order.Modify = roles.ID
  6732. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6733. // detailStr := string(setlDetail)
  6734. // order.SetlDetail = detailStr
  6735. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6736. // err = service.UpDateOrder(order)
  6737. // if err == nil {
  6738. // c.ServeSuccessJSON(map[string]interface{}{
  6739. // "msg": "预结算成功",
  6740. // })
  6741. // } else {
  6742. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6743. // return
  6744. // }
  6745. // }
  6746. // } else {
  6747. // adminUser := c.GetAdminUserInfo()
  6748. // errlog := &models.HisOrderError{
  6749. // UserOrgId: adminUser.CurrentOrgId,
  6750. // Ctime: time.Now().Unix(),
  6751. // Mtime: time.Now().Unix(),
  6752. // ErrMsg: res.ErrMsg,
  6753. // Status: 1,
  6754. // PatientId: id,
  6755. // RecordTime: recordDateTime,
  6756. // Stage: 4,
  6757. // }
  6758. // service.CreateErrMsgLog(errlog)
  6759. //
  6760. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6761. // return
  6762. // }
  6763. // } else {
  6764. // adminUser := c.GetAdminUserInfo()
  6765. // errlog := &models.HisOrderError{
  6766. // UserOrgId: adminUser.CurrentOrgId,
  6767. // Ctime: time.Now().Unix(),
  6768. // Mtime: time.Now().Unix(),
  6769. // ErrMsg: res.ErrMsg,
  6770. // Status: 1,
  6771. // PatientId: id,
  6772. // RecordTime: recordDateTime,
  6773. // Stage: 4,
  6774. // }
  6775. // service.CreateErrMsgLog(errlog)
  6776. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6777. // return
  6778. // }
  6779. //
  6780. // } else {
  6781. // var total float64
  6782. // for _, item := range prescriptions {
  6783. // if item.Type == 1 { //药品
  6784. // for _, subItem := range item.HisDoctorAdviceInfo {
  6785. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6786. // }
  6787. // }
  6788. // if item.Type == 2 { //项目
  6789. // for _, subItem := range item.HisPrescriptionProject {
  6790. // total = total + (subItem.Price * float64(subItem.Count))
  6791. // }
  6792. // }
  6793. //
  6794. // for _, subItem := range item.HisAdditionalCharge {
  6795. // total = total + (subItem.Price * float64(subItem.Count))
  6796. // }
  6797. // }
  6798. //
  6799. // allTotal := fmt.Sprintf("%.2f", total)
  6800. // totals, _ := strconv.ParseFloat(allTotal, 64)
  6801. // order := &models.HisOrder{
  6802. // UserOrgId: adminUser.CurrentOrgId,
  6803. // HisPatientId: his.ID,
  6804. // PatientId: id,
  6805. // SettleAccountsDate: recordDateTime,
  6806. // Ctime: time.Now().Unix(),
  6807. // Mtime: time.Now().Unix(),
  6808. // Status: 1,
  6809. // OrderStatus: 2,
  6810. // Number: chrg_bchno,
  6811. // MedfeeSumamt: totals,
  6812. // }
  6813. // err = service.CreateOrder(order)
  6814. // if err != nil {
  6815. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6816. // return
  6817. // }
  6818. //
  6819. // var customs []*Custom
  6820. // for _, item := range prescriptions {
  6821. //
  6822. // if item.Type == 1 { //药品
  6823. // for _, subItem := range item.HisDoctorAdviceInfo {
  6824. // cus := &Custom{
  6825. // AdviceId: subItem.ID,
  6826. // ProjectId: 0,
  6827. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  6828. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  6829. // FeedetlSn: subItem.FeedetlSn,
  6830. // Price: fmt.Sprintf("%.2f", subItem.Price),
  6831. // MedListCodg: subItem.MedListCodg,
  6832. // Type: 1,
  6833. // }
  6834. // customs = append(customs, cus)
  6835. // }
  6836. // }
  6837. //
  6838. // if item.Type == 2 { //项目
  6839. // for _, subItem := range item.HisPrescriptionProject {
  6840. //
  6841. // cus := &Custom{
  6842. // AdviceId: 0,
  6843. // ProjectId: subItem.ID,
  6844. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  6845. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  6846. // FeedetlSn: subItem.FeedetlSn,
  6847. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  6848. // MedListCodg: subItem.MedListCodg,
  6849. // Type: 2,
  6850. // }
  6851. //
  6852. // customs = append(customs, cus)
  6853. // }
  6854. // }
  6855. //
  6856. // for _, item := range item.HisAdditionalCharge {
  6857. // cus := &Custom{
  6858. // ItemId: item.ID,
  6859. // AdviceId: 0,
  6860. // ProjectId: 0,
  6861. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  6862. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  6863. // FeedetlSn: item.FeedetlSn,
  6864. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  6865. // MedListCodg: item.XtHisAddtionConfig.Code,
  6866. // Type: 3,
  6867. // }
  6868. //
  6869. // customs = append(customs, cus)
  6870. // }
  6871. //
  6872. // }
  6873. //
  6874. // for _, item := range customs {
  6875. // var advice_id int64 = 0
  6876. // var project_id int64 = 0
  6877. // var item_id int64 = 0
  6878. //
  6879. // var types int64 = 0
  6880. //
  6881. // if item.Type == 1 {
  6882. // advice_id = item.AdviceId
  6883. // project_id = 0
  6884. // item_id = 0
  6885. // } else if item.Type == 2 {
  6886. // advice_id = 0
  6887. // item_id = 0
  6888. //
  6889. // project_id = item.ProjectId
  6890. // } else if item.Type == 3 {
  6891. // advice_id = 0
  6892. // item_id = item.ItemId
  6893. // project_id = 0
  6894. // }
  6895. //
  6896. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  6897. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  6898. // pric, _ := strconv.ParseFloat(item.Price, 32)
  6899. //
  6900. // info := &models.HisOrderInfo{
  6901. // OrderNumber: order.Number,
  6902. // UploadDate: time.Now().Unix(),
  6903. // AdviceId: advice_id,
  6904. // DetItemFeeSumamt: detItemFeeSumamt,
  6905. // Cnt: cut,
  6906. // Pric: pric,
  6907. // PatientId: id,
  6908. // Status: 1,
  6909. // Mtime: time.Now().Unix(),
  6910. // Ctime: time.Now().Unix(),
  6911. // UserOrgId: adminUser.CurrentOrgId,
  6912. // HisPatientId: his.ID,
  6913. // OrderId: order.ID,
  6914. // ProjectId: project_id,
  6915. // Type: types,
  6916. // ItemId: item_id,
  6917. // }
  6918. // service.CreateOrderInfo(info)
  6919. // }
  6920. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6921. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6922. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  6923. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6924. // if err == nil {
  6925. // c.ServeSuccessJSON(map[string]interface{}{
  6926. // "msg": "结算成功",
  6927. // })
  6928. // } else {
  6929. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6930. // return
  6931. // }
  6932. // }
  6933. //}
  6934. //上传明细-预结算-
  6935. func (c *HisApiController) GetPreUploadInfo() {
  6936. id, _ := c.GetInt64("id")
  6937. record_time := c.GetString("record_time")
  6938. his_patient_id, _ := c.GetInt64("his_patient_id")
  6939. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6940. admin_user_id, _ := c.GetInt64("admin_user_id")
  6941. diagnosis_id := c.GetString("diagnosis")
  6942. sick_type, _ := c.GetInt64("sick_type")
  6943. reg_type, _ := c.GetInt64("p_type")
  6944. begin_time := c.GetString("begin_time")
  6945. id_str := c.GetString("ids")
  6946. ids_arr := strings.Split(id_str, ",")
  6947. timeLayout := "2006-01-02"
  6948. loc, _ := time.LoadLocation("Local")
  6949. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6950. if err != nil {
  6951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6952. return
  6953. }
  6954. recordDateTime := theTime.Unix()
  6955. adminUser := c.GetAdminUserInfo()
  6956. diagnosis_ids := strings.Split(diagnosis_id, ",")
  6957. var config []*models.HisXtDiagnoseConfig
  6958. for _, item := range diagnosis_ids {
  6959. id, _ := strconv.ParseInt(item, 10, 64)
  6960. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6961. config = append(config, &diagnosisConfig)
  6962. }
  6963. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  6964. sickConfig, _ := service.FindSickById(sick_type)
  6965. var prescriptions []*models.HisPrescription
  6966. var start_time int64
  6967. var end_time int64
  6968. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6969. fmt.Println(his_patient_id)
  6970. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6971. timestamp := time.Now().Unix()
  6972. tempTime := time.Unix(timestamp, 0)
  6973. timeFormat := tempTime.Format("20060102150405")
  6974. chrgBchno := rand.Intn(100000) + 10000
  6975. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6976. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6977. var patientPrescription models.HisPrescriptionInfo
  6978. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6979. if patientPrescription.ID == 0 {
  6980. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6981. }
  6982. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6983. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6984. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6985. strconv.FormatInt(his.PatientId, 10)
  6986. var res2 ResultSix
  6987. var resSix10265 ResultSix10265
  6988. var time_stamp string
  6989. if miConfig.MdtrtareaAdmvs == "421300" {
  6990. data := make(map[string]interface{})
  6991. client := &http.Client{}
  6992. data["psn_no"] = his.PsnNo
  6993. data["mdtrt_id"] = his.Number
  6994. data["department"] = department.Name
  6995. data["org_name"] = miConfig.OrgName
  6996. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6997. data["doctor_id"] = doctor_info.DoctorNumber
  6998. data["doctor_name"] = roles.UserName
  6999. data["fixmedins_code"] = miConfig.Code
  7000. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7001. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7002. data["secret_key"] = miConfig.SecretKey
  7003. data["sick_code"] = sickConfig.CountryCode
  7004. data["sick_name"] = sickConfig.ClassName
  7005. data["begin_time"] = begin_time
  7006. data["dept"] = strconv.FormatInt(department.ID, 10)
  7007. data["config"] = config
  7008. data["opter"] = roles.UserName
  7009. fmt.Println(data)
  7010. bytesData, _ := json.Marshal(data)
  7011. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  7012. resp, _ := client.Do(req)
  7013. defer resp.Body.Close()
  7014. body, ioErr := ioutil.ReadAll(resp.Body)
  7015. if ioErr != nil {
  7016. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7018. return
  7019. }
  7020. var respJSON map[string]interface{}
  7021. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7022. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7024. return
  7025. }
  7026. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7027. userJSONBytes, _ := json.Marshal(respJSON)
  7028. fmt.Println("log")
  7029. fmt.Println(string(userJSONBytes))
  7030. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7031. utils.ErrorLog("解析失败:%v", err)
  7032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7033. return
  7034. }
  7035. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7036. data := make(map[string]interface{})
  7037. client := &http.Client{}
  7038. data["psn_no"] = his.PsnNo
  7039. data["mdtrt_id"] = his.Number
  7040. data["doctor"] = roles.UserName
  7041. data["department"] = department.Name
  7042. data["org_name"] = miConfig.OrgName
  7043. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7044. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  7045. data["fixmedins_code"] = miConfig.Code
  7046. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7047. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7048. data["secret_key"] = miConfig.SecretKey
  7049. data["sick_code"] = sickConfig.CountryCode
  7050. data["sick_name"] = sickConfig.ClassName
  7051. data["begin_time"] = begin_time
  7052. data["dept"] = strconv.FormatInt(department.ID, 10)
  7053. data["config"] = config
  7054. data["url"] = miConfig.Url
  7055. data["ak"] = miConfig.AccessKey
  7056. data["cainfo"] = miConfig.Cainfo
  7057. bytesData, _ := json.Marshal(data)
  7058. var req *http.Request
  7059. if miConfig.MdtrtareaAdmvs == "320921" {
  7060. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7061. //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 +
  7062. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  7063. } else {
  7064. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7065. }
  7066. resp, _ := client.Do(req)
  7067. defer resp.Body.Close()
  7068. body, ioErr := ioutil.ReadAll(resp.Body)
  7069. if ioErr != nil {
  7070. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7072. return
  7073. }
  7074. var respJSON map[string]interface{}
  7075. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7076. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7078. return
  7079. }
  7080. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  7081. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  7082. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  7083. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7084. userJSONBytes, _ := json.Marshal(respJSON)
  7085. fmt.Println("log")
  7086. fmt.Println(string(userJSONBytes))
  7087. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7088. utils.ErrorLog("解析失败:%v", err)
  7089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7090. return
  7091. }
  7092. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7093. res2.Output = resSix10265.Output
  7094. res2.ErrMsg = resSix10265.ErrMsg
  7095. res2.Cainfo = resSix10265.Cainfo
  7096. res2.WarnMsg = resSix10265.WarnMsg
  7097. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7098. res2.Infcode = infocode
  7099. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7100. 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)
  7101. saveLog(result, requestLog, "2203", "上传就诊信息")
  7102. var respJSON2 map[string]interface{}
  7103. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7104. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7106. return
  7107. }
  7108. userJSONBytes2, _ := json.Marshal(respJSON2)
  7109. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7110. utils.ErrorLog("解析失败:%v", err)
  7111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7112. return
  7113. }
  7114. } else {
  7115. var result string
  7116. var requestLog string
  7117. if miConfig.MdtrtareaAdmvs == "440781" { //
  7118. 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)
  7119. } else {
  7120. if miConfig.Code == "H15049901371" {
  7121. //赤峰地区国家医保医疗类别
  7122. //职工透析:医疗类别选特殊情况门诊990502
  7123. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7124. var med_type string
  7125. if his.Insutype == "390" {
  7126. if reg_type == 14 {
  7127. med_type = "9933"
  7128. } else if reg_type == 11 {
  7129. med_type = "11"
  7130. }
  7131. } else if his.Insutype == "310" {
  7132. if reg_type == 14 {
  7133. med_type = "990502"
  7134. } else if reg_type == 11 {
  7135. med_type = "11"
  7136. }
  7137. }
  7138. 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)
  7139. } else {
  7140. 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)
  7141. }
  7142. saveLog(result, requestLog, "2203", "上传就诊信息")
  7143. var respJSON2 map[string]interface{}
  7144. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7145. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7147. return
  7148. }
  7149. userJSONBytes2, _ := json.Marshal(respJSON2)
  7150. if miConfig.Code == "H15049901371" {
  7151. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  7152. utils.ErrorLog("解析失败:%v", err)
  7153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7154. return
  7155. }
  7156. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7157. res2.Output = resSix10265.Output
  7158. res2.ErrMsg = resSix10265.ErrMsg
  7159. res2.Cainfo = resSix10265.Cainfo
  7160. res2.WarnMsg = resSix10265.WarnMsg
  7161. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7162. res2.Infcode = infocode
  7163. } else {
  7164. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7165. utils.ErrorLog("解析失败:%v", err)
  7166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7167. return
  7168. }
  7169. }
  7170. }
  7171. }
  7172. if res2.Infcode != 0 {
  7173. adminUser := c.GetAdminUserInfo()
  7174. errlog := &models.HisOrderError{
  7175. UserOrgId: adminUser.CurrentOrgId,
  7176. Ctime: time.Now().Unix(),
  7177. Mtime: time.Now().Unix(),
  7178. ErrMsg: res2.ErrMsg,
  7179. Status: 1,
  7180. PatientId: id,
  7181. RecordTime: recordDateTime,
  7182. Stage: 3,
  7183. }
  7184. service.CreateErrMsgLog(errlog)
  7185. c.ServeSuccessJSON(map[string]interface{}{
  7186. "failed_code": -10,
  7187. "msg": res2.ErrMsg,
  7188. })
  7189. return
  7190. } else {
  7191. his.Diagnosis = diagnosis_id
  7192. his.SickType = sickConfig.ID
  7193. his.PType = fmt.Sprintf("%d", reg_type)
  7194. service.UpdateHisPatientThree(&his)
  7195. data := make(map[string]interface{})
  7196. if settle_accounts_type == 1 { //日结
  7197. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  7198. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  7199. } else {
  7200. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  7201. }
  7202. data["pre"] = prescriptions
  7203. } else { //月结
  7204. start_time_str := c.GetString("start_time")
  7205. end_time_str := c.GetString("end_time")
  7206. timeLayout := "2006-01-02"
  7207. loc, _ := time.LoadLocation("Local")
  7208. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7209. if err != nil {
  7210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7211. return
  7212. }
  7213. recordStartTime := theStartTime.Unix()
  7214. start_time = recordStartTime
  7215. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7216. if err != nil {
  7217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7218. return
  7219. }
  7220. recordEndTime := theEndTime.Unix()
  7221. end_time = recordEndTime
  7222. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  7223. data["pre"] = prescriptions
  7224. }
  7225. client := &http.Client{}
  7226. data["psn_no"] = his.PsnNo
  7227. data["mdtrt_id"] = his.Number
  7228. data["chrg_bchno"] = chrg_bchno
  7229. data["org_name"] = miConfig.OrgName
  7230. data["doctor"] = roles.UserName
  7231. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  7232. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  7233. data["fixmedins_code"] = miConfig.Code
  7234. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  7235. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  7236. data["dept_code"] = "15"
  7237. } else {
  7238. data["dept_code"] = department.Number
  7239. }
  7240. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7241. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7242. data["secret_key"] = miConfig.SecretKey
  7243. data["url"] = miConfig.Url
  7244. data["ak"] = miConfig.AccessKey
  7245. data["new_doctor_name"] = patientPrescription.Doctor
  7246. data["diag_code"] = sickConfig.CountryCode
  7247. data["time_stamp"] = time_stamp
  7248. data["cainfo"] = miConfig.Cainfo
  7249. var ids []int64
  7250. for _, item := range prescriptions {
  7251. ids = append(ids, item.ID)
  7252. }
  7253. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7254. if config.IsOpen == 1 { //对接了医保,走医保流程
  7255. var res ResultFour
  7256. var resFour10265 ResultFour10265
  7257. if miConfig.MdtrtareaAdmvs == "421300" {
  7258. bytesData, _ := json.Marshal(data)
  7259. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  7260. resp, _ := client.Do(req)
  7261. defer resp.Body.Close()
  7262. body, ioErr := ioutil.ReadAll(resp.Body)
  7263. if ioErr != nil {
  7264. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7266. return
  7267. }
  7268. var respJSON map[string]interface{}
  7269. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7270. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7272. return
  7273. }
  7274. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7275. userJSONBytes, _ := json.Marshal(respJSON)
  7276. fmt.Println("log")
  7277. fmt.Println(string(userJSONBytes))
  7278. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7279. utils.ErrorLog("解析失败:%v", err)
  7280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7281. return
  7282. }
  7283. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7284. bytesData, _ := json.Marshal(data)
  7285. var req *http.Request
  7286. if miConfig.MdtrtareaAdmvs == "320921" {
  7287. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7288. } else {
  7289. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7290. }
  7291. resp, _ := client.Do(req)
  7292. defer resp.Body.Close()
  7293. body, ioErr := ioutil.ReadAll(resp.Body)
  7294. if ioErr != nil {
  7295. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7297. return
  7298. }
  7299. var respJSON map[string]interface{}
  7300. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7301. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7303. return
  7304. }
  7305. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7306. userJSONBytes, _ := json.Marshal(respJSON)
  7307. fmt.Println("log")
  7308. fmt.Println(string(userJSONBytes))
  7309. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7310. utils.ErrorLog("解析失败:%v", err)
  7311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7312. return
  7313. }
  7314. res.InfRefmsgid = resFour10265.InfRefmsgid
  7315. res.Output = resFour10265.Output
  7316. res.ErrMsg = resFour10265.ErrMsg
  7317. res.Cainfo = resFour10265.Cainfo
  7318. res.WarnMsg = resFour10265.WarnMsg
  7319. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7320. res.Infcode = infocode
  7321. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7322. 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)
  7323. var dat map[string]interface{}
  7324. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7325. fmt.Println(dat)
  7326. } else {
  7327. fmt.Println(err)
  7328. }
  7329. saveLog(result, request_log, "2204", "上传费用明细")
  7330. userJSONBytes, _ := json.Marshal(dat)
  7331. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7332. utils.ErrorLog("解析失败:%v", err)
  7333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7334. return
  7335. }
  7336. } else {
  7337. if miConfig.Code == "H15049901371" {
  7338. 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)
  7339. var dat map[string]interface{}
  7340. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7341. fmt.Println(dat)
  7342. } else {
  7343. fmt.Println(err)
  7344. }
  7345. saveLog(result, request_log, "2204", "上传费用明细")
  7346. userJSONBytes, _ := json.Marshal(dat)
  7347. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7348. utils.ErrorLog("解析失败:%v", err)
  7349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7350. return
  7351. }
  7352. res.InfRefmsgid = resFour10265.InfRefmsgid
  7353. res.Output = resFour10265.Output
  7354. res.ErrMsg = resFour10265.ErrMsg
  7355. res.Cainfo = resFour10265.Cainfo
  7356. res.WarnMsg = resFour10265.WarnMsg
  7357. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7358. res.Infcode = infocode
  7359. } else {
  7360. 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)
  7361. var dat map[string]interface{}
  7362. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7363. fmt.Println(dat)
  7364. } else {
  7365. fmt.Println(err)
  7366. }
  7367. saveLog(result, request_log, "2204", "上传费用明细")
  7368. userJSONBytes, _ := json.Marshal(dat)
  7369. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7370. utils.ErrorLog("解析失败:%v", err)
  7371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7372. return
  7373. }
  7374. }
  7375. }
  7376. if res.Infcode == 0 {
  7377. order := &models.HisOrder{
  7378. UserOrgId: adminUser.CurrentOrgId,
  7379. HisPatientId: his.ID,
  7380. PatientId: his.PatientId,
  7381. SettleAccountsDate: recordDateTime,
  7382. Ctime: time.Now().Unix(),
  7383. Mtime: time.Now().Unix(),
  7384. MdtrtId: his.Number,
  7385. PsnNo: his.PsnNo,
  7386. MedType: strconv.FormatInt(reg_type, 10),
  7387. Status: 1,
  7388. Number: chrg_bchno,
  7389. Infcode: res.Infcode,
  7390. WarnMsg: res.WarnMsg,
  7391. Cainfo: res.Cainfo,
  7392. ErrMsg: res.ErrMsg,
  7393. RespondTime: res.RefmsgTime,
  7394. InfRefmsgid: res.InfRefmsgid,
  7395. OrderStatus: 1,
  7396. IsMedicineInsurance: 1,
  7397. SettleType: settle_accounts_type,
  7398. SettleStartTime: start_time,
  7399. SettleEndTime: end_time,
  7400. Creator: roles.AdminUserId,
  7401. Modify: roles.AdminUserId,
  7402. PType: 2,
  7403. Diagnosis: diagnosis_id,
  7404. }
  7405. err = service.CreateOrder(order)
  7406. if err != nil {
  7407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7408. return
  7409. }
  7410. for _, item := range res.Output.Result {
  7411. temp := strings.Split(item.FeedetlSn, "-")
  7412. var advice_id int64 = 0
  7413. var project_id int64 = 0
  7414. var types int64 = 0
  7415. id, _ := strconv.ParseInt(temp[2], 10, 64)
  7416. types, _ = strconv.ParseInt(temp[1], 10, 64)
  7417. if temp[1] == "1" {
  7418. advice_id = id
  7419. project_id = 0
  7420. } else if temp[1] == "2" {
  7421. advice_id = 0
  7422. project_id = id
  7423. }
  7424. info := &models.HisOrderInfo{
  7425. OrderNumber: order.Number,
  7426. FeedetlSn: item.FeedetlSn,
  7427. UploadDate: time.Now().Unix(),
  7428. AdviceId: advice_id,
  7429. DetItemFeeSumamt: item.DetItemFeeSumamt,
  7430. Cnt: item.Cnt,
  7431. Pric: float64(item.Pric),
  7432. PatientId: his.PatientId,
  7433. PricUplmtAmt: item.PricUplmtAmt,
  7434. SelfpayProp: item.SelfpayProp,
  7435. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7436. OverlmtAmt: item.OverlmtAmt,
  7437. PreselfpayAmt: item.PreselfpayAmt,
  7438. BasMednFlag: item.BasMednFlag,
  7439. MedChrgitmType: item.MedChrgitmType,
  7440. HiNegoDrugFlag: item.HiNegoDrugFlag,
  7441. Status: 1,
  7442. Memo: item.Memo,
  7443. Mtime: time.Now().Unix(),
  7444. InscpScpAmt: item.InscpScpAmt,
  7445. DrtReimFlag: item.DrtReimFlag,
  7446. Ctime: time.Now().Unix(),
  7447. ListSpItemFlag: item.ListSpItemFlag,
  7448. ChldMedcFlag: item.ChldMedcFlag,
  7449. LmtUsedFlag: item.LmtUsedFlag,
  7450. ChrgitmLv: item.ChrgitmLv,
  7451. UserOrgId: adminUser.CurrentOrgId,
  7452. HisPatientId: his.ID,
  7453. OrderId: order.ID,
  7454. ProjectId: project_id,
  7455. Type: types,
  7456. }
  7457. service.CreateOrderInfo(info)
  7458. }
  7459. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7460. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  7461. var total float64
  7462. for _, item := range prescriptions {
  7463. if item.Type == 1 { //药品
  7464. for _, subItem := range item.HisDoctorAdviceInfo {
  7465. total = total + (subItem.Price * subItem.PrescribingNumber)
  7466. }
  7467. }
  7468. if item.Type == 2 { //项目
  7469. for _, subItem := range item.HisPrescriptionProject {
  7470. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7471. total = total + (subItem.Price * cnt)
  7472. }
  7473. }
  7474. }
  7475. for _, item := range prescriptions {
  7476. for _, subItem := range item.HisAdditionalCharge {
  7477. total = total + (subItem.Price * float64(subItem.Count))
  7478. }
  7479. }
  7480. allTotal := fmt.Sprintf("%.4f", total)
  7481. if res.Infcode == 0 {
  7482. var rf []*ResultFive
  7483. json.Unmarshal([]byte(his.Iinfo), &rf)
  7484. chrg_bchno := chrg_bchno
  7485. cert_no := his.Certno
  7486. var insutypes []string
  7487. var insutype string
  7488. var is390 int = 0
  7489. var is310 int = 0
  7490. for _, item := range rf {
  7491. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7492. insutypes = append(insutypes, item.Insutype)
  7493. }
  7494. }
  7495. if len(insutypes) == 1 {
  7496. insutype = insutypes[0]
  7497. } else {
  7498. for _, i := range insutypes {
  7499. if i == "390" {
  7500. is390 = 1
  7501. }
  7502. if i == "310" {
  7503. is310 = 1
  7504. }
  7505. }
  7506. }
  7507. if is390 == 1 {
  7508. insutype = "390"
  7509. }
  7510. if is310 == 1 {
  7511. insutype = "310"
  7512. }
  7513. if len(insutypes) == 0 {
  7514. insutype = "310"
  7515. }
  7516. if len(insutypes) == 2 {
  7517. insutype = strconv.FormatInt(his.SocialType, 64)
  7518. }
  7519. //insutype = "390"
  7520. if his.IdCardType == 1 {
  7521. cert_no = his.MedicalInsuranceNumber
  7522. } else {
  7523. cert_no = his.Certno
  7524. }
  7525. var res ResultSeven
  7526. var resSeven10265 ResultSeven10265
  7527. if miConfig.MdtrtareaAdmvs == "421300" {
  7528. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7529. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7530. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7531. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7532. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7533. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7534. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  7535. resp, requestErr := http.Get(api)
  7536. if requestErr != nil {
  7537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7538. return
  7539. }
  7540. body, ioErr := ioutil.ReadAll(resp.Body)
  7541. if ioErr != nil {
  7542. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7544. return
  7545. }
  7546. var respJSON map[string]interface{}
  7547. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7548. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7550. return
  7551. }
  7552. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7553. result, _ := json.Marshal(respJSON)
  7554. fmt.Println("log")
  7555. fmt.Println(string(result))
  7556. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7557. utils.ErrorLog("解析失败:%v", err)
  7558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7559. return
  7560. }
  7561. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7562. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7563. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7564. bas := strings.Split(psn_info.CardInfo, "|")
  7565. if his.IdCardType == 1 {
  7566. cert_no = bas[2]
  7567. } else {
  7568. cert_no = bas[1]
  7569. }
  7570. //江苏地区国家医保医疗类别
  7571. //职工透析:医疗类别选特殊情况门诊9933
  7572. //居民血透门慢: 医疗类别选门诊慢病1402
  7573. //var med_type string
  7574. //if his.Insutype == "310" {
  7575. // if reg_type == 14 {
  7576. // med_type = "9933"
  7577. // } else if reg_type == 11 {
  7578. // med_type = "11"
  7579. //
  7580. // }
  7581. //} else if his.Insutype == "390" {
  7582. // if reg_type == 14 {
  7583. // med_type = "1402"
  7584. // } else if reg_type == 11 {
  7585. // med_type = "11"
  7586. // }
  7587. //}
  7588. var api string
  7589. if miConfig.MdtrtareaAdmvs == "320921" {
  7590. api = "http://192.168.2.110:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7591. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7592. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7593. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7594. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7595. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7596. "&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
  7597. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7598. } else {
  7599. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7600. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7601. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7602. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7603. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7604. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7605. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7606. "&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
  7607. }
  7608. resp, requestErr := http.Get(api)
  7609. if requestErr != nil {
  7610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7611. return
  7612. }
  7613. body, ioErr := ioutil.ReadAll(resp.Body)
  7614. if ioErr != nil {
  7615. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7617. return
  7618. }
  7619. var respJSON map[string]interface{}
  7620. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7621. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7623. return
  7624. }
  7625. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7626. result, _ := json.Marshal(respJSON)
  7627. fmt.Println("log")
  7628. fmt.Println(string(result))
  7629. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7630. utils.ErrorLog("解析失败:%v", err)
  7631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7632. return
  7633. }
  7634. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7635. res.Output = resSeven10265.Output
  7636. res.ErrMsg = resSeven10265.ErrMsg
  7637. res.Cainfo = resSeven10265.Cainfo
  7638. res.WarnMsg = resSeven10265.WarnMsg
  7639. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7640. res.Infcode = infocode
  7641. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7642. 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)
  7643. var dat map[string]interface{}
  7644. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7645. fmt.Println(dat)
  7646. } else {
  7647. fmt.Println(err)
  7648. }
  7649. saveLog(result, request_log, "2206", "预结算")
  7650. userJSONBytes, _ := json.Marshal(dat)
  7651. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7652. utils.ErrorLog("解析失败:%v", err)
  7653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7654. return
  7655. }
  7656. } else {
  7657. var result string
  7658. var request_log string
  7659. if miConfig.Code == "H15049901371" {
  7660. //赤峰地区国家医保医疗类别
  7661. //职工透析:医疗类别选特殊情况门诊990502
  7662. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7663. var med_type string
  7664. if his.Insutype == "390" {
  7665. if reg_type == 14 {
  7666. med_type = "9933"
  7667. } else if reg_type == 11 {
  7668. med_type = "11"
  7669. }
  7670. } else if his.Insutype == "310" {
  7671. if reg_type == 14 {
  7672. med_type = "990502"
  7673. } else if reg_type == 11 {
  7674. med_type = "11"
  7675. }
  7676. }
  7677. 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)
  7678. } else {
  7679. 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)
  7680. }
  7681. var dat map[string]interface{}
  7682. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7683. fmt.Println(dat)
  7684. } else {
  7685. fmt.Println(err)
  7686. }
  7687. saveLog(result, request_log, "2206", "预结算")
  7688. //userJSONBytes, _ := json.Marshal(dat)
  7689. //
  7690. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7691. // utils.ErrorLog("解析失败:%v", err)
  7692. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7693. // return
  7694. //}
  7695. userJSONBytes, _ := json.Marshal(dat)
  7696. if miConfig.Code == "H15049901371" {
  7697. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7698. utils.ErrorLog("解析失败:%v", err)
  7699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7700. return
  7701. }
  7702. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7703. res.Output = resSeven10265.Output
  7704. res.ErrMsg = resSeven10265.ErrMsg
  7705. res.Cainfo = resSeven10265.Cainfo
  7706. res.WarnMsg = resSeven10265.WarnMsg
  7707. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7708. res.Infcode = infocode
  7709. } else {
  7710. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7711. utils.ErrorLog("解析失败:%v", err)
  7712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7713. return
  7714. }
  7715. }
  7716. }
  7717. if res.Infcode != 0 {
  7718. errlog := &models.HisOrderError{
  7719. UserOrgId: adminUser.CurrentOrgId,
  7720. Ctime: time.Now().Unix(),
  7721. Mtime: time.Now().Unix(),
  7722. Number: chrg_bchno,
  7723. ErrMsg: res.ErrMsg,
  7724. Status: 1,
  7725. PatientId: id,
  7726. RecordTime: recordDateTime,
  7727. Stage: 20,
  7728. }
  7729. service.CreateErrMsgLog(errlog)
  7730. c.ServeSuccessJSON(map[string]interface{}{
  7731. "failed_code": -10,
  7732. "msg": res.ErrMsg,
  7733. })
  7734. return
  7735. } else {
  7736. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7737. order.OrderStatus = 1
  7738. order.IsPre = 1
  7739. order.Status = 1
  7740. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7741. order.SetlId = res.Output.Setlinfo.SetlID
  7742. order.PsnNo = res.Output.Setlinfo.PsnNo
  7743. order.PsnName = res.Output.Setlinfo.PsnName
  7744. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7745. order.Certno = res.Output.Setlinfo.Certno
  7746. order.Gend = res.Output.Setlinfo.Gend
  7747. order.Naty = res.Output.Setlinfo.Naty
  7748. order.Age = res.Output.Setlinfo.Age
  7749. order.Insutype = res.Output.Setlinfo.Insutype
  7750. order.PsnType = res.Output.Setlinfo.PsnType
  7751. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7752. order.SetlTime = res.Output.Setlinfo.SetlTime
  7753. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7754. if res.Output.Setlinfo.MedType == "140101" {
  7755. order.MedType = "14"
  7756. } else {
  7757. order.MedType = res.Output.Setlinfo.MedType
  7758. }
  7759. if reg_type == 1112 {
  7760. order.MedType = "1112"
  7761. }
  7762. if reg_type == 1111 {
  7763. order.MedType = "1111"
  7764. }
  7765. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7766. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7767. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7768. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7769. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7770. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7771. order.HifpPay = res.Output.Setlinfo.HifpPay
  7772. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7773. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7774. order.HifesPay = res.Output.Setlinfo.HifesPay
  7775. order.HifobPay = res.Output.Setlinfo.HifobPay
  7776. order.MafPay = res.Output.Setlinfo.MafPay
  7777. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  7778. order.OthPay = res.Output.Setlinfo.OthPay
  7779. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7780. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7781. order.AcctPay = res.Output.Setlinfo.AcctPay
  7782. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7783. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7784. order.Balc = res.Output.Setlinfo.Balc
  7785. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7786. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7787. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7788. order.ClrWay = res.Output.Setlinfo.ClrWay
  7789. order.Creator = order.Creator
  7790. order.Modify = roles.AdminUserId
  7791. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7792. detailStr := string(setlDetail)
  7793. order.SetlDetail = detailStr
  7794. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7795. err = service.UpDateOrder(order)
  7796. if err == nil {
  7797. c.ServeSuccessJSON(map[string]interface{}{
  7798. "msg": "预结算成功",
  7799. })
  7800. } else {
  7801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7802. return
  7803. }
  7804. }
  7805. } else {
  7806. adminUser := c.GetAdminUserInfo()
  7807. errlog := &models.HisOrderError{
  7808. UserOrgId: adminUser.CurrentOrgId,
  7809. Ctime: time.Now().Unix(),
  7810. Mtime: time.Now().Unix(),
  7811. ErrMsg: res.ErrMsg,
  7812. Status: 1,
  7813. PatientId: id,
  7814. RecordTime: recordDateTime,
  7815. Stage: 4,
  7816. }
  7817. service.CreateErrMsgLog(errlog)
  7818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7819. return
  7820. }
  7821. } else {
  7822. adminUser := c.GetAdminUserInfo()
  7823. errlog := &models.HisOrderError{
  7824. UserOrgId: adminUser.CurrentOrgId,
  7825. Ctime: time.Now().Unix(),
  7826. Mtime: time.Now().Unix(),
  7827. ErrMsg: res.ErrMsg,
  7828. Status: 1,
  7829. PatientId: id,
  7830. RecordTime: recordDateTime,
  7831. Stage: 4,
  7832. }
  7833. service.CreateErrMsgLog(errlog)
  7834. c.ServeSuccessJSON(map[string]interface{}{
  7835. "failed_code": -10,
  7836. "msg": res.ErrMsg,
  7837. })
  7838. return
  7839. }
  7840. }
  7841. }
  7842. }
  7843. //退款
  7844. func (c *HisApiController) Refund() {
  7845. order_id, _ := c.GetInt64("order_id")
  7846. admin_user_id, _ := c.GetInt64("admin_user_id")
  7847. adminUser := c.GetAdminUserInfo()
  7848. var order models.HisOrder
  7849. order, _ = service.GetHisOrderByID(order_id)
  7850. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7851. if order.ID == 0 {
  7852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7853. return
  7854. }
  7855. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7856. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7857. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7858. if config.IsOpen == 1 { //对接了医保,走医保流程
  7859. var res ResultSixteen
  7860. var resSixteen10265 ResultSixteen10265
  7861. var src_resquest string
  7862. var result string
  7863. if miConfig.MdtrtareaAdmvs == "421300" {
  7864. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  7865. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7866. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7867. resp3, requestErr3 := http.Get(api3)
  7868. if requestErr3 != nil {
  7869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7870. return
  7871. }
  7872. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7873. if ioErr3 != nil {
  7874. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7876. return
  7877. }
  7878. var respJSON3 map[string]interface{}
  7879. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7880. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7882. return
  7883. }
  7884. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7885. userJSONBytes3, _ := json.Marshal(respJSON3)
  7886. fmt.Println("log")
  7887. fmt.Println(string(userJSONBytes3))
  7888. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  7889. utils.ErrorLog("解析失败:%v", err)
  7890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7891. return
  7892. }
  7893. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7894. var api3 string
  7895. if miConfig.MdtrtareaAdmvs == "320921" {
  7896. api3 = "http://192.168.2.110:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7897. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7898. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7899. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7900. } else {
  7901. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7902. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7903. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7904. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7905. }
  7906. resp3, requestErr3 := http.Get(api3)
  7907. if requestErr3 != nil {
  7908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7909. return
  7910. }
  7911. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7912. if ioErr3 != nil {
  7913. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7915. return
  7916. }
  7917. var respJSON3 map[string]interface{}
  7918. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7919. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7921. return
  7922. }
  7923. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7924. userJSONBytes3, _ := json.Marshal(respJSON3)
  7925. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  7926. utils.ErrorLog("解析失败:%v", err)
  7927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7928. return
  7929. }
  7930. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7931. res.Output = resSixteen10265.Output
  7932. res.ErrMsg = resSixteen10265.ErrMsg
  7933. res.Cainfo = resSixteen10265.Cainfo
  7934. res.WarnMsg = resSixteen10265.WarnMsg
  7935. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7936. res.Infcode = infocode
  7937. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7938. 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)
  7939. var dat map[string]interface{}
  7940. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7941. fmt.Println(dat)
  7942. } else {
  7943. fmt.Println(err)
  7944. }
  7945. saveLog(result, src_resquest, "2208", "退费")
  7946. userJSONBytes, _ := json.Marshal(dat)
  7947. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7948. utils.ErrorLog("解析失败:%v", err)
  7949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7950. return
  7951. }
  7952. } else {
  7953. if miConfig.Code == "H15049901371" {
  7954. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7955. var dat map[string]interface{}
  7956. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7957. fmt.Println(dat)
  7958. } else {
  7959. fmt.Println(err)
  7960. }
  7961. saveLog(result, src_resquest, "2208", "退费")
  7962. userJSONBytes, _ := json.Marshal(dat)
  7963. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  7964. utils.ErrorLog("解析失败:%v", err)
  7965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7966. return
  7967. }
  7968. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7969. res.Output = resSixteen10265.Output
  7970. res.ErrMsg = resSixteen10265.ErrMsg
  7971. res.Cainfo = resSixteen10265.Cainfo
  7972. res.WarnMsg = resSixteen10265.WarnMsg
  7973. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7974. res.Infcode = infocode
  7975. } else {
  7976. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7977. var dat map[string]interface{}
  7978. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7979. fmt.Println(dat)
  7980. } else {
  7981. fmt.Println(err)
  7982. }
  7983. saveLog(result, src_resquest, "2208", "退费")
  7984. userJSONBytes, _ := json.Marshal(dat)
  7985. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7986. utils.ErrorLog("解析失败:%v", err)
  7987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7988. return
  7989. }
  7990. }
  7991. }
  7992. if res.Infcode == 0 {
  7993. var res2 ResultSix
  7994. var resSix10265 ResultSix10265
  7995. if miConfig.MdtrtareaAdmvs == "421300" {
  7996. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7997. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7998. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7999. resp3, requestErr3 := http.Get(api3)
  8000. if requestErr3 != nil {
  8001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8002. return
  8003. }
  8004. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8005. if ioErr3 != nil {
  8006. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8008. return
  8009. }
  8010. var respJSON3 map[string]interface{}
  8011. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8012. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8014. return
  8015. }
  8016. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8017. userJSONBytes3, _ := json.Marshal(respJSON3)
  8018. fmt.Println("log")
  8019. fmt.Println(string(userJSONBytes3))
  8020. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8021. utils.ErrorLog("解析失败:%v", err)
  8022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8023. return
  8024. }
  8025. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8026. var api3 string
  8027. if miConfig.MdtrtareaAdmvs == "320921" {
  8028. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8029. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8030. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8031. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8032. } else {
  8033. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8034. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8035. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8036. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8037. }
  8038. resp3, requestErr3 := http.Get(api3)
  8039. if requestErr3 != nil {
  8040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8041. return
  8042. }
  8043. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8044. if ioErr3 != nil {
  8045. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8047. return
  8048. }
  8049. var respJSON3 map[string]interface{}
  8050. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8051. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8053. return
  8054. }
  8055. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8056. userJSONBytes3, _ := json.Marshal(respJSON3)
  8057. fmt.Println("log")
  8058. fmt.Println(string(userJSONBytes3))
  8059. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8060. utils.ErrorLog("解析失败:%v", err)
  8061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8062. return
  8063. }
  8064. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8065. res2.Output = resSix10265.Output
  8066. res2.ErrMsg = resSix10265.ErrMsg
  8067. res2.Cainfo = resSix10265.Cainfo
  8068. res2.WarnMsg = resSix10265.WarnMsg
  8069. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8070. res2.Infcode = infocode
  8071. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8072. 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)
  8073. var dat map[string]interface{}
  8074. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8075. fmt.Println(dat)
  8076. } else {
  8077. fmt.Println(err)
  8078. }
  8079. saveLog(result2, src_request, "2205", "撤销明细")
  8080. userJSONBytes, _ := json.Marshal(dat)
  8081. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8082. utils.ErrorLog("解析失败:%v", err)
  8083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8084. return
  8085. }
  8086. } else {
  8087. if miConfig.Code == "H15049901371" {
  8088. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8089. var dat map[string]interface{}
  8090. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8091. fmt.Println(dat)
  8092. } else {
  8093. fmt.Println(err)
  8094. }
  8095. saveLog(result2, src_request, "2205", "撤销明细")
  8096. userJSONBytes, _ := json.Marshal(dat)
  8097. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  8098. utils.ErrorLog("解析失败:%v", err)
  8099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8100. return
  8101. }
  8102. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8103. res2.Output = resSix10265.Output
  8104. res2.ErrMsg = resSix10265.ErrMsg
  8105. res2.Cainfo = resSix10265.Cainfo
  8106. res2.WarnMsg = resSix10265.WarnMsg
  8107. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8108. res2.Infcode = infocode
  8109. } else {
  8110. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8111. var dat map[string]interface{}
  8112. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8113. fmt.Println(dat)
  8114. } else {
  8115. fmt.Println(err)
  8116. }
  8117. saveLog(result2, src_request, "2205", "撤销明细")
  8118. userJSONBytes, _ := json.Marshal(dat)
  8119. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8120. utils.ErrorLog("解析失败:%v", err)
  8121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8122. return
  8123. }
  8124. }
  8125. }
  8126. if res2.Infcode == 0 {
  8127. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  8128. if err == nil {
  8129. //当押金不为零时产生退费记录
  8130. if order.Decimal != 0 {
  8131. tmp := strconv.FormatInt(order.ID, 10)
  8132. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  8133. if err != nil {
  8134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8135. return
  8136. }
  8137. }
  8138. c.ServeSuccessJSON(map[string]interface{}{
  8139. "msg": "退费成功",
  8140. })
  8141. } else {
  8142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8143. return
  8144. }
  8145. } else {
  8146. c.ServeSuccessJSON(map[string]interface{}{
  8147. "code": -10,
  8148. "msg": res2.ErrMsg,
  8149. })
  8150. }
  8151. } else {
  8152. c.ServeSuccessJSON(map[string]interface{}{
  8153. "code": -10,
  8154. "msg": res.ErrMsg,
  8155. })
  8156. }
  8157. }
  8158. }
  8159. func (c *HisApiController) RefundNumber() {
  8160. record_time := c.GetString("record_time")
  8161. //patient_id, _ := c.GetInt64("patient_id")
  8162. admin_user_id, _ := c.GetInt64("admin_user_id")
  8163. his_patient_id, _ := c.GetInt64("id")
  8164. timeLayout := "2006-01-02"
  8165. loc, _ := time.LoadLocation("Local")
  8166. adminUser := c.GetAdminUserInfo()
  8167. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8168. fmt.Println(err)
  8169. if err != nil {
  8170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8171. return
  8172. }
  8173. recordDateTime := theTime.Unix()
  8174. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8175. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  8176. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8177. //order, _ := service.GetHisOrderByID(order_id)
  8178. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8179. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8180. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8181. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  8182. if count > 0 {
  8183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  8184. return
  8185. }
  8186. if config.IsOpen == 1 { //对接了医保,走医保流程
  8187. var res2 ResultSix
  8188. var resSix10265 ResultSix10265
  8189. if miConfig.MdtrtareaAdmvs == "421300" {
  8190. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  8191. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8192. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8193. resp3, requestErr3 := http.Get(api3)
  8194. if requestErr3 != nil {
  8195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8196. return
  8197. }
  8198. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8199. if ioErr3 != nil {
  8200. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8202. return
  8203. }
  8204. var respJSON3 map[string]interface{}
  8205. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8206. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8208. return
  8209. }
  8210. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8211. userJSONBytes3, _ := json.Marshal(respJSON3)
  8212. fmt.Println("log")
  8213. fmt.Println(string(userJSONBytes3))
  8214. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8215. utils.ErrorLog("解析失败:%v", err)
  8216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8217. return
  8218. }
  8219. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8220. var api3 string
  8221. if miConfig.MdtrtareaAdmvs == "320921" {
  8222. api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8223. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8224. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8225. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8226. } else {
  8227. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8228. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8229. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8230. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8231. }
  8232. resp3, requestErr3 := http.Get(api3)
  8233. if requestErr3 != nil {
  8234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8235. return
  8236. }
  8237. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8238. if ioErr3 != nil {
  8239. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8241. return
  8242. }
  8243. var respJSON3 map[string]interface{}
  8244. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8245. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8247. return
  8248. }
  8249. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8250. userJSONBytes3, _ := json.Marshal(respJSON3)
  8251. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8252. utils.ErrorLog("解析失败:%v", err)
  8253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8254. return
  8255. }
  8256. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8257. res2.Output = resSix10265.Output
  8258. res2.ErrMsg = resSix10265.ErrMsg
  8259. res2.Cainfo = resSix10265.Cainfo
  8260. res2.WarnMsg = resSix10265.WarnMsg
  8261. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8262. res2.Infcode = infocode
  8263. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8264. 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)
  8265. var dat map[string]interface{}
  8266. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8267. fmt.Println(dat)
  8268. } else {
  8269. fmt.Println(err)
  8270. }
  8271. saveLog(result, request, "2202", "退号")
  8272. userJSONBytes, _ := json.Marshal(dat)
  8273. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8274. utils.ErrorLog("解析失败:%v", err)
  8275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8276. return
  8277. }
  8278. } else {
  8279. var api3 string
  8280. if miConfig.Code == "H15049901371" {
  8281. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8282. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8283. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8284. } else {
  8285. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8286. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8287. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8288. }
  8289. resp3, requestErr3 := http.Get(api3)
  8290. if requestErr3 != nil {
  8291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8292. return
  8293. }
  8294. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8295. if ioErr3 != nil {
  8296. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8298. return
  8299. }
  8300. var respJSON3 map[string]interface{}
  8301. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8302. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8304. return
  8305. }
  8306. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8307. userJSONBytes3, _ := json.Marshal(respJSON3)
  8308. if miConfig.Code == "H15049901371" {
  8309. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8310. utils.ErrorLog("解析失败:%v", err)
  8311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8312. return
  8313. }
  8314. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8315. res2.Output = resSix10265.Output
  8316. res2.ErrMsg = resSix10265.ErrMsg
  8317. res2.Cainfo = resSix10265.Cainfo
  8318. res2.WarnMsg = resSix10265.WarnMsg
  8319. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8320. res2.Infcode = infocode
  8321. } else {
  8322. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8323. utils.ErrorLog("解析失败:%v", err)
  8324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8325. return
  8326. }
  8327. }
  8328. }
  8329. if res2.Infcode == 0 {
  8330. if err == nil {
  8331. c.ServeSuccessJSON(map[string]interface{}{
  8332. "msg": "退号成功",
  8333. })
  8334. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  8335. } else {
  8336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8337. return
  8338. }
  8339. } else {
  8340. c.ServeSuccessJSON(map[string]interface{}{
  8341. "code": -10,
  8342. "msg": res2.ErrMsg,
  8343. })
  8344. }
  8345. } else {
  8346. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  8347. //if err == nil {
  8348. // c.ServeSuccessJSON(map[string]interface{}{
  8349. // "msg": "退费成功",
  8350. // })
  8351. //} else {
  8352. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8353. // return
  8354. //}
  8355. }
  8356. }
  8357. func (c *HisApiController) RefundDetail() {
  8358. order_id, _ := c.GetInt64("order_id")
  8359. admin_user_id, _ := c.GetInt64("admin_user_id")
  8360. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8361. number := c.GetString("number")
  8362. record_time := c.GetString("record_time")
  8363. patient_id, _ := c.GetInt64("patient_id")
  8364. //med_type, _ := c.GetInt64("med_type")
  8365. timeLayout := "2006-01-02"
  8366. loc, _ := time.LoadLocation("Local")
  8367. adminUser := c.GetAdminUserInfo()
  8368. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8369. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8370. fmt.Println(err)
  8371. if err != nil {
  8372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8373. return
  8374. }
  8375. recordDateTime := theTime.Unix()
  8376. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8377. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8378. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8379. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8380. var order models.HisOrder
  8381. order, _ = service.GetHisOrderByID(order_id)
  8382. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8383. if config.IsOpen == 1 { //对接了医保,走医保流程
  8384. var res2 ResultSix
  8385. if miConfig.MdtrtareaAdmvs == "421300" {
  8386. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8387. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8388. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8389. resp3, requestErr3 := http.Get(api3)
  8390. if requestErr3 != nil {
  8391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8392. return
  8393. }
  8394. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8395. if ioErr3 != nil {
  8396. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8398. return
  8399. }
  8400. var respJSON3 map[string]interface{}
  8401. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8402. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8404. return
  8405. }
  8406. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8407. userJSONBytes3, _ := json.Marshal(respJSON3)
  8408. fmt.Println("log")
  8409. fmt.Println(string(userJSONBytes3))
  8410. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8411. utils.ErrorLog("解析失败:%v", err)
  8412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8413. return
  8414. }
  8415. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8416. if err == nil {
  8417. c.ServeSuccessJSON(map[string]interface{}{
  8418. "msg": "撤销明细成功",
  8419. })
  8420. return
  8421. } else {
  8422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8423. return
  8424. }
  8425. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8426. var resSix10265 ResultSix10265
  8427. var api3 string
  8428. if miConfig.MdtrtareaAdmvs == "320921" {
  8429. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8430. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8431. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8432. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8433. } else {
  8434. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8435. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8436. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8437. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8438. }
  8439. resp3, requestErr3 := http.Get(api3)
  8440. if requestErr3 != nil {
  8441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8442. return
  8443. }
  8444. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8445. if ioErr3 != nil {
  8446. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8448. return
  8449. }
  8450. var respJSON3 map[string]interface{}
  8451. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8452. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8454. return
  8455. }
  8456. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8457. userJSONBytes3, _ := json.Marshal(respJSON3)
  8458. fmt.Println("log")
  8459. fmt.Println(string(userJSONBytes3))
  8460. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8461. utils.ErrorLog("解析失败:%v", err)
  8462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8463. return
  8464. }
  8465. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8466. res2.Output = resSix10265.Output
  8467. res2.ErrMsg = resSix10265.ErrMsg
  8468. res2.Cainfo = resSix10265.Cainfo
  8469. res2.WarnMsg = resSix10265.WarnMsg
  8470. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8471. res2.Infcode = infocode
  8472. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8473. if err == nil {
  8474. c.ServeSuccessJSON(map[string]interface{}{
  8475. "msg": "撤销明细成功",
  8476. })
  8477. return
  8478. } else {
  8479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8480. return
  8481. }
  8482. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8483. 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)
  8484. var dat map[string]interface{}
  8485. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8486. fmt.Println(dat)
  8487. } else {
  8488. fmt.Println(err)
  8489. }
  8490. saveLog(result2, src_request, "2205", "撤销明细")
  8491. userJSONBytes, _ := json.Marshal(dat)
  8492. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8493. utils.ErrorLog("解析失败:%v", err)
  8494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8495. return
  8496. }
  8497. if res2.Infcode == 0 {
  8498. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8499. if err == nil {
  8500. c.ServeSuccessJSON(map[string]interface{}{
  8501. "msg": "撤销明细成功",
  8502. })
  8503. return
  8504. } else {
  8505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8506. return
  8507. }
  8508. } else {
  8509. c.ServeSuccessJSON(map[string]interface{}{
  8510. "code": -10,
  8511. "msg": res2.ErrMsg,
  8512. })
  8513. }
  8514. } else {
  8515. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  8516. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8517. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8518. resp2, requestErr2 := http.Get(api2)
  8519. if requestErr2 != nil {
  8520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8521. return
  8522. }
  8523. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8524. if ioErr2 != nil {
  8525. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8527. return
  8528. }
  8529. var respJSON2 map[string]interface{}
  8530. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8531. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8533. return
  8534. }
  8535. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8536. if err == nil {
  8537. c.ServeSuccessJSON(map[string]interface{}{
  8538. "msg": "撤销明细成功",
  8539. })
  8540. return
  8541. } else {
  8542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8543. return
  8544. }
  8545. }
  8546. } else {
  8547. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8548. if err == nil {
  8549. c.ServeSuccessJSON(map[string]interface{}{
  8550. "msg": "退费成功",
  8551. })
  8552. } else {
  8553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8554. return
  8555. }
  8556. }
  8557. }
  8558. //对账
  8559. func (c *HisApiController) GetCheckAccount() {
  8560. start_time := c.GetString("start_time")
  8561. end_time := c.GetString("end_time")
  8562. insutype := c.GetString("insutype")
  8563. clr_type := c.GetString("clr_type")
  8564. clr_org := c.GetString("clr_optins")
  8565. admin_user_id, _ := c.GetInt64("admin_user_id")
  8566. adminUser := c.GetAdminUserInfo()
  8567. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8568. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8569. if len(clr_org) == 0 {
  8570. clr_org = miConfig.MdtrtareaAdmvs
  8571. }
  8572. timeLayout := "2006-01-02"
  8573. loc, _ := time.LoadLocation("Local")
  8574. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8575. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8576. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  8577. fixmedins_setl_cnt := int64(len(orders))
  8578. var medfee_sumamt float64
  8579. var acct_pay float64
  8580. var fund_pay_sumamt float64
  8581. for _, item := range orders {
  8582. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8583. acct_pay = acct_pay + item.AcctPay
  8584. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8585. }
  8586. var user_name string
  8587. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8588. if role.ID == 0 {
  8589. user_name = "xxx"
  8590. } else {
  8591. user_name = role.UserName
  8592. }
  8593. var res ResultEight
  8594. var res10188 ResultEightFor10188
  8595. if config.IsOpen == 1 {
  8596. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8597. api := "http://192.168.2.110:9532/" + "jsyb/3201?" +
  8598. "insutype=" + insutype +
  8599. "&clr_type=" + clr_type +
  8600. "&setl_optins=" + clr_org +
  8601. "&stmt_begndate=" + start_time +
  8602. "&stm_enddate=" + end_time +
  8603. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8604. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8605. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8606. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8607. "&fixmedins_code=" + miConfig.Code +
  8608. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8609. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8610. "&secret_key=" + miConfig.SecretKey +
  8611. "&org_name=" + miConfig.OrgName +
  8612. "&doctor=" + user_name +
  8613. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8614. fmt.Println(api)
  8615. resp, requestErr := http.Get(api)
  8616. if requestErr != nil {
  8617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8618. return
  8619. }
  8620. body, ioErr := ioutil.ReadAll(resp.Body)
  8621. fmt.Println(body)
  8622. if ioErr != nil {
  8623. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8625. return
  8626. }
  8627. var respJSON map[string]interface{}
  8628. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8629. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8631. return
  8632. }
  8633. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8634. userJSONBytes, _ := json.Marshal(respJSON)
  8635. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8636. utils.ErrorLog("解析失败:%v", err)
  8637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8638. return
  8639. }
  8640. res.InfRefmsgid = res10188.InfRefmsgid
  8641. res.Output = res10188.Output
  8642. res.ErrMsg = res10188.ErrMsg
  8643. res.Cainfo = res10188.Cainfo
  8644. res.WarnMsg = res10188.WarnMsg
  8645. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8646. res.Infcode = infocode
  8647. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8648. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  8649. "insutype=" + insutype +
  8650. "&clr_type=" + clr_type +
  8651. "&setl_optins=" + clr_org +
  8652. "&stmt_begndate=" + start_time +
  8653. "&stm_enddate=" + end_time +
  8654. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8655. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8656. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8657. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8658. "&fixmedins_code=" + miConfig.Code +
  8659. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8660. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8661. "&secret_key=" + miConfig.SecretKey +
  8662. "&org_name=" + miConfig.OrgName +
  8663. "&doctor=" + user_name
  8664. resp, requestErr := http.Get(api)
  8665. if requestErr != nil {
  8666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8667. return
  8668. }
  8669. body, ioErr := ioutil.ReadAll(resp.Body)
  8670. if ioErr != nil {
  8671. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8673. return
  8674. }
  8675. var respJSON map[string]interface{}
  8676. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8677. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8679. return
  8680. }
  8681. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8682. result, _ := json.Marshal(respJSON)
  8683. fmt.Println("log")
  8684. fmt.Println(string(result))
  8685. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  8686. utils.ErrorLog("解析失败:%v", err)
  8687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8688. return
  8689. }
  8690. res.InfRefmsgid = res10188.InfRefmsgid
  8691. res.Output = res10188.Output
  8692. res.ErrMsg = res10188.ErrMsg
  8693. res.Cainfo = res10188.Cainfo
  8694. res.WarnMsg = res10188.WarnMsg
  8695. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8696. res.Infcode = infocode
  8697. } else {
  8698. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8699. "insutype=" + insutype +
  8700. "&clr_type=" + clr_type +
  8701. "&setl_optins=" + clr_org +
  8702. "&stmt_begndate=" + start_time +
  8703. "&stm_enddate=" + end_time +
  8704. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8705. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8706. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8707. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8708. "&fixmedins_code=" + miConfig.Code +
  8709. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8710. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8711. "&secret_key=" + miConfig.SecretKey +
  8712. "&org_name=" + miConfig.OrgName +
  8713. "&doctor=" + user_name
  8714. fmt.Println(api)
  8715. resp, requestErr := http.Get(api)
  8716. if requestErr != nil {
  8717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8718. return
  8719. }
  8720. body, ioErr := ioutil.ReadAll(resp.Body)
  8721. fmt.Println(body)
  8722. if ioErr != nil {
  8723. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8725. return
  8726. }
  8727. var respJSON map[string]interface{}
  8728. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8729. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8731. return
  8732. }
  8733. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8734. userJSONBytes, _ := json.Marshal(respJSON)
  8735. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8736. utils.ErrorLog("解析失败:%v", err)
  8737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8738. return
  8739. }
  8740. }
  8741. if res.Infcode == 0 {
  8742. if res.Output.Stmtinfo.StmtRslt == "0" {
  8743. micc := &models.MedicalInsuranceCostCompare{
  8744. StartTime: startime.Unix(),
  8745. EndTime: endtime.Unix(),
  8746. Insutype: insutype,
  8747. CheckType: 1,
  8748. Num: fixmedins_setl_cnt,
  8749. Mtime: time.Now().Unix(),
  8750. Status: 1,
  8751. UserOrgId: adminUser.CurrentOrgId,
  8752. CostTotal: medfee_sumamt,
  8753. FuncTotal: fund_pay_sumamt,
  8754. PsnPay: acct_pay,
  8755. Creator: admin_user_id,
  8756. Ctime: time.Now().Unix(),
  8757. ClrType: clr_type,
  8758. }
  8759. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  8760. if err == nil {
  8761. c.ServeSuccessJSON(map[string]interface{}{
  8762. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8763. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8764. })
  8765. } else {
  8766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8767. }
  8768. } else {
  8769. c.ServeSuccessJSON(map[string]interface{}{
  8770. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8771. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8772. })
  8773. }
  8774. } else {
  8775. c.ServeSuccessJSON(map[string]interface{}{
  8776. "code": -10,
  8777. "msg": res.ErrMsg,
  8778. })
  8779. }
  8780. }
  8781. }
  8782. func (c *HisApiController) Check310() {
  8783. adminUser := c.GetAdminUserInfo()
  8784. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8785. var user_name string
  8786. user_name = "高慧裕"
  8787. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8788. "insutype=" + "310" +
  8789. "&clr_type=" + "" +
  8790. "&setl_optins=" + "441202" +
  8791. "&stmt_begndate=" + "2022-03-01" +
  8792. "&stm_enddate=" + "2022-03-31" +
  8793. "&medfee_sumamt=" + "194930.12" +
  8794. "&fund_pay_sumamt=" + "188741.46" +
  8795. "&acct_pay=" + "0" +
  8796. "&fixmedins_setl_cnt=" + "452" +
  8797. "&fixmedins_code=" + miConfig.Code +
  8798. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8799. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8800. "&secret_key=" + miConfig.SecretKey +
  8801. "&org_name=" + miConfig.OrgName +
  8802. "&doctor=" + user_name
  8803. fmt.Println(api)
  8804. resp, requestErr := http.Get(api)
  8805. if requestErr != nil {
  8806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8807. return
  8808. }
  8809. body, ioErr := ioutil.ReadAll(resp.Body)
  8810. fmt.Println(body)
  8811. if ioErr != nil {
  8812. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8814. return
  8815. }
  8816. var respJSON map[string]interface{}
  8817. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8818. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8820. return
  8821. }
  8822. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8823. userJSONBytes, _ := json.Marshal(respJSON)
  8824. var res ResultEight
  8825. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8826. utils.ErrorLog("解析失败:%v", err)
  8827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8828. return
  8829. }
  8830. }
  8831. func (c *HisApiController) Check390() {
  8832. adminUser := c.GetAdminUserInfo()
  8833. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8834. var user_name string
  8835. user_name = "高慧裕"
  8836. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8837. "insutype=" + "390" +
  8838. "&clr_type=" + "" +
  8839. "&setl_optins=" + "441202" +
  8840. "&stmt_begndate=" + "2022-03-01" +
  8841. "&stm_enddate=" + "2022-03-31" +
  8842. "&medfee_sumamt=" + "1068448.89" +
  8843. "&fund_pay_sumamt=" + "1014677.62" +
  8844. "&acct_pay=" + "0" +
  8845. "&fixmedins_setl_cnt=" + "1950" +
  8846. "&fixmedins_code=" + miConfig.Code +
  8847. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8848. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8849. "&secret_key=" + miConfig.SecretKey +
  8850. "&org_name=" + miConfig.OrgName +
  8851. "&doctor=" + user_name
  8852. fmt.Println(api)
  8853. resp, requestErr := http.Get(api)
  8854. if requestErr != nil {
  8855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8856. return
  8857. }
  8858. body, ioErr := ioutil.ReadAll(resp.Body)
  8859. fmt.Println(body)
  8860. if ioErr != nil {
  8861. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8863. return
  8864. }
  8865. var respJSON map[string]interface{}
  8866. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8867. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8869. return
  8870. }
  8871. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8872. userJSONBytes, _ := json.Marshal(respJSON)
  8873. var res ResultEight
  8874. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8875. utils.ErrorLog("解析失败:%v", err)
  8876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8877. return
  8878. }
  8879. }
  8880. //对账明细
  8881. func (c *HisApiController) GetCheckDetailAccount() {
  8882. start_time := c.GetString("start_time")
  8883. end_time := c.GetString("end_time")
  8884. admin_user_id, _ := c.GetInt64("admin_user_id")
  8885. adminUser := c.GetAdminUserInfo()
  8886. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8887. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8888. timeLayout := "2006-01-02"
  8889. loc, _ := time.LoadLocation("Local")
  8890. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8891. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8892. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  8893. rand.Seed(time.Now().UnixNano())
  8894. num := rand.Intn(30000)
  8895. Mkdir(miConfig.OrgName)
  8896. file := strconv.FormatInt(int64(num), 10)
  8897. file_name := file + ".txt"
  8898. zip_name := file + ".zip"
  8899. zip_path := miConfig.OrgName + "/" + zip_name
  8900. file_path := miConfig.OrgName + "/" + file_name
  8901. decimal.DivisionPrecision = 2
  8902. var medfee_sumamt float64
  8903. var psn_cash_pay float64
  8904. var fund_pay_sumamt float64
  8905. fixmedins_setl_cnt := int64(len(orders))
  8906. for _, item := range orders {
  8907. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8908. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  8909. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8910. }
  8911. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  8912. defer f.Close()
  8913. if err != nil {
  8914. fmt.Println(err.Error())
  8915. } else {
  8916. for _, item := range orders {
  8917. var refd_setl_flag string
  8918. if item.OrderStatus == 2 {
  8919. refd_setl_flag = "0"
  8920. var str string
  8921. str = item.SetlId + " " +
  8922. item.MdtrtId + " " +
  8923. item.PsnNo + " " +
  8924. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8925. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8926. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  8927. _, err = f.Write([]byte(str))
  8928. }
  8929. if item.OrderStatus == 3 {
  8930. var str string
  8931. str = item.SetlId + " " +
  8932. item.MdtrtId + " " +
  8933. item.PsnNo + " " +
  8934. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8935. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8936. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  8937. _, err = f.Write([]byte(str))
  8938. var str2 string
  8939. str2 = item.SetlId + " " +
  8940. item.MdtrtId + " " +
  8941. item.PsnNo + " " +
  8942. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  8943. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  8944. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  8945. _, err = f.Write([]byte(str2))
  8946. }
  8947. }
  8948. }
  8949. Zip(file_path, zip_path)
  8950. fmt.Println(ReadFile(zip_path))
  8951. fmt.Println(string(ReadFile(zip_path)))
  8952. if config.IsOpen == 1 {
  8953. var user_name string
  8954. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8955. if role.ID == 0 {
  8956. user_name = "管理员"
  8957. } else {
  8958. user_name = role.UserName
  8959. }
  8960. baseParams := models.BaseParams{
  8961. SecretKey: miConfig.SecretKey,
  8962. FixmedinsCode: miConfig.Code,
  8963. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8964. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8965. OrgName: miConfig.OrgName,
  8966. Doctor: user_name,
  8967. }
  8968. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  8969. var dat map[string]interface{}
  8970. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8971. fmt.Println(dat)
  8972. } else {
  8973. fmt.Println(err)
  8974. }
  8975. userJSONBytes, _ := json.Marshal(dat)
  8976. var res ResultNine
  8977. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8978. utils.ErrorLog("解析失败:%v", err)
  8979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8980. return
  8981. }
  8982. if res.Infcode == 0 {
  8983. fileNo := res.Output.FileQuryNo
  8984. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  8985. "file_qury_no=" + fileNo +
  8986. "&setl_optins=" + "定点医保中心" +
  8987. "&stmt_begndate=" + start_time +
  8988. "&stm_enddate=" + end_time +
  8989. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8990. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8991. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  8992. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8993. "&fixmedins_code=" + miConfig.Code +
  8994. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8995. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8996. "&secret_key=" + miConfig.SecretKey +
  8997. "&org_name=" + miConfig.OrgName +
  8998. "&doctor=" + user_name
  8999. resp, requestErr := http.Get(api)
  9000. if requestErr != nil {
  9001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9002. return
  9003. }
  9004. body, ioErr := ioutil.ReadAll(resp.Body)
  9005. if ioErr != nil {
  9006. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9008. return
  9009. }
  9010. var respJSON map[string]interface{}
  9011. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9012. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9014. return
  9015. }
  9016. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9017. userJSONBytes, _ := json.Marshal(respJSON)
  9018. var res ResultTen
  9019. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9020. utils.ErrorLog("解析失败:%v", err)
  9021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9022. return
  9023. }
  9024. if res.Infcode == 0 {
  9025. service.Gdyb9102(baseParams, zip_name, fileNo)
  9026. micc := &models.MedicalInsuranceCostCompare{
  9027. StartTime: startime.Unix(),
  9028. EndTime: endtime.Unix(),
  9029. Insutype: "0",
  9030. CheckType: 2,
  9031. Num: fixmedins_setl_cnt,
  9032. Mtime: time.Now().Unix(),
  9033. Status: 1,
  9034. UserOrgId: adminUser.CurrentOrgId,
  9035. CostTotal: medfee_sumamt,
  9036. FuncTotal: fund_pay_sumamt,
  9037. PsnPay: psn_cash_pay,
  9038. Creator: admin_user_id,
  9039. Ctime: time.Now().Unix(),
  9040. }
  9041. service.CreateMedicalInsuranceCostCompareRecord(micc)
  9042. c.ServeSuccessJSON(map[string]interface{}{
  9043. "msg": "明细对账成功",
  9044. })
  9045. }
  9046. } else {
  9047. }
  9048. }
  9049. }
  9050. type CustomOrderInfo struct {
  9051. Name string
  9052. Spec string
  9053. Unit string
  9054. Count float64
  9055. Price float64
  9056. Total float64
  9057. }
  9058. func (c *HisApiController) GetSettleAccounts() {
  9059. //id, _ := c.GetInt64("id")
  9060. //record_time := c.GetString("record_time")
  9061. order_id, _ := c.GetInt64("order_id")
  9062. admin_user_id, _ := c.GetInt64("admin_user_id")
  9063. //timeLayout := "2006-01-02"
  9064. //loc, _ := time.LoadLocation("Local")
  9065. //
  9066. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9067. //if err != nil {
  9068. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9069. // return
  9070. //}
  9071. //recordDateTime := theTime.Unix()
  9072. adminUser := c.GetAdminUserInfo()
  9073. order, _ := service.GetHisOrderByID(order_id)
  9074. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9075. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  9076. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  9077. orderInfos = append(orderInfos, orderInfos_two...)
  9078. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9079. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  9080. var diagnosis_ids []string
  9081. if his.ID > 0 {
  9082. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  9083. } else {
  9084. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  9085. }
  9086. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  9087. var dia_config []*models.HisXtDiagnoseConfig
  9088. var name string
  9089. for _, item := range diagnosis_ids {
  9090. id, _ := strconv.ParseInt(item, 10, 64)
  9091. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9092. dia_config = append(dia_config, &diagnosisConfig)
  9093. if len(name) == 0 {
  9094. name = diagnosisConfig.ClassName
  9095. } else {
  9096. name = name + "," + diagnosisConfig.ClassName
  9097. }
  9098. }
  9099. var bedCostTotal float64 = 0 //床位总费
  9100. var bedCostSelfTotal float64 = 0 //床位自费
  9101. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  9102. var operationCostTotal float64 = 0 //手术费
  9103. var operationCostSelfTotal float64 = 0 //手术费
  9104. var operationCostPartSelfTotal float64 = 0 //手术费
  9105. var otherCostTotal float64 = 0 //其他费用
  9106. var otherCostSelfTotal float64 = 0 //其他费用
  9107. var otherCostPartSelfTotal float64 = 0 //其他费用
  9108. var materialCostTotal float64 = 0 //材料费
  9109. var materialCostSelfTotal float64 = 0 //材料费
  9110. var materialCostPartSelfTotal float64 = 0 //材料费
  9111. var westernMedicineCostTotal float64 = 0 //西药费
  9112. var westernMedicineCostSelfTotal float64 = 0 //西药费
  9113. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  9114. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  9115. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  9116. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  9117. var checkCostTotal float64 = 0 //检查费
  9118. var checkCostSelfTotal float64 = 0 //检查费
  9119. var checkCostPartSelfTotal float64 = 0 //检查费
  9120. var laboratoryCostTotal float64 = 0 //化验费
  9121. var laboratoryCostSelfTotal float64 = 0 //化验费
  9122. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  9123. var treatCostTotal float64 = 0 //治疗费用
  9124. var treatCostSelfTotal float64 = 0 //治疗费用
  9125. var treatCostPartSelfTotal float64 = 0 //治疗费用
  9126. decimal.DivisionPrecision = 2
  9127. for _, item := range orderInfos {
  9128. if item.MedChrgitmType == "01" { //床位费
  9129. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9130. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9131. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9132. }
  9133. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  9134. if item.MedChrgitmType == "03" { //检查费
  9135. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9136. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9137. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9138. }
  9139. } else {
  9140. if item.MedChrgitmType == "03" { //检查费
  9141. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9142. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9143. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9144. }
  9145. }
  9146. if item.MedChrgitmType == "04" { //化验费
  9147. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9148. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9149. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9150. }
  9151. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  9152. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9153. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9154. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9155. }
  9156. if item.MedChrgitmType == "06" { //手术费
  9157. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9158. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9159. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9160. }
  9161. if item.MedChrgitmType == "08" { //材料费
  9162. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9163. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9164. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9165. }
  9166. if item.MedChrgitmType == "09" { //西药费
  9167. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9168. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9169. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9170. }
  9171. if item.MedChrgitmType == "11" { //中成费
  9172. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9173. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9174. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9175. }
  9176. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  9177. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9178. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9179. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9180. }
  9181. }
  9182. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9183. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9184. var user_name string
  9185. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9186. if role.ID == 0 {
  9187. user_name = "管理员"
  9188. } else {
  9189. user_name = role.UserName
  9190. }
  9191. baseParams := models.BaseParams{
  9192. SecretKey: miConfig.SecretKey,
  9193. FixmedinsCode: miConfig.Code,
  9194. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9195. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9196. OrgName: miConfig.OrgName,
  9197. Doctor: user_name,
  9198. }
  9199. businessParams := models.BusinessParams{
  9200. PsnNo: order.PsnNo,
  9201. MdtrtId: order.MdtrtId,
  9202. SetlId: order.SetlId,
  9203. }
  9204. var res ResultEleven
  9205. var resEleven10265 ResultEleven10265
  9206. if config.IsOpen == 1 {
  9207. if miConfig.MdtrtareaAdmvs == "421300" {
  9208. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9209. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9210. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9211. resp, requestErr := http.Get(api)
  9212. if requestErr != nil {
  9213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9214. return
  9215. }
  9216. body, ioErr := ioutil.ReadAll(resp.Body)
  9217. if ioErr != nil {
  9218. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9220. return
  9221. }
  9222. var respJSON map[string]interface{}
  9223. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9224. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9226. return
  9227. }
  9228. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9229. result, _ := json.Marshal(respJSON)
  9230. fmt.Println("log")
  9231. fmt.Println(string(result))
  9232. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9233. utils.ErrorLog("解析失败:%v", err)
  9234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9235. return
  9236. }
  9237. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9238. var api string
  9239. if miConfig.MdtrtareaAdmvs == "320921" {
  9240. api = "http://192.168.2.110:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9241. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9242. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9243. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9244. } else {
  9245. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9246. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9247. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9248. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9249. }
  9250. resp, requestErr := http.Get(api)
  9251. if requestErr != nil {
  9252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9253. return
  9254. }
  9255. body, ioErr := ioutil.ReadAll(resp.Body)
  9256. if ioErr != nil {
  9257. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9259. return
  9260. }
  9261. var respJSON map[string]interface{}
  9262. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9263. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9265. return
  9266. }
  9267. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9268. result, _ := json.Marshal(respJSON)
  9269. fmt.Println("log")
  9270. fmt.Println(string(result))
  9271. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9272. utils.ErrorLog("解析失败:%v", err)
  9273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9274. return
  9275. }
  9276. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9277. res.Output = resEleven10265.Output
  9278. res.ErrMsg = resEleven10265.ErrMsg
  9279. res.Cainfo = resEleven10265.Cainfo
  9280. res.WarnMsg = resEleven10265.WarnMsg
  9281. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9282. res.Infcode = infocode
  9283. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9284. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  9285. saveLog(result, requestLog, "5203", "结算单")
  9286. var dat map[string]interface{}
  9287. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9288. fmt.Println(dat)
  9289. } else {
  9290. fmt.Println(err)
  9291. }
  9292. userJSONBytes, _ := json.Marshal(dat)
  9293. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9294. utils.ErrorLog("解析失败:%v", err)
  9295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9296. return
  9297. }
  9298. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9299. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9300. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9301. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9302. resp, requestErr := http.Get(api)
  9303. if requestErr != nil {
  9304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9305. return
  9306. }
  9307. body, ioErr := ioutil.ReadAll(resp.Body)
  9308. if ioErr != nil {
  9309. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9311. return
  9312. }
  9313. var respJSON map[string]interface{}
  9314. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9315. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9317. return
  9318. }
  9319. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9320. result, _ := json.Marshal(respJSON)
  9321. fmt.Println("log")
  9322. fmt.Println(string(result))
  9323. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9324. utils.ErrorLog("解析失败:%v", err)
  9325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9326. return
  9327. }
  9328. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9329. res.Output = resEleven10265.Output
  9330. res.ErrMsg = resEleven10265.ErrMsg
  9331. res.Cainfo = resEleven10265.Cainfo
  9332. res.WarnMsg = resEleven10265.WarnMsg
  9333. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9334. res.Infcode = infocode
  9335. } else {
  9336. result := service.Gdyb5203(baseParams, businessParams)
  9337. //service.Gdyb5204(baseParams, businessParams)
  9338. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  9339. var dat map[string]interface{}
  9340. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9341. fmt.Println(dat)
  9342. } else {
  9343. fmt.Println(err)
  9344. }
  9345. userJSONBytes, _ := json.Marshal(dat)
  9346. if miConfig.Code == "H15049901371" {
  9347. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  9348. utils.ErrorLog("解析失败:%v", err)
  9349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9350. return
  9351. }
  9352. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9353. res.Output = resEleven10265.Output
  9354. res.ErrMsg = resEleven10265.ErrMsg
  9355. res.Cainfo = resEleven10265.Cainfo
  9356. res.WarnMsg = resEleven10265.WarnMsg
  9357. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9358. res.Infcode = infocode
  9359. } else {
  9360. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9361. utils.ErrorLog("解析失败:%v", err)
  9362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9363. return
  9364. }
  9365. }
  9366. }
  9367. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9368. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  9369. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  9370. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9371. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  9372. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9373. var doctor_name string
  9374. if roles.ID == 0 {
  9375. doctor_name = "管理员"
  9376. } else {
  9377. doctor_name = roles.UserName
  9378. }
  9379. yiliao_leibie := ""
  9380. switch order.MedType {
  9381. case "11":
  9382. yiliao_leibie = "普通门诊"
  9383. break
  9384. case "12":
  9385. yiliao_leibie = "门诊挂号"
  9386. break
  9387. case "13":
  9388. yiliao_leibie = "急诊"
  9389. break
  9390. case "14":
  9391. yiliao_leibie = "门诊特殊病"
  9392. break
  9393. case "15":
  9394. yiliao_leibie = "门诊统筹"
  9395. break
  9396. case "16":
  9397. yiliao_leibie = "门诊慢性病"
  9398. break
  9399. case "21":
  9400. yiliao_leibie = "普通住院"
  9401. break
  9402. }
  9403. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9404. if res.Infcode == 0 {
  9405. c.ServeSuccessJSON(map[string]interface{}{
  9406. "diagnosis": name,
  9407. "order_infos": orderInfos,
  9408. "number": order.MdtrtId,
  9409. "date": order.SettleAccountsDate,
  9410. "charge_admin": charge_admin,
  9411. "printor_admin": printor_admin,
  9412. "info": res.Output.Setlinfo,
  9413. "order": order,
  9414. "bedCostTotal": bedCostTotal,
  9415. "bedCostSelfTotal": bedCostSelfTotal,
  9416. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  9417. "operationCostTotal": operationCostTotal,
  9418. "operationCostSelfTotal": operationCostSelfTotal,
  9419. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  9420. "otherCostTotal": otherCostTotal,
  9421. "otherCostSelfTotal": otherCostSelfTotal,
  9422. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  9423. "materialCostTotal": materialCostTotal,
  9424. "materialCostSelfTotal": materialCostSelfTotal,
  9425. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  9426. "westernMedicineCostTotal": westernMedicineCostTotal,
  9427. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  9428. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  9429. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  9430. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  9431. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  9432. "checkCostTotal": checkCostTotal,
  9433. "checkCostSelfTotal": checkCostSelfTotal,
  9434. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  9435. "laboratoryCostTotal": laboratoryCostTotal,
  9436. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  9437. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  9438. "treatCostTotal": treatCostTotal,
  9439. "treatCostSelfTotal": treatCostSelfTotal,
  9440. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  9441. "doctor_info": doctor_info,
  9442. "doctor_code": adminRole_two.DoctorCode,
  9443. "doctor_name": doctor_name,
  9444. "health_card_no": order.PsnNo,
  9445. "department": departments.Name,
  9446. "yiliao_leibie": yiliao_leibie,
  9447. "after_money": order.AccountPrice,
  9448. "patient": patient,
  9449. "org_name": miConfig.OrgName,
  9450. "org_code": miConfig.Code,
  9451. "order_number": order.Number,
  9452. "his_hospital": his_hospital,
  9453. "his": his,
  9454. "dia_config": dia_config,
  9455. //"check_order_info": cus_slice,
  9456. })
  9457. }
  9458. }
  9459. }
  9460. func (c *HisApiController) CheckTreatment() {
  9461. patient_id, _ := c.GetInt64("patient_id")
  9462. id_card_no := c.GetString("id_card_no")
  9463. insutype := c.GetString("insutype")
  9464. med_type := c.GetString("med_type")
  9465. admin_user_id, _ := c.GetInt64("admin_user_id")
  9466. adminUser := c.GetAdminUserInfo()
  9467. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9468. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9469. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9470. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9471. if miConfig.MdtrtareaAdmvs == "421300" {
  9472. var res ResultTwo
  9473. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  9474. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9475. "&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)
  9476. resp, requestErr := http.Get(api)
  9477. if requestErr != nil {
  9478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9479. return
  9480. }
  9481. body, ioErr := ioutil.ReadAll(resp.Body)
  9482. if ioErr != nil {
  9483. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9485. return
  9486. }
  9487. var respJSON map[string]interface{}
  9488. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9489. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9491. return
  9492. }
  9493. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9494. result, _ := json.Marshal(respJSON)
  9495. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9496. utils.ErrorLog("解析失败:%v", err)
  9497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9498. return
  9499. }
  9500. if res.Infcode == 0 {
  9501. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  9502. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9503. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  9504. resp, requestErr := http.Get(api)
  9505. if requestErr != nil {
  9506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9507. return
  9508. }
  9509. body, ioErr := ioutil.ReadAll(resp.Body)
  9510. if ioErr != nil {
  9511. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9513. return
  9514. }
  9515. var respJSON map[string]interface{}
  9516. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9517. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9519. return
  9520. }
  9521. var res Result2001
  9522. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9523. result2, _ := json.Marshal(respJSON)
  9524. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9525. utils.ErrorLog("解析失败:%v", err)
  9526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9527. return
  9528. }
  9529. if res.Infcode == 0 {
  9530. c.ServeSuccessJSON(map[string]interface{}{
  9531. "msg": res.Output.Trtinfo,
  9532. })
  9533. }
  9534. } else {
  9535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9536. return
  9537. }
  9538. } else {
  9539. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9540. var dat map[string]interface{}
  9541. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9542. fmt.Println(dat)
  9543. } else {
  9544. fmt.Println(err)
  9545. }
  9546. userJSONBytes, _ := json.Marshal(dat)
  9547. var res ResultTwo
  9548. var res10265 ResultTwo10265
  9549. if miConfig.Code == "H15049901371" {
  9550. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9551. utils.ErrorLog("解析失败:%v", err)
  9552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9553. return
  9554. }
  9555. res.ErrMsg = res10265.ErrMsg
  9556. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9557. res.Infcode = infocode
  9558. res.Output = res10265.Output
  9559. res.InfRefmsgid = res10265.InfRefmsgid
  9560. } else {
  9561. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9562. utils.ErrorLog("解析失败:%v", err)
  9563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9564. return
  9565. }
  9566. }
  9567. var user_name string
  9568. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  9569. if role.ID == 0 {
  9570. user_name = "xxx"
  9571. } else {
  9572. user_name = role.UserName
  9573. }
  9574. baseParams := models.BaseParams{
  9575. SecretKey: miConfig.SecretKey,
  9576. FixmedinsCode: miConfig.Code,
  9577. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9578. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9579. OrgName: miConfig.OrgName,
  9580. Doctor: user_name,
  9581. }
  9582. if config.IsOpen == 1 {
  9583. if miConfig.Code == "H15049901371" {
  9584. if med_type == "14" {
  9585. if insutype == "390" {
  9586. med_type = "9933"
  9587. } else if insutype == "310" {
  9588. med_type = "990502"
  9589. }
  9590. } else if med_type == "11" {
  9591. med_type = "11"
  9592. }
  9593. }
  9594. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  9595. var dat map[string]interface{}
  9596. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9597. fmt.Println(dat)
  9598. } else {
  9599. fmt.Println(err)
  9600. }
  9601. var res Result2001
  9602. var res10265 Result2001Org10265
  9603. if miConfig.Code == "H15049901371" {
  9604. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9605. utils.ErrorLog("解析失败:%v", err)
  9606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9607. return
  9608. }
  9609. res.ErrMsg = res10265.ErrMsg
  9610. res.Output = res10265.Output
  9611. res.InfRefmsgid = res10265.InfRefmsgid
  9612. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9613. res.Infcode = infocode
  9614. } else {
  9615. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9616. utils.ErrorLog("解析失败:%v", err)
  9617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9618. return
  9619. }
  9620. }
  9621. if res.Infcode == 0 {
  9622. c.ServeSuccessJSON(map[string]interface{}{
  9623. "msg": res.Output.Trtinfo,
  9624. })
  9625. }
  9626. }
  9627. }
  9628. }
  9629. //func (c *HisApiController) PutRecord() {
  9630. // id, _ := c.GetInt64("id")
  9631. // record_time := c.GetString("record_time")
  9632. // timeLayout := "2006-01-02"
  9633. // loc, _ := time.LoadLocation("Local")
  9634. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9635. // if err != nil {
  9636. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9637. // return
  9638. // }
  9639. // recordDateTime := theTime.Unix()
  9640. //
  9641. // adminInfo := c.GetAdminUserInfo()
  9642. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  9643. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9644. //
  9645. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9646. //
  9647. // fmt.Println(miConfig.SecretKey)
  9648. //
  9649. // if patient == nil {
  9650. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9651. // return
  9652. // }
  9653. // if len(patient.IdCardNo) == 0 {
  9654. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  9655. // return
  9656. // }
  9657. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  9658. // if config.IsOpen == 1 {
  9659. // 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
  9660. // resp, requestErr := http.Get(api)
  9661. // if requestErr != nil {
  9662. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9663. // return
  9664. // }
  9665. // defer resp.Body.Close()
  9666. // body, ioErr := ioutil.ReadAll(resp.Body)
  9667. // if ioErr != nil {
  9668. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9669. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9670. // return
  9671. // }
  9672. // var respJSON map[string]interface{}
  9673. //
  9674. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9675. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9676. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9677. // return
  9678. // }
  9679. //
  9680. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9681. // userJSONBytes, _ := json.Marshal(userJSON)
  9682. // var res ResultTwo
  9683. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9684. // utils.ErrorLog("解析失败:%v", err)
  9685. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9686. // return
  9687. // }
  9688. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9689. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9690. // infoStr := string(Iinfos)
  9691. // idetinfoStr := string(Idetinfos)
  9692. //
  9693. // if res.Infcode == 0 {
  9694. // his := models.VMHisPatient{
  9695. // Status: 1,
  9696. // Ctime: time.Now().Unix(),
  9697. // Mtime: time.Now().Unix(),
  9698. // PsnNo: res.Output.Baseinfo.PsnNo,
  9699. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  9700. // Certno: res.Output.Baseinfo.Certno,
  9701. // PsnName: res.Output.Baseinfo.PsnName,
  9702. // Gend: res.Output.Baseinfo.Gend,
  9703. // Naty: res.Output.Baseinfo.Naty,
  9704. // Brdy: res.Output.Baseinfo.Brdy,
  9705. // Age: res.Output.Baseinfo.Age,
  9706. // Iinfo: infoStr,
  9707. // Idetinfo: idetinfoStr,
  9708. // PatientId: patient.ID,
  9709. // RecordDate: theTime.Unix(),
  9710. // UserOrgId: adminInfo.CurrentOrgId,
  9711. // AdminUserId: adminInfo.AdminUser.Id,
  9712. // IsReturn: 1,
  9713. // }
  9714. //
  9715. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  9716. // //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")
  9717. // //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")
  9718. //
  9719. // //var dat map[string]interface{}
  9720. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9721. // // fmt.Println(dat)
  9722. // //} else {
  9723. // // fmt.Println(err)
  9724. // //}
  9725. //
  9726. // var dat2 map[string]interface{}
  9727. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9728. // fmt.Println(dat2)
  9729. // } else {
  9730. // fmt.Println(err)
  9731. // }
  9732. //
  9733. // } else {
  9734. // adminUser := c.GetAdminUserInfo()
  9735. // errlog := &models.HisOrderError{
  9736. // UserOrgId: adminUser.CurrentOrgId,
  9737. // Ctime: time.Now().Unix(),
  9738. // Mtime: time.Now().Unix(),
  9739. // ErrMsg: res.ErrMsg,
  9740. // Status: 1,
  9741. // PatientId: id,
  9742. // RecordTime: recordDateTime,
  9743. // Stage: 1,
  9744. // }
  9745. // service.CreateErrMsgLog(errlog)
  9746. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  9747. // return
  9748. // }
  9749. // }
  9750. //
  9751. //}
  9752. //func (c *HisApiController) GetUploadDiag() {
  9753. // id, _ := c.GetInt64("id")
  9754. // record_time := c.GetString("record_time")
  9755. //
  9756. // diagnosis_id, _ := c.GetInt64("diagnosis")
  9757. // sick_type, _ := c.GetInt64("sick_type")
  9758. // reg_type, _ := c.GetInt64("reg_type")
  9759. //
  9760. // timeLayout := "2006-01-02"
  9761. // loc, _ := time.LoadLocation("Local")
  9762. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9763. // if err != nil {
  9764. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9765. // return
  9766. // }
  9767. //
  9768. // var patientPrescription models.HisPrescriptionInfo
  9769. // recordDateTime := theTime.Unix()
  9770. // adminInfo := c.GetAdminUserInfo()
  9771. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9772. //
  9773. // if patientPrescription.ID == 0 {
  9774. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9775. // }
  9776. //
  9777. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9778. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9779. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9780. // sickConfig, _ := service.FindSickById(sick_type)
  9781. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9782. //
  9783. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  9784. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  9785. // "&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 +
  9786. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  9787. // resp2, requestErr2 := http.Get(api2)
  9788. // if requestErr2 != nil {
  9789. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9790. // return
  9791. // }
  9792. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  9793. // if ioErr2 != nil {
  9794. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  9795. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9796. // return
  9797. // }
  9798. // var respJSON2 map[string]interface{}
  9799. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  9800. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9801. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9802. // return
  9803. // }
  9804. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9805. // userJSONBytes2, _ := json.Marshal(respJSON2)
  9806. //
  9807. // var res2 ResultSix
  9808. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9809. // utils.ErrorLog("解析失败:%v", err)
  9810. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9811. // return
  9812. // }
  9813. // if res2.Infcode != 0 {
  9814. // adminUser := c.GetAdminUserInfo()
  9815. // errlog := &models.HisOrderError{
  9816. // UserOrgId: adminUser.CurrentOrgId,
  9817. // Ctime: time.Now().Unix(),
  9818. // Mtime: time.Now().Unix(),
  9819. // ErrMsg: res2.ErrMsg,
  9820. // Status: 1,
  9821. // PatientId: id,
  9822. // RecordTime: recordDateTime,
  9823. // Stage: 3,
  9824. // }
  9825. // service.CreateErrMsgLog(errlog)
  9826. //
  9827. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  9828. // return
  9829. // }
  9830. //
  9831. // c.ServeSuccessJSON(map[string]interface{}{
  9832. // "msg": "上传成功",
  9833. // })
  9834. //
  9835. //}
  9836. type QueryResult struct {
  9837. ID int64
  9838. Name string
  9839. Code string
  9840. List_type_code string
  9841. }
  9842. func (c *HisApiController) GetCheckCode() {
  9843. ids_str := c.GetString("ids")
  9844. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9845. ids_arr := strings.Split(ids_str, ",")
  9846. var queryResult []QueryResult
  9847. ids := make([]int64, 0)
  9848. for _, item := range ids_arr {
  9849. id, _ := strconv.ParseInt(item, 10, 64)
  9850. ids = append(ids, id)
  9851. }
  9852. if record_type == 1 {
  9853. drugs, _ := service.GetBatchDrugList(ids)
  9854. for _, item := range drugs {
  9855. result := QueryResult{
  9856. ID: item.ID,
  9857. Name: item.DrugName,
  9858. Code: item.MedicalInsuranceNumber,
  9859. List_type_code: "101",
  9860. }
  9861. queryResult = append(queryResult, result)
  9862. }
  9863. } else if record_type == 2 {
  9864. goods, _ := service.GetBatchGoodInformationList(ids)
  9865. for _, item := range goods {
  9866. result := QueryResult{
  9867. ID: item.ID,
  9868. Name: item.GoodName,
  9869. Code: item.MedicalInsuranceNumber,
  9870. List_type_code: "301",
  9871. }
  9872. queryResult = append(queryResult, result)
  9873. }
  9874. } else if record_type == 3 {
  9875. projects, _ := service.GetBathchMyPorjecgList(ids)
  9876. for _, item := range projects {
  9877. result := QueryResult{
  9878. ID: item.ID,
  9879. Name: item.ProjectName,
  9880. Code: item.MedicalCode,
  9881. List_type_code: "201",
  9882. }
  9883. queryResult = append(queryResult, result)
  9884. }
  9885. }
  9886. admin_user_id, _ := c.GetInt64("admin_user_id")
  9887. adminUser := c.GetAdminUserInfo()
  9888. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9889. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9890. var user_name string
  9891. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9892. if role.ID == 0 {
  9893. user_name = "xxx"
  9894. } else {
  9895. user_name = role.UserName
  9896. }
  9897. baseParams := &models.BaseParams{
  9898. SecretKey: miConfig.SecretKey,
  9899. FixmedinsCode: miConfig.Code,
  9900. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9901. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9902. OrgName: miConfig.OrgName,
  9903. Doctor: user_name,
  9904. }
  9905. if config.IsOpen == 1 {
  9906. for _, item := range queryResult {
  9907. var result string
  9908. if record_type == 1 {
  9909. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9910. } else if record_type == 2 {
  9911. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9912. } else if record_type == 3 {
  9913. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9914. }
  9915. var dat map[string]interface{}
  9916. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9917. fmt.Println(dat)
  9918. } else {
  9919. fmt.Println(err)
  9920. }
  9921. userJSONBytes, _ := json.Marshal(dat)
  9922. var res ResultSix
  9923. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9924. utils.ErrorLog("解析失败:%v", err)
  9925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9926. return
  9927. }
  9928. if res.Infcode == 0 {
  9929. if record_type == 1 {
  9930. service.UpdateBaseDrugById(item.ID)
  9931. } else if record_type == 2 {
  9932. service.UpdateGoodInformaitonByDetail(item.ID)
  9933. } else if record_type == 3 {
  9934. service.UpdateProjectById(item.ID)
  9935. }
  9936. c.ServeSuccessJSON(map[string]interface{}{
  9937. "failed_code": 0,
  9938. "msg": "目录对照成功",
  9939. })
  9940. } else {
  9941. c.ServeSuccessJSON(map[string]interface{}{
  9942. "failed_code": -10,
  9943. "msg": res.ErrMsg,
  9944. })
  9945. }
  9946. }
  9947. }
  9948. }
  9949. func (c *HisApiController) UnCheckCode() {
  9950. ids_str := c.GetString("ids")
  9951. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9952. admin_user_id, _ := c.GetInt64("admin_user_id")
  9953. ids_arr := strings.Split(ids_str, ",")
  9954. var queryResult []QueryResult
  9955. ids := make([]int64, 0)
  9956. for _, item := range ids_arr {
  9957. id, _ := strconv.ParseInt(item, 10, 64)
  9958. ids = append(ids, id)
  9959. }
  9960. if record_type == 1 {
  9961. drugs, _ := service.GetBatchDrugList(ids)
  9962. for _, item := range drugs {
  9963. result := QueryResult{
  9964. ID: item.ID,
  9965. Name: item.DrugName,
  9966. Code: item.MedicalInsuranceNumber,
  9967. List_type_code: "101",
  9968. }
  9969. queryResult = append(queryResult, result)
  9970. }
  9971. } else if record_type == 2 {
  9972. goods, _ := service.GetBatchGoodInformationList(ids)
  9973. for _, item := range goods {
  9974. result := QueryResult{
  9975. ID: item.ID,
  9976. Name: item.GoodName,
  9977. Code: item.MedicalInsuranceNumber,
  9978. List_type_code: "301",
  9979. }
  9980. queryResult = append(queryResult, result)
  9981. }
  9982. } else if record_type == 3 {
  9983. projects, _ := service.GetBathchMyPorjecgList(ids)
  9984. for _, item := range projects {
  9985. result := QueryResult{
  9986. ID: item.ID,
  9987. Name: item.ProjectName,
  9988. Code: item.MedicalCode,
  9989. List_type_code: "201",
  9990. }
  9991. queryResult = append(queryResult, result)
  9992. }
  9993. }
  9994. adminUser := c.GetAdminUserInfo()
  9995. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9996. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9997. var user_name string
  9998. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9999. if role.ID == 0 {
  10000. user_name = "xxx"
  10001. } else {
  10002. user_name = role.UserName
  10003. }
  10004. baseParams := &models.BaseParams{
  10005. SecretKey: miConfig.SecretKey,
  10006. FixmedinsCode: miConfig.Code,
  10007. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  10008. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  10009. OrgName: miConfig.OrgName,
  10010. Doctor: user_name,
  10011. }
  10012. if config.IsOpen == 1 {
  10013. for _, item := range queryResult {
  10014. var result string
  10015. if record_type == 1 {
  10016. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10017. } else if record_type == 2 {
  10018. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10019. } else if record_type == 3 {
  10020. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10021. }
  10022. var dat2 map[string]interface{}
  10023. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  10024. fmt.Println(dat2)
  10025. } else {
  10026. fmt.Println(err)
  10027. }
  10028. userJSONBytes, _ := json.Marshal(dat2)
  10029. var res ResultSix
  10030. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10031. utils.ErrorLog("解析失败:%v", err)
  10032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10033. return
  10034. }
  10035. if res.Infcode == 0 {
  10036. if record_type == 1 {
  10037. service.UpdateDrugByIdDetail(item.ID)
  10038. } else if record_type == 2 {
  10039. service.UpdateGoodInfoById(item.ID)
  10040. } else if record_type == 3 {
  10041. service.UpdateMyProjectById(item.ID)
  10042. }
  10043. c.ServeSuccessJSON(map[string]interface{}{
  10044. "failed_code": 0,
  10045. "msg": "撤销目录对照成功",
  10046. })
  10047. } else {
  10048. c.ServeSuccessJSON(map[string]interface{}{
  10049. "failed_code": -10,
  10050. "msg": res.ErrMsg,
  10051. })
  10052. }
  10053. }
  10054. }
  10055. }
  10056. func (c *HisApiController) GetPatientInfo() {
  10057. id_card_no := c.GetString("id_card_no")
  10058. admin_user_id, _ := c.GetInt64("admin_user_id")
  10059. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  10060. if patient.ID == 0 {
  10061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  10062. return
  10063. }
  10064. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10065. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10066. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  10067. if config.IsOpen == 1 {
  10068. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  10069. var dat map[string]interface{}
  10070. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10071. fmt.Println(dat)
  10072. } else {
  10073. fmt.Println(err)
  10074. }
  10075. userJSONBytes, _ := json.Marshal(dat)
  10076. var res ResultTwo
  10077. var res10265 ResultTwo10265
  10078. if miConfig.Code == "H15049901371" {
  10079. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10080. utils.ErrorLog("解析失败:%v", err)
  10081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10082. return
  10083. }
  10084. res.ErrMsg = res10265.ErrMsg
  10085. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10086. res.Infcode = infocode
  10087. res.Output = res10265.Output
  10088. res.InfRefmsgid = res10265.InfRefmsgid
  10089. } else {
  10090. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10091. utils.ErrorLog("解析失败:%v", err)
  10092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10093. return
  10094. }
  10095. }
  10096. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10097. // utils.ErrorLog("解析失败:%v", err)
  10098. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10099. // return
  10100. //}
  10101. if res.Infcode != 0 {
  10102. c.ServeSuccessJSON(map[string]interface{}{
  10103. "failed_code": -10,
  10104. "msg": res.ErrMsg,
  10105. })
  10106. } else {
  10107. c.ServeSuccessJSON(map[string]interface{}{
  10108. "failed_code": 0,
  10109. "info": res,
  10110. })
  10111. }
  10112. }
  10113. }
  10114. func (c *HisApiController) PsnPutOnRecord() {
  10115. record_type, _ := c.GetInt64("type")
  10116. patient_id, _ := c.GetInt64("patient_id")
  10117. admin_user_id, _ := c.GetInt64("admin_user_id")
  10118. start_time := c.GetString("start_time")
  10119. end_time := c.GetString("end_time")
  10120. adminUser := c.GetAdminUserInfo()
  10121. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10122. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10123. var patients []*models.Patients
  10124. if record_type == 1 { //全部备案
  10125. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  10126. patients = append(patients, patient...)
  10127. } else { //单个备案
  10128. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10129. patients = append(patients, patient)
  10130. }
  10131. var user_name string
  10132. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10133. if role.ID == 0 {
  10134. user_name = "xxx"
  10135. } else {
  10136. user_name = role.UserName
  10137. }
  10138. if config.IsOpen == 1 {
  10139. for _, item := range patients {
  10140. 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
  10141. resp, requestErr := http.Get(api)
  10142. if requestErr != nil {
  10143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10144. return
  10145. }
  10146. defer resp.Body.Close()
  10147. body, ioErr := ioutil.ReadAll(resp.Body)
  10148. if ioErr != nil {
  10149. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10151. return
  10152. }
  10153. var respJSON map[string]interface{}
  10154. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10155. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10157. return
  10158. }
  10159. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10160. userJSONBytes, _ := json.Marshal(userJSON)
  10161. var res ResultTwo
  10162. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10163. utils.ErrorLog("解析失败:%v", err)
  10164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10165. return
  10166. }
  10167. if res.Infcode == 0 {
  10168. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  10169. var dat map[string]interface{}
  10170. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10171. fmt.Println(dat)
  10172. } else {
  10173. fmt.Println(err)
  10174. }
  10175. userJSONBytes, _ := json.Marshal(dat)
  10176. var res2 ResultThirteen
  10177. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10178. utils.ErrorLog("解析失败:%v", err)
  10179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10180. return
  10181. }
  10182. if res2.Infcode == 0 {
  10183. psnResult := &models.GdybPsnRecord{
  10184. UserOrgId: adminUser.CurrentOrgId,
  10185. PatientId: item.ID,
  10186. PsnNo: res.Output.Baseinfo.PsnNo,
  10187. Ctime: time.Now().Unix(),
  10188. Mtime: time.Now().Unix(),
  10189. Status: 1,
  10190. IsCancel: 1,
  10191. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10192. }
  10193. service.CreatePsnRecord(psnResult)
  10194. } else {
  10195. c.ServeSuccessJSON(map[string]interface{}{
  10196. "failed_code": -10,
  10197. "msg": res2.ErrMsg,
  10198. })
  10199. return
  10200. }
  10201. }
  10202. }
  10203. }
  10204. }
  10205. func (c *HisApiController) PsnUnPutOnRecord() {
  10206. id, _ := c.GetInt64("id")
  10207. //record_type, _ := c.GetInt64("type")
  10208. admin_user_id, _ := c.GetInt64("admin_user_id")
  10209. adminUser := c.GetAdminUserInfo()
  10210. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10211. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10212. var user_name string
  10213. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10214. if role.ID == 0 {
  10215. user_name = "xxx"
  10216. } else {
  10217. user_name = role.UserName
  10218. }
  10219. psn_record, _ := service.GetPsnRecordById(id)
  10220. if psn_record.ID == 0 {
  10221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10222. return
  10223. }
  10224. if config.IsOpen == 1 {
  10225. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10226. var dat map[string]interface{}
  10227. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10228. fmt.Println(dat)
  10229. } else {
  10230. fmt.Println(err)
  10231. }
  10232. userJSONBytes, _ := json.Marshal(dat)
  10233. var res ResultFourteen
  10234. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10235. utils.ErrorLog("解析失败:%v", err)
  10236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10237. return
  10238. }
  10239. if res.Infcode == 0 {
  10240. psn_record.IsCancel = 2
  10241. service.CreatePsnRecord(&psn_record)
  10242. } else {
  10243. c.ServeSuccessJSON(map[string]interface{}{
  10244. "failed_code": -10,
  10245. "msg": res.ErrMsg,
  10246. })
  10247. return
  10248. }
  10249. }
  10250. }
  10251. func (c *HisApiController) PsnPutNCDSOnRecord() {
  10252. patient_id, _ := c.GetInt64("patient_id")
  10253. insutype_two := c.GetString("insutype")
  10254. psn_no := c.GetString("psn_no")
  10255. doctor_id, _ := c.GetInt64("doctor_id")
  10256. sick_id, _ := c.GetInt64("sick_id")
  10257. department_id, _ := c.GetInt64("department_id")
  10258. start_time := c.GetString("start_time")
  10259. end_time := c.GetString("end_time")
  10260. check_time := c.GetString("check_time")
  10261. adminUser := c.GetAdminUserInfo()
  10262. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10263. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10264. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10265. sick, _ := service.FindSickById(sick_id)
  10266. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10267. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10268. var res ResultTwo
  10269. var res10265 ResultTwo10265
  10270. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10271. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  10272. api := "http://192.168.2.110:9532/" + "hbyb/1101?cert_no=" + "" +
  10273. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  10274. "&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
  10275. resp, requestErr := http.Get(api)
  10276. if requestErr != nil {
  10277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10278. return
  10279. }
  10280. body, ioErr := ioutil.ReadAll(resp.Body)
  10281. if ioErr != nil {
  10282. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10284. return
  10285. }
  10286. var respJSON map[string]interface{}
  10287. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10288. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10290. return
  10291. }
  10292. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10293. result, _ := json.Marshal(respJSON)
  10294. fmt.Println("log")
  10295. fmt.Println(string(result))
  10296. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10297. utils.ErrorLog("解析失败:%v", err)
  10298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10299. return
  10300. }
  10301. res.ErrMsg = res10265.ErrMsg
  10302. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10303. res.Infcode = infocode
  10304. res.Output = res10265.Output
  10305. res.InfRefmsgid = res10265.InfRefmsgid
  10306. } else {
  10307. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10308. if miConfig.Code == "H15049901371" {
  10309. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10310. utils.ErrorLog("解析失败:%v", err)
  10311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10312. return
  10313. }
  10314. res.ErrMsg = res10265.ErrMsg
  10315. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10316. res.Infcode = infocode
  10317. res.Output = res10265.Output
  10318. res.InfRefmsgid = res10265.InfRefmsgid
  10319. } else {
  10320. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10321. utils.ErrorLog("解析失败:%v", err)
  10322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10323. return
  10324. }
  10325. }
  10326. }
  10327. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10328. infoStr := string(Iinfos)
  10329. var rf []*ResultFive
  10330. json.Unmarshal([]byte(infoStr), &rf)
  10331. var insuplc_admdvs string
  10332. var insutype string
  10333. var is390 int = 0
  10334. var is310 int = 0
  10335. var insutypes []*ResultFive
  10336. for _, item := range rf {
  10337. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10338. insutypes = append(insutypes, item)
  10339. }
  10340. }
  10341. if len(insutypes) == 1 {
  10342. insutype = insutypes[0].Insutype
  10343. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10344. } else {
  10345. for _, i := range insutypes {
  10346. if i.Insutype == "390" {
  10347. is390 = 1
  10348. }
  10349. if i.Insutype == "310" {
  10350. is310 = 1
  10351. }
  10352. }
  10353. }
  10354. if is390 == 1 {
  10355. insutype = "390"
  10356. }
  10357. if is310 == 1 {
  10358. insutype = "310"
  10359. }
  10360. if len(insutypes) == 2 {
  10361. insutype = insutype_two
  10362. }
  10363. if len(insutypes) == 0 {
  10364. insutype = "310"
  10365. }
  10366. insutype = insutype_two
  10367. fmt.Println(insutype)
  10368. for _, item := range rf {
  10369. fmt.Println(item.Insutype)
  10370. fmt.Println(insutype)
  10371. if item.Insutype == insutype {
  10372. fmt.Println(item.Insutype)
  10373. fmt.Println(insutype)
  10374. insuplc_admdvs = item.InsuplcAdmdvs
  10375. }
  10376. }
  10377. fmt.Println(insuplc_admdvs)
  10378. var res2 ResultThirteen
  10379. var res10265_2 ResultThirteen10265
  10380. if config.IsOpen == 1 {
  10381. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10382. } else {
  10383. 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)
  10384. var dat map[string]interface{}
  10385. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10386. fmt.Println(dat)
  10387. } else {
  10388. fmt.Println(err)
  10389. }
  10390. userJSONBytes, _ := json.Marshal(dat)
  10391. if miConfig.Code == "H15049901371" {
  10392. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  10393. utils.ErrorLog("解析失败:%v", err)
  10394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10395. return
  10396. }
  10397. res2.ErrMsg = res10265_2.ErrMsg
  10398. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  10399. res2.Infcode = infocode
  10400. res2.Output = res10265_2.Output
  10401. res2.InfRefmsgid = res10265_2.InfRefmsgid
  10402. } else {
  10403. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10404. utils.ErrorLog("解析失败:%v", err)
  10405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10406. return
  10407. }
  10408. }
  10409. }
  10410. if res2.Infcode == 0 {
  10411. psnResult := &models.GdybPsnNcdsRecord{
  10412. UserOrgId: adminUser.CurrentOrgId,
  10413. PatientId: patient.ID,
  10414. PsnNo: psn_no,
  10415. DoctorId: doctor.AdminUserId,
  10416. DepartmentId: department_id,
  10417. SickType: sick_id,
  10418. Insutype: insutype,
  10419. Ctime: time.Now().Unix(),
  10420. Mtime: time.Now().Unix(),
  10421. Status: 1,
  10422. IsCancel: 1,
  10423. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10424. }
  10425. service.CreatePsnNCDSRecord(psnResult)
  10426. c.ServeSuccessJSON(map[string]interface{}{
  10427. "failed_code": 0,
  10428. "msg": "备案成功",
  10429. "result": psnResult,
  10430. })
  10431. } else {
  10432. c.ServeSuccessJSON(map[string]interface{}{
  10433. "failed_code": -10,
  10434. "msg": res2.ErrMsg,
  10435. })
  10436. return
  10437. }
  10438. }
  10439. }
  10440. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  10441. id, _ := c.GetInt64("id")
  10442. admin_user_id, _ := c.GetInt64("admin_user_id")
  10443. adminUser := c.GetAdminUserInfo()
  10444. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10445. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10446. //config, _ := service.Ge(adminUser.CurrentOrgId)
  10447. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  10448. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10449. //var user_name string
  10450. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10451. //if role.ID == 0 {
  10452. // user_name = "xxx"
  10453. //} else {
  10454. // user_name = role.UserName
  10455. //}
  10456. psn_record, _ := service.GetPsnNCDSRecordById(id)
  10457. if psn_record.ID == 0 {
  10458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10459. return
  10460. }
  10461. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10462. var res ResultTwo
  10463. var res10265 ResultTwo10265
  10464. if miConfig.Code == "H15049901371" {
  10465. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10466. utils.ErrorLog("解析失败:%v", err)
  10467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10468. return
  10469. }
  10470. res.ErrMsg = res10265.ErrMsg
  10471. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10472. res.Infcode = infocode
  10473. res.Output = res10265.Output
  10474. res.InfRefmsgid = res10265.InfRefmsgid
  10475. } else {
  10476. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10477. utils.ErrorLog("解析失败:%v", err)
  10478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10479. return
  10480. }
  10481. }
  10482. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10483. infoStr := string(Iinfos)
  10484. var rf []*ResultFive
  10485. json.Unmarshal([]byte(infoStr), &rf)
  10486. var insuplc_admdvs string
  10487. var insutype string
  10488. var is390 int = 0
  10489. var is310 int = 0
  10490. var insutypes []*ResultFive
  10491. for _, item := range rf {
  10492. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10493. insutypes = append(insutypes, item)
  10494. }
  10495. }
  10496. if len(insutypes) == 1 {
  10497. insutype = insutypes[0].Insutype
  10498. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10499. } else {
  10500. for _, i := range insutypes {
  10501. if i.Insutype == "390" {
  10502. is390 = 1
  10503. }
  10504. if i.Insutype == "310" {
  10505. is310 = 1
  10506. }
  10507. }
  10508. }
  10509. if is390 == 1 {
  10510. insutype = "390"
  10511. }
  10512. if is310 == 1 {
  10513. insutype = "310"
  10514. }
  10515. if len(insutypes) == 0 {
  10516. insutype = "310"
  10517. }
  10518. insutype = psn_record.Insutype
  10519. for _, item := range rf {
  10520. if item.Insutype == insutype {
  10521. insuplc_admdvs = item.InsuplcAdmdvs
  10522. }
  10523. }
  10524. if config.IsOpen == 1 {
  10525. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10526. var dat map[string]interface{}
  10527. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10528. fmt.Println(dat)
  10529. } else {
  10530. fmt.Println(err)
  10531. }
  10532. userJSONBytes, _ := json.Marshal(dat)
  10533. var res ResultFourteen
  10534. var res10265 ResultFourteen10265
  10535. if miConfig.Code == "H15049901371" {
  10536. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10537. utils.ErrorLog("解析失败:%v", err)
  10538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10539. return
  10540. }
  10541. res.ErrMsg = res10265.ErrMsg
  10542. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10543. res.Infcode = infocode
  10544. res.Output = res10265.Output
  10545. res.InfRefmsgid = res10265.InfRefmsgid
  10546. } else {
  10547. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10548. utils.ErrorLog("解析失败:%v", err)
  10549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10550. return
  10551. }
  10552. }
  10553. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10554. // utils.ErrorLog("解析失败:%v", err)
  10555. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10556. // return
  10557. //}
  10558. if res.Infcode == 0 {
  10559. psn_record.IsCancel = 2
  10560. service.CreatePsnNCDSRecord(&psn_record)
  10561. c.ServeSuccessJSON(map[string]interface{}{
  10562. "failed_code": 0,
  10563. "msg": "撤销备案成功",
  10564. })
  10565. } else {
  10566. c.ServeSuccessJSON(map[string]interface{}{
  10567. "failed_code": -10,
  10568. "msg": res.ErrMsg,
  10569. })
  10570. return
  10571. }
  10572. }
  10573. }
  10574. func (c *HisApiController) TestTest() {
  10575. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  10576. fmt.Println(patient.Iinfo)
  10577. }
  10578. type CustomData struct {
  10579. MsgId string
  10580. PsnNo string
  10581. Info string
  10582. }
  10583. func (c *HisApiController) ReversalData() {
  10584. var customData []*CustomData
  10585. custom := &CustomData{
  10586. MsgId: "H44022900158202103301714472004",
  10587. PsnNo: "44020000001101329945",
  10588. Info: "2207",
  10589. }
  10590. customData = append(customData, custom)
  10591. custom1 := &CustomData{
  10592. MsgId: "H4402290015820210330172057803",
  10593. PsnNo: "44020000001101161813",
  10594. Info: "2207",
  10595. }
  10596. customData = append(customData, custom1)
  10597. custom2 := &CustomData{
  10598. MsgId: "H44022900158202103301705198813",
  10599. PsnNo: "44190000133097375417",
  10600. Info: "2207",
  10601. }
  10602. customData = append(customData, custom2)
  10603. custom3 := &CustomData{
  10604. MsgId: "H44022900158202103301715524756",
  10605. PsnNo: "44020000001100187221",
  10606. Info: "2207",
  10607. }
  10608. customData = append(customData, custom3)
  10609. custom4 := &CustomData{
  10610. MsgId: "H44022900158202103301730376224",
  10611. PsnNo: "44020000001101959155",
  10612. Info: "2207",
  10613. }
  10614. customData = append(customData, custom4)
  10615. custom5 := &CustomData{
  10616. MsgId: "H44022900158202103301748008725",
  10617. PsnNo: "44020000001104246641",
  10618. Info: "2207",
  10619. }
  10620. customData = append(customData, custom5)
  10621. custom6 := &CustomData{
  10622. MsgId: "H44022900158202103301718096755",
  10623. PsnNo: "44020000001102211860",
  10624. Info: "2207",
  10625. }
  10626. customData = append(customData, custom6)
  10627. custom7 := &CustomData{
  10628. MsgId: "H44022900158202103301736551640",
  10629. PsnNo: "44020000001102687718",
  10630. Info: "2207",
  10631. }
  10632. customData = append(customData, custom7)
  10633. custom8 := &CustomData{
  10634. MsgId: "H44022900158202103301743097676",
  10635. PsnNo: "44020000001102127785",
  10636. Info: "2207",
  10637. }
  10638. customData = append(customData, custom8)
  10639. custom9 := &CustomData{
  10640. MsgId: "H44022900158202103301712304203",
  10641. PsnNo: "44020000001101518097",
  10642. Info: "2207",
  10643. }
  10644. customData = append(customData, custom9)
  10645. custom10 := &CustomData{
  10646. MsgId: "H44022900158202103301738448785",
  10647. PsnNo: "44020000001100500813",
  10648. Info: "2207",
  10649. }
  10650. customData = append(customData, custom10)
  10651. custom11 := &CustomData{
  10652. MsgId: "H44022900158202103301732455843",
  10653. PsnNo: "44020000001102690557",
  10654. Info: "2207",
  10655. }
  10656. customData = append(customData, custom11)
  10657. custom12 := &CustomData{
  10658. MsgId: "H44022900158202103301745421708",
  10659. PsnNo: "44020000001102211928",
  10660. Info: "2207",
  10661. }
  10662. customData = append(customData, custom12)
  10663. custom1212 := &CustomData{
  10664. MsgId: "H440229001582021033017351627",
  10665. PsnNo: "44020000001102481733",
  10666. Info: "2207",
  10667. }
  10668. customData = append(customData, custom1212)
  10669. custom13 := &CustomData{
  10670. MsgId: "H44022900158202103301740327951",
  10671. PsnNo: "44020000001103174866",
  10672. Info: "2207",
  10673. }
  10674. customData = append(customData, custom13)
  10675. custom14 := &CustomData{
  10676. MsgId: "H4402290015820210330174922668",
  10677. PsnNo: "44020000001102927272",
  10678. Info: "2207",
  10679. }
  10680. customData = append(customData, custom14)
  10681. custom15 := &CustomData{
  10682. MsgId: "H44022900158202103301752362273",
  10683. PsnNo: "44020000001102942890",
  10684. Info: "2207",
  10685. }
  10686. customData = append(customData, custom15)
  10687. custom16 := &CustomData{
  10688. MsgId: "H44022900158202103301751082917",
  10689. PsnNo: "44020000001101662162",
  10690. Info: "2207",
  10691. }
  10692. customData = append(customData, custom16)
  10693. custom17 := &CustomData{
  10694. MsgId: "H44022900158202103301754147728",
  10695. PsnNo: "44020000000229014511",
  10696. Info: "2207",
  10697. }
  10698. customData = append(customData, custom17)
  10699. adminUser := c.GetAdminUserInfo()
  10700. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10701. for _, item := range customData {
  10702. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10703. fmt.Println(result)
  10704. }
  10705. }
  10706. //func (c *HisApiController) GetAllopatry() {
  10707. // year := c.GetString("year")
  10708. // month := c.GetString("month")
  10709. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10710. // adminUser := c.GetAdminUserInfo()
  10711. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10712. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10713. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10714. //
  10715. // var dat map[string]interface{}
  10716. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10717. // fmt.Println(dat)
  10718. // } else {
  10719. // fmt.Println(err)
  10720. // }
  10721. // userJSONBytes, _ := json.Marshal(dat)
  10722. // var res models.Result9001
  10723. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10724. // utils.ErrorLog("解析失败:%v", err)
  10725. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10726. // return
  10727. // }
  10728. //
  10729. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10730. // var dat2 map[string]interface{}
  10731. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10732. // fmt.Println(dat)
  10733. // } else {
  10734. // fmt.Println(err)
  10735. // }
  10736. // userJSONBytes2, _ := json.Marshal(dat2)
  10737. // var res2 models.Result3260
  10738. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10739. // utils.ErrorLog("解析失败:%v", err)
  10740. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10741. // return
  10742. // }
  10743. // if res2.Infcode == 0 {
  10744. // c.ServeSuccessJSON(map[string]interface{}{
  10745. // "list": res2.Output.Data,
  10746. // })
  10747. // return
  10748. // } else {
  10749. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10750. // return
  10751. // }
  10752. //
  10753. //}
  10754. //func (c *HisApiController) ComfirmAllopatry() {
  10755. // year := c.GetString("year")
  10756. // month := c.GetString("month")
  10757. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10758. // adminUser := c.GetAdminUserInfo()
  10759. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10760. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10761. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10762. // var dat map[string]interface{}
  10763. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10764. // fmt.Println(dat)
  10765. // } else {
  10766. // fmt.Println(err)
  10767. // }
  10768. // userJSONBytes, _ := json.Marshal(dat)
  10769. // var res models.Result9001
  10770. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10771. // utils.ErrorLog("解析失败:%v", err)
  10772. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10773. // return
  10774. // }
  10775. //
  10776. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10777. // var dat2 map[string]interface{}
  10778. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10779. // fmt.Println(dat)
  10780. // } else {
  10781. // fmt.Println(err)
  10782. // }
  10783. // userJSONBytes2, _ := json.Marshal(dat2)
  10784. // var res2 models.Result3260
  10785. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10786. // utils.ErrorLog("解析失败:%v", err)
  10787. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10788. // return
  10789. // }
  10790. //
  10791. // if res2.Infcode == 0 {
  10792. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  10793. // var dat map[string]interface{}
  10794. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10795. // fmt.Println(dat)
  10796. // } else {
  10797. // fmt.Println(err)
  10798. // }
  10799. // userJSONBytes, _ := json.Marshal(dat)
  10800. // var res3 models.Result3261
  10801. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  10802. // utils.ErrorLog("解析失败:%v", err)
  10803. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10804. // return
  10805. // }
  10806. //
  10807. // if res3.Infcode == 0 {
  10808. // record := &models.HisYidiClearRecord{
  10809. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10810. // Ctime: time.Now().Unix(),
  10811. // Mtime: time.Now().Unix(),
  10812. // Status: 1,
  10813. // MsgId: msgId,
  10814. // }
  10815. // service.SaveClearRecord(record)
  10816. // c.ServeSuccessJSON(map[string]interface{}{
  10817. // "msg": "提取成功",
  10818. // })
  10819. // }
  10820. // }
  10821. //}
  10822. func (c *HisApiController) RefundAllopatry() {
  10823. year := c.GetString("year")
  10824. month := c.GetString("month")
  10825. id, _ := c.GetInt64("id")
  10826. admin_user_id, _ := c.GetInt64("admin_user_id")
  10827. adminUser := c.GetAdminUserInfo()
  10828. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10829. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10830. record, _ := service.GetClearRecordById(id)
  10831. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  10832. var dat map[string]interface{}
  10833. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10834. fmt.Println(dat)
  10835. } else {
  10836. fmt.Println(err)
  10837. }
  10838. userJSONBytes, _ := json.Marshal(dat)
  10839. var empty ResultFourteen
  10840. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  10841. utils.ErrorLog("解析失败:%v", err)
  10842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10843. return
  10844. }
  10845. if empty.Infcode == 0 {
  10846. c.ServeSuccessJSON(map[string]interface{}{
  10847. "msg": "撤销成功",
  10848. })
  10849. return
  10850. }
  10851. }
  10852. func (c *HisApiController) ReversalOtherData() {
  10853. var customData []*CustomData
  10854. custom := &CustomData{
  10855. MsgId: "H44022900158202103301714472004",
  10856. PsnNo: "44020000001101329945",
  10857. Info: "2208",
  10858. }
  10859. customData = append(customData, custom)
  10860. custom1 := &CustomData{
  10861. MsgId: "H4402290015820210330172057803",
  10862. PsnNo: "44020000001101161813",
  10863. Info: "2208",
  10864. }
  10865. customData = append(customData, custom1)
  10866. custom2 := &CustomData{
  10867. MsgId: "H44022900158202103301705198813",
  10868. PsnNo: "44190000133097375417",
  10869. Info: "2208",
  10870. }
  10871. customData = append(customData, custom2)
  10872. custom3 := &CustomData{
  10873. MsgId: "H44022900158202103301715524756",
  10874. PsnNo: "44020000001100187221",
  10875. Info: "2208",
  10876. }
  10877. customData = append(customData, custom3)
  10878. custom4 := &CustomData{
  10879. MsgId: "H44022900158202103301730376224",
  10880. PsnNo: "44020000001101959155",
  10881. Info: "2208",
  10882. }
  10883. customData = append(customData, custom4)
  10884. custom5 := &CustomData{
  10885. MsgId: "H44022900158202103301748008725",
  10886. PsnNo: "44020000001104246641",
  10887. Info: "2208",
  10888. }
  10889. customData = append(customData, custom5)
  10890. custom6 := &CustomData{
  10891. MsgId: "H44022900158202103301718096755",
  10892. PsnNo: "44020000001102211860",
  10893. Info: "2208",
  10894. }
  10895. customData = append(customData, custom6)
  10896. custom7 := &CustomData{
  10897. MsgId: "H44022900158202103301736551640",
  10898. PsnNo: "44020000001102687718",
  10899. Info: "2208",
  10900. }
  10901. customData = append(customData, custom7)
  10902. custom8 := &CustomData{
  10903. MsgId: "H44022900158202103301743097676",
  10904. PsnNo: "44020000001102127785",
  10905. Info: "2208",
  10906. }
  10907. customData = append(customData, custom8)
  10908. custom9 := &CustomData{
  10909. MsgId: "H44022900158202103301712304203",
  10910. PsnNo: "44020000001101518097",
  10911. Info: "2208",
  10912. }
  10913. customData = append(customData, custom9)
  10914. custom10 := &CustomData{
  10915. MsgId: "H44022900158202103301738448785",
  10916. PsnNo: "44020000001100500813",
  10917. Info: "2208",
  10918. }
  10919. customData = append(customData, custom10)
  10920. custom11 := &CustomData{
  10921. MsgId: "H44022900158202103301732455843",
  10922. PsnNo: "44020000001102690557",
  10923. Info: "2208",
  10924. }
  10925. customData = append(customData, custom11)
  10926. custom12 := &CustomData{
  10927. MsgId: "H44022900158202103301745421708",
  10928. PsnNo: "44020000001102211928",
  10929. Info: "2208",
  10930. }
  10931. customData = append(customData, custom12)
  10932. custom1212 := &CustomData{
  10933. MsgId: "H440229001582021033017351627",
  10934. PsnNo: "44020000001102481733",
  10935. Info: "2208",
  10936. }
  10937. customData = append(customData, custom1212)
  10938. custom13 := &CustomData{
  10939. MsgId: "H44022900158202103301740327951",
  10940. PsnNo: "44020000001103174866",
  10941. Info: "2208",
  10942. }
  10943. customData = append(customData, custom13)
  10944. custom14 := &CustomData{
  10945. MsgId: "H4402290015820210330174922668",
  10946. PsnNo: "44020000001102927272",
  10947. Info: "2208",
  10948. }
  10949. customData = append(customData, custom14)
  10950. custom15 := &CustomData{
  10951. MsgId: "H44022900158202103301752362273",
  10952. PsnNo: "44020000001102942890",
  10953. Info: "2208",
  10954. }
  10955. customData = append(customData, custom15)
  10956. custom16 := &CustomData{
  10957. MsgId: "H44022900158202103301751082917",
  10958. PsnNo: "44020000001101662162",
  10959. Info: "2208",
  10960. }
  10961. customData = append(customData, custom16)
  10962. custom17 := &CustomData{
  10963. MsgId: "H44022900158202103301754147728",
  10964. PsnNo: "44020000000229014511",
  10965. Info: "2208",
  10966. }
  10967. customData = append(customData, custom17)
  10968. adminUser := c.GetAdminUserInfo()
  10969. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10970. for _, item := range customData {
  10971. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10972. fmt.Println(result)
  10973. }
  10974. }
  10975. func PathExists(path string) (bool, error) {
  10976. _, err := os.Stat(path)
  10977. if err == nil {
  10978. return true, nil
  10979. }
  10980. if os.IsNotExist(err) {
  10981. return false, nil
  10982. }
  10983. return false, err
  10984. }
  10985. //创建文件夹
  10986. func Mkdir(dir string) {
  10987. // 创建文件夹
  10988. exist, err := PathExists(dir)
  10989. if err != nil {
  10990. fmt.Println(err.Error())
  10991. } else {
  10992. if exist {
  10993. fmt.Println(dir + "文件夹已存在!")
  10994. } else {
  10995. // 文件夹名称,权限
  10996. err := os.Mkdir(dir, os.ModePerm)
  10997. if err != nil {
  10998. fmt.Println(dir+"文件夹创建失败:", err.Error())
  10999. } else {
  11000. fmt.Println(dir + "文件夹创建成功!")
  11001. }
  11002. }
  11003. }
  11004. }
  11005. //压缩文件
  11006. func Zip(srcFile string, destZip string) error {
  11007. zipfile, err := os.Create(destZip)
  11008. if err != nil {
  11009. return err
  11010. }
  11011. defer zipfile.Close()
  11012. archive := zip.NewWriter(zipfile)
  11013. defer archive.Close()
  11014. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  11015. if err != nil {
  11016. return err
  11017. }
  11018. header, err := zip.FileInfoHeader(info)
  11019. if err != nil {
  11020. return err
  11021. }
  11022. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  11023. // header.Name = path
  11024. if info.IsDir() {
  11025. header.Name += "/"
  11026. } else {
  11027. header.Method = zip.Deflate
  11028. }
  11029. writer, err := archive.CreateHeader(header)
  11030. if err != nil {
  11031. return err
  11032. }
  11033. if !info.IsDir() {
  11034. file, err := os.Open(path)
  11035. if err != nil {
  11036. return err
  11037. }
  11038. defer file.Close()
  11039. _, err = io.Copy(writer, file)
  11040. }
  11041. return err
  11042. })
  11043. return err
  11044. }
  11045. func ReadFile(filePath string) []byte {
  11046. f, err := os.Open(filePath)
  11047. if err != nil {
  11048. fmt.Println("read file fail", err)
  11049. return nil
  11050. }
  11051. defer f.Close()
  11052. fd, err := ioutil.ReadAll(f)
  11053. if err != nil {
  11054. fmt.Println("read to fd fail", err)
  11055. return nil
  11056. }
  11057. return fd
  11058. }
  11059. func saveLog(result string, request string, infno string, desc string) {
  11060. org_id, _ := beego.AppConfig.Int64("org_id")
  11061. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  11062. dir := miConfig.OrgName + "日志"
  11063. utils.Mkdir(dir)
  11064. month := time.Unix(1557042972, 0).Format("1")
  11065. year := time.Now().Format("2006")
  11066. month = time.Now().Format("01")
  11067. day := time.Now().Format("02")
  11068. hour := time.Now().Format("15")
  11069. min := time.Now().Format("04")
  11070. sec := time.Now().Format("05")
  11071. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  11072. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  11073. file_name := file + ".txt"
  11074. file_path := miConfig.OrgName + "日志" + "/" + file_name
  11075. exist, _ := utils.PathExists(file_path)
  11076. if exist { //存在
  11077. fmt.Println("存在")
  11078. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  11079. if err != nil {
  11080. fmt.Println("read fail")
  11081. }
  11082. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  11083. n, _ := f.Seek(0, 2)
  11084. _, err = f.WriteAt([]byte(content), n)
  11085. } else { //不存在
  11086. fmt.Println("文件不存在,创建文件")
  11087. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  11088. defer f.Close()
  11089. if err != nil {
  11090. } else {
  11091. _, err = f.Write([]byte("记录日志"))
  11092. }
  11093. }
  11094. }
  11095. type Charset string
  11096. const (
  11097. UTF8 = Charset("UTF-8")
  11098. GB18030 = Charset("GB18030")
  11099. )
  11100. func ConvertToString(src string, srcCode string, tagCode string) string {
  11101. srcCoder := mahonia.NewDecoder(srcCode)
  11102. srcResult := srcCoder.ConvertString(src)
  11103. tagCoder := mahonia.NewDecoder(tagCode)
  11104. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  11105. result := string(cdata)
  11106. return result
  11107. }
  11108. func (c *HisApiController) ReadEleCard() {
  11109. id_card_type, _ := c.GetInt64("id_card_type")
  11110. admin_user_id, _ := c.GetInt64("admin_user_id")
  11111. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  11112. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11113. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11114. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11115. var api string
  11116. if miConfig.MdtrtareaAdmvs == "320921" {
  11117. 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 +
  11118. "&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
  11119. fmt.Println(api)
  11120. } else {
  11121. 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 +
  11122. "&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
  11123. }
  11124. resp, requestErr := http.Get(api)
  11125. if requestErr != nil {
  11126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11127. return
  11128. }
  11129. body, ioErr := ioutil.ReadAll(resp.Body)
  11130. if ioErr != nil {
  11131. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11133. return
  11134. }
  11135. var respJSON map[string]interface{}
  11136. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11137. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11139. return
  11140. }
  11141. var status string
  11142. status = respJSON["data"].(map[string]interface{})["status"].(string)
  11143. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  11144. var token string
  11145. var res ResultTwo //1101结果
  11146. var res10265 ResultTwo10265 //1101结果
  11147. if status == "0" { //读卡成功
  11148. var card_info string //卡信息
  11149. var busi_card_info string
  11150. token = respJSON["data"].(map[string]interface{})["token"].(string)
  11151. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  11152. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  11153. fmt.Println(card_info)
  11154. fmt.Println(busi_card_info)
  11155. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  11156. result, _ := json.Marshal(respJSON)
  11157. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11158. utils.ErrorLog("解析失败:%v", err)
  11159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11160. return
  11161. }
  11162. res.ErrMsg = res10265.ErrMsg
  11163. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11164. res.Infcode = infocode
  11165. res.Output = res10265.Output
  11166. res.InfRefmsgid = res10265.InfRefmsgid
  11167. if res.Infcode == 0 {
  11168. c.ServeSuccessJSON(map[string]interface{}{
  11169. "number": token,
  11170. })
  11171. }
  11172. } else {
  11173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11174. return
  11175. }
  11176. } else { //读卡失败
  11177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11178. return
  11179. }
  11180. }
  11181. func DeleteExtraSpaceTwo(s string) string {
  11182. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11183. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11184. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11185. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11186. s2 := make([]byte, len(s1)) //定义字符数组切片
  11187. copy(s2, s1) //将字符串复制到切片
  11188. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11189. for len(spc_index) > 0 { //找到适配项
  11190. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11191. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11192. }
  11193. return string(s2)
  11194. }
  11195. func Remove0000(s string) string {
  11196. str := make([]rune, 0, len(s))
  11197. for _, v := range []rune(s) {
  11198. if v == 0 {
  11199. continue
  11200. }
  11201. str = append(str, v)
  11202. }
  11203. return string(str)
  11204. }
  11205. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  11206. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  11207. readCard := DllDef.MustFindProc("EcQuery")
  11208. pCardInfo := make([]byte, 8192)
  11209. pBusiCardInfo := make([]byte, 8192)
  11210. data := make(map[string]interface{})
  11211. //pData := make(map[string]interface{})
  11212. inputData := make(map[string]interface{})
  11213. inputData["orgId"] = code
  11214. inputData["businessType"] = "01101"
  11215. inputData["operatorId"] = operator_id
  11216. inputData["operatorName"] = operator_name
  11217. inputData["officeId"] = "001"
  11218. inputData["officeName"] = "血透室"
  11219. //
  11220. data["data"] = inputData
  11221. data["transType"] = "ec.query"
  11222. data["orgId"] = code
  11223. bytesData, _ := json.Marshal(data)
  11224. pCardInfo = bytesData
  11225. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  11226. fmt.Println(ret2)
  11227. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  11228. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11229. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  11230. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11231. if ret2 != 0 {
  11232. return "", ""
  11233. }
  11234. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  11235. }
  11236. func DeleteExtraSpace(s string) string {
  11237. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11238. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11239. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11240. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11241. s2 := make([]byte, len(s1)) //定义字符数组切片
  11242. copy(s2, s1) //将字符串复制到切片
  11243. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11244. for len(spc_index) > 0 { //找到适配项
  11245. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11246. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11247. }
  11248. return string(s2)
  11249. }