his_api_controller.go 450KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326
  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. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  50. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  51. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  52. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  53. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  54. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  55. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  56. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  57. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  58. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  59. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  60. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  61. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  62. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  63. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  64. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  65. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  66. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  67. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  68. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  69. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  70. //beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  71. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  72. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  73. beego.Router("/api/check", &HisApiController{}, "get:Check")
  74. beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  75. beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  76. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  77. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  78. beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  79. }
  80. func (c *HisApiController) Get9001() {
  81. adminUser := c.GetAdminUserInfo()
  82. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  83. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  84. if miConfig.MdtrtareaAdmvs == "350500" {
  85. fmt.Println("350500")
  86. service.GetFjAuthorizationInfo(miConfig.Code)
  87. } else {
  88. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  89. var dat map[string]interface{}
  90. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  91. fmt.Println(dat)
  92. } else {
  93. fmt.Println(err)
  94. }
  95. userJSONBytes, _ := json.Marshal(dat)
  96. var res models.Result9001
  97. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  98. utils.ErrorLog("解析失败:%v", err)
  99. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  100. return
  101. }
  102. }
  103. }
  104. func (c *HisApiController) Check3101() {
  105. patient_id, _ := c.GetInt64("patient_id")
  106. his_patient_id, _ := c.GetInt64("his_patient_id")
  107. admin_user_id, _ := c.GetInt64("admin_user_id")
  108. adminUser := c.GetAdminUserInfo()
  109. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  110. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  111. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  112. record_time := c.GetString("record_time")
  113. trig_scen := c.GetString("trig_scen")
  114. timeLayout := "2006-01-02"
  115. loc, _ := time.LoadLocation("Local")
  116. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  117. if err != nil {
  118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  119. return
  120. }
  121. recordDateTime := theTime.Unix()
  122. var patientPrescription models.HisPrescriptionInfo
  123. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  124. if patientPrescription.ID == 0 {
  125. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  126. }
  127. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  128. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  129. //
  130. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  131. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  132. var pp models.PublicParams
  133. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  134. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  135. pp.FixmedinsName = miConfig.OrgName
  136. pp.FixmedinsCode = miConfig.Code
  137. pp.RequestUrl = miConfig.Url
  138. pp.Cainfo = miConfig.Cainfo
  139. pp.SecretKey = miConfig.SecretKey
  140. pp.AccessKey = miConfig.AccessKey
  141. pp.OpterName = roles.UserName
  142. var config []*models.HisXtDiagnoseConfig
  143. for _, item := range diagnosis_ids {
  144. id, _ := strconv.ParseInt(item, 10, 64)
  145. diagnosisConfig, _ := service.FindDiagnoseById(id)
  146. config = append(config, &diagnosisConfig)
  147. }
  148. var pd models.PatientDtos
  149. pd.PatnID = his.PsnNo
  150. pd.PatnName = his.Name
  151. pd.Gend = his.Gend
  152. pd.Brdy = his.Brdy
  153. pd.Poolarea = his.InsuplcAdmdvs
  154. pd.CurrMdtrtID = his.Number
  155. var fed models.FsiEncounterDtos
  156. fed.MdtrtID = his.Number
  157. fed.MedinsID = miConfig.Code
  158. fed.MedinsName = miConfig.OrgName
  159. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  160. fed.MedMdtrtType = "1"
  161. fed.MedinsType = "1"
  162. fed.MedinsLv = "11"
  163. tm := time.Unix(his.RecordDate, 0)
  164. s_tm := tm.Format("2006-01-02 15:04:05")
  165. fed.AdmDate = s_tm
  166. fed.DscgDate = s_tm
  167. fed.DscgMainDiseCodg = config[0].CountryCode
  168. fed.DscgMainDiseName = config[0].CountryContentName
  169. //诊断信息
  170. var fdds []*models.FsiDiagnoseDtos
  171. for index, item := range config {
  172. if index == 0 {
  173. var fdd models.FsiDiagnoseDtos
  174. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  175. fdd.InoutDiseType = "1"
  176. fdd.MaindiseFlag = "1"
  177. fdd.DiseDate = s_tm
  178. fdd.DiasSrtNo = "1"
  179. fdd.DiseName = item.CountryContentName
  180. fdd.DiseCodg = item.CountryCode
  181. fdds = append(fdds, &fdd)
  182. } else {
  183. var fdd models.FsiDiagnoseDtos
  184. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  185. fdd.InoutDiseType = "1"
  186. fdd.MaindiseFlag = "1"
  187. fdd.DiseDate = s_tm
  188. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  189. fdd.DiseName = item.CountryContentName
  190. fdd.DiseCodg = item.CountryCode
  191. fdds = append(fdds, &fdd)
  192. }
  193. }
  194. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  195. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  196. fed.AdmDeptName = department.Name
  197. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  198. fed.DscgDeptName = department.Name
  199. fed.MedMdtrtType = "1"
  200. fed.MedType = "11"
  201. //if his.Insutype == "390" {
  202. // fed.MedType = "1402"
  203. //} else {
  204. // fed.MedType = "9933"
  205. //}
  206. var orders []*models.FsiOrderDtos
  207. if trig_scen == "2" {
  208. //处方医嘱信息
  209. for _, item := range prescriptions {
  210. for _, subItem := range item.HisDoctorAdviceInfo {
  211. var order models.FsiOrderDtos
  212. order.RxID = strconv.FormatInt(item.ID, 10)
  213. order.Rxno = strconv.FormatInt(item.ID, 10)
  214. order.LongDrordFlag = "0"
  215. order.HilistType = "1"
  216. order.ChrgType = "1"
  217. order.DrordBhvr = "-"
  218. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  219. order.HosplistName = subItem.BaseDrugLib.DrugName
  220. order.HilistLv = "1"
  221. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  222. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  223. order.HosplistName = subItem.BaseDrugLib.DrugName
  224. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  225. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  226. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  227. order.OwnpayAmt = ""
  228. order.SelfpayAmt = ""
  229. order.Spec = ""
  230. order.SpecUnt = ""
  231. order.DrordBegnDate = s_tm
  232. order.DrordStopDate = ""
  233. order.DrordDrCodg = "1"
  234. order.DrordDeptName = department.Name
  235. order.DrordDrCodg = "1"
  236. order.DrordDrName = doctor_info.UserName
  237. order.DrordDrProfttl = ""
  238. order.CurrDrordFlag = "1"
  239. orders = append(orders, &order)
  240. }
  241. for _, subItem := range item.HisPrescriptionProject {
  242. if subItem.Type == 2 {
  243. var order models.FsiOrderDtos
  244. order.RxID = strconv.FormatInt(item.ID, 10)
  245. order.Rxno = strconv.FormatInt(item.ID, 10)
  246. order.LongDrordFlag = "0"
  247. order.HilistType = "1"
  248. order.ChrgType = "1"
  249. order.DrordBhvr = "-"
  250. order.HilistCode = subItem.HisProject.MedicalCode
  251. order.HosplistName = subItem.HisProject.ProjectName
  252. order.HilistLv = "1"
  253. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  254. order.HosplistCode = subItem.HisProject.MedicalCode
  255. order.HosplistName = subItem.HisProject.ProjectName
  256. order.Cnt = subItem.Count
  257. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  258. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  259. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  260. order.OwnpayAmt = ""
  261. order.SelfpayAmt = ""
  262. order.Spec = ""
  263. order.SpecUnt = ""
  264. order.DrordBegnDate = s_tm
  265. order.DrordStopDate = ""
  266. order.DrordDrCodg = "1"
  267. order.DrordDeptName = department.Name
  268. order.DrordDrCodg = "1"
  269. order.DrordDrName = doctor_info.UserName
  270. order.DrordDrProfttl = ""
  271. order.CurrDrordFlag = "1"
  272. orders = append(orders, &order)
  273. }
  274. if subItem.Type == 3 {
  275. var order models.FsiOrderDtos
  276. order.RxID = strconv.FormatInt(item.ID, 10)
  277. order.Rxno = strconv.FormatInt(item.ID, 10)
  278. order.LongDrordFlag = "0"
  279. order.HilistType = "1"
  280. order.ChrgType = "1"
  281. order.DrordBhvr = "-"
  282. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  283. order.HosplistName = subItem.GoodInfo.GoodName
  284. order.HilistLv = "1"
  285. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  286. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  287. order.HosplistName = subItem.GoodInfo.GoodName
  288. order.Cnt = subItem.Count
  289. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  290. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  291. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  292. order.OwnpayAmt = ""
  293. order.SelfpayAmt = ""
  294. order.Spec = ""
  295. order.SpecUnt = ""
  296. order.DrordBegnDate = s_tm
  297. order.DrordStopDate = ""
  298. order.DrordDrCodg = "1"
  299. order.DrordDeptName = department.Name
  300. order.DrordDrCodg = "1"
  301. order.DrordDrName = doctor_info.UserName
  302. order.DrordDrProfttl = ""
  303. order.CurrDrordFlag = "1"
  304. orders = append(orders, &order)
  305. }
  306. }
  307. }
  308. //处方医嘱信息
  309. }
  310. fed.MatnStas = "0"
  311. fed.MedfeeSumamt = "0"
  312. fed.OwnpayAmt = "0"
  313. fed.SelfpayAmt = "0"
  314. fed.AcctPayamt = "0"
  315. fed.MaAmt = "0"
  316. fed.HifpPayamt = "0"
  317. fed.SetlTotlnum = "1"
  318. fed.Insutype = his.Insutype
  319. fed.ReimFlag = "0"
  320. fed.OutSetlFlag = "0"
  321. var fopd []*models.FsiOperationDtosData
  322. data := make(map[string]interface{})
  323. data["fed"] = fed
  324. data["fdd"] = fdds
  325. data["fod"] = orders
  326. data["pd"] = pd
  327. data["pp"] = pp
  328. data["fopd"] = fopd
  329. data["trig_scen"] = trig_scen
  330. fmt.Println(data)
  331. fmt.Println(fed)
  332. fmt.Println(fdds)
  333. fmt.Println(orders)
  334. fmt.Println(pd)
  335. fmt.Println(pp)
  336. fmt.Println(fopd)
  337. client := &http.Client{}
  338. bytesData, _ := json.Marshal(data)
  339. var req *http.Request
  340. if miConfig.MdtrtareaAdmvs == "320921" {
  341. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  342. } else {
  343. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  344. }
  345. resp, _ := client.Do(req)
  346. defer resp.Body.Close()
  347. body, ioErr := ioutil.ReadAll(resp.Body)
  348. if ioErr != nil {
  349. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  351. return
  352. }
  353. var respJSON map[string]interface{}
  354. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  355. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  357. return
  358. }
  359. //手术操作集合
  360. //手术操作集合
  361. }
  362. func (c *HisApiController) Check3102() {
  363. patient_id, _ := c.GetInt64("patient_id")
  364. order_id, _ := c.GetInt64("order_id")
  365. his_patient_id, _ := c.GetInt64("his_patient_id")
  366. admin_user_id, _ := c.GetInt64("admin_user_id")
  367. trig_scen := c.GetString("trig_scen")
  368. adminUser := c.GetAdminUserInfo()
  369. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  370. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  371. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  372. record_time := c.GetString("record_time")
  373. order, _ := service.GetHisOrderByID(order_id)
  374. timeLayout := "2006-01-02"
  375. loc, _ := time.LoadLocation("Local")
  376. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  377. if err != nil {
  378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  379. return
  380. }
  381. recordDateTime := theTime.Unix()
  382. var patientPrescription models.HisPrescriptionInfo
  383. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  384. if patientPrescription.ID == 0 {
  385. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  386. }
  387. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  388. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  389. //
  390. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  391. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  392. var pp models.PublicParams
  393. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  394. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  395. pp.FixmedinsName = miConfig.OrgName
  396. pp.FixmedinsCode = miConfig.Code
  397. pp.RequestUrl = miConfig.Url
  398. pp.Cainfo = miConfig.Cainfo
  399. pp.SecretKey = miConfig.SecretKey
  400. pp.AccessKey = miConfig.AccessKey
  401. pp.OpterName = roles.UserName
  402. var config []*models.HisXtDiagnoseConfig
  403. for _, item := range diagnosis_ids {
  404. id, _ := strconv.ParseInt(item, 10, 64)
  405. diagnosisConfig, _ := service.FindDiagnoseById(id)
  406. config = append(config, &diagnosisConfig)
  407. }
  408. var pd models.PatientDtos
  409. pd.PatnID = his.PsnNo
  410. pd.PatnName = his.Name
  411. pd.Gend = his.Gend
  412. pd.Brdy = his.Brdy
  413. pd.Poolarea = his.InsuplcAdmdvs
  414. pd.CurrMdtrtID = his.Number
  415. var fed models.FsiEncounterDtos
  416. fed.MdtrtID = his.Number
  417. fed.MedinsID = miConfig.Code
  418. fed.MedinsName = miConfig.OrgName
  419. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  420. fed.MedMdtrtType = "1"
  421. fed.MedinsType = "1"
  422. fed.MedinsLv = "11"
  423. tm := time.Unix(his.RecordDate, 0)
  424. s_tm := tm.Format("2006-01-02 15:04:05")
  425. fed.AdmDate = s_tm
  426. fed.DscgDate = s_tm
  427. fed.DscgMainDiseCodg = config[0].CountryCode
  428. fed.DscgMainDiseName = config[0].CountryContentName
  429. //诊断信息
  430. var fdds []*models.FsiDiagnoseDtos
  431. for index, item := range config {
  432. if index == 0 {
  433. var fdd models.FsiDiagnoseDtos
  434. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  435. fdd.InoutDiseType = "1"
  436. fdd.MaindiseFlag = "1"
  437. fdd.DiseDate = s_tm
  438. fdd.DiasSrtNo = "1"
  439. fdd.DiseName = item.CountryContentName
  440. fdd.DiseCodg = item.CountryCode
  441. fdds = append(fdds, &fdd)
  442. } else {
  443. var fdd models.FsiDiagnoseDtos
  444. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  445. fdd.InoutDiseType = "1"
  446. fdd.MaindiseFlag = "1"
  447. fdd.DiseDate = s_tm
  448. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  449. fdd.DiseName = item.CountryContentName
  450. fdd.DiseCodg = item.CountryCode
  451. fdds = append(fdds, &fdd)
  452. }
  453. }
  454. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  455. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  456. fed.AdmDeptName = department.Name
  457. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  458. fed.DscgDeptName = department.Name
  459. fed.MedType = order.MedType
  460. //处方医嘱信息
  461. var orders []*models.FsiOrderDtos
  462. //for _, item := range prescriptions {
  463. // for _, subItem := range item.HisDoctorAdviceInfo {
  464. // var order models.FsiOrderDtos
  465. // order.RxID = strconv.FormatInt(item.ID, 10)
  466. // order.Rxno = strconv.FormatInt(item.ID, 10)
  467. // order.LongDrordFlag = "0"
  468. // order.HilistType = "1"
  469. // order.ChrgType = "1"
  470. // order.DrordBhvr = "-"
  471. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  472. // order.HosplistName = subItem.BaseDrugLib.DrugName
  473. // order.HilistLv = "1"
  474. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  475. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  476. // order.HosplistName = subItem.BaseDrugLib.DrugName
  477. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  478. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  479. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  480. // order.OwnpayAmt = ""
  481. // order.SelfpayAmt = ""
  482. // order.Spec = ""
  483. // order.SpecUnt = ""
  484. // order.DrordBegnDate = s_tm
  485. // order.DrordStopDate = ""
  486. // order.DrordDrCodg = "1"
  487. // order.DrordDeptName = department.Name
  488. // order.DrordDrCodg = "1"
  489. // order.DrordDrName = doctor_info.UserName
  490. // order.DrordDrProfttl = ""
  491. // order.CurrDrordFlag = "1"
  492. // orders = append(orders, &order)
  493. // }
  494. // for _, subItem := range item.HisPrescriptionProject {
  495. // if subItem.Type == 2 {
  496. // var order models.FsiOrderDtos
  497. // order.RxID = strconv.FormatInt(item.ID, 10)
  498. // order.Rxno = strconv.FormatInt(item.ID, 10)
  499. // order.LongDrordFlag = "0"
  500. // order.HilistType = "1"
  501. // order.ChrgType = "1"
  502. // order.DrordBhvr = "-"
  503. // order.HilistCode = subItem.HisProject.MedicalCode
  504. // order.HosplistName = subItem.HisProject.ProjectName
  505. // order.HilistLv = "1"
  506. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  507. // order.HosplistCode = subItem.HisProject.MedicalCode
  508. // order.HosplistName = subItem.HisProject.ProjectName
  509. // order.Cnt = subItem.Count
  510. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  511. //
  512. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  513. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  514. // order.OwnpayAmt = ""
  515. // order.SelfpayAmt = ""
  516. // order.Spec = ""
  517. // order.SpecUnt = ""
  518. // order.DrordBegnDate = s_tm
  519. // order.DrordStopDate = ""
  520. // order.DrordDrCodg = "1"
  521. // order.DrordDeptName = department.Name
  522. // order.DrordDrCodg = "1"
  523. // order.DrordDrName = doctor_info.UserName
  524. // order.DrordDrProfttl = ""
  525. // order.CurrDrordFlag = "1"
  526. // orders = append(orders, &order)
  527. //
  528. // }
  529. // if subItem.Type == 3 {
  530. //
  531. // var order models.FsiOrderDtos
  532. // order.RxID = strconv.FormatInt(item.ID, 10)
  533. // order.Rxno = strconv.FormatInt(item.ID, 10)
  534. // order.LongDrordFlag = "0"
  535. // order.HilistType = "1"
  536. // order.ChrgType = "1"
  537. // order.DrordBhvr = "-"
  538. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  539. // order.HosplistName = subItem.GoodInfo.GoodName
  540. // order.HilistLv = "1"
  541. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  542. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  543. // order.HosplistName = subItem.GoodInfo.GoodName
  544. // order.Cnt = subItem.Count
  545. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  546. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  547. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  548. // order.OwnpayAmt = ""
  549. // order.SelfpayAmt = ""
  550. // order.Spec = ""
  551. // order.SpecUnt = ""
  552. // order.DrordBegnDate = s_tm
  553. // order.DrordStopDate = ""
  554. // order.DrordDrCodg = "1"
  555. // order.DrordDeptName = department.Name
  556. // order.DrordDrCodg = "1"
  557. // order.DrordDrName = doctor_info.UserName
  558. // order.DrordDrProfttl = ""
  559. // order.CurrDrordFlag = "1"
  560. // orders = append(orders, &order)
  561. //
  562. // }
  563. // }
  564. //}
  565. for _, item := range prescriptions {
  566. for _, subItem := range item.HisDoctorAdviceInfo {
  567. var order models.FsiOrderDtos
  568. order.RxID = strconv.FormatInt(item.ID, 10)
  569. order.Rxno = strconv.FormatInt(item.ID, 10)
  570. order.LongDrordFlag = "0"
  571. order.HilistType = "1"
  572. order.ChrgType = "1"
  573. order.DrordBhvr = "-"
  574. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  575. order.HosplistName = subItem.BaseDrugLib.DrugName
  576. order.HilistLv = "1"
  577. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  578. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  579. order.HosplistName = subItem.BaseDrugLib.DrugName
  580. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  581. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  582. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  583. order.OwnpayAmt = ""
  584. order.SelfpayAmt = ""
  585. order.Spec = ""
  586. order.SpecUnt = ""
  587. order.DrordBegnDate = s_tm
  588. order.DrordStopDate = ""
  589. order.DrordDrCodg = "1"
  590. order.DrordDeptName = department.Name
  591. order.DrordDrCodg = "1"
  592. order.DrordDrName = doctor_info.UserName
  593. order.DrordDrProfttl = ""
  594. order.CurrDrordFlag = "1"
  595. orders = append(orders, &order)
  596. }
  597. for _, subItem := range item.HisPrescriptionProject {
  598. if subItem.Type == 2 {
  599. var order models.FsiOrderDtos
  600. order.RxID = strconv.FormatInt(item.ID, 10)
  601. order.Rxno = strconv.FormatInt(item.ID, 10)
  602. order.LongDrordFlag = "0"
  603. order.HilistType = "1"
  604. order.ChrgType = "1"
  605. order.DrordBhvr = "-"
  606. order.HilistCode = subItem.HisProject.MedicalCode
  607. order.HosplistName = subItem.HisProject.ProjectName
  608. order.HilistLv = "1"
  609. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  610. order.HosplistCode = subItem.HisProject.MedicalCode
  611. order.HosplistName = subItem.HisProject.ProjectName
  612. order.Cnt = subItem.Count
  613. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  614. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  615. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  616. order.OwnpayAmt = ""
  617. order.SelfpayAmt = ""
  618. order.Spec = ""
  619. order.SpecUnt = ""
  620. order.DrordBegnDate = s_tm
  621. order.DrordStopDate = ""
  622. order.DrordDrCodg = "1"
  623. order.DrordDeptName = department.Name
  624. order.DrordDrCodg = "1"
  625. order.DrordDrName = doctor_info.UserName
  626. order.DrordDrProfttl = ""
  627. order.CurrDrordFlag = "1"
  628. orders = append(orders, &order)
  629. }
  630. if subItem.Type == 3 {
  631. var order models.FsiOrderDtos
  632. order.RxID = strconv.FormatInt(item.ID, 10)
  633. order.Rxno = strconv.FormatInt(item.ID, 10)
  634. order.LongDrordFlag = "0"
  635. order.HilistType = "1"
  636. order.ChrgType = "1"
  637. order.DrordBhvr = "-"
  638. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  639. order.HosplistName = subItem.GoodInfo.GoodName
  640. order.HilistLv = "1"
  641. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  642. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  643. order.HosplistName = subItem.GoodInfo.GoodName
  644. order.Cnt = subItem.Count
  645. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  646. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  647. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  648. order.OwnpayAmt = ""
  649. order.SelfpayAmt = ""
  650. order.Spec = ""
  651. order.SpecUnt = ""
  652. order.DrordBegnDate = s_tm
  653. order.DrordStopDate = ""
  654. order.DrordDrCodg = "1"
  655. order.DrordDeptName = department.Name
  656. order.DrordDrCodg = "1"
  657. order.DrordDrName = doctor_info.UserName
  658. order.DrordDrProfttl = ""
  659. order.CurrDrordFlag = "1"
  660. orders = append(orders, &order)
  661. }
  662. }
  663. }
  664. //处方医嘱信息
  665. fed.MatnStas = "0"
  666. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  667. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  668. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  669. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  670. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  671. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  672. fed.SetlTotlnum = "1"
  673. fed.Insutype = his.Insutype
  674. fed.ReimFlag = "0"
  675. fed.OutSetlFlag = "0"
  676. var fopd []*models.FsiOperationDtosData
  677. data := make(map[string]interface{})
  678. data["fed"] = fed
  679. data["fdd"] = fdds
  680. data["fod"] = orders
  681. data["pd"] = pd
  682. data["pp"] = pp
  683. data["fopd"] = fopd
  684. data["trig_scen"] = trig_scen
  685. client := &http.Client{}
  686. bytesData, _ := json.Marshal(data)
  687. var req *http.Request
  688. if miConfig.MdtrtareaAdmvs == "320921" {
  689. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  690. } else {
  691. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  692. }
  693. resp, _ := client.Do(req)
  694. defer resp.Body.Close()
  695. body, ioErr := ioutil.ReadAll(resp.Body)
  696. if ioErr != nil {
  697. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  699. return
  700. }
  701. var respJSON map[string]interface{}
  702. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  703. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  705. return
  706. }
  707. //手术操作集合
  708. //手术操作集合
  709. }
  710. func (c *HisApiController) Check() {
  711. psn_no := c.GetString("psn_no")
  712. in := c.GetString("in")
  713. mt := c.GetString("mt")
  714. baseParams := models.BaseParams{
  715. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  716. FixmedinsCode: "H15049901371",
  717. InsuplcAdmdvs: "150499",
  718. MdtrtareaAdmvs: "150499",
  719. OrgName: "赤峰费森血液透析中心",
  720. Doctor: "1111",
  721. }
  722. service.Gdyb2001(baseParams, psn_no, in, mt)
  723. }
  724. func (c *HisApiController) GetPsnNcdsInfo() {
  725. admin_user_id, _ := c.GetInt64("admin_user_id")
  726. patient_id, _ := c.GetInt64("patient_id")
  727. id, _ := c.GetInt64("id")
  728. adminUser := c.GetAdminUserInfo()
  729. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  730. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  731. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  732. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  733. psn_record, _ := service.GetPsnNCDSRecordById(id)
  734. //
  735. //if psn_record.ID == 0 {
  736. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  737. // return
  738. //}
  739. var res Result5301
  740. var res10265 Result5301For10265
  741. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  742. psn_info, _ := service.GetPsnByPatientId(patient_id)
  743. var api string
  744. if miConfig.MdtrtareaAdmvs == "320921" {
  745. 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 +
  746. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  747. } else {
  748. 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 +
  749. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  750. }
  751. resp, requestErr := http.Get(api)
  752. if requestErr != nil {
  753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  754. return
  755. }
  756. body, ioErr := ioutil.ReadAll(resp.Body)
  757. if ioErr != nil {
  758. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  760. return
  761. }
  762. var respJSON map[string]interface{}
  763. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  764. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  766. return
  767. }
  768. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  769. result, _ := json.Marshal(respJSON)
  770. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  771. utils.ErrorLog("解析失败:%v", err)
  772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  773. return
  774. }
  775. res.ErrMsg = res10265.ErrMsg
  776. res.Output = res10265.Output
  777. res.InfRefmsgid = res10265.InfRefmsgid
  778. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  779. res.Infcode = infocode
  780. } else {
  781. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  782. var dat map[string]interface{}
  783. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  784. fmt.Println(dat)
  785. } else {
  786. fmt.Println(err)
  787. }
  788. userJSONBytes, _ := json.Marshal(dat)
  789. if miConfig.Code == "H15049901371" {
  790. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  791. utils.ErrorLog("解析失败:%v", err)
  792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  793. return
  794. }
  795. res.InfRefmsgid = res10265.InfRefmsgid
  796. res.Output = res10265.Output
  797. res.ErrMsg = res10265.ErrMsg
  798. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  799. res.Infcode = infocode
  800. } else {
  801. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  802. utils.ErrorLog("解析失败:%v", err)
  803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  804. return
  805. }
  806. }
  807. }
  808. if res.Infcode == 0 {
  809. c.ServeSuccessJSON(map[string]interface{}{
  810. "result": res.Output.Result,
  811. })
  812. }
  813. }
  814. func (c *HisApiController) CheckInsutype() {
  815. his_patient_id, _ := c.GetInt64("his_patient_id")
  816. admin_user_id, _ := c.GetInt64("admin_user_id")
  817. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  818. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  819. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  820. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  821. var dat map[string]interface{}
  822. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  823. fmt.Println(dat)
  824. } else {
  825. fmt.Println(err)
  826. }
  827. userJSONBytes, _ := json.Marshal(dat)
  828. var res Result90100
  829. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  830. utils.ErrorLog("解析失败:%v", err)
  831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  832. return
  833. }
  834. if res.Infcode != 0 {
  835. c.ServeSuccessJSON(map[string]interface{}{
  836. "failed_code": -10,
  837. "msg": res.ErrMsg,
  838. })
  839. return
  840. } else {
  841. fmt.Println(res)
  842. }
  843. }
  844. func (c *HisApiController) CheckCardPWD() {
  845. card_pwd := c.GetString("card_pwd")
  846. his_patient_id, _ := c.GetInt64("his_patient_id")
  847. admin_user_id, _ := c.GetInt64("admin_user_id")
  848. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  849. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  850. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  851. psn, _ := service.GetPsnByPatientId(his.PatientId)
  852. bas := strings.Split(psn.CardInfo, "|")
  853. basNumber := bas[2]
  854. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  855. var dat map[string]interface{}
  856. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  857. fmt.Println(dat)
  858. } else {
  859. fmt.Println(err)
  860. }
  861. userJSONBytes, _ := json.Marshal(dat)
  862. var res Result90991
  863. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  864. utils.ErrorLog("解析失败:%v", err)
  865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  866. return
  867. }
  868. if res.Infcode != 0 {
  869. c.ServeSuccessJSON(map[string]interface{}{
  870. "failed_code": -10,
  871. "msg": res.ErrMsg,
  872. })
  873. return
  874. } else {
  875. if res.Output.Result.SscnoCheckStat == "0" {
  876. var msg string
  877. switch res.Output.Result.CardStat {
  878. case "00":
  879. msg = "未激活"
  880. break
  881. case "10":
  882. msg = "激活"
  883. break
  884. case "20":
  885. msg = "窗口挂失"
  886. break
  887. case "21":
  888. msg = "电话挂失"
  889. break
  890. case "22":
  891. msg = "单位网上申报挂失"
  892. break
  893. case "23":
  894. msg = "保健办挂失"
  895. break
  896. case "24":
  897. msg = "个人网上挂失"
  898. break
  899. case "25":
  900. msg = "网上服务大厅挂失"
  901. break
  902. case "30":
  903. msg = "注销"
  904. break
  905. case "40":
  906. msg = "回收"
  907. break
  908. case "99":
  909. msg = "制卡中(无效卡)"
  910. break
  911. }
  912. c.ServeSuccessJSON(map[string]interface{}{
  913. "failed_code": -10,
  914. "msg": msg,
  915. })
  916. return
  917. } else {
  918. c.ServeSuccessJSON(map[string]interface{}{
  919. "msg": "校验成功",
  920. })
  921. return
  922. }
  923. }
  924. }
  925. func (c *HisApiController) CheckCardPWDTwo() {
  926. //card_pwd := c.GetString("card_pwd")
  927. //his_patient_id, _ := c.GetInt64("his_patient_id")
  928. admin_user_id, _ := c.GetInt64("admin_user_id")
  929. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  930. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  931. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  932. var dat map[string]interface{}
  933. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  934. fmt.Println(dat)
  935. } else {
  936. fmt.Println(err)
  937. }
  938. userJSONBytes, _ := json.Marshal(dat)
  939. var res Result90991
  940. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  941. utils.ErrorLog("解析失败:%v", err)
  942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  943. return
  944. }
  945. if res.Infcode != 0 {
  946. c.ServeSuccessJSON(map[string]interface{}{
  947. "failed_code": -10,
  948. "msg": res.ErrMsg,
  949. })
  950. return
  951. } else {
  952. if res.Output.Result.SscnoCheckStat == "0" {
  953. var msg string
  954. switch res.Output.Result.CardStat {
  955. case "00":
  956. msg = "未激活"
  957. break
  958. case "10":
  959. msg = "激活"
  960. break
  961. case "20":
  962. msg = "窗口挂失"
  963. break
  964. case "21":
  965. msg = "电话挂失"
  966. break
  967. case "22":
  968. msg = "单位网上申报挂失"
  969. break
  970. case "23":
  971. msg = "保健办挂失"
  972. break
  973. case "24":
  974. msg = "个人网上挂失"
  975. break
  976. case "25":
  977. msg = "网上服务大厅挂失"
  978. break
  979. case "30":
  980. msg = "注销"
  981. break
  982. case "40":
  983. msg = "回收"
  984. break
  985. case "99":
  986. msg = "制卡中(无效卡)"
  987. break
  988. }
  989. c.ServeSuccessJSON(map[string]interface{}{
  990. "failed_code": -10,
  991. "msg": msg,
  992. })
  993. return
  994. } else {
  995. c.ServeSuccessJSON(map[string]interface{}{
  996. "msg": "校验成功",
  997. })
  998. return
  999. }
  1000. }
  1001. }
  1002. func (c *HisApiController) ReadCard() {
  1003. id_card_type, _ := c.GetInt64("id_card_type")
  1004. admin_user_id, _ := c.GetInt64("admin_user_id")
  1005. certificates, _ := c.GetInt64("certificates")
  1006. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  1007. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1008. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1009. switch id_card_type {
  1010. case 1:
  1011. if miConfig.MdtrtareaAdmvs == "421300" {
  1012. var res ResultTwo
  1013. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  1014. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  1015. "&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)
  1016. resp, requestErr := http.Get(api)
  1017. if requestErr != nil {
  1018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1019. return
  1020. }
  1021. body, ioErr := ioutil.ReadAll(resp.Body)
  1022. if ioErr != nil {
  1023. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1025. return
  1026. }
  1027. var respJSON map[string]interface{}
  1028. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1029. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1031. return
  1032. }
  1033. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1034. result, _ := json.Marshal(respJSON)
  1035. fmt.Println("log")
  1036. fmt.Println(string(result))
  1037. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1038. utils.ErrorLog("解析失败:%v", err)
  1039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1040. return
  1041. }
  1042. if res.Infcode == 0 {
  1043. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1044. if err == gorm.ErrRecordNotFound {
  1045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1046. return
  1047. } else if err != nil {
  1048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1049. return
  1050. } else {
  1051. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1052. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1053. infoStr := string(Iinfos)
  1054. idetinfoStr := string(Idetinfos)
  1055. psn := &models.HisPsn{
  1056. PsnNo: res.Output.Baseinfo.PsnNo,
  1057. Age: res.Output.Baseinfo.Age,
  1058. PatientId: patient.ID,
  1059. Certno: res.Output.Baseinfo.Certno,
  1060. Brdy: res.Output.Baseinfo.Brdy,
  1061. Gend: res.Output.Baseinfo.Gend,
  1062. Naty: res.Output.Baseinfo.Naty,
  1063. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1064. PsnName: res.Output.Baseinfo.PsnName,
  1065. Idetinfo: idetinfoStr,
  1066. Insuinfo: infoStr,
  1067. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1068. }
  1069. service.CreateHisPsn(psn)
  1070. c.ServeSuccessJSON(map[string]interface{}{
  1071. "patient": patient,
  1072. "number": res.Output.Baseinfo.Certno,
  1073. })
  1074. }
  1075. } else {
  1076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1077. return
  1078. }
  1079. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1080. var api string
  1081. if miConfig.MdtrtareaAdmvs == "320921" {
  1082. 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 +
  1083. "&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
  1084. fmt.Println(api)
  1085. } else {
  1086. 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 +
  1087. "&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)
  1088. }
  1089. resp, requestErr := http.Get(api)
  1090. if requestErr != nil {
  1091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1092. return
  1093. }
  1094. body, ioErr := ioutil.ReadAll(resp.Body)
  1095. if ioErr != nil {
  1096. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1098. return
  1099. }
  1100. var respJSON map[string]interface{}
  1101. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1102. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1104. return
  1105. }
  1106. var status string
  1107. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1108. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1109. //console.log()
  1110. fmt.Println("type===")
  1111. fmt.Println(card_type)
  1112. var token string
  1113. var res ResultTwo //1101结果
  1114. var res10265 ResultTwo10265 //1101结果
  1115. var card_info string //卡信息
  1116. var busi_card_info string
  1117. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1118. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1119. if status == "0" { //读卡成功
  1120. if card_type == "1" {
  1121. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1122. result, _ := json.Marshal(respJSON)
  1123. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1124. utils.ErrorLog("解析失败:%v", err)
  1125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1126. return
  1127. }
  1128. res.ErrMsg = res10265.ErrMsg
  1129. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1130. res.Infcode = infocode
  1131. res.Output = res10265.Output
  1132. res.InfRefmsgid = res10265.InfRefmsgid
  1133. } else {
  1134. //var card_info string //卡信息
  1135. //var busi_card_info string
  1136. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1137. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1138. //fmt.Println(card_info)
  1139. //fmt.Println(busi_card_info)
  1140. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1141. result, _ := json.Marshal(respJSON)
  1142. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1143. utils.ErrorLog("解析失败:%v", err)
  1144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1145. return
  1146. }
  1147. res.ErrMsg = res10265.ErrMsg
  1148. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1149. res.Infcode = infocode
  1150. res.Output = res10265.Output
  1151. res.InfRefmsgid = res10265.InfRefmsgid
  1152. }
  1153. if res.Infcode == 0 {
  1154. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1155. if err == gorm.ErrRecordNotFound {
  1156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1157. return
  1158. } else if err != nil {
  1159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1160. return
  1161. } else {
  1162. if card_type == "1" {
  1163. bas := strings.Split(card_info, "|")
  1164. basNumber := bas[2]
  1165. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1166. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1167. infoStr := string(Iinfos)
  1168. idetinfoStr := string(Idetinfos)
  1169. psn := &models.HisPsn{
  1170. PsnNo: res.Output.Baseinfo.PsnNo,
  1171. Age: res.Output.Baseinfo.Age,
  1172. PatientId: patient.ID,
  1173. Certno: res.Output.Baseinfo.Certno,
  1174. Brdy: res.Output.Baseinfo.Brdy,
  1175. Gend: res.Output.Baseinfo.Gend,
  1176. Naty: res.Output.Baseinfo.Naty,
  1177. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1178. PsnName: res.Output.Baseinfo.PsnName,
  1179. Idetinfo: idetinfoStr,
  1180. Insuinfo: infoStr,
  1181. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1182. CardInfo: card_info,
  1183. VerifyNumber: busi_card_info,
  1184. }
  1185. service.CreateHisPsn(psn)
  1186. var rf []*ResultFive
  1187. json.Unmarshal([]byte(infoStr), &rf)
  1188. var insutypes []*ResultFive
  1189. var insutype string
  1190. var is390 int = 0
  1191. var is310 int = 0
  1192. for _, item := range rf {
  1193. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1194. insutypes = append(insutypes, item)
  1195. }
  1196. }
  1197. if len(insutypes) == 1 {
  1198. insutype = insutypes[0].Insutype
  1199. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1200. } else {
  1201. for _, i := range insutypes {
  1202. if i.Insutype == "390" {
  1203. is390 = 1
  1204. }
  1205. if i.Insutype == "310" {
  1206. is310 = 1
  1207. }
  1208. }
  1209. }
  1210. if is390 == 1 {
  1211. insutype = "390"
  1212. }
  1213. if is310 == 1 {
  1214. insutype = "310"
  1215. }
  1216. if len(insutypes) == 0 {
  1217. insutype = "310"
  1218. }
  1219. c.ServeSuccessJSON(map[string]interface{}{
  1220. "patient": patient,
  1221. "number": basNumber,
  1222. "insutype": insutype,
  1223. })
  1224. } else {
  1225. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1226. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1227. infoStr := string(Iinfos)
  1228. idetinfoStr := string(Idetinfos)
  1229. psn := &models.HisPsn{
  1230. PsnNo: res.Output.Baseinfo.PsnNo,
  1231. Age: res.Output.Baseinfo.Age,
  1232. PatientId: patient.ID,
  1233. Certno: res.Output.Baseinfo.Certno,
  1234. Brdy: res.Output.Baseinfo.Brdy,
  1235. Gend: res.Output.Baseinfo.Gend,
  1236. Naty: res.Output.Baseinfo.Naty,
  1237. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1238. PsnName: res.Output.Baseinfo.PsnName,
  1239. Idetinfo: idetinfoStr,
  1240. Insuinfo: infoStr,
  1241. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1242. CardInfo: card_info,
  1243. VerifyNumber: token,
  1244. }
  1245. service.CreateHisPsn(psn)
  1246. c.ServeSuccessJSON(map[string]interface{}{
  1247. "patient": patient,
  1248. "number": token,
  1249. })
  1250. }
  1251. }
  1252. } else {
  1253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1254. return
  1255. }
  1256. } else { //读卡失败
  1257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1258. return
  1259. }
  1260. } else if miConfig.MdtrtareaAdmvs == "350500" {
  1261. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  1262. cardnum = DeleteExtraSpaceTwo(cardnum)
  1263. cardCode = DeleteExtraSpaceTwo(cardCode)
  1264. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  1265. name = DeleteExtraSpaceTwo(name)
  1266. errmsg = DeleteExtraSpaceTwo(errmsg)
  1267. cardnum = Remove0000(cardnum)
  1268. cardCode = Remove0000(cardCode)
  1269. id_card_no = Remove0000(id_card_no)
  1270. name = Remove0000(name)
  1271. errmsg = Remove0000(errmsg)
  1272. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  1273. result, _ := service.FJyb1101(cardnum, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, cardCode, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  1274. var dat map[string]interface{}
  1275. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1276. fmt.Println(dat)
  1277. } else {
  1278. fmt.Println(err)
  1279. }
  1280. userJSONBytes, _ := json.Marshal(dat)
  1281. var res ResultTwo
  1282. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1283. utils.ErrorLog("解析失败:%v", err)
  1284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1285. return
  1286. }
  1287. if res.Infcode == 0 {
  1288. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  1289. if err == gorm.ErrRecordNotFound {
  1290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1291. return
  1292. } else if err != nil {
  1293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1294. return
  1295. } else {
  1296. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1297. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1298. infoStr := string(Iinfos)
  1299. idetinfoStr := string(Idetinfos)
  1300. psn := &models.HisPsn{
  1301. PsnNo: res.Output.Baseinfo.PsnNo,
  1302. Age: res.Output.Baseinfo.Age,
  1303. PatientId: patient.ID,
  1304. Certno: res.Output.Baseinfo.Certno,
  1305. Brdy: res.Output.Baseinfo.Brdy,
  1306. Gend: res.Output.Baseinfo.Gend,
  1307. Naty: res.Output.Baseinfo.Naty,
  1308. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1309. PsnName: res.Output.Baseinfo.PsnName,
  1310. Idetinfo: idetinfoStr,
  1311. Insuinfo: infoStr,
  1312. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1313. CardInfo: basStr,
  1314. VerifyNumber: "",
  1315. }
  1316. service.CreateHisPsn(psn)
  1317. c.ServeSuccessJSON(map[string]interface{}{
  1318. "patient": patient,
  1319. "number": cardnum,
  1320. })
  1321. }
  1322. } else {
  1323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1324. return
  1325. }
  1326. } else {
  1327. if initFlag == 0 {
  1328. c.TestGetBasBaseInit()
  1329. }
  1330. basStr := c.GetBasBaseInfo()
  1331. if len(basStr) == 0 {
  1332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1333. return
  1334. }
  1335. fmt.Println(basStr)
  1336. bas := strings.Split(basStr, "|")
  1337. basNumber := bas[1]
  1338. fmt.Println(basNumber)
  1339. card_sn := bas[3]
  1340. fmt.Println(card_sn)
  1341. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1342. var dat map[string]interface{}
  1343. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1344. fmt.Println(dat)
  1345. } else {
  1346. fmt.Println(err)
  1347. }
  1348. userJSONBytes, _ := json.Marshal(dat)
  1349. var res ResultTwo
  1350. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1351. utils.ErrorLog("解析失败:%v", err)
  1352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1353. return
  1354. }
  1355. if res.Infcode == 0 {
  1356. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1357. if err == gorm.ErrRecordNotFound {
  1358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1359. return
  1360. } else if err != nil {
  1361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1362. return
  1363. } else {
  1364. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1365. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1366. infoStr := string(Iinfos)
  1367. idetinfoStr := string(Idetinfos)
  1368. psn := &models.HisPsn{
  1369. PsnNo: res.Output.Baseinfo.PsnNo,
  1370. Age: res.Output.Baseinfo.Age,
  1371. PatientId: patient.ID,
  1372. Certno: res.Output.Baseinfo.Certno,
  1373. Brdy: res.Output.Baseinfo.Brdy,
  1374. Gend: res.Output.Baseinfo.Gend,
  1375. Naty: res.Output.Baseinfo.Naty,
  1376. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1377. PsnName: res.Output.Baseinfo.PsnName,
  1378. Idetinfo: idetinfoStr,
  1379. Insuinfo: infoStr,
  1380. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1381. CardInfo: basStr,
  1382. VerifyNumber: "",
  1383. }
  1384. service.CreateHisPsn(psn)
  1385. c.ServeSuccessJSON(map[string]interface{}{
  1386. "patient": patient,
  1387. "number": basNumber,
  1388. })
  1389. }
  1390. } else {
  1391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1392. return
  1393. }
  1394. break
  1395. }
  1396. case 2:
  1397. SFZStr := c.GetSFZBaseInfo()
  1398. id_card_str := strings.Split(SFZStr, "^")
  1399. id_card_number := id_card_str[0]
  1400. card_sn := ""
  1401. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1402. var dat map[string]interface{}
  1403. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1404. fmt.Println(dat)
  1405. } else {
  1406. fmt.Println(err)
  1407. }
  1408. userJSONBytes, _ := json.Marshal(dat)
  1409. var res ResultTwo
  1410. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1411. utils.ErrorLog("解析失败:%v", err)
  1412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1413. return
  1414. }
  1415. if res.Infcode == 0 {
  1416. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1417. if err == gorm.ErrRecordNotFound {
  1418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1419. return
  1420. } else if err != nil {
  1421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1422. return
  1423. } else {
  1424. c.ServeSuccessJSON(map[string]interface{}{
  1425. "patient": patient,
  1426. "number": id_card_number,
  1427. })
  1428. }
  1429. } else {
  1430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1431. return
  1432. }
  1433. break
  1434. case 3:
  1435. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1436. var api string
  1437. if miConfig.MdtrtareaAdmvs == "320921" {
  1438. 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 +
  1439. "&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
  1440. fmt.Println(api)
  1441. } else {
  1442. 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 +
  1443. "&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)
  1444. }
  1445. resp, requestErr := http.Get(api)
  1446. if requestErr != nil {
  1447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1448. return
  1449. }
  1450. body, ioErr := ioutil.ReadAll(resp.Body)
  1451. if ioErr != nil {
  1452. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1454. return
  1455. }
  1456. var respJSON map[string]interface{}
  1457. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1458. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1460. return
  1461. }
  1462. var status string
  1463. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1464. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1465. var token string
  1466. var res ResultTwo //1101结果
  1467. var res10265 ResultTwo10265 //1101结果
  1468. var card_info string //卡信息
  1469. var busi_card_info string
  1470. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1471. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1472. if status == "0" { //读卡成功
  1473. if card_type == "1" {
  1474. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1475. result, _ := json.Marshal(respJSON)
  1476. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1477. utils.ErrorLog("解析失败:%v", err)
  1478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1479. return
  1480. }
  1481. res.ErrMsg = res10265.ErrMsg
  1482. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1483. res.Infcode = infocode
  1484. res.Output = res10265.Output
  1485. res.InfRefmsgid = res10265.InfRefmsgid
  1486. } else {
  1487. //var card_info string //卡信息
  1488. //var busi_card_info string
  1489. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1490. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1491. //fmt.Println(card_info)
  1492. //fmt.Println(busi_card_info)
  1493. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1494. result, _ := json.Marshal(respJSON)
  1495. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1496. utils.ErrorLog("解析失败:%v", err)
  1497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1498. return
  1499. }
  1500. res.ErrMsg = res10265.ErrMsg
  1501. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1502. res.Infcode = infocode
  1503. res.Output = res10265.Output
  1504. res.InfRefmsgid = res10265.InfRefmsgid
  1505. }
  1506. if res.Infcode == 0 {
  1507. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1508. if err == gorm.ErrRecordNotFound {
  1509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1510. return
  1511. } else if err != nil {
  1512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1513. return
  1514. } else {
  1515. if card_type == "1" {
  1516. bas := strings.Split(card_info, "|")
  1517. basNumber := bas[2]
  1518. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1519. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1520. infoStr := string(Iinfos)
  1521. idetinfoStr := string(Idetinfos)
  1522. psn := &models.HisPsn{
  1523. PsnNo: res.Output.Baseinfo.PsnNo,
  1524. Age: res.Output.Baseinfo.Age,
  1525. PatientId: patient.ID,
  1526. Certno: res.Output.Baseinfo.Certno,
  1527. Brdy: res.Output.Baseinfo.Brdy,
  1528. Gend: res.Output.Baseinfo.Gend,
  1529. Naty: res.Output.Baseinfo.Naty,
  1530. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1531. PsnName: res.Output.Baseinfo.PsnName,
  1532. Idetinfo: idetinfoStr,
  1533. Insuinfo: infoStr,
  1534. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1535. CardInfo: card_info,
  1536. VerifyNumber: busi_card_info,
  1537. }
  1538. service.CreateHisPsn(psn)
  1539. c.ServeSuccessJSON(map[string]interface{}{
  1540. "patient": patient,
  1541. "number": basNumber,
  1542. })
  1543. } else {
  1544. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1545. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1546. infoStr := string(Iinfos)
  1547. idetinfoStr := string(Idetinfos)
  1548. psn := &models.HisPsn{
  1549. PsnNo: res.Output.Baseinfo.PsnNo,
  1550. Age: res.Output.Baseinfo.Age,
  1551. PatientId: patient.ID,
  1552. Certno: res.Output.Baseinfo.Certno,
  1553. Brdy: res.Output.Baseinfo.Brdy,
  1554. Gend: res.Output.Baseinfo.Gend,
  1555. Naty: res.Output.Baseinfo.Naty,
  1556. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1557. PsnName: res.Output.Baseinfo.PsnName,
  1558. Idetinfo: idetinfoStr,
  1559. Insuinfo: infoStr,
  1560. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1561. CardInfo: card_info,
  1562. VerifyNumber: token,
  1563. }
  1564. service.CreateHisPsn(psn)
  1565. var rf []*ResultFive
  1566. json.Unmarshal([]byte(infoStr), &rf)
  1567. var insutypes []*ResultFive
  1568. var insutype string
  1569. var is390 int = 0
  1570. var is310 int = 0
  1571. for _, item := range rf {
  1572. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1573. insutypes = append(insutypes, item)
  1574. }
  1575. }
  1576. if len(insutypes) == 1 {
  1577. insutype = insutypes[0].Insutype
  1578. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1579. } else {
  1580. for _, i := range insutypes {
  1581. if i.Insutype == "390" {
  1582. is390 = 1
  1583. }
  1584. if i.Insutype == "310" {
  1585. is310 = 1
  1586. }
  1587. }
  1588. }
  1589. if is390 == 1 {
  1590. insutype = "390"
  1591. }
  1592. if is310 == 1 {
  1593. insutype = "310"
  1594. }
  1595. if len(insutypes) == 0 {
  1596. insutype = "310"
  1597. }
  1598. c.ServeSuccessJSON(map[string]interface{}{
  1599. "patient": patient,
  1600. "number": token,
  1601. "insutype": insutype,
  1602. })
  1603. }
  1604. }
  1605. } else {
  1606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1607. return
  1608. }
  1609. } else { //读卡失败
  1610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1611. return
  1612. }
  1613. }
  1614. break
  1615. case 4:
  1616. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1617. var api string
  1618. if miConfig.MdtrtareaAdmvs == "320921" {
  1619. 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 +
  1620. "&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
  1621. fmt.Println(api)
  1622. } else {
  1623. 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 +
  1624. "&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)
  1625. }
  1626. resp, requestErr := http.Get(api)
  1627. if requestErr != nil {
  1628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1629. return
  1630. }
  1631. body, ioErr := ioutil.ReadAll(resp.Body)
  1632. if ioErr != nil {
  1633. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1635. return
  1636. }
  1637. var respJSON map[string]interface{}
  1638. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1639. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1641. return
  1642. }
  1643. var status string
  1644. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1645. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1646. var token string
  1647. var res ResultTwo //1101结果
  1648. var res10265 ResultTwo10265 //1101结果
  1649. if status == "0" { //读卡成功
  1650. var card_info string //卡信息
  1651. var busi_card_info string
  1652. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1653. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1654. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1655. fmt.Println(card_info)
  1656. fmt.Println(busi_card_info)
  1657. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1658. result, _ := json.Marshal(respJSON)
  1659. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1660. utils.ErrorLog("解析失败:%v", err)
  1661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1662. return
  1663. }
  1664. res.ErrMsg = res10265.ErrMsg
  1665. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1666. res.Infcode = infocode
  1667. res.Output = res10265.Output
  1668. res.InfRefmsgid = res10265.InfRefmsgid
  1669. if res.Infcode == 0 {
  1670. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1671. if err == gorm.ErrRecordNotFound {
  1672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1673. return
  1674. } else if err != nil {
  1675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1676. return
  1677. } else {
  1678. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1679. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1680. infoStr := string(Iinfos)
  1681. idetinfoStr := string(Idetinfos)
  1682. psn := &models.HisPsn{
  1683. PsnNo: res.Output.Baseinfo.PsnNo,
  1684. Age: res.Output.Baseinfo.Age,
  1685. PatientId: patient.ID,
  1686. Certno: res.Output.Baseinfo.Certno,
  1687. Brdy: res.Output.Baseinfo.Brdy,
  1688. Gend: res.Output.Baseinfo.Gend,
  1689. Naty: res.Output.Baseinfo.Naty,
  1690. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1691. PsnName: res.Output.Baseinfo.PsnName,
  1692. Idetinfo: idetinfoStr,
  1693. Insuinfo: infoStr,
  1694. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1695. CardInfo: card_info,
  1696. VerifyNumber: token,
  1697. }
  1698. service.CreateHisPsn(psn)
  1699. c.ServeSuccessJSON(map[string]interface{}{
  1700. "patient": patient,
  1701. "number": token,
  1702. })
  1703. }
  1704. } else {
  1705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1706. return
  1707. }
  1708. } else { //读卡失败
  1709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1710. return
  1711. }
  1712. }
  1713. break
  1714. }
  1715. }
  1716. var initFlag int64 = 0
  1717. func (c *HisApiController) TestGetBasBaseInit() {
  1718. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1719. Iinit := DllDef.MustFindProc("Init")
  1720. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1721. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  1722. if ret != 0 {
  1723. fmt.Println("SSCard的报错原因:", err)
  1724. fmt.Println("SSCard的运算结果为:", ret)
  1725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1726. return
  1727. }
  1728. result := int(ret)
  1729. fmt.Println("SSCard的运算结果为1:", result)
  1730. initFlag = 1
  1731. return
  1732. }
  1733. func (c *HisApiController) GetSFZBaseInfo() string {
  1734. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1735. readCard := DllDef.MustFindProc("ReadSFZ")
  1736. if readCard == nil {
  1737. fmt.Println("readcard is nil")
  1738. readCard = DllDef.MustFindProc("ReadSFZ")
  1739. }
  1740. str := make([]byte, 256)
  1741. str1 := make([]byte, 256)
  1742. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1743. fmt.Println(r)
  1744. return string(str)
  1745. }
  1746. func (c *HisApiController) GetBasBaseInfo() string {
  1747. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1748. readCard := DllDef.MustFindProc("ReadCardBas")
  1749. if readCard == nil {
  1750. fmt.Println("readcard is nil")
  1751. readCard = DllDef.MustFindProc("ReadCardBas")
  1752. }
  1753. str := make([]byte, 1024)
  1754. str1 := make([]byte, 1024)
  1755. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  1756. fmt.Println(string(str1))
  1757. fmt.Println(string(str))
  1758. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1759. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1760. if ret2 != 0 {
  1761. return ""
  1762. }
  1763. return string(str)
  1764. }
  1765. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  1766. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  1767. readCard := DllDef.MustFindProc("read_cardinfo")
  1768. if readCard == nil {
  1769. fmt.Println("readcard is nil")
  1770. readCard = DllDef.MustFindProc("read_cardinfo")
  1771. }
  1772. str := make([]byte, 1024) //卡号
  1773. str1 := make([]byte, 1024) //卡识别码
  1774. str2 := make([]byte, 1024) //身份证号
  1775. str3 := make([]byte, 1024) //姓名
  1776. str4 := make([]byte, 1024) //错误信息
  1777. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])), (uintptr)(unsafe.Pointer(&str2[0])), (uintptr)(unsafe.Pointer(&str3[0])), (uintptr)(unsafe.Pointer(&str4[0])))
  1778. fmt.Println(string(str1))
  1779. fmt.Println(string(str))
  1780. fmt.Println(string(str2))
  1781. fmt.Println(string(str3))
  1782. fmt.Println(string(str4))
  1783. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1784. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1785. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  1786. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  1787. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  1788. if ret2 != 0 {
  1789. return "", "", "", "", ""
  1790. }
  1791. return string(str), string(str1), string(str2), string(str3), string(str4)
  1792. }
  1793. type CustomFundPay struct {
  1794. FundPayType string `json:"fund_pay_type"`
  1795. FundPayamt float64 `json:"fund_payamt"`
  1796. }
  1797. func (c *HisApiController) GetSettleList() {
  1798. order_id, _ := c.GetInt64("order_id")
  1799. admin_user_id, _ := c.GetInt64("admin_user_id")
  1800. order, _ := service.GetHisOrderByIDTwo(order_id)
  1801. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1802. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1803. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1804. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1805. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1806. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1807. if order.ID == 0 {
  1808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1809. return
  1810. }
  1811. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1812. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1813. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1814. fmt.Println(count)
  1815. var zero string
  1816. number := count + 1
  1817. if number >= 1000 {
  1818. zero = "0000" + strconv.FormatInt(number, 10)
  1819. } else if number >= 10000 {
  1820. zero = "000" + strconv.FormatInt(number, 10)
  1821. } else if number >= 100000 {
  1822. zero = "00" + strconv.FormatInt(number, 10)
  1823. } else if number >= 1000000 {
  1824. zero = "0" + strconv.FormatInt(number, 10)
  1825. } else {
  1826. zero = strconv.FormatInt(number, 10)
  1827. }
  1828. fmt.Println(zero)
  1829. struct4101 := service.Struct4101{
  1830. PsnNo: order.PsnNo,
  1831. MdtrtId: order.MdtrtId,
  1832. SetlId: order.SetlId,
  1833. PsnName: order.PsnName,
  1834. Gend: order.Gend,
  1835. Brdy: his.Brdy,
  1836. Age: his.Age,
  1837. Naty: order.Naty,
  1838. PatnCertType: "01",
  1839. Certno: order.Certno,
  1840. Prfs: "90",
  1841. ConerName: roles[0].UserName,
  1842. PatnRlts: "99",
  1843. ConerAddr: miConfig.OrgName,
  1844. ConerTel: admin.Mobile,
  1845. HiType: order.Insutype,
  1846. Insuplc: miConfig.InsuplcAdmdvs,
  1847. MaindiagFlag: "1",
  1848. BillCode: last_order.FaPiaoCode,
  1849. BillNo: zero,
  1850. BizSn: order.Number,
  1851. PsnSelfPay: order.PsnPartAmt,
  1852. PsnOwnPay: order.PsnPartAmt,
  1853. AcctPay: order.AcctPay,
  1854. PsnCashpay: order.PsnCashPay,
  1855. HiPaymtd: "1",
  1856. Hsorg: miConfig.InsuplcAdmdvs,
  1857. HsorgOpter: miConfig.InsuplcAdmdvs,
  1858. MedinsFillPsn: curRoles.UserName,
  1859. MedinsFillDept: depart.Name,
  1860. IptMedType: "2",
  1861. }
  1862. struct4101.SetlBegnDate = order.SetlTime
  1863. struct4101.SetlEndDate = order.SetlTime
  1864. time_arr := strings.Split(order.SetlTime, " ")
  1865. struct4101.AdmTime = time_arr[0]
  1866. struct4101.AdmEndTime = time_arr[0]
  1867. var rf []CustomFundPay
  1868. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1869. var tempFunPays []service.CustomStruct
  1870. for _, item := range rf {
  1871. var tempFunPay service.CustomStruct
  1872. tempFunPay.FundPayamt = item.FundPayamt
  1873. tempFunPay.FundPayType = item.FundPayType
  1874. tempFunPays = append(tempFunPays, tempFunPay)
  1875. }
  1876. struct4101.CustomStruct = tempFunPays
  1877. var tempDiaginfos []service.DiaginfoStructTwo
  1878. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1879. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1880. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  1881. var config []*models.HisXtDiagnoseConfig
  1882. for _, item := range diagnosis_ids {
  1883. id, _ := strconv.ParseInt(item, 10, 64)
  1884. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1885. config = append(config, &diagnosisConfig)
  1886. }
  1887. for index, item := range config {
  1888. if index == 0 {
  1889. var tempDiaginfo service.DiaginfoStructTwo
  1890. tempDiaginfo.DiagCode = item.CountryCode
  1891. tempDiaginfo.DiagName = item.CountryContentName
  1892. tempDiaginfo.DiagType = "1"
  1893. tempDiaginfo.MaindiagFlag = "1"
  1894. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1895. } else {
  1896. var tempDiaginfo service.DiaginfoStructTwo
  1897. tempDiaginfo.DiagCode = item.CountryCode
  1898. tempDiaginfo.DiagName = item.CountryContentName
  1899. tempDiaginfo.DiagType = "2"
  1900. tempDiaginfo.MaindiagFlag = "0"
  1901. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1902. }
  1903. }
  1904. struct4101.Diseinfo = tempDiaginfos
  1905. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1906. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1907. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1908. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  1909. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  1910. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1911. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1912. var iteminfo service.IteminfoStruct
  1913. var bedCostTotal float64 = 0 //床位总费
  1914. var bedCostSelfTotal float64 = 0 //床位自费
  1915. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1916. var operationCostTotal float64 = 0 //手术费
  1917. var operationCostSelfTotal float64 = 0 //手术费
  1918. var operationCostPartSelfTotal float64 = 0 //手术费
  1919. var otherCostTotal float64 = 0 //其他费用
  1920. var otherCostSelfTotal float64 = 0 //其他费用
  1921. var otherCostPartSelfTotal float64 = 0 //其他费用
  1922. var materialCostTotal float64 = 0 //材料费
  1923. var materialCostSelfTotal float64 = 0 //材料费
  1924. var materialCostPartSelfTotal float64 = 0 //材料费
  1925. var westernMedicineCostTotal float64 = 0 //西药费
  1926. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1927. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1928. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1929. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1930. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1931. var checkCostTotal float64 = 0 //检查费
  1932. var checkCostSelfTotal float64 = 0 //检查费
  1933. var checkCostPartSelfTotal float64 = 0 //检查费
  1934. var laboratoryCostTotal float64 = 0 //化验费
  1935. var laboratoryCostSelfTotal float64 = 0 //化验费
  1936. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1937. var treatCostTotal float64 = 0 //治疗费用
  1938. var treatCostSelfTotal float64 = 0 //治疗费用
  1939. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1940. decimal.DivisionPrecision = 2
  1941. var bed_fulamt_ownpay_amt float64 = 0
  1942. var operation_fulamt_ownpay_amt float64 = 0
  1943. var other_fulamt_ownpay_amt float64 = 0
  1944. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1945. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1946. var check_fulamt_ownpay_amt float64 = 0
  1947. var material_fulamt_ownpay_amt float64 = 0
  1948. var laboratory_fulamt_ownpay_amt float64 = 0
  1949. var treat_fulamt_ownpay_amt float64 = 0
  1950. var bed_claa_sunmfee float64 = 0
  1951. var bed_clab_amt float64 = 0
  1952. var bed_other_amt float64 = 0
  1953. var operation_claa_sunmfee float64 = 0
  1954. var operation_clab_amt float64 = 0
  1955. var operation_other_amt float64 = 0
  1956. var other_claa_sunmfee float64 = 0
  1957. var other_clab_amt float64 = 0
  1958. var other_other_amt float64 = 0
  1959. var westernMedicine_claa_sunmfee float64 = 0
  1960. var westernMedicine_clab_amt float64 = 0
  1961. var westernMedicine_other_amt float64 = 0
  1962. var chineseTraditional_claa_sunmfee float64 = 0
  1963. var chineseTraditional_clab_amt float64 = 0
  1964. var chineseTraditional_other_amt float64 = 0
  1965. var check_claa_sunmfee float64 = 0
  1966. var check_clab_amt float64 = 0
  1967. var check_other_amt float64 = 0
  1968. var material_claa_sunmfee float64 = 0
  1969. var material_clab_amt float64 = 0
  1970. var material_other_amt float64 = 0
  1971. var laboratory_claa_sunmfee float64 = 0
  1972. var laboratory_clab_amt float64 = 0
  1973. var laboratory_other_amt float64 = 0
  1974. var treat_claa_sunmfee float64 = 0
  1975. var treat_clab_amt float64 = 0
  1976. var treat_other_amt float64 = 0
  1977. for _, item := range order.HisOrderInfo {
  1978. if item.MedChrgitmType == "01" { //床位费
  1979. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1980. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1981. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1982. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1983. if item.ChrgitmLv == "1" {
  1984. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1985. }
  1986. if item.ChrgitmLv == "2" {
  1987. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1988. }
  1989. if item.ChrgitmLv == "3" {
  1990. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1991. }
  1992. }
  1993. if item.MedChrgitmType == "03" { //检查费
  1994. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1995. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1996. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1997. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1998. if item.ChrgitmLv == "1" {
  1999. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2000. }
  2001. if item.ChrgitmLv == "2" {
  2002. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2003. }
  2004. if item.ChrgitmLv == "3" {
  2005. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2006. }
  2007. }
  2008. if item.MedChrgitmType == "04" { //化验费
  2009. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2010. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2011. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2012. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2013. if item.ChrgitmLv == "1" {
  2014. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2015. }
  2016. if item.ChrgitmLv == "2" {
  2017. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2018. }
  2019. if item.ChrgitmLv == "3" {
  2020. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2021. }
  2022. }
  2023. if item.MedChrgitmType == "05" { //治疗费
  2024. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2025. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2026. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2027. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2028. if item.ChrgitmLv == "1" {
  2029. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2030. }
  2031. if item.ChrgitmLv == "2" {
  2032. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2033. }
  2034. if item.ChrgitmLv == "3" {
  2035. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2036. }
  2037. }
  2038. if item.MedChrgitmType == "06" { //手术费
  2039. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2040. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2041. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2042. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2043. if item.ChrgitmLv == "1" {
  2044. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2045. }
  2046. if item.ChrgitmLv == "2" {
  2047. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2048. }
  2049. if item.ChrgitmLv == "3" {
  2050. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2051. }
  2052. }
  2053. if item.MedChrgitmType == "08" { //材料费
  2054. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2055. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2056. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2057. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2058. if item.ChrgitmLv == "1" {
  2059. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2060. }
  2061. if item.ChrgitmLv == "2" {
  2062. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2063. }
  2064. if item.ChrgitmLv == "3" {
  2065. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2066. }
  2067. }
  2068. if item.MedChrgitmType == "09" { //西药费
  2069. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2070. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2071. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2072. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2073. if item.ChrgitmLv == "1" {
  2074. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2075. }
  2076. if item.ChrgitmLv == "2" {
  2077. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2078. }
  2079. if item.ChrgitmLv == "3" {
  2080. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2081. }
  2082. }
  2083. if item.MedChrgitmType == "11" { //中成费
  2084. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2085. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2086. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2087. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2088. if item.ChrgitmLv == "1" {
  2089. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2090. }
  2091. if item.ChrgitmLv == "2" {
  2092. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2093. }
  2094. if item.ChrgitmLv == "3" {
  2095. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2096. }
  2097. }
  2098. if item.MedChrgitmType == "14" { //其他费
  2099. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2100. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2101. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2102. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2103. if item.ChrgitmLv == "1" {
  2104. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2105. }
  2106. if item.ChrgitmLv == "2" {
  2107. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2108. }
  2109. if item.ChrgitmLv == "3" {
  2110. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2111. }
  2112. }
  2113. }
  2114. var iteminfoStructs []service.IteminfoStruct
  2115. if bedCostTotal != 0 {
  2116. iteminfo.MedChrgitm = "01"
  2117. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2118. iteminfo.Amt = bedCostTotal
  2119. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2120. iteminfo.ClabAmt = bed_clab_amt
  2121. iteminfo.OthAmt = bed_other_amt
  2122. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2123. }
  2124. if checkCostTotal != 0 {
  2125. iteminfo.MedChrgitm = "03"
  2126. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2127. iteminfo.Amt = checkCostTotal
  2128. iteminfo.ClaaSumfee = check_claa_sunmfee
  2129. iteminfo.ClabAmt = check_clab_amt
  2130. iteminfo.OthAmt = check_other_amt
  2131. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2132. }
  2133. if laboratoryCostTotal != 0 {
  2134. iteminfo.MedChrgitm = "04"
  2135. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2136. iteminfo.Amt = laboratoryCostTotal
  2137. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2138. iteminfo.ClabAmt = laboratory_clab_amt
  2139. iteminfo.OthAmt = laboratory_other_amt
  2140. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2141. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2142. }
  2143. if treatCostTotal != 0 {
  2144. iteminfo.MedChrgitm = "05"
  2145. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2146. iteminfo.Amt = treatCostTotal
  2147. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2148. iteminfo.ClabAmt = treat_clab_amt
  2149. iteminfo.OthAmt = treat_other_amt
  2150. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2151. //(struct4101.IteminfoStruct, iteminfo)
  2152. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2153. }
  2154. if operationCostTotal != 0 {
  2155. iteminfo.MedChrgitm = "06"
  2156. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2157. iteminfo.Amt = operationCostTotal
  2158. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2159. iteminfo.ClabAmt = operation_clab_amt
  2160. iteminfo.OthAmt = operation_other_amt
  2161. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2162. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2163. }
  2164. if materialCostTotal != 0 {
  2165. iteminfo.MedChrgitm = "08"
  2166. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2167. iteminfo.Amt = materialCostTotal
  2168. iteminfo.ClaaSumfee = material_claa_sunmfee
  2169. iteminfo.ClabAmt = material_clab_amt
  2170. iteminfo.OthAmt = material_other_amt
  2171. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2172. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2173. }
  2174. if westernMedicineCostTotal != 0 {
  2175. iteminfo.MedChrgitm = "09"
  2176. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2177. iteminfo.Amt = westernMedicineCostTotal
  2178. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2179. iteminfo.ClabAmt = westernMedicine_clab_amt
  2180. iteminfo.OthAmt = westernMedicine_other_amt
  2181. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2182. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2183. }
  2184. if chineseTraditionalMedicineCostTotal != 0 {
  2185. iteminfo.MedChrgitm = "11"
  2186. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2187. iteminfo.Amt = westernMedicineCostTotal
  2188. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2189. iteminfo.ClabAmt = westernMedicine_clab_amt
  2190. iteminfo.OthAmt = westernMedicine_other_amt
  2191. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2192. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2193. }
  2194. if otherCostTotal != 0 {
  2195. iteminfo.MedChrgitm = "14"
  2196. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2197. iteminfo.Amt = otherCostTotal
  2198. iteminfo.ClaaSumfee = other_claa_sunmfee
  2199. iteminfo.ClabAmt = other_clab_amt
  2200. iteminfo.OthAmt = other_other_amt
  2201. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2202. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2203. }
  2204. struct4101.IteminfoStruct = iteminfoStructs
  2205. struct4101.Ntly = "中国"
  2206. struct4101.AdmCaty = "A03.06"
  2207. var res ResultSeventeen
  2208. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2209. var resOther ResultSeventeenOther
  2210. var pp models.PublicParams
  2211. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2212. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2213. pp.FixmedinsName = miConfig.OrgName
  2214. pp.FixmedinsCode = miConfig.Code
  2215. pp.RequestUrl = miConfig.Url
  2216. pp.Cainfo = miConfig.Cainfo
  2217. pp.SecretKey = miConfig.SecretKey
  2218. pp.AccessKey = miConfig.AccessKey
  2219. pp.OpterName = curRoles.UserName
  2220. client := &http.Client{}
  2221. var req *http.Request
  2222. data := make(map[string]interface{})
  2223. data["struct4101"] = struct4101
  2224. data["pp"] = pp
  2225. bytesData, _ := json.Marshal(data)
  2226. if miConfig.MdtrtareaAdmvs == "320921" {
  2227. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2228. } else {
  2229. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2230. }
  2231. resp, _ := client.Do(req)
  2232. defer resp.Body.Close()
  2233. body, ioErr := ioutil.ReadAll(resp.Body)
  2234. if ioErr != nil {
  2235. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2237. return
  2238. }
  2239. var respJSON map[string]interface{}
  2240. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2241. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2243. return
  2244. }
  2245. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2246. userJSONBytes, _ := json.Marshal(respJSON)
  2247. fmt.Println("log")
  2248. fmt.Println(string(userJSONBytes))
  2249. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  2250. utils.ErrorLog("解析失败:%v", err)
  2251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2252. return
  2253. }
  2254. res.InfRefmsgid = resOther.InfRefmsgid
  2255. res.Output = resOther.Output
  2256. res.ErrMsg = resOther.ErrMsg
  2257. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  2258. res.Infcode = infocode
  2259. } else {
  2260. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2261. var dat map[string]interface{}
  2262. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2263. fmt.Println(dat)
  2264. } else {
  2265. fmt.Println(err)
  2266. }
  2267. userJSONBytes, _ := json.Marshal(dat)
  2268. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2269. utils.ErrorLog("解析失败:%v", err)
  2270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2271. return
  2272. }
  2273. }
  2274. if res.Infcode != 0 {
  2275. c.ServeSuccessJSON(map[string]interface{}{
  2276. "failed_code": -10,
  2277. "msg": res.ErrMsg,
  2278. })
  2279. return
  2280. } else {
  2281. order.FaPiaoNumber = zero
  2282. order.FaPiaoCode = last_order.FaPiaoCode
  2283. service.UpdateOrder(order)
  2284. hisFundSettleListResult := &models.HisFundSettleListResult{
  2285. Number: res.Output.SetlListId,
  2286. Status: 1,
  2287. Ctime: time.Now().Unix(),
  2288. Mtime: time.Now().Unix(),
  2289. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2290. IsUpload: 1,
  2291. OrderId: order_id,
  2292. }
  2293. service.CreateUploadRecord(hisFundSettleListResult)
  2294. c.ServeSuccessJSON(map[string]interface{}{
  2295. "msg": "上传成功",
  2296. "result": hisFundSettleListResult,
  2297. })
  2298. return
  2299. }
  2300. }
  2301. func (c *HisApiController) GetSettleListHospital() {
  2302. order_id, _ := c.GetInt64("order_id")
  2303. admin_user_id, _ := c.GetInt64("admin_user_id")
  2304. order, _ := service.GetHisOrderByIDTwo(order_id)
  2305. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2306. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2307. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2308. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2309. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2310. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2311. if order.ID == 0 {
  2312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2313. return
  2314. }
  2315. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  2316. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  2317. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  2318. fmt.Println(count)
  2319. var zero string
  2320. number := count + 1
  2321. if number >= 1000 {
  2322. zero = "0000" + strconv.FormatInt(number, 10)
  2323. } else if number >= 10000 {
  2324. zero = "000" + strconv.FormatInt(number, 10)
  2325. } else if number >= 100000 {
  2326. zero = "00" + strconv.FormatInt(number, 10)
  2327. } else if number >= 1000000 {
  2328. zero = "0" + strconv.FormatInt(number, 10)
  2329. } else {
  2330. zero = strconv.FormatInt(number, 10)
  2331. }
  2332. fmt.Println(zero)
  2333. struct4101 := service.Struct4101{
  2334. PsnNo: order.PsnNo,
  2335. MdtrtId: order.MdtrtId,
  2336. SetlId: order.SetlId,
  2337. PsnName: order.PsnName,
  2338. Gend: order.Gend,
  2339. Brdy: his.Brdy,
  2340. Age: int64(order.Age),
  2341. Naty: order.Naty,
  2342. PatnCertType: "01",
  2343. Certno: order.Certno,
  2344. Prfs: "90",
  2345. ConerName: roles[0].UserName,
  2346. PatnRlts: "99",
  2347. ConerAddr: miConfig.OrgName,
  2348. ConerTel: admin.Mobile,
  2349. HiType: order.Insutype,
  2350. Insuplc: miConfig.InsuplcAdmdvs,
  2351. MaindiagFlag: "1",
  2352. BillCode: last_order.FaPiaoCode,
  2353. BillNo: zero,
  2354. BizSn: order.Number,
  2355. PsnSelfPay: order.PsnPartAmt,
  2356. PsnOwnPay: order.PsnPartAmt,
  2357. AcctPay: order.AcctPay,
  2358. PsnCashpay: order.PsnCashPay,
  2359. HiPaymtd: "1",
  2360. Hsorg: miConfig.InsuplcAdmdvs,
  2361. HsorgOpter: miConfig.InsuplcAdmdvs,
  2362. MedinsFillPsn: curRoles.UserName,
  2363. MedinsFillDept: depart.Name,
  2364. IptMedType: "2",
  2365. AdmTime: his.InHosptialTime,
  2366. AdmEndTime: his.OutHosptialTime,
  2367. }
  2368. struct4101.SetlBegnDate = order.SetlTime
  2369. struct4101.SetlEndDate = order.SetlTime
  2370. var rf []CustomFundPay
  2371. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2372. var tempFunPays []service.CustomStruct
  2373. for _, item := range rf {
  2374. var tempFunPay service.CustomStruct
  2375. tempFunPay.FundPayamt = item.FundPayamt
  2376. tempFunPay.FundPayType = item.FundPayType
  2377. tempFunPays = append(tempFunPays, tempFunPay)
  2378. }
  2379. struct4101.CustomStruct = tempFunPays
  2380. var tempDiaginfos []service.DiaginfoStructTwo
  2381. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2382. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2383. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2384. var config []*models.HisXtDiagnoseConfig
  2385. for _, item := range diagnosis_ids {
  2386. id, _ := strconv.ParseInt(item, 10, 64)
  2387. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2388. config = append(config, &diagnosisConfig)
  2389. }
  2390. for index, item := range config {
  2391. if index == 0 {
  2392. var tempDiaginfo service.DiaginfoStructTwo
  2393. tempDiaginfo.DiagCode = item.CountryCode
  2394. tempDiaginfo.DiagName = item.CountryContentName
  2395. tempDiaginfo.DiagType = "1"
  2396. tempDiaginfo.MaindiagFlag = "1"
  2397. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2398. } else {
  2399. var tempDiaginfo service.DiaginfoStructTwo
  2400. tempDiaginfo.DiagCode = item.CountryCode
  2401. tempDiaginfo.DiagName = item.CountryContentName
  2402. tempDiaginfo.DiagType = "2"
  2403. tempDiaginfo.MaindiagFlag = "0"
  2404. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2405. }
  2406. }
  2407. struct4101.Diseinfo = tempDiaginfos
  2408. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2409. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2410. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2411. tempOpspdiseinfo2.OprnOprtCode = ""
  2412. tempOpspdiseinfo2.OprnOprtName = ""
  2413. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2414. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2415. var iteminfo service.IteminfoStruct
  2416. var bedCostTotal float64 = 0 //床位总费
  2417. var bedCostSelfTotal float64 = 0 //床位自费
  2418. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2419. var operationCostTotal float64 = 0 //手术费
  2420. var operationCostSelfTotal float64 = 0 //手术费
  2421. var operationCostPartSelfTotal float64 = 0 //手术费
  2422. var otherCostTotal float64 = 0 //其他费用
  2423. var otherCostSelfTotal float64 = 0 //其他费用
  2424. var otherCostPartSelfTotal float64 = 0 //其他费用
  2425. var materialCostTotal float64 = 0 //材料费
  2426. var materialCostSelfTotal float64 = 0 //材料费
  2427. var materialCostPartSelfTotal float64 = 0 //材料费
  2428. var westernMedicineCostTotal float64 = 0 //西药费
  2429. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2430. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2431. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2432. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2433. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2434. var checkCostTotal float64 = 0 //检查费
  2435. var checkCostSelfTotal float64 = 0 //检查费
  2436. var checkCostPartSelfTotal float64 = 0 //检查费
  2437. var laboratoryCostTotal float64 = 0 //化验费
  2438. var laboratoryCostSelfTotal float64 = 0 //化验费
  2439. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2440. var treatCostTotal float64 = 0 //治疗费用
  2441. var treatCostSelfTotal float64 = 0 //治疗费用
  2442. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2443. decimal.DivisionPrecision = 2
  2444. var bed_fulamt_ownpay_amt float64 = 0
  2445. var operation_fulamt_ownpay_amt float64 = 0
  2446. var other_fulamt_ownpay_amt float64 = 0
  2447. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2448. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2449. var check_fulamt_ownpay_amt float64 = 0
  2450. var material_fulamt_ownpay_amt float64 = 0
  2451. var laboratory_fulamt_ownpay_amt float64 = 0
  2452. var treat_fulamt_ownpay_amt float64 = 0
  2453. var bed_claa_sunmfee float64 = 0
  2454. var bed_clab_amt float64 = 0
  2455. var bed_other_amt float64 = 0
  2456. var operation_claa_sunmfee float64 = 0
  2457. var operation_clab_amt float64 = 0
  2458. var operation_other_amt float64 = 0
  2459. var other_claa_sunmfee float64 = 0
  2460. var other_clab_amt float64 = 0
  2461. var other_other_amt float64 = 0
  2462. var westernMedicine_claa_sunmfee float64 = 0
  2463. var westernMedicine_clab_amt float64 = 0
  2464. var westernMedicine_other_amt float64 = 0
  2465. var chineseTraditional_claa_sunmfee float64 = 0
  2466. var chineseTraditional_clab_amt float64 = 0
  2467. var chineseTraditional_other_amt float64 = 0
  2468. var check_claa_sunmfee float64 = 0
  2469. var check_clab_amt float64 = 0
  2470. var check_other_amt float64 = 0
  2471. var material_claa_sunmfee float64 = 0
  2472. var material_clab_amt float64 = 0
  2473. var material_other_amt float64 = 0
  2474. var laboratory_claa_sunmfee float64 = 0
  2475. var laboratory_clab_amt float64 = 0
  2476. var laboratory_other_amt float64 = 0
  2477. var treat_claa_sunmfee float64 = 0
  2478. var treat_clab_amt float64 = 0
  2479. var treat_other_amt float64 = 0
  2480. for _, item := range order.HisOrderInfo {
  2481. if item.MedChrgitmType == "01" { //床位费
  2482. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2483. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2484. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2485. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2486. if item.ChrgitmLv == "1" {
  2487. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2488. }
  2489. if item.ChrgitmLv == "2" {
  2490. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2491. }
  2492. if item.ChrgitmLv == "3" {
  2493. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2494. }
  2495. }
  2496. if item.MedChrgitmType == "03" { //检查费
  2497. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2498. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2499. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2500. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2501. if item.ChrgitmLv == "1" {
  2502. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2503. }
  2504. if item.ChrgitmLv == "2" {
  2505. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2506. }
  2507. if item.ChrgitmLv == "3" {
  2508. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2509. }
  2510. }
  2511. if item.MedChrgitmType == "04" { //化验费
  2512. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2513. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2514. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2515. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2516. if item.ChrgitmLv == "1" {
  2517. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2518. }
  2519. if item.ChrgitmLv == "2" {
  2520. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2521. }
  2522. if item.ChrgitmLv == "3" {
  2523. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2524. }
  2525. }
  2526. if item.MedChrgitmType == "05" { //治疗费
  2527. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2528. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2529. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2530. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2531. if item.ChrgitmLv == "1" {
  2532. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2533. }
  2534. if item.ChrgitmLv == "2" {
  2535. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2536. }
  2537. if item.ChrgitmLv == "3" {
  2538. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2539. }
  2540. }
  2541. if item.MedChrgitmType == "06" { //手术费
  2542. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2543. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2544. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2545. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2546. if item.ChrgitmLv == "1" {
  2547. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2548. }
  2549. if item.ChrgitmLv == "2" {
  2550. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2551. }
  2552. if item.ChrgitmLv == "3" {
  2553. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2554. }
  2555. }
  2556. if item.MedChrgitmType == "08" { //材料费
  2557. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2558. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2559. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2560. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2561. if item.ChrgitmLv == "1" {
  2562. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2563. }
  2564. if item.ChrgitmLv == "2" {
  2565. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2566. }
  2567. if item.ChrgitmLv == "3" {
  2568. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2569. }
  2570. }
  2571. if item.MedChrgitmType == "09" { //西药费
  2572. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2573. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2574. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2575. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2576. if item.ChrgitmLv == "1" {
  2577. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2578. }
  2579. if item.ChrgitmLv == "2" {
  2580. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2581. }
  2582. if item.ChrgitmLv == "3" {
  2583. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2584. }
  2585. }
  2586. if item.MedChrgitmType == "11" { //中成费
  2587. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2588. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2589. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2590. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2591. if item.ChrgitmLv == "1" {
  2592. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2593. }
  2594. if item.ChrgitmLv == "2" {
  2595. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2596. }
  2597. if item.ChrgitmLv == "3" {
  2598. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2599. }
  2600. }
  2601. if item.MedChrgitmType == "14" { //其他费
  2602. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2603. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2604. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2605. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2606. if item.ChrgitmLv == "1" {
  2607. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2608. }
  2609. if item.ChrgitmLv == "2" {
  2610. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2611. }
  2612. if item.ChrgitmLv == "3" {
  2613. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2614. }
  2615. }
  2616. }
  2617. var iteminfoStructs []service.IteminfoStruct
  2618. if bedCostTotal != 0 {
  2619. iteminfo.MedChrgitm = "01"
  2620. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2621. iteminfo.Amt = bedCostTotal
  2622. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2623. iteminfo.ClabAmt = bed_clab_amt
  2624. iteminfo.OthAmt = bed_other_amt
  2625. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2626. }
  2627. if checkCostTotal != 0 {
  2628. iteminfo.MedChrgitm = "03"
  2629. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2630. iteminfo.Amt = checkCostTotal
  2631. iteminfo.ClaaSumfee = check_claa_sunmfee
  2632. iteminfo.ClabAmt = check_clab_amt
  2633. iteminfo.OthAmt = check_other_amt
  2634. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2635. }
  2636. if laboratoryCostTotal != 0 {
  2637. iteminfo.MedChrgitm = "04"
  2638. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2639. iteminfo.Amt = laboratoryCostTotal
  2640. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2641. iteminfo.ClabAmt = laboratory_clab_amt
  2642. iteminfo.OthAmt = laboratory_other_amt
  2643. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2644. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2645. }
  2646. if treatCostTotal != 0 {
  2647. iteminfo.MedChrgitm = "05"
  2648. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2649. iteminfo.Amt = treatCostTotal
  2650. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2651. iteminfo.ClabAmt = treat_clab_amt
  2652. iteminfo.OthAmt = treat_other_amt
  2653. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2654. //(struct4101.IteminfoStruct, iteminfo)
  2655. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2656. }
  2657. if operationCostTotal != 0 {
  2658. iteminfo.MedChrgitm = "06"
  2659. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2660. iteminfo.Amt = operationCostTotal
  2661. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2662. iteminfo.ClabAmt = operation_clab_amt
  2663. iteminfo.OthAmt = operation_other_amt
  2664. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2665. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2666. }
  2667. if materialCostTotal != 0 {
  2668. iteminfo.MedChrgitm = "08"
  2669. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2670. iteminfo.Amt = materialCostTotal
  2671. iteminfo.ClaaSumfee = material_claa_sunmfee
  2672. iteminfo.ClabAmt = material_clab_amt
  2673. iteminfo.OthAmt = material_other_amt
  2674. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2675. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2676. }
  2677. if westernMedicineCostTotal != 0 {
  2678. iteminfo.MedChrgitm = "09"
  2679. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2680. iteminfo.Amt = westernMedicineCostTotal
  2681. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2682. iteminfo.ClabAmt = westernMedicine_clab_amt
  2683. iteminfo.OthAmt = westernMedicine_other_amt
  2684. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2685. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2686. }
  2687. if chineseTraditionalMedicineCostTotal != 0 {
  2688. iteminfo.MedChrgitm = "11"
  2689. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2690. iteminfo.Amt = westernMedicineCostTotal
  2691. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2692. iteminfo.ClabAmt = westernMedicine_clab_amt
  2693. iteminfo.OthAmt = westernMedicine_other_amt
  2694. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2695. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2696. }
  2697. if otherCostTotal != 0 {
  2698. iteminfo.MedChrgitm = "14"
  2699. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2700. iteminfo.Amt = otherCostTotal
  2701. iteminfo.ClaaSumfee = other_claa_sunmfee
  2702. iteminfo.ClabAmt = other_clab_amt
  2703. iteminfo.OthAmt = other_other_amt
  2704. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2705. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2706. }
  2707. struct4101.IteminfoStruct = iteminfoStructs
  2708. struct4101.Ntly = "中国"
  2709. struct4101.AdmCaty = "A03.06"
  2710. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2711. fmt.Println(result)
  2712. var dat map[string]interface{}
  2713. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2714. fmt.Println(dat)
  2715. } else {
  2716. fmt.Println(err)
  2717. }
  2718. userJSONBytes, _ := json.Marshal(dat)
  2719. var res ResultSeventeen
  2720. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2721. utils.ErrorLog("解析失败:%v", err)
  2722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2723. return
  2724. }
  2725. if res.Infcode != 0 {
  2726. c.ServeSuccessJSON(map[string]interface{}{
  2727. "failed_code": -10,
  2728. "msg": res.ErrMsg,
  2729. })
  2730. return
  2731. } else {
  2732. order.FaPiaoNumber = zero
  2733. order.FaPiaoCode = last_order.FaPiaoCode
  2734. service.UpdateOrder(order)
  2735. hisFundSettleListResult := &models.HisFundSettleListResult{
  2736. Number: res.Output.SetlListId,
  2737. Status: 1,
  2738. Ctime: time.Now().Unix(),
  2739. Mtime: time.Now().Unix(),
  2740. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2741. IsUpload: 1,
  2742. OrderId: order_id,
  2743. }
  2744. service.CreateUploadRecord(hisFundSettleListResult)
  2745. c.ServeSuccessJSON(map[string]interface{}{
  2746. "msg": "上传成功",
  2747. "result": hisFundSettleListResult,
  2748. })
  2749. return
  2750. }
  2751. }
  2752. func (c *HisApiController) GetBatchSettleList() {
  2753. orders, _ := service.GetAllHisOrder(10106)
  2754. for _, item := range orders {
  2755. order_id := item.ID
  2756. order, _ := service.GetHisOrderByIDTwo(order_id)
  2757. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2758. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2759. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2760. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  2761. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2762. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2763. if order.ID == 0 {
  2764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2765. return
  2766. }
  2767. if his.BalanceAccountsType == 2 {
  2768. continue
  2769. }
  2770. struct4101 := service.Struct4101{
  2771. PsnNo: order.PsnNo,
  2772. MdtrtId: order.MdtrtId,
  2773. SetlId: order.SetlId,
  2774. PsnName: order.PsnName,
  2775. Gend: order.Gend,
  2776. Brdy: his.Brdy,
  2777. Age: his.Age,
  2778. Naty: order.Naty,
  2779. PatnCertType: "01",
  2780. Certno: order.Certno,
  2781. Prfs: "90",
  2782. ConerName: roles[0].UserName,
  2783. PatnRlts: "99",
  2784. ConerAddr: miConfig.OrgName,
  2785. ConerTel: admin.Mobile,
  2786. HiType: order.Insutype,
  2787. Insuplc: his.InsuplcAdmdvs,
  2788. MaindiagFlag: "1",
  2789. BillCode: order.FaPiaoCode,
  2790. BillNo: order.FaPiaoNumber,
  2791. BizSn: order.Number,
  2792. PsnSelfPay: order.PsnPartAmt,
  2793. PsnOwnPay: order.PsnPartAmt,
  2794. AcctPay: order.AcctPay,
  2795. PsnCashpay: order.PsnCashPay,
  2796. HiPaymtd: "1",
  2797. Hsorg: his.InsuplcAdmdvs,
  2798. HsorgOpter: his.InsuplcAdmdvs,
  2799. MedinsFillPsn: curRoles.UserName,
  2800. MedinsFillDept: depart.Name,
  2801. IptMedType: "2",
  2802. }
  2803. struct4101.SetlBegnDate = order.SetlTime
  2804. struct4101.SetlEndDate = order.SetlTime
  2805. //if order.SettleType == 1 {
  2806. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  2807. // dateStr := t.Format("2006-01-02")
  2808. // struct4101.SetlBegnDate = dateStr
  2809. // struct4101.SetlEndDate = dateStr
  2810. //} else {
  2811. // t := time.Unix(int64(order.SettleStartTime), 0)
  2812. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  2813. // dateStartStr := t.Format("2006-01-02")
  2814. // dateEndStr := t2.Format("2006-01-02")
  2815. // struct4101.SetlBegnDate = dateStartStr
  2816. // struct4101.SetlEndDate = dateEndStr
  2817. //}
  2818. var rf []CustomFundPay
  2819. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2820. var tempFunPays []service.CustomStruct
  2821. var tempFunPay610100 service.CustomStruct
  2822. for _, item := range rf {
  2823. if item.FundPayType == "610100" {
  2824. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  2825. tempFunPay610100.FundPayType = item.FundPayType
  2826. } else {
  2827. var tempFunPay service.CustomStruct
  2828. tempFunPay.FundPayamt = item.FundPayamt
  2829. tempFunPay.FundPayType = item.FundPayType
  2830. tempFunPays = append(tempFunPays, tempFunPay)
  2831. }
  2832. }
  2833. tempFunPays = append(tempFunPays, tempFunPay610100)
  2834. struct4101.CustomStruct = tempFunPays
  2835. var tempDiaginfos []service.DiaginfoStructTwo
  2836. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2837. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2838. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2839. var config []*models.HisXtDiagnoseConfig
  2840. for _, item := range diagnosis_ids {
  2841. id, _ := strconv.ParseInt(item, 10, 64)
  2842. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2843. config = append(config, &diagnosisConfig)
  2844. }
  2845. for index, item := range config {
  2846. if index == 0 {
  2847. var tempDiaginfo service.DiaginfoStructTwo
  2848. tempDiaginfo.DiagCode = item.CountryCode
  2849. tempDiaginfo.DiagName = item.CountryContentName
  2850. tempDiaginfo.DiagType = "1"
  2851. tempDiaginfo.MaindiagFlag = "1"
  2852. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2853. } else {
  2854. var tempDiaginfo service.DiaginfoStructTwo
  2855. tempDiaginfo.DiagCode = item.CountryCode
  2856. tempDiaginfo.DiagName = item.CountryContentName
  2857. tempDiaginfo.DiagType = "2"
  2858. tempDiaginfo.MaindiagFlag = "0"
  2859. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2860. }
  2861. }
  2862. struct4101.Diseinfo = tempDiaginfos
  2863. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2864. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2865. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2866. tempOpspdiseinfo2.OprnOprtCode = ""
  2867. tempOpspdiseinfo2.OprnOprtName = ""
  2868. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2869. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2870. var iteminfo service.IteminfoStruct
  2871. var bedCostTotal float64 = 0 //床位总费
  2872. var bedCostSelfTotal float64 = 0 //床位自费
  2873. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2874. var examineCostTotal float64 = 0 //诊查总费
  2875. var examineCostSelfTotal float64 = 0 //诊查自费
  2876. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  2877. var nursingCostTotal float64 = 0 //护理总费
  2878. var nursingCostSelfTotal float64 = 0 //护理自费
  2879. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  2880. var chineseMedicineCostTotal float64 = 0 //中成药
  2881. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  2882. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  2883. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  2884. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  2885. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  2886. var registerCostTotal float64 = 0 //一般诊疗费
  2887. var registerCostSelfTotal float64 = 0 //一般诊疗费
  2888. var registerPartSelfTotal float64 = 0 //一般诊疗费
  2889. var operationCostTotal float64 = 0 //手术费
  2890. var operationCostSelfTotal float64 = 0 //手术费
  2891. var operationCostPartSelfTotal float64 = 0 //手术费
  2892. var otherCostTotal float64 = 0 //其他费用
  2893. var otherCostSelfTotal float64 = 0 //其他费用
  2894. var otherCostPartSelfTotal float64 = 0 //其他费用
  2895. var materialCostTotal float64 = 0 //材料费
  2896. var materialCostSelfTotal float64 = 0 //材料费
  2897. var materialCostPartSelfTotal float64 = 0 //材料费
  2898. var westernMedicineCostTotal float64 = 0 //西药费
  2899. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2900. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2901. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2902. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2903. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2904. var checkCostTotal float64 = 0 //检查费
  2905. var checkCostSelfTotal float64 = 0 //检查费
  2906. var checkCostPartSelfTotal float64 = 0 //检查费
  2907. var laboratoryCostTotal float64 = 0 //化验费
  2908. var laboratoryCostSelfTotal float64 = 0 //化验费
  2909. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2910. var treatCostTotal float64 = 0 //治疗费用
  2911. var treatCostSelfTotal float64 = 0 //治疗费用
  2912. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2913. decimal.DivisionPrecision = 2
  2914. var bed_fulamt_ownpay_amt float64 = 0
  2915. var examine_fulamt_ownpay_amt float64 = 0
  2916. var nursing_fulamt_ownpay_amt float64 = 0
  2917. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  2918. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  2919. var register_fulamt_ownpay_amt float64 = 0
  2920. var operation_fulamt_ownpay_amt float64 = 0
  2921. var other_fulamt_ownpay_amt float64 = 0
  2922. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2923. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2924. var check_fulamt_ownpay_amt float64 = 0
  2925. var material_fulamt_ownpay_amt float64 = 0
  2926. var laboratory_fulamt_ownpay_amt float64 = 0
  2927. var treat_fulamt_ownpay_amt float64 = 0
  2928. var bed_claa_sunmfee float64 = 0
  2929. var bed_clab_amt float64 = 0
  2930. var bed_other_amt float64 = 0
  2931. var examine_claa_sunmfee float64 = 0
  2932. var examine_clab_amt float64 = 0
  2933. var examine_other_amt float64 = 0
  2934. var nursing_claa_sunmfee float64 = 0
  2935. var nursing_clab_amt float64 = 0
  2936. var nursing_other_amt float64 = 0
  2937. var chinese_medicine_claa_sunmfee float64 = 0
  2938. var chinese_medicine_clab_amt float64 = 0
  2939. var chinese_medicine_other_amt float64 = 0
  2940. var commonly_treatment_claa_sunmfee float64 = 0
  2941. var commonly_treatment_clab_amt float64 = 0
  2942. var commonly_treatment_other_amt float64 = 0
  2943. var operation_claa_sunmfee float64 = 0
  2944. var operation_clab_amt float64 = 0
  2945. var operation_other_amt float64 = 0
  2946. var other_claa_sunmfee float64 = 0
  2947. var other_clab_amt float64 = 0
  2948. var other_other_amt float64 = 0
  2949. var westernMedicine_claa_sunmfee float64 = 0
  2950. var westernMedicine_clab_amt float64 = 0
  2951. var westernMedicine_other_amt float64 = 0
  2952. var chineseTraditional_claa_sunmfee float64 = 0
  2953. var chineseTraditional_clab_amt float64 = 0
  2954. var chineseTraditional_other_amt float64 = 0
  2955. var check_claa_sunmfee float64 = 0
  2956. var check_clab_amt float64 = 0
  2957. var check_other_amt float64 = 0
  2958. var material_claa_sunmfee float64 = 0
  2959. var material_clab_amt float64 = 0
  2960. var material_other_amt float64 = 0
  2961. var laboratory_claa_sunmfee float64 = 0
  2962. var laboratory_clab_amt float64 = 0
  2963. var laboratory_other_amt float64 = 0
  2964. var treat_claa_sunmfee float64 = 0
  2965. var treat_clab_amt float64 = 0
  2966. var treat_other_amt float64 = 0
  2967. var register_claa_sunmfee float64 = 0
  2968. var register_clab_amt float64 = 0
  2969. var register_other_amt float64 = 0
  2970. for _, item := range order.HisOrderInfo {
  2971. if item.MedChrgitmType == "01" { //床位费
  2972. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2973. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2974. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2975. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2976. if item.ChrgitmLv == "1" {
  2977. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2978. }
  2979. if item.ChrgitmLv == "2" {
  2980. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2981. }
  2982. if item.ChrgitmLv == "3" {
  2983. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2984. }
  2985. }
  2986. if item.MedChrgitmType == "02" { //诊查
  2987. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2988. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2989. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2990. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2991. if item.ChrgitmLv == "1" {
  2992. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2993. }
  2994. if item.ChrgitmLv == "2" {
  2995. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2996. }
  2997. if item.ChrgitmLv == "3" {
  2998. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2999. }
  3000. }
  3001. if item.MedChrgitmType == "03" { //检查费
  3002. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3003. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3004. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3005. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3006. if item.ChrgitmLv == "1" {
  3007. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3008. }
  3009. if item.ChrgitmLv == "2" {
  3010. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3011. }
  3012. if item.ChrgitmLv == "3" {
  3013. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3014. }
  3015. }
  3016. if item.MedChrgitmType == "04" { //化验费
  3017. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3018. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3019. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3020. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3021. if item.ChrgitmLv == "1" {
  3022. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3023. }
  3024. if item.ChrgitmLv == "2" {
  3025. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3026. }
  3027. if item.ChrgitmLv == "3" {
  3028. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3029. }
  3030. }
  3031. if item.MedChrgitmType == "05" { //治疗费
  3032. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3033. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3034. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3035. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3036. if item.ChrgitmLv == "1" {
  3037. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3038. }
  3039. if item.ChrgitmLv == "2" {
  3040. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3041. }
  3042. if item.ChrgitmLv == "3" {
  3043. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3044. }
  3045. }
  3046. if item.MedChrgitmType == "06" { //手术费
  3047. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3048. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3049. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3050. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3051. if item.ChrgitmLv == "1" {
  3052. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3053. }
  3054. if item.ChrgitmLv == "2" {
  3055. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3056. }
  3057. if item.ChrgitmLv == "3" {
  3058. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3059. }
  3060. }
  3061. if item.MedChrgitmType == "07" { //手术费
  3062. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3063. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3064. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3065. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3066. if item.ChrgitmLv == "1" {
  3067. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3068. }
  3069. if item.ChrgitmLv == "2" {
  3070. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3071. }
  3072. if item.ChrgitmLv == "3" {
  3073. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3074. }
  3075. }
  3076. if item.MedChrgitmType == "08" { //材料费
  3077. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3078. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3079. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3080. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3081. if item.ChrgitmLv == "1" {
  3082. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3083. }
  3084. if item.ChrgitmLv == "2" {
  3085. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3086. }
  3087. if item.ChrgitmLv == "3" {
  3088. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3089. }
  3090. }
  3091. if item.MedChrgitmType == "09" { //西药费
  3092. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3093. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3094. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3095. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3096. if item.ChrgitmLv == "1" {
  3097. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3098. }
  3099. if item.ChrgitmLv == "2" {
  3100. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3101. }
  3102. if item.ChrgitmLv == "3" {
  3103. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3104. }
  3105. }
  3106. if item.MedChrgitmType == "10" { //中药饮片
  3107. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3108. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3109. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3110. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3111. if item.ChrgitmLv == "1" {
  3112. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3113. }
  3114. if item.ChrgitmLv == "2" {
  3115. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3116. }
  3117. if item.ChrgitmLv == "3" {
  3118. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3119. }
  3120. }
  3121. if item.MedChrgitmType == "11" { //中成费
  3122. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3123. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3124. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3125. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3126. if item.ChrgitmLv == "1" {
  3127. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3128. }
  3129. if item.ChrgitmLv == "2" {
  3130. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3131. }
  3132. if item.ChrgitmLv == "3" {
  3133. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3134. }
  3135. }
  3136. if item.MedChrgitmType == "12" { //中成费
  3137. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3138. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3139. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3140. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3141. if item.ChrgitmLv == "1" {
  3142. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3143. }
  3144. if item.ChrgitmLv == "2" {
  3145. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3146. }
  3147. if item.ChrgitmLv == "3" {
  3148. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3149. }
  3150. }
  3151. if item.MedChrgitmType == "13" { //中成费
  3152. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3153. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3154. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3155. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3156. if item.ChrgitmLv == "1" {
  3157. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3158. }
  3159. if item.ChrgitmLv == "2" {
  3160. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3161. }
  3162. if item.ChrgitmLv == "3" {
  3163. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3164. }
  3165. }
  3166. if item.MedChrgitmType == "14" { //其他费
  3167. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3168. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3169. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3170. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3171. if item.ChrgitmLv == "1" {
  3172. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3173. }
  3174. if item.ChrgitmLv == "2" {
  3175. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3176. }
  3177. if item.ChrgitmLv == "3" {
  3178. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3179. }
  3180. }
  3181. }
  3182. var iteminfoStructs []service.IteminfoStruct
  3183. if bedCostTotal != 0 {
  3184. iteminfo.MedChrgitm = "01"
  3185. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3186. iteminfo.Amt = bedCostTotal
  3187. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3188. iteminfo.ClabAmt = bed_clab_amt
  3189. iteminfo.OthAmt = bed_other_amt
  3190. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3191. }
  3192. if examineCostTotal != 0 {
  3193. iteminfo.MedChrgitm = "02"
  3194. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  3195. iteminfo.Amt = examineCostTotal
  3196. iteminfo.ClaaSumfee = examine_claa_sunmfee
  3197. iteminfo.ClabAmt = examine_clab_amt
  3198. iteminfo.OthAmt = examine_other_amt
  3199. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3200. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3201. }
  3202. if checkCostTotal != 0 {
  3203. iteminfo.MedChrgitm = "03"
  3204. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3205. iteminfo.Amt = checkCostTotal
  3206. iteminfo.ClaaSumfee = check_claa_sunmfee
  3207. iteminfo.ClabAmt = check_clab_amt
  3208. iteminfo.OthAmt = check_other_amt
  3209. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3210. }
  3211. if laboratoryCostTotal != 0 {
  3212. iteminfo.MedChrgitm = "04"
  3213. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3214. iteminfo.Amt = laboratoryCostTotal
  3215. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3216. iteminfo.ClabAmt = laboratory_clab_amt
  3217. iteminfo.OthAmt = laboratory_other_amt
  3218. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3219. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3220. }
  3221. if treatCostTotal != 0 {
  3222. iteminfo.MedChrgitm = "05"
  3223. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3224. iteminfo.Amt = treatCostTotal
  3225. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3226. iteminfo.ClabAmt = treat_clab_amt
  3227. iteminfo.OthAmt = treat_other_amt
  3228. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3229. //(struct4101.IteminfoStruct, iteminfo)
  3230. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3231. }
  3232. if operationCostTotal != 0 {
  3233. iteminfo.MedChrgitm = "06"
  3234. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3235. iteminfo.Amt = operationCostTotal
  3236. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3237. iteminfo.ClabAmt = operation_clab_amt
  3238. iteminfo.OthAmt = operation_other_amt
  3239. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3240. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3241. }
  3242. if nursingCostTotal != 0 {
  3243. iteminfo.MedChrgitm = "07"
  3244. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  3245. iteminfo.Amt = nursingCostTotal
  3246. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  3247. iteminfo.ClabAmt = nursing_clab_amt
  3248. iteminfo.OthAmt = nursing_other_amt
  3249. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3250. }
  3251. if materialCostTotal != 0 {
  3252. iteminfo.MedChrgitm = "08"
  3253. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3254. iteminfo.Amt = materialCostTotal
  3255. iteminfo.ClaaSumfee = material_claa_sunmfee
  3256. iteminfo.ClabAmt = material_clab_amt
  3257. iteminfo.OthAmt = material_other_amt
  3258. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3259. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3260. }
  3261. if westernMedicineCostTotal != 0 {
  3262. iteminfo.MedChrgitm = "09"
  3263. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3264. iteminfo.Amt = westernMedicineCostTotal
  3265. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3266. iteminfo.ClabAmt = westernMedicine_clab_amt
  3267. iteminfo.OthAmt = westernMedicine_other_amt
  3268. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3269. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3270. }
  3271. if chineseMedicineCostTotal != 0 {
  3272. iteminfo.MedChrgitm = "10"
  3273. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  3274. iteminfo.Amt = chineseMedicineCostTotal
  3275. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  3276. iteminfo.ClabAmt = chinese_medicine_clab_amt
  3277. iteminfo.OthAmt = chinese_medicine_other_amt
  3278. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3279. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3280. }
  3281. if chineseTraditionalMedicineCostTotal != 0 {
  3282. iteminfo.MedChrgitm = "11"
  3283. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3284. iteminfo.Amt = westernMedicineCostTotal
  3285. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3286. iteminfo.ClabAmt = westernMedicine_clab_amt
  3287. iteminfo.OthAmt = westernMedicine_other_amt
  3288. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3289. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3290. }
  3291. if commonlyTreatmentCostTotal != 0 {
  3292. iteminfo.MedChrgitm = "12"
  3293. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  3294. iteminfo.Amt = commonlyTreatmentCostTotal
  3295. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  3296. iteminfo.ClabAmt = commonly_treatment_clab_amt
  3297. iteminfo.OthAmt = commonly_treatment_other_amt
  3298. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3299. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3300. }
  3301. if registerCostTotal != 0 {
  3302. iteminfo.MedChrgitm = "13"
  3303. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  3304. iteminfo.Amt = registerCostTotal
  3305. iteminfo.ClaaSumfee = register_claa_sunmfee
  3306. iteminfo.ClabAmt = register_clab_amt
  3307. iteminfo.OthAmt = register_other_amt
  3308. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3309. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3310. }
  3311. if otherCostTotal != 0 {
  3312. iteminfo.MedChrgitm = "14"
  3313. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3314. iteminfo.Amt = otherCostTotal
  3315. iteminfo.ClaaSumfee = other_claa_sunmfee
  3316. iteminfo.ClabAmt = other_clab_amt
  3317. iteminfo.OthAmt = other_other_amt
  3318. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3319. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3320. }
  3321. struct4101.IteminfoStruct = iteminfoStructs
  3322. struct4101.Ntly = "中国"
  3323. struct4101.AdmCaty = "A03.06"
  3324. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  3325. fmt.Println(result)
  3326. var dat map[string]interface{}
  3327. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3328. fmt.Println(dat)
  3329. } else {
  3330. fmt.Println(err)
  3331. }
  3332. userJSONBytes, _ := json.Marshal(dat)
  3333. var res ResultSeventeen
  3334. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3335. utils.ErrorLog("解析失败:%v", err)
  3336. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3337. adminUser := c.GetAdminUserInfo()
  3338. errlog := &models.HisOrderError{
  3339. UserOrgId: adminUser.CurrentOrgId,
  3340. Ctime: time.Now().Unix(),
  3341. Mtime: time.Now().Unix(),
  3342. ErrMsg: res.ErrMsg + "解析失败",
  3343. Status: 1,
  3344. PatientId: order_id,
  3345. Stage: 10106,
  3346. }
  3347. service.CreateErrMsgLog(errlog)
  3348. continue
  3349. }
  3350. if res.Infcode != 0 {
  3351. adminUser := c.GetAdminUserInfo()
  3352. errlog := &models.HisOrderError{
  3353. UserOrgId: adminUser.CurrentOrgId,
  3354. Ctime: time.Now().Unix(),
  3355. Mtime: time.Now().Unix(),
  3356. ErrMsg: res.ErrMsg,
  3357. Status: 1,
  3358. PatientId: order_id,
  3359. Stage: 10106,
  3360. }
  3361. service.CreateErrMsgLog(errlog)
  3362. continue
  3363. } else {
  3364. hisFundSettleListResult := &models.HisFundSettleListResult{
  3365. Number: res.Output.SetlListId,
  3366. Status: 1,
  3367. Ctime: time.Now().Unix(),
  3368. Mtime: time.Now().Unix(),
  3369. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3370. IsUpload: 1,
  3371. OrderId: order_id,
  3372. }
  3373. service.CreateUploadRecord(hisFundSettleListResult)
  3374. continue
  3375. }
  3376. }
  3377. }
  3378. func (c *HisApiController) GetOrgInfo() {
  3379. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  3380. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  3381. }
  3382. func (c *HisApiController) GetHisPatientInfo() {
  3383. medical_insurance_card := c.GetString("medical_insurance_card")
  3384. id_card_type, _ := c.GetInt64("id_card_type")
  3385. id_card := c.GetString("id_card")
  3386. adminInfo := c.GetAdminUserInfo()
  3387. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3388. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3389. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  3390. IdCardNo := ""
  3391. if id_card_type == 1 {
  3392. IdCardNo = medical_insurance_card
  3393. } else if id_card_type == 2 {
  3394. IdCardNo = id_card
  3395. }
  3396. if config.IsOpen == 1 {
  3397. api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + IdCardNo + "&org_name=" + miConfig.OrgName + "&doctor=" + appRole.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  3398. resp, requestErr := http.Get(api)
  3399. if requestErr != nil {
  3400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3401. return
  3402. }
  3403. defer resp.Body.Close()
  3404. body, ioErr := ioutil.ReadAll(resp.Body)
  3405. if ioErr != nil {
  3406. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3408. return
  3409. }
  3410. var respJSON map[string]interface{}
  3411. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3412. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3414. return
  3415. }
  3416. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3417. userJSONBytes, _ := json.Marshal(userJSON)
  3418. var res ResultTwo
  3419. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3420. utils.ErrorLog("解析失败:%v", err)
  3421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3422. return
  3423. }
  3424. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3425. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3426. infoStr := string(Iinfos)
  3427. idetinfoStr := string(Idetinfos)
  3428. if res.Infcode == 0 {
  3429. his := models.VMHisPatient{
  3430. Status: 1,
  3431. Ctime: time.Now().Unix(),
  3432. Mtime: time.Now().Unix(),
  3433. PsnNo: res.Output.Baseinfo.PsnNo,
  3434. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3435. Certno: res.Output.Baseinfo.Certno,
  3436. PsnName: res.Output.Baseinfo.PsnName,
  3437. Gend: res.Output.Baseinfo.Gend,
  3438. Naty: res.Output.Baseinfo.Naty,
  3439. Brdy: res.Output.Baseinfo.Brdy,
  3440. Age: res.Output.Baseinfo.Age,
  3441. Iinfo: infoStr,
  3442. Idetinfo: idetinfoStr,
  3443. UserOrgId: adminInfo.CurrentOrgId,
  3444. IsReturn: 1,
  3445. IdCardType: id_card_type,
  3446. }
  3447. c.ServeSuccessJSON(map[string]interface{}{
  3448. "info": his,
  3449. })
  3450. } else {
  3451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3452. return
  3453. }
  3454. }
  3455. }
  3456. //func GetBasBaseInfo() (jsonStr string, err error) {
  3457. //
  3458. // handle := syscall.NewLazyDLL("SSCard.dll")
  3459. // add := handle.NewProc("ReadCardBas")
  3460. // str := make([]byte, 1024)
  3461. // str1 := make([]byte, 1024)
  3462. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3463. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3464. //
  3465. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3466. //
  3467. // fmt.Println("> Add(4,5)的结果为:", ret)
  3468. // handle.Release()
  3469. //
  3470. // return "", nil
  3471. //
  3472. //}
  3473. //func GetQRBaseInfo() (jsonStr string, err error) {
  3474. // handle := syscall.LoadDLL("SSCard.dll")
  3475. // ReadCardBas := handle.FindProc("GetQRBase")
  3476. //
  3477. // str := make([]byte, 256)
  3478. // str1 := make([]byte, 256)
  3479. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3480. //
  3481. // fmt.Println(string(str))
  3482. // fmt.Println(r)
  3483. // return string(str), nil
  3484. //}
  3485. //func CardInit() int {
  3486. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  3487. // add := DllTestDef.MustFindProc("Init")
  3488. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3489. // if err != nil {
  3490. // fmt.Println("SSCard的运算结果为:", ret)
  3491. // }
  3492. // result := int(ret)
  3493. // return result
  3494. //}
  3495. //func CardInit() int {
  3496. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3497. // if err != nil {
  3498. // fmt.Println("SSCard的运算结果为:", ret)
  3499. // }
  3500. // fmt.Println(err)
  3501. // result := int(ret)
  3502. // return result
  3503. //}
  3504. func IntPtr(n int) uintptr {
  3505. return uintptr(n)
  3506. }
  3507. func StrPtr(s string) uintptr {
  3508. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3509. }
  3510. type Result2001 struct {
  3511. Cainfo interface{} `json:"cainfo"`
  3512. ErrMsg string `json:"err_msg"`
  3513. InfRefmsgid string `json:"inf_refmsgid"`
  3514. Infcode int64 `json:"infcode"`
  3515. Output struct {
  3516. Trtinfo struct {
  3517. PsnNo string `json:"psn_no"`
  3518. TrtChkType string `json:"trt_chk_type"`
  3519. FundPayType string `json:"fund_pay_type"`
  3520. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3521. Begndate string `json:"begndate"`
  3522. Enddate string `json:"enddate"`
  3523. TrtChkRslt string `json:"trt_chk_rslt"`
  3524. } `json:"trtinfo"`
  3525. } `json:"output"`
  3526. RefmsgTime string `json:"refmsg_time"`
  3527. RespondTime string `json:"respond_time"`
  3528. Signtype interface{} `json:"signtype"`
  3529. WarnMsg interface{} `json:"warn_msg"`
  3530. }
  3531. type Result2001Org10265 struct {
  3532. Cainfo interface{} `json:"cainfo"`
  3533. ErrMsg string `json:"err_msg"`
  3534. InfRefmsgid string `json:"inf_refmsgid"`
  3535. Infcode string `json:"infcode"`
  3536. Output struct {
  3537. Trtinfo struct {
  3538. PsnNo string `json:"psn_no"`
  3539. TrtChkType string `json:"trt_chk_type"`
  3540. FundPayType string `json:"fund_pay_type"`
  3541. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3542. Begndate string `json:"begndate"`
  3543. Enddate string `json:"enddate"`
  3544. TrtChkRslt string `json:"trt_chk_rslt"`
  3545. } `json:"trtinfo"`
  3546. } `json:"output"`
  3547. RefmsgTime string `json:"refmsg_time"`
  3548. RespondTime string `json:"respond_time"`
  3549. Signtype interface{} `json:"signtype"`
  3550. WarnMsg interface{} `json:"warn_msg"`
  3551. }
  3552. type ResultTwo struct {
  3553. ErrMsg string `json:"err_msg"`
  3554. InfRefmsgid string `json:"inf_refmsgid"`
  3555. Infcode int64 `json:"infcode"`
  3556. Output struct {
  3557. Baseinfo struct {
  3558. Age float64 `json:"age"`
  3559. Brdy string `json:"brdy"`
  3560. Certno string `json:"certno"`
  3561. Gend string `json:"gend"`
  3562. Naty string `json:"naty"`
  3563. PsnCertType string `json:"psn_cert_type"`
  3564. PsnName string `json:"psn_name"`
  3565. PsnNo string `json:"psn_no"`
  3566. } `json:"baseinfo"`
  3567. Idetinfo []interface{} `json:"idetinfo"`
  3568. Iinfo []struct {
  3569. Balc float64 `json:"balc"`
  3570. CvlservFlag string `json:"cvlserv_flag"`
  3571. EmpName string `json:"emp_name"`
  3572. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3573. Insutype string `json:"insutype"`
  3574. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3575. PausInsuDate string `json:"paus_insu_date"`
  3576. PsnInsuDate string `json:"psn_insu_date"`
  3577. PsnInsuStas string `json:"psn_insu_stas"`
  3578. PsnType string `json:"psn_type"`
  3579. } `json:"insuinfo"`
  3580. } `json:"output"`
  3581. RefmsgTime string `json:"refmsg_time"`
  3582. RespondTime string `json:"respond_time"`
  3583. Signtype interface{} `json:"signtype"`
  3584. WarnInfo interface{} `json:"warn_info"`
  3585. }
  3586. type ResultTwo10265 struct {
  3587. ErrMsg string `json:"err_msg"`
  3588. InfRefmsgid string `json:"inf_refmsgid"`
  3589. Infcode string `json:"infcode"`
  3590. Output struct {
  3591. Baseinfo struct {
  3592. Age float64 `json:"age"`
  3593. Brdy string `json:"brdy"`
  3594. Certno string `json:"certno"`
  3595. Gend string `json:"gend"`
  3596. Naty string `json:"naty"`
  3597. PsnCertType string `json:"psn_cert_type"`
  3598. PsnName string `json:"psn_name"`
  3599. PsnNo string `json:"psn_no"`
  3600. } `json:"baseinfo"`
  3601. Idetinfo []interface{} `json:"idetinfo"`
  3602. Iinfo []struct {
  3603. Balc float64 `json:"balc"`
  3604. CvlservFlag string `json:"cvlserv_flag"`
  3605. EmpName string `json:"emp_name"`
  3606. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3607. Insutype string `json:"insutype"`
  3608. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3609. PausInsuDate string `json:"paus_insu_date"`
  3610. PsnInsuDate string `json:"psn_insu_date"`
  3611. PsnInsuStas string `json:"psn_insu_stas"`
  3612. PsnType string `json:"psn_type"`
  3613. } `json:"insuinfo"`
  3614. } `json:"output"`
  3615. RefmsgTime string `json:"refmsg_time"`
  3616. RespondTime string `json:"respond_time"`
  3617. Signtype interface{} `json:"signtype"`
  3618. WarnInfo interface{} `json:"warn_info"`
  3619. }
  3620. type ResultThree struct {
  3621. Cainfo interface{} `json:"cainfo"`
  3622. ErrMsg string `json:"err_msg"`
  3623. InfRefmsgid string `json:"inf_refmsgid"`
  3624. Infcode int64 `json:"infcode"`
  3625. Output struct {
  3626. Data struct {
  3627. IptOtpNo string `json:"ipt_otp_no"`
  3628. MdtrtID string `json:"mdtrt_id"`
  3629. PsnNo string `json:"psn_no"`
  3630. } `json:"data"`
  3631. } `json:"output"`
  3632. RefmsgTime string `json:"refmsg_time"`
  3633. RespondTime string `json:"respond_time"`
  3634. Signtype interface{} `json:"signtype"`
  3635. WarnMsg interface{} `json:"warn_msg"`
  3636. }
  3637. type ResultThree10265 struct {
  3638. Cainfo interface{} `json:"cainfo"`
  3639. ErrMsg string `json:"err_msg"`
  3640. InfRefmsgid string `json:"inf_refmsgid"`
  3641. Infcode string `json:"infcode"`
  3642. Output struct {
  3643. Data struct {
  3644. IptOtpNo string `json:"ipt_otp_no"`
  3645. MdtrtID string `json:"mdtrt_id"`
  3646. PsnNo string `json:"psn_no"`
  3647. } `json:"data"`
  3648. } `json:"output"`
  3649. RefmsgTime string `json:"refmsg_time"`
  3650. RespondTime string `json:"respond_time"`
  3651. Signtype interface{} `json:"signtype"`
  3652. WarnMsg interface{} `json:"warn_msg"`
  3653. }
  3654. type ResultFour struct {
  3655. Cainfo string `json:"cainfo"`
  3656. ErrMsg string `json:"err_msg"`
  3657. InfRefmsgid string `json:"inf_refmsgid"`
  3658. Infcode int64 `json:"infcode"`
  3659. Output struct {
  3660. Result []struct {
  3661. BasMednFlag string `json:"bas_medn_flag"`
  3662. ChldMedcFlag string `json:"chld_medc_flag"`
  3663. ChrgitmLv string `json:"chrgitm_lv"`
  3664. Cnt float64 `json:"cnt"`
  3665. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3666. DrtReimFlag string `json:"drt_reim_flag"`
  3667. FeedetlSn string `json:"feedetl_sn"`
  3668. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3669. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3670. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3671. ListSpItemFlag string `json:"list_sp_item_flag"`
  3672. LmtUsedFlag string `json:"lmt_used_flag"`
  3673. MedChrgitmType string `json:"med_chrgitm_type"`
  3674. Memo string `json:"memo"`
  3675. OverlmtAmt float64 `json:"overlmt_amt"`
  3676. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3677. Pric float64 `json:"pric"`
  3678. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3679. SelfpayProp float64 `json:"selfpay_prop"`
  3680. } `json:"result"`
  3681. } `json:"output"`
  3682. RefmsgTime string `json:"refmsg_time"`
  3683. RespondTime string `json:"respond_time"`
  3684. Signtype string `json:"signtype"`
  3685. WarnMsg string `json:"warn_msg"`
  3686. }
  3687. type ResultFour10265 struct {
  3688. Cainfo string `json:"cainfo"`
  3689. ErrMsg string `json:"err_msg"`
  3690. InfRefmsgid string `json:"inf_refmsgid"`
  3691. Infcode string `json:"infcode"`
  3692. Output struct {
  3693. Result []struct {
  3694. BasMednFlag string `json:"bas_medn_flag"`
  3695. ChldMedcFlag string `json:"chld_medc_flag"`
  3696. ChrgitmLv string `json:"chrgitm_lv"`
  3697. Cnt float64 `json:"cnt"`
  3698. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3699. DrtReimFlag string `json:"drt_reim_flag"`
  3700. FeedetlSn string `json:"feedetl_sn"`
  3701. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3702. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3703. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3704. ListSpItemFlag string `json:"list_sp_item_flag"`
  3705. LmtUsedFlag string `json:"lmt_used_flag"`
  3706. MedChrgitmType string `json:"med_chrgitm_type"`
  3707. Memo string `json:"memo"`
  3708. OverlmtAmt float64 `json:"overlmt_amt"`
  3709. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3710. Pric float64 `json:"pric"`
  3711. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3712. SelfpayProp float64 `json:"selfpay_prop"`
  3713. } `json:"result"`
  3714. } `json:"output"`
  3715. RefmsgTime string `json:"refmsg_time"`
  3716. RespondTime string `json:"respond_time"`
  3717. Signtype string `json:"signtype"`
  3718. WarnMsg string `json:"warn_msg"`
  3719. }
  3720. type ResultFive struct {
  3721. Balc float64 `json:"balc"`
  3722. CvlservFlag string `json:"cvlserv_flag"`
  3723. EmpName string `json:"emp_name"`
  3724. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3725. Insutype string `json:"insutype"`
  3726. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3727. PausInsuDate string `json:"paus_insu_date"`
  3728. PsnInsuDate string `json:"psn_insu_date"`
  3729. PsnInsuStas string `json:"psn_insu_stas"`
  3730. PsnType string `json:"psn_type"`
  3731. }
  3732. type ResultSix struct {
  3733. Cainfo interface{} `json:"cainfo"`
  3734. ErrMsg string `json:"err_msg"`
  3735. InfRefmsgid string `json:"inf_refmsgid"`
  3736. Infcode int64 `json:"infcode"`
  3737. Output struct {
  3738. } `json:"output"`
  3739. RefmsgTime string `json:"refmsg_time"`
  3740. RespondTime string `json:"respond_time"`
  3741. Signtype interface{} `json:"signtype"`
  3742. WarnMsg interface{} `json:"warn_msg"`
  3743. }
  3744. type ResultSix10265 struct {
  3745. Cainfo interface{} `json:"cainfo"`
  3746. ErrMsg string `json:"err_msg"`
  3747. InfRefmsgid string `json:"inf_refmsgid"`
  3748. Infcode string `json:"infcode"`
  3749. Output struct {
  3750. } `json:"output"`
  3751. RefmsgTime string `json:"refmsg_time"`
  3752. RespondTime string `json:"respond_time"`
  3753. Signtype interface{} `json:"signtype"`
  3754. WarnMsg interface{} `json:"warn_msg"`
  3755. }
  3756. type ResultSeven struct {
  3757. Cainfo string `json:"cainfo"`
  3758. ErrMsg string `json:"err_msg"`
  3759. InfRefmsgid string `json:"inf_refmsgid"`
  3760. Infcode int64 `json:"infcode"`
  3761. Output struct {
  3762. Setldetail []interface{} `json:"setldetail"`
  3763. Setlinfo struct {
  3764. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3765. AcctPay float64 `json:"acct_pay"`
  3766. ActPayDedc float64 `json:"act_pay_dedc"`
  3767. Age float64 `json:"age"`
  3768. Balc float64 `json:"balc"`
  3769. Brdy string `json:"brdy"`
  3770. Certno string `json:"certno"`
  3771. ClrOptins string `json:"clr_optins"`
  3772. ClrType string `json:"clr_type"`
  3773. ClrWay string `json:"clr_way"`
  3774. CvlservFlag string `json:"cvlserv_flag"`
  3775. CvlservPay float64 `json:"cvlserv_pay"`
  3776. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3777. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3778. Gend string `json:"gend"`
  3779. HifesPay float64 `json:"hifes_pay"`
  3780. HifmiPay float64 `json:"hifmi_pay"`
  3781. HifpPay float64 `json:"hifp_pay"`
  3782. HospPartAmt float64 `json:"hosp_part_amt"`
  3783. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3784. Insutype string `json:"insutype"`
  3785. MafPay float64 `json:"maf_pay"`
  3786. MdtrtCertType string `json:"mdtrt_cert_type"`
  3787. HifobPay float64 `json:"hifob_pay"`
  3788. MdtrtID string `json:"mdtrt_id"`
  3789. MedType string `json:"med_type"`
  3790. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3791. MedinsSetlID string `json:"medins_setl_id"`
  3792. Naty string `json:"naty"`
  3793. OthPay float64 `json:"oth_pay"`
  3794. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3795. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3796. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3797. PsnCashPay float64 `json:"psn_cash_pay"`
  3798. PsnCertType string `json:"psn_cert_type"`
  3799. PsnName string `json:"psn_name"`
  3800. PsnNo string `json:"psn_no"`
  3801. PsnPartAmt float64 `json:"psn_part_amt"`
  3802. PsnType string `json:"psn_type"`
  3803. SetlID string `json:"setl_id"`
  3804. SetlTime string `json:"setl_time"`
  3805. } `json:"setlinfo"`
  3806. } `json:"output"`
  3807. RefmsgTime string `json:"refmsg_time"`
  3808. RespondTime string `json:"respond_time"`
  3809. Signtype interface{} `json:"signtype"`
  3810. WarnMsg interface{} `json:"warn_msg"`
  3811. }
  3812. type ResultSeven10265 struct {
  3813. Cainfo string `json:"cainfo"`
  3814. ErrMsg string `json:"err_msg"`
  3815. InfRefmsgid string `json:"inf_refmsgid"`
  3816. Infcode string `json:"infcode"`
  3817. Output struct {
  3818. Setldetail []interface{} `json:"setldetail"`
  3819. Setlinfo struct {
  3820. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3821. AcctPay float64 `json:"acct_pay"`
  3822. ActPayDedc float64 `json:"act_pay_dedc"`
  3823. Age float64 `json:"age"`
  3824. Balc float64 `json:"balc"`
  3825. Brdy string `json:"brdy"`
  3826. Certno string `json:"certno"`
  3827. ClrOptins string `json:"clr_optins"`
  3828. ClrType string `json:"clr_type"`
  3829. ClrWay string `json:"clr_way"`
  3830. CvlservFlag string `json:"cvlserv_flag"`
  3831. CvlservPay float64 `json:"cvlserv_pay"`
  3832. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3833. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3834. Gend string `json:"gend"`
  3835. HifesPay float64 `json:"hifes_pay"`
  3836. HifmiPay float64 `json:"hifmi_pay"`
  3837. HifpPay float64 `json:"hifp_pay"`
  3838. HospPartAmt float64 `json:"hosp_part_amt"`
  3839. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3840. Insutype string `json:"insutype"`
  3841. MafPay float64 `json:"maf_pay"`
  3842. MdtrtCertType string `json:"mdtrt_cert_type"`
  3843. HifobPay float64 `json:"hifob_pay"`
  3844. MdtrtID string `json:"mdtrt_id"`
  3845. MedType string `json:"med_type"`
  3846. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3847. MedinsSetlID string `json:"medins_setl_id"`
  3848. Naty string `json:"naty"`
  3849. OthPay float64 `json:"oth_pay"`
  3850. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3851. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3852. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3853. PsnCashPay float64 `json:"psn_cash_pay"`
  3854. PsnCertType string `json:"psn_cert_type"`
  3855. PsnName string `json:"psn_name"`
  3856. PsnNo string `json:"psn_no"`
  3857. PsnPartAmt float64 `json:"psn_part_amt"`
  3858. PsnType string `json:"psn_type"`
  3859. SetlID string `json:"setl_id"`
  3860. SetlTime string `json:"setl_time"`
  3861. } `json:"setlinfo"`
  3862. } `json:"output"`
  3863. RefmsgTime string `json:"refmsg_time"`
  3864. RespondTime string `json:"respond_time"`
  3865. Signtype interface{} `json:"signtype"`
  3866. WarnMsg interface{} `json:"warn_msg"`
  3867. }
  3868. type ResultEight struct {
  3869. Cainfo string `json:"cainfo"`
  3870. ErrMsg string `json:"err_msg"`
  3871. InfRefmsgid string `json:"inf_refmsgid"`
  3872. Infcode int64 `json:"infcode"`
  3873. Output struct {
  3874. Stmtinfo struct {
  3875. SetlOptins string `json:"setl_optins"`
  3876. StmtRslt string `json:"stmt_rslt"`
  3877. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3878. } `json:"stmtinfo"`
  3879. } `json:"output"`
  3880. RefmsgTime string `json:"refmsg_time"`
  3881. RespondTime string `json:"respond_time"`
  3882. Signtype interface{} `json:"signtype"`
  3883. WarnMsg interface{} `json:"warn_msg"`
  3884. }
  3885. type ResultEightFor10188 struct {
  3886. Cainfo string `json:"cainfo"`
  3887. ErrMsg string `json:"err_msg"`
  3888. InfRefmsgid string `json:"inf_refmsgid"`
  3889. Infcode string `json:"infcode"`
  3890. Output struct {
  3891. Stmtinfo struct {
  3892. SetlOptins string `json:"setl_optins"`
  3893. StmtRslt string `json:"stmt_rslt"`
  3894. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3895. } `json:"stmtinfo"`
  3896. } `json:"output"`
  3897. RefmsgTime string `json:"refmsg_time"`
  3898. RespondTime string `json:"respond_time"`
  3899. Signtype interface{} `json:"signtype"`
  3900. WarnMsg interface{} `json:"warn_msg"`
  3901. }
  3902. type ResultNine struct {
  3903. Cainfo string `json:"cainfo"`
  3904. ErrMsg string `json:"err_msg"`
  3905. InfRefmsgid string `json:"inf_refmsgid"`
  3906. Infcode int64 `json:"infcode"`
  3907. Output struct {
  3908. FileQuryNo string `json:"file_qury_no"`
  3909. } `json:"output"`
  3910. RefmsgTime string `json:"refmsg_time"`
  3911. RespondTime string `json:"respond_time"`
  3912. Signtype interface{} `json:"signtype"`
  3913. WarnMsg interface{} `json:"warn_msg"`
  3914. }
  3915. type ResultTen struct {
  3916. Cainfo string `json:"cainfo"`
  3917. ErrMsg string `json:"err_msg"`
  3918. InfRefmsgid string `json:"inf_refmsgid"`
  3919. Infcode int64 `json:"infcode"`
  3920. Output struct {
  3921. DldEndtime string `json:"dld_endtime"`
  3922. FileQuryNo string `json:"file_qury_no"`
  3923. Filename string `json:"filename"`
  3924. } `json:"output"`
  3925. RefmsgTime string `json:"refmsg_time"`
  3926. RespondTime string `json:"respond_time"`
  3927. Signtype interface{} `json:"signtype"`
  3928. WarnMsg interface{} `json:"warn_msg"`
  3929. }
  3930. //type Autogenerated struct {
  3931. // Output struct {
  3932. // Setlinfo struct {
  3933. // SetlTime string `json:"setl_time"`
  3934. // CvlservPay float64 `json:"cvlserv_pay"`
  3935. // Year string `json:"year"`
  3936. // MedType string `json:"med_type"`
  3937. // PsnPay float64 `json:"psn_pay"`
  3938. // OpterID string `json:"opter_id"`
  3939. // Begndate string `json:"begndate"`
  3940. // FlxempeFlag string `json:"flxempe_flag"`
  3941. // HifmiPay float64 `json:"hifmi_pay"`
  3942. // PsnNo string `json:"psn_no"`
  3943. // ActPayDedc float64 `json:"act_pay_dedc"`
  3944. // MedinsSetlID interface{} `json:"medins_setl_id"`
  3945. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3946. // ClrWay string `json:"clr_way"`
  3947. // OthPay float64 `json:"oth_pay"`
  3948. // Gend string `json:"gend"`
  3949. // MdtrtID string `json:"mdtrt_id"`
  3950. // AcctPay float64 `json:"acct_pay"`
  3951. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  3952. // Insutype string `json:"insutype"`
  3953. // Invono interface{} `json:"invono"`
  3954. // Enddate string `json:"enddate"`
  3955. // CashPayamt float64 `json:"cash_payamt"`
  3956. // PsnType string `json:"psn_type"`
  3957. // FixmedinsName string `json:"fixmedins_name"`
  3958. // HifpPay float64 `json:"hifp_pay"`
  3959. // NewFlag interface{} `json:"new_flag"`
  3960. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3961. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  3962. // PayLoc string `json:"pay_loc"`
  3963. // ClrType string `json:"clr_type"`
  3964. // RefdSetlFlag string `json:"refd_setl_flag"`
  3965. // CvlservFlag string `json:"cvlserv_flag"`
  3966. // EmpName string `json:"emp_name"`
  3967. // Brdy string `json:"brdy"`
  3968. // Naty string `json:"naty"`
  3969. // Certno string `json:"certno"`
  3970. // DiseCode string `json:"dise_code"`
  3971. // FixmedinsCode string `json:"fixmedins_code"`
  3972. // DedcHospLv string `json:"dedc_hosp_lv"`
  3973. // OpterName string `json:"opter_name"`
  3974. // Balc float64 `json:"balc"`
  3975. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3976. // PsnCertType string `json:"psn_cert_type"`
  3977. // HifobPay float64 `json:"hifob_pay"`
  3978. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  3979. // HifesPay float64 `json:"hifes_pay"`
  3980. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3981. // OptTime string `json:"opt_time"`
  3982. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3983. // SetlID string `json:"setl_id"`
  3984. // MafPay float64 `json:"maf_pay"`
  3985. // PsnName string `json:"psn_name"`
  3986. // InsuOptins interface{} `json:"insu_optins"`
  3987. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3988. // ClrOptins string `json:"clr_optins"`
  3989. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3990. // DiseName string `json:"dise_name"`
  3991. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3992. // Age float64 `json:"age"`
  3993. // DtrtCertType string `json:"dtrt_cert_type"`
  3994. // HospLv string `json:"hosp_lv"`
  3995. // } `json:"setlinfo"`
  3996. // Setldetail []struct {
  3997. // FundPayType string `json:"fund_pay_type"`
  3998. // FundPayamt float64 `json:"fund_payamt"`
  3999. // SetlProcInfo interface{} `json:"setl_proc_info"`
  4000. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  4001. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  4002. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  4003. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4004. // } `json:"setldetail"`
  4005. // } `json:"output"`
  4006. // Infcode int `json:"infcode"`
  4007. // WarnMsg interface{} `json:"warn_msg"`
  4008. // Cainfo interface{} `json:"cainfo"`
  4009. // ErrMsg interface{} `json:"err_msg"`
  4010. // RefmsgTime string `json:"refmsg_time"`
  4011. // Signtype interface{} `json:"signtype"`
  4012. // RespondTime string `json:"respond_time"`
  4013. // InfRefmsgid string `json:"inf_refmsgid"`
  4014. //}
  4015. type ResultEleven struct {
  4016. Cainfo string `json:"cainfo"`
  4017. ErrMsg string `json:"err_msg"`
  4018. InfRefmsgid string `json:"inf_refmsgid"`
  4019. Infcode int64 `json:"infcode"`
  4020. Output struct {
  4021. Setlinfo struct {
  4022. SetlTime string `json:"setl_time"`
  4023. CvlservPay float64 `json:"cvlserv_pay"`
  4024. Year string `json:"year"`
  4025. MedType string `json:"med_type"`
  4026. PsnPay float64 `json:"psn_pay"`
  4027. OpterID string `json:"opter_id"`
  4028. Begndate string `json:"begndate"`
  4029. FlxempeFlag string `json:"flxempe_flag"`
  4030. HifmiPay float64 `json:"hifmi_pay"`
  4031. PsnNo string `json:"psn_no"`
  4032. ActPayDedc float64 `json:"act_pay_dedc"`
  4033. MedinsSetlID interface{} `json:"medins_setl_id"`
  4034. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4035. ClrWay string `json:"clr_way"`
  4036. OthPay float64 `json:"oth_pay"`
  4037. Gend string `json:"gend"`
  4038. MdtrtID string `json:"mdtrt_id"`
  4039. AcctPay float64 `json:"acct_pay"`
  4040. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4041. Insutype string `json:"insutype"`
  4042. Invono interface{} `json:"invono"`
  4043. Enddate string `json:"enddate"`
  4044. CashPayamt float64 `json:"cash_payamt"`
  4045. PsnType string `json:"psn_type"`
  4046. FixmedinsName string `json:"fixmedins_name"`
  4047. HifpPay float64 `json:"hifp_pay"`
  4048. NewFlag interface{} `json:"new_flag"`
  4049. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4050. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4051. PayLoc string `json:"pay_loc"`
  4052. ClrType string `json:"clr_type"`
  4053. RefdSetlFlag string `json:"refd_setl_flag"`
  4054. CvlservFlag string `json:"cvlserv_flag"`
  4055. EmpName string `json:"emp_name"`
  4056. Brdy string `json:"brdy"`
  4057. Naty string `json:"naty"`
  4058. Certno string `json:"certno"`
  4059. DiseCode string `json:"dise_code"`
  4060. FixmedinsCode string `json:"fixmedins_code"`
  4061. DedcHospLv string `json:"dedc_hosp_lv"`
  4062. OpterName string `json:"opter_name"`
  4063. Balc float64 `json:"balc"`
  4064. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4065. PsnCertType string `json:"psn_cert_type"`
  4066. HifobPay float64 `json:"hifob_pay"`
  4067. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4068. HifesPay float64 `json:"hifes_pay"`
  4069. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4070. OptTime string `json:"opt_time"`
  4071. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4072. SetlID string `json:"setl_id"`
  4073. MafPay float64 `json:"maf_pay"`
  4074. PsnName string `json:"psn_name"`
  4075. InsuOptins interface{} `json:"insu_optins"`
  4076. PrefFundPay interface{} `json:"pref_fund_pay"`
  4077. ClrOptins string `json:"clr_optins"`
  4078. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4079. DiseName string `json:"dise_name"`
  4080. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4081. Age float64 `json:"age"`
  4082. DtrtCertType string `json:"dtrt_cert_type"`
  4083. HospLv string `json:"hosp_lv"`
  4084. } `json:"setlinfo"`
  4085. } `json:"output"`
  4086. RefmsgTime string `json:"refmsg_time"`
  4087. RespondTime string `json:"respond_time"`
  4088. Signtype interface{} `json:"signtype"`
  4089. WarnMsg interface{} `json:"warn_msg"`
  4090. }
  4091. type ResultEleven10265 struct {
  4092. Cainfo string `json:"cainfo"`
  4093. ErrMsg string `json:"err_msg"`
  4094. InfRefmsgid string `json:"inf_refmsgid"`
  4095. Infcode string `json:"infcode"`
  4096. Output struct {
  4097. Setlinfo struct {
  4098. SetlTime string `json:"setl_time"`
  4099. CvlservPay float64 `json:"cvlserv_pay"`
  4100. Year string `json:"year"`
  4101. MedType string `json:"med_type"`
  4102. PsnPay float64 `json:"psn_pay"`
  4103. OpterID string `json:"opter_id"`
  4104. Begndate string `json:"begndate"`
  4105. FlxempeFlag string `json:"flxempe_flag"`
  4106. HifmiPay float64 `json:"hifmi_pay"`
  4107. PsnNo string `json:"psn_no"`
  4108. ActPayDedc float64 `json:"act_pay_dedc"`
  4109. MedinsSetlID interface{} `json:"medins_setl_id"`
  4110. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4111. ClrWay string `json:"clr_way"`
  4112. OthPay float64 `json:"oth_pay"`
  4113. Gend string `json:"gend"`
  4114. MdtrtID string `json:"mdtrt_id"`
  4115. AcctPay float64 `json:"acct_pay"`
  4116. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4117. Insutype string `json:"insutype"`
  4118. Invono interface{} `json:"invono"`
  4119. Enddate string `json:"enddate"`
  4120. CashPayamt float64 `json:"cash_payamt"`
  4121. PsnType string `json:"psn_type"`
  4122. FixmedinsName string `json:"fixmedins_name"`
  4123. HifpPay float64 `json:"hifp_pay"`
  4124. NewFlag interface{} `json:"new_flag"`
  4125. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4126. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4127. PayLoc string `json:"pay_loc"`
  4128. ClrType string `json:"clr_type"`
  4129. RefdSetlFlag string `json:"refd_setl_flag"`
  4130. CvlservFlag string `json:"cvlserv_flag"`
  4131. EmpName string `json:"emp_name"`
  4132. Brdy string `json:"brdy"`
  4133. Naty string `json:"naty"`
  4134. Certno string `json:"certno"`
  4135. DiseCode string `json:"dise_code"`
  4136. FixmedinsCode string `json:"fixmedins_code"`
  4137. DedcHospLv string `json:"dedc_hosp_lv"`
  4138. OpterName string `json:"opter_name"`
  4139. Balc float64 `json:"balc"`
  4140. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4141. PsnCertType string `json:"psn_cert_type"`
  4142. HifobPay float64 `json:"hifob_pay"`
  4143. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4144. HifesPay float64 `json:"hifes_pay"`
  4145. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4146. OptTime string `json:"opt_time"`
  4147. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4148. SetlID string `json:"setl_id"`
  4149. MafPay float64 `json:"maf_pay"`
  4150. PsnName string `json:"psn_name"`
  4151. InsuOptins interface{} `json:"insu_optins"`
  4152. PrefFundPay interface{} `json:"pref_fund_pay"`
  4153. ClrOptins string `json:"clr_optins"`
  4154. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4155. DiseName string `json:"dise_name"`
  4156. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4157. Age float64 `json:"age"`
  4158. DtrtCertType string `json:"dtrt_cert_type"`
  4159. HospLv string `json:"hosp_lv"`
  4160. } `json:"setlinfo"`
  4161. } `json:"output"`
  4162. RefmsgTime string `json:"refmsg_time"`
  4163. RespondTime string `json:"respond_time"`
  4164. Signtype interface{} `json:"signtype"`
  4165. WarnMsg interface{} `json:"warn_msg"`
  4166. }
  4167. type ResultTwelve struct {
  4168. Cainfo string `json:"cainfo"`
  4169. ErrMsg string `json:"err_msg"`
  4170. InfRefmsgid string `json:"inf_refmsgid"`
  4171. Infcode int64 `json:"infcode"`
  4172. Output struct {
  4173. MdtrtId string `json:"mdtrt_id"`
  4174. ChrgBchno string `json:"chrg_bchno"`
  4175. PsnNo string `json:"psn_no"`
  4176. } `json:"output"`
  4177. RefmsgTime string `json:"refmsg_time"`
  4178. RespondTime string `json:"respond_time"`
  4179. Signtype interface{} `json:"signtype"`
  4180. WarnMsg interface{} `json:"warn_msg"`
  4181. }
  4182. type ResultThirteen struct {
  4183. ErrMsg string `json:"err_msg"`
  4184. InfRefmsgid string `json:"inf_refmsgid"`
  4185. Infcode int64 `json:"infcode"`
  4186. Output struct {
  4187. Result struct {
  4188. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4189. } `json:"result"`
  4190. } `json:"output"`
  4191. RefmsgTime string `json:"refmsg_time"`
  4192. RespondTime string `json:"respond_time"`
  4193. Signtype interface{} `json:"signtype"`
  4194. WarnInfo interface{} `json:"warn_info"`
  4195. }
  4196. type ResultThirteen10265 struct {
  4197. ErrMsg string `json:"err_msg"`
  4198. InfRefmsgid string `json:"inf_refmsgid"`
  4199. Infcode string `json:"infcode"`
  4200. Output struct {
  4201. Result struct {
  4202. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4203. } `json:"result"`
  4204. } `json:"output"`
  4205. RefmsgTime string `json:"refmsg_time"`
  4206. RespondTime string `json:"respond_time"`
  4207. Signtype interface{} `json:"signtype"`
  4208. WarnInfo interface{} `json:"warn_info"`
  4209. }
  4210. type ResultFourteen struct {
  4211. ErrMsg string `json:"err_msg"`
  4212. InfRefmsgid string `json:"inf_refmsgid"`
  4213. Infcode int64 `json:"infcode"`
  4214. Output struct {
  4215. } `json:"output"`
  4216. RefmsgTime string `json:"refmsg_time"`
  4217. RespondTime string `json:"respond_time"`
  4218. Signtype interface{} `json:"signtype"`
  4219. WarnInfo interface{} `json:"warn_info"`
  4220. }
  4221. type ResultFourteen10265 struct {
  4222. ErrMsg string `json:"err_msg"`
  4223. InfRefmsgid string `json:"inf_refmsgid"`
  4224. Infcode string `json:"infcode"`
  4225. Output struct {
  4226. } `json:"output"`
  4227. RefmsgTime string `json:"refmsg_time"`
  4228. RespondTime string `json:"respond_time"`
  4229. Signtype interface{} `json:"signtype"`
  4230. WarnInfo interface{} `json:"warn_info"`
  4231. }
  4232. type ResultSixteen struct {
  4233. Cainfo string `json:"cainfo"`
  4234. ErrMsg string `json:"err_msg"`
  4235. InfRefmsgid string `json:"inf_refmsgid"`
  4236. Infcode int64 `json:"infcode"`
  4237. Output struct {
  4238. Setldetail []interface{} `json:"setldetail"`
  4239. Setlinfo struct {
  4240. MdtrtID string `json:"mdtrt_id"`
  4241. SetlID string `json:"setl_id"`
  4242. ClrOptins string `json:"clr_optins"`
  4243. SetlTime string `json:"setl_time"`
  4244. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4245. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4246. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4247. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4248. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4249. ActPayDedc float64 `json:"act_pay_dedc"`
  4250. HifpPay float64 `json:"hifp_pay"`
  4251. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4252. Lfpay float64 `json:"selfpay"`
  4253. CvlservPay float64 `json:"cvlserv_pay"`
  4254. HifesPay float64 `json:"hifes_pay"`
  4255. HifmiPay float64 `json:"hifmi_pay"`
  4256. HifobPay float64 `json:"hifob_pay"`
  4257. MafPay float64 `json:"maf_pay"`
  4258. OthPay float64 `json:"oth_pay"`
  4259. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4260. PsnPartAmt float64 `json:"psn_part_amt"`
  4261. AcctPay float64 `json:"acct_pay"`
  4262. Balc float64 `json:"balc"`
  4263. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4264. HospPartAmt float64 `json:"hosp_part_amt"`
  4265. MedinsSetlID string `json:"medins_setl_id"`
  4266. PdnCashPay string `json:"pdn_cash_pay"`
  4267. } `json:"setlinfo"`
  4268. } `json:"output"`
  4269. RefmsgTime string `json:"refmsg_time"`
  4270. RespondTime string `json:"respond_time"`
  4271. Signtype interface{} `json:"signtype"`
  4272. WarnMsg interface{} `json:"warn_msg"`
  4273. }
  4274. type ResultSixteen10265 struct {
  4275. Cainfo string `json:"cainfo"`
  4276. ErrMsg string `json:"err_msg"`
  4277. InfRefmsgid string `json:"inf_refmsgid"`
  4278. Infcode string `json:"infcode"`
  4279. Output struct {
  4280. Setldetail []interface{} `json:"setldetail"`
  4281. Setlinfo struct {
  4282. MdtrtID string `json:"mdtrt_id"`
  4283. SetlID string `json:"setl_id"`
  4284. ClrOptins string `json:"clr_optins"`
  4285. SetlTime string `json:"setl_time"`
  4286. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4287. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4288. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4289. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4290. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4291. ActPayDedc float64 `json:"act_pay_dedc"`
  4292. HifpPay float64 `json:"hifp_pay"`
  4293. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4294. Lfpay float64 `json:"selfpay"`
  4295. CvlservPay float64 `json:"cvlserv_pay"`
  4296. HifesPay float64 `json:"hifes_pay"`
  4297. HifmiPay float64 `json:"hifmi_pay"`
  4298. HifobPay float64 `json:"hifob_pay"`
  4299. MafPay float64 `json:"maf_pay"`
  4300. OthPay float64 `json:"oth_pay"`
  4301. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4302. PsnPartAmt float64 `json:"psn_part_amt"`
  4303. AcctPay float64 `json:"acct_pay"`
  4304. Balc float64 `json:"balc"`
  4305. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4306. HospPartAmt float64 `json:"hosp_part_amt"`
  4307. MedinsSetlID string `json:"medins_setl_id"`
  4308. PdnCashPay string `json:"pdn_cash_pay"`
  4309. } `json:"setlinfo"`
  4310. } `json:"output"`
  4311. RefmsgTime string `json:"refmsg_time"`
  4312. RespondTime string `json:"respond_time"`
  4313. Signtype interface{} `json:"signtype"`
  4314. WarnMsg interface{} `json:"warn_msg"`
  4315. }
  4316. type ResultSeventeen struct {
  4317. ErrMsg string `json:"err_msg"`
  4318. InfRefmsgid string `json:"inf_refmsgid"`
  4319. Infcode int64 `json:"infcode"`
  4320. Output struct {
  4321. SetlListId string `json:"setl_list_id"`
  4322. } `json:"output"`
  4323. RefmsgTime string `json:"refmsg_time"`
  4324. RespondTime string `json:"respond_time"`
  4325. Signtype string `json:"signtype"`
  4326. WarnInfo string `json:"warn_info"`
  4327. }
  4328. type ResultSeventeenOther struct {
  4329. ErrMsg string `json:"err_msg"`
  4330. InfRefmsgid string `json:"inf_refmsgid"`
  4331. Infcode string `json:"infcode"`
  4332. Output struct {
  4333. SetlListId string `json:"setl_list_id"`
  4334. } `json:"output"`
  4335. RefmsgTime string `json:"refmsg_time"`
  4336. RespondTime string `json:"respond_time"`
  4337. Signtype string `json:"signtype"`
  4338. WarnInfo string `json:"warn_info"`
  4339. }
  4340. type Result90991 struct {
  4341. ErrMsg string `json:"err_msg"`
  4342. InfRefmsgid string `json:"inf_refmsgid"`
  4343. Infcode int64 `json:"infcode"`
  4344. Output struct {
  4345. Result struct {
  4346. PsnNo string `json:"psn_no"`
  4347. CardStat string `json:"card_stat"`
  4348. Certno string `json:"certno"`
  4349. PsnName string `json:"psn_name"`
  4350. CheckStat string `json:"check_stat"`
  4351. SscnoCheckStat string `json:"sscno_check_stat"`
  4352. } `json:"result"`
  4353. } `json:"output"`
  4354. RefmsgTime string `json:"refmsg_time"`
  4355. RespondTime string `json:"respond_time"`
  4356. Signtype interface{} `json:"signtype"`
  4357. WarnInfo interface{} `json:"warn_info"`
  4358. }
  4359. type Result90100 struct {
  4360. ErrMsg string `json:"err_msg"`
  4361. InfRefmsgid string `json:"inf_refmsgid"`
  4362. Infcode int64 `json:"infcode"`
  4363. Output struct {
  4364. PoolareaNo string `json:"poolarea_no"`
  4365. PoolareaNoName string `json:"poolarea_no_name"`
  4366. Insutype string `json:"insutype"`
  4367. InsutypeName string `json:"insutype_name"`
  4368. ClctType string `json:"clct_type"`
  4369. ClctTypeName string `json:"clct_type_name"`
  4370. ClctFlag string `json:"clct_flag"`
  4371. ClctFlagName string `json:"clct_flag_name"`
  4372. AccrymBegn string `json:"accrym_begn"`
  4373. AccrymEnd string `json:"accrym_end"`
  4374. ClctTime string `json:"clct_time"`
  4375. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  4376. } `json:"output"`
  4377. RefmsgTime string `json:"refmsg_time"`
  4378. RespondTime string `json:"respond_time"`
  4379. Signtype interface{} `json:"signtype"`
  4380. WarnInfo interface{} `json:"warn_info"`
  4381. }
  4382. type Custom struct {
  4383. DetItemFeeSumamt string
  4384. Cut string
  4385. FeedetlSn string
  4386. Price string
  4387. MedListCodg string
  4388. Type int64
  4389. AdviceId int64
  4390. ProjectId int64
  4391. ItemId int64
  4392. }
  4393. type Result5301 struct {
  4394. ErrMsg string `json:"err_msg"`
  4395. InfRefmsgid string `json:"inf_refmsgid"`
  4396. Infcode int64 `json:"infcode"`
  4397. Output struct {
  4398. Result []struct {
  4399. OpspDiseCode string `json:"opsp_dise_code"`
  4400. OpspDiseName string `json:"opsp_dise_name"`
  4401. Begndate string `json:"begndate"`
  4402. Enddate string `json:"enddate"`
  4403. } `json:"feedetail"`
  4404. } `json:"output"`
  4405. RefmsgTime string `json:"refmsg_time"`
  4406. RespondTime string `json:"respond_time"`
  4407. Signtype interface{} `json:"signtype"`
  4408. WarnInfo interface{} `json:"warn_info"`
  4409. }
  4410. type Result5301For10265 struct {
  4411. ErrMsg string `json:"err_msg"`
  4412. InfRefmsgid string `json:"inf_refmsgid"`
  4413. Infcode string `json:"infcode"`
  4414. Output struct {
  4415. Result []struct {
  4416. OpspDiseCode string `json:"opsp_dise_code"`
  4417. OpspDiseName string `json:"opsp_dise_name"`
  4418. Begndate string `json:"begndate"`
  4419. Enddate string `json:"enddate"`
  4420. } `json:"feedetail"`
  4421. } `json:"output"`
  4422. RefmsgTime string `json:"refmsg_time"`
  4423. RespondTime string `json:"respond_time"`
  4424. Signtype interface{} `json:"signtype"`
  4425. WarnInfo interface{} `json:"warn_info"`
  4426. }
  4427. //获取个人信息----挂号-----上传就诊信息
  4428. func (c *HisApiController) GetRegisterInfo() {
  4429. id, _ := c.GetInt64("id")
  4430. record_time := c.GetString("record_time")
  4431. settlementValue, _ := c.GetInt64("settlement_value")
  4432. medical_insurance_card := c.GetString("medical_insurance_card")
  4433. name := c.GetString("name")
  4434. id_card_type, _ := c.GetInt64("id_card_type")
  4435. certificates, _ := c.GetInt64("certificates")
  4436. medical_care, _ := c.GetInt64("medical_care")
  4437. birthday := c.GetString("birthday")
  4438. id_card := c.GetString("id_card")
  4439. register_type, _ := c.GetInt64("register")
  4440. doctor, _ := c.GetInt64("doctor")
  4441. department, _ := c.GetInt64("department")
  4442. gender, _ := c.GetInt64("sex")
  4443. registration_fee, _ := c.GetFloat("registration_fee")
  4444. medical_expenses, _ := c.GetFloat("medical_expenses")
  4445. social_type, _ := c.GetInt64("social_type")
  4446. med_type := c.GetString("social_type")
  4447. admin_user_id, _ := c.GetInt64("admin_user_id")
  4448. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4449. timeLayout := "2006-01-02"
  4450. loc, _ := time.LoadLocation("Local")
  4451. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4452. birthUnix := birthdays.Unix()
  4453. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4454. if err != nil {
  4455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4456. return
  4457. }
  4458. recordDateTime := theTime.Unix()
  4459. adminInfo := c.GetAdminUserInfo()
  4460. var patient service.Patients
  4461. if id == 0 {
  4462. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4463. } else {
  4464. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4465. }
  4466. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4467. if patientPrescription.ID == 0 {
  4468. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4469. }
  4470. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4471. if patient.ID == 0 {
  4472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4473. return
  4474. }
  4475. if len(patient.IdCardNo) == 0 {
  4476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4477. return
  4478. }
  4479. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4480. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4481. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4482. //就诊结算未完成,不能进行二次挂号
  4483. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4484. if len(his) >= 1 {
  4485. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  4486. if len(his) >= 1 && order.ID == 0 {
  4487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  4488. return
  4489. }
  4490. }
  4491. //var register_log string
  4492. if config.IsOpen == 1 {
  4493. var res ResultTwo
  4494. var res10265 ResultTwo10265
  4495. var PsnNo string
  4496. var PsnCertType string
  4497. var Certno string
  4498. var PsnName string
  4499. var Gend string
  4500. var Naty string
  4501. var Brdy string
  4502. var Age float64
  4503. var infoStr string
  4504. var idetinfoStr string
  4505. var infocode int64
  4506. var verify_number string
  4507. fmt.Println(verify_number)
  4508. if miConfig.MdtrtareaAdmvs == "421300" {
  4509. psn_info, _ := service.GetPsnByPatientId(id)
  4510. PsnNo = psn_info.PsnNo
  4511. PsnCertType = psn_info.PsnCertType
  4512. Certno = psn_info.Certno
  4513. PsnName = psn_info.PsnName
  4514. Gend = psn_info.Gend
  4515. Naty = psn_info.Naty
  4516. Brdy = psn_info.Brdy
  4517. Age = psn_info.Age
  4518. infoStr = psn_info.Insuinfo
  4519. idetinfoStr = psn_info.Idetinfo
  4520. infocode = 0
  4521. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4522. psn_info, _ := service.GetPsnByPatientId(id)
  4523. PsnNo = psn_info.PsnNo
  4524. PsnCertType = psn_info.PsnCertType
  4525. Certno = psn_info.Certno
  4526. PsnName = psn_info.PsnName
  4527. Gend = psn_info.Gend
  4528. Naty = psn_info.Naty
  4529. Brdy = psn_info.Brdy
  4530. Age = psn_info.Age
  4531. infoStr = psn_info.Insuinfo
  4532. idetinfoStr = psn_info.Idetinfo
  4533. infocode = 0
  4534. verify_number = psn_info.VerifyNumber
  4535. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4536. psn_info, _ := service.GetPsnByPatientId(id)
  4537. PsnNo = psn_info.PsnNo
  4538. PsnCertType = psn_info.PsnCertType
  4539. Certno = psn_info.Certno
  4540. PsnName = psn_info.PsnName
  4541. Gend = psn_info.Gend
  4542. Naty = psn_info.Naty
  4543. Brdy = psn_info.Brdy
  4544. Age = psn_info.Age
  4545. infoStr = psn_info.Insuinfo
  4546. idetinfoStr = psn_info.Idetinfo
  4547. infocode = 0
  4548. verify_number = psn_info.VerifyNumber
  4549. } else {
  4550. var result string
  4551. var requestLog string
  4552. if miConfig.UserOrgId == 10138 {
  4553. result, requestLog = service.Gdyb1101D(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name, record_time)
  4554. } else {
  4555. result, requestLog = service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name)
  4556. }
  4557. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4558. if miConfig.Code == "H15049901371" {
  4559. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4560. utils.ErrorLog("解析失败:%v", err)
  4561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4562. return
  4563. }
  4564. res.ErrMsg = res10265.ErrMsg
  4565. res.Output = res10265.Output
  4566. res.InfRefmsgid = res10265.InfRefmsgid
  4567. } else {
  4568. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4569. utils.ErrorLog("解析失败:%v", err)
  4570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4571. return
  4572. }
  4573. }
  4574. PsnNo = res.Output.Baseinfo.PsnNo
  4575. PsnCertType = res.Output.Baseinfo.PsnCertType
  4576. Certno = res.Output.Baseinfo.Certno
  4577. PsnName = res.Output.Baseinfo.PsnName
  4578. Gend = res.Output.Baseinfo.Gend
  4579. Naty = res.Output.Baseinfo.Naty
  4580. Brdy = res.Output.Baseinfo.Brdy
  4581. Age = res.Output.Baseinfo.Age
  4582. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4583. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4584. infoStr = string(Iinfos)
  4585. idetinfoStr = string(Idetinfos)
  4586. if miConfig.Code == "H15049901371" {
  4587. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  4588. } else {
  4589. infocode = res.Infcode
  4590. }
  4591. }
  4592. if infocode == 0 {
  4593. his := models.VMHisPatient{
  4594. Name: name,
  4595. Gender: gender,
  4596. Birthday: birthUnix,
  4597. MedicalTreatmentType: medical_care,
  4598. IdType: certificates,
  4599. IdCardNo: id_card,
  4600. BalanceAccountsType: settlementValue,
  4601. SocialType: social_type,
  4602. MedicalInsuranceNumber: medical_insurance_card,
  4603. RegisterType: register_type,
  4604. RegisterCost: registration_fee,
  4605. TreatmentCost: medical_expenses,
  4606. Status: 1,
  4607. Ctime: time.Now().Unix(),
  4608. Mtime: time.Now().Unix(),
  4609. PsnNo: PsnNo,
  4610. PsnCertType: PsnCertType,
  4611. Certno: Certno,
  4612. PsnName: PsnName,
  4613. Gend: Gend,
  4614. Naty: Naty,
  4615. Brdy: Brdy,
  4616. Age: Age,
  4617. Iinfo: infoStr,
  4618. Idetinfo: idetinfoStr,
  4619. PatientId: patient.ID,
  4620. RecordDate: theTime.Unix(),
  4621. UserOrgId: adminInfo.CurrentOrgId,
  4622. AdminUserId: admin_user_id,
  4623. IsReturn: 1,
  4624. IdCardType: id_card_type,
  4625. Doctor: doctor,
  4626. Departments: department,
  4627. }
  4628. timestamp := time.Now().Unix()
  4629. tempTime := time.Unix(timestamp, 0)
  4630. timeFormat := tempTime.Format("20060102150405")
  4631. chrgBchno := rand.Intn(100000) + 10000
  4632. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4633. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  4634. department, _ := service.GetDepartMentDetail(department)
  4635. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  4636. IdCardNo := ""
  4637. if id_card_type == 1 {
  4638. // IdCardNo = medical_insurance_card
  4639. IdCardNo = patient.IdCardNo
  4640. } else {
  4641. IdCardNo = patient.IdCardNo
  4642. }
  4643. var rf []*ResultFive
  4644. json.Unmarshal([]byte(his.Iinfo), &rf)
  4645. var insutypes []*ResultFive
  4646. var insutype string
  4647. var insuplc_admdvs_temp string
  4648. var is390 int = 0
  4649. var is310 int = 0
  4650. for _, item := range rf {
  4651. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4652. insutypes = append(insutypes, item)
  4653. }
  4654. }
  4655. if len(insutypes) == 1 {
  4656. insutype = insutypes[0].Insutype
  4657. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4658. } else {
  4659. for _, i := range insutypes {
  4660. if i.Insutype == "390" {
  4661. is390 = 1
  4662. }
  4663. if i.Insutype == "310" {
  4664. is310 = 1
  4665. }
  4666. }
  4667. }
  4668. if is390 == 1 {
  4669. insutype = "390"
  4670. }
  4671. if is310 == 1 {
  4672. insutype = "310"
  4673. }
  4674. if len(insutypes) == 0 {
  4675. insutype = "310"
  4676. }
  4677. if len(insutypes) == 2 {
  4678. insutype = med_type
  4679. }
  4680. if len(med_type) > 0 {
  4681. insutype = med_type
  4682. }
  4683. //for _, item := range rf {
  4684. // if item.Insutype == insutype {
  4685. // insuplc_admdvs = item.InsuplcAdmdvs
  4686. // }
  4687. //}
  4688. var infocode int64
  4689. var resThree ResultThree
  4690. var resThree10265 ResultThree10265
  4691. if len(insuplc_admdvs) == 0 {
  4692. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  4693. } else {
  4694. insuplc_admdvs_temp = insuplc_admdvs
  4695. }
  4696. if miConfig.MdtrtareaAdmvs == "421300" {
  4697. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  4698. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  4699. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4700. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + hb_doctor_info.DoctorNumber + "&doctor_name=" + hb_doctor_info.UserName + "&opter=" + roles.UserName
  4701. resp, requestErr := http.Get(api)
  4702. if requestErr != nil {
  4703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4704. return
  4705. }
  4706. body, ioErr := ioutil.ReadAll(resp.Body)
  4707. if ioErr != nil {
  4708. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4710. return
  4711. }
  4712. var respJSON map[string]interface{}
  4713. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4714. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4716. return
  4717. }
  4718. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4719. result, _ := json.Marshal(respJSON)
  4720. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4721. utils.ErrorLog("解析失败:%v", err)
  4722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4723. return
  4724. }
  4725. infocode = resThree.Infcode
  4726. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4727. psn_info, _ := service.GetPsnByPatientId(id)
  4728. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4729. var cert_no string
  4730. if id_card_type == 3 {
  4731. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  4732. cert_no = IdCardNo
  4733. } else if id_card_type == 4 {
  4734. cert_no = IdCardNo
  4735. psn_info.VerifyNumber = psn_info.VerifyNumber
  4736. } else {
  4737. bas := strings.Split(psn_info.CardInfo, "|")
  4738. cert_no = bas[2]
  4739. }
  4740. var api string
  4741. if miConfig.MdtrtareaAdmvs == "320921" {
  4742. api = "http://192.168.2.110:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4743. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4744. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4745. } else {
  4746. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4747. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4748. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4749. }
  4750. resp, requestErr := http.Get(api)
  4751. if requestErr != nil {
  4752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4753. return
  4754. }
  4755. body, ioErr := ioutil.ReadAll(resp.Body)
  4756. if ioErr != nil {
  4757. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4759. return
  4760. }
  4761. var respJSON map[string]interface{}
  4762. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4763. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4765. return
  4766. }
  4767. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4768. result, _ := json.Marshal(respJSON)
  4769. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4770. utils.ErrorLog("解析失败:%v", err)
  4771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4772. return
  4773. }
  4774. resThree.ErrMsg = resThree10265.ErrMsg
  4775. resThree.Output = resThree10265.Output
  4776. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4777. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4778. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4779. result, requestLog := service.FJyb2201(res.Output.Baseinfo.PsnNo, insutype, IdCardNo, miConfig.OrgName, doctor_info.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_id, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, roles.UserName, doctor_info.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  4780. saveLog(result, requestLog, "2201", "挂号")
  4781. if miConfig.Code == "H15049901371" {
  4782. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4783. utils.ErrorLog("解析失败:%v", err)
  4784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4785. return
  4786. }
  4787. resThree.ErrMsg = resThree10265.ErrMsg
  4788. resThree.Output = resThree10265.Output
  4789. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4790. } else {
  4791. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4792. utils.ErrorLog("解析失败:%v", err)
  4793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4794. return
  4795. }
  4796. }
  4797. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4798. } else {
  4799. result, requestLog := service.Gdyb2201A(res.Output.Baseinfo.PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_id, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, record_time)
  4800. saveLog(result, requestLog, "2201A", "挂号")
  4801. if miConfig.Code == "H15049901371" {
  4802. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4803. utils.ErrorLog("解析失败:%v", err)
  4804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4805. return
  4806. }
  4807. resThree.ErrMsg = resThree10265.ErrMsg
  4808. resThree.Output = resThree10265.Output
  4809. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4810. } else {
  4811. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4812. utils.ErrorLog("解析失败:%v", err)
  4813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4814. return
  4815. }
  4816. }
  4817. if miConfig.Code == "H15049901371" {
  4818. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4819. } else {
  4820. infocode = resThree.Infcode
  4821. }
  4822. }
  4823. if infocode != 0 {
  4824. adminUser := c.GetAdminUserInfo()
  4825. errlog := &models.HisOrderError{
  4826. UserOrgId: adminUser.CurrentOrgId,
  4827. Ctime: time.Now().Unix(),
  4828. Mtime: time.Now().Unix(),
  4829. ErrMsg: resThree.ErrMsg,
  4830. Status: 1,
  4831. PatientId: id,
  4832. RecordTime: recordDateTime,
  4833. Stage: 2,
  4834. }
  4835. service.CreateErrMsgLog(errlog)
  4836. c.ServeSuccessJSON(map[string]interface{}{
  4837. "failed_code": -10,
  4838. "msg": resThree.ErrMsg,
  4839. })
  4840. return
  4841. }
  4842. his.Number = resThree.Output.Data.MdtrtID
  4843. his.PsnNo = resThree.Output.Data.PsnNo
  4844. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  4845. his.IdCardNo = patient.IdCardNo
  4846. his.PhoneNumber = patient.Phone
  4847. his.UserOrgId = adminInfo.CurrentOrgId
  4848. his.Insutype = insutype
  4849. his.Ctime = time.Now().Unix()
  4850. his.Mtime = time.Now().Unix()
  4851. his.InsuplcAdmdvs = insuplc_admdvs_temp
  4852. his.Status = 1
  4853. service.UpdateHisPatientStatus(&his)
  4854. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  4855. c.ServeSuccessJSON(map[string]interface{}{
  4856. "his_info": his,
  4857. })
  4858. } else {
  4859. adminUser := c.GetAdminUserInfo()
  4860. errlog := &models.HisOrderError{
  4861. UserOrgId: adminUser.CurrentOrgId,
  4862. Ctime: time.Now().Unix(),
  4863. Mtime: time.Now().Unix(),
  4864. ErrMsg: res.ErrMsg,
  4865. Status: 1,
  4866. PatientId: id,
  4867. RecordTime: recordDateTime,
  4868. Stage: 1,
  4869. }
  4870. service.CreateErrMsgLog(errlog)
  4871. c.ServeSuccessJSON(map[string]interface{}{
  4872. "failed_code": -10,
  4873. "msg": res.ErrMsg,
  4874. })
  4875. return
  4876. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  4877. }
  4878. }
  4879. }
  4880. //上传明细----预结算----确认订单
  4881. func (c *HisApiController) GetUploadInfo() {
  4882. id, _ := c.GetInt64("id")
  4883. record_time := c.GetString("record_time")
  4884. his_patient_id, _ := c.GetInt64("his_patient_id")
  4885. order_id, _ := c.GetInt64("order_id")
  4886. pay_way, _ := c.GetInt64("pay_way")
  4887. pay_price, _ := c.GetFloat("pay_price")
  4888. pay_card_no := c.GetString("pay_card_no")
  4889. token := c.GetString("token")
  4890. discount_price, _ := c.GetFloat("discount_price")
  4891. preferential_price, _ := c.GetFloat("preferential_price")
  4892. reality_price, _ := c.GetFloat("reality_price")
  4893. found_price, _ := c.GetFloat("found_price")
  4894. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  4895. private_price, _ := c.GetFloat("private_price")
  4896. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4897. admin_user_id, _ := c.GetInt64("admin_user_id")
  4898. fapiao_code := c.GetString("fapiao_code")
  4899. fapiao_number := c.GetString("fapiao_number")
  4900. diagnosis_id := c.GetString("diagnosis")
  4901. sick_type, _ := c.GetInt64("sick_type")
  4902. reg_type, _ := c.GetInt64("p_type")
  4903. begin_time := c.GetString("begin_time")
  4904. id_str := c.GetString("ids")
  4905. ids_arr := strings.Split(id_str, ",")
  4906. timeLayout := "2006-01-02"
  4907. loc, _ := time.LoadLocation("Local")
  4908. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4909. if err != nil {
  4910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4911. return
  4912. }
  4913. recordDateTime := theTime.Unix()
  4914. adminUser := c.GetAdminUserInfo()
  4915. var tempOrder models.HisOrder
  4916. tempOrder, _ = service.GetHisOrderByID(order_id)
  4917. var prescriptions []*models.HisPrescription
  4918. var start_time int64
  4919. var end_time int64
  4920. //押金模块
  4921. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  4922. tmp_decimal := c.GetString("tmp_decimal")
  4923. var decimal float64 //本次使用的押金
  4924. var errmsg error
  4925. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  4926. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  4927. return
  4928. }
  4929. if len(tmp_decimal) > 0 {
  4930. if tmp_decimal[0] == 45 {
  4931. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  4932. return
  4933. }
  4934. }
  4935. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  4936. fmt.Println(errs)
  4937. decimal = tt
  4938. //if adminUser.CurrentOrgId == 10106{
  4939. // if len(fapiao_code) == 0{
  4940. // fapiao_code = "144072080589"
  4941. // }
  4942. // if len(fapiao_number) == 0{
  4943. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  4944. // if order.ID == 0{
  4945. // fapiao_number = "00001520"
  4946. // }else{
  4947. // //fapiao_code = "00001520"
  4948. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  4949. // var zero string
  4950. // if fpNumber >= 1000{
  4951. // zero = "0000" + strconv.Itoa(fpNumber)
  4952. // }else if fpNumber >= 10000{
  4953. // zero = "000" + strconv.Itoa(fpNumber)
  4954. // } else if fpNumber >= 100000{
  4955. // zero = "00" + strconv.Itoa(fpNumber)
  4956. // } else if fpNumber >= 1000000{
  4957. // zero = "0" + strconv.Itoa(fpNumber)
  4958. // }else {
  4959. // zero = strconv.Itoa(fpNumber)
  4960. // }
  4961. // fapiao_number = zero
  4962. // }
  4963. // }
  4964. //}
  4965. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4966. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4967. var patientPrescription models.HisPrescriptionInfo
  4968. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4969. if patientPrescription.ID == 0 {
  4970. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4971. }
  4972. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4973. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4974. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4975. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4976. var config []*models.HisXtDiagnoseConfig
  4977. for _, item := range diagnosis_ids {
  4978. id, _ := strconv.ParseInt(item, 10, 64)
  4979. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4980. config = append(config, &diagnosisConfig)
  4981. }
  4982. sickConfig, _ := service.FindSickById(sick_type)
  4983. //if tempOrder.ID == 0 {
  4984. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  4985. //}
  4986. if tempOrder.ID == 0 {
  4987. var result string
  4988. var requestLog string
  4989. var res2 ResultSix
  4990. var ressix10265 ResultSix10265
  4991. if miConfig.MdtrtareaAdmvs == "421300" {
  4992. data := make(map[string]interface{})
  4993. client := &http.Client{}
  4994. data["psn_no"] = his.PsnNo
  4995. data["mdtrt_id"] = his.Number
  4996. data["opter"] = roles.UserName
  4997. data["org_name"] = miConfig.OrgName
  4998. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4999. data["doctor_id"] = doctor_info.DoctorNumber
  5000. data["doctor_name"] = doctor_info.UserName
  5001. data["department"] = department.Name
  5002. data["fixmedins_code"] = miConfig.Code
  5003. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5004. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5005. data["secret_key"] = miConfig.SecretKey
  5006. data["sick_code"] = sickConfig.CountryCode
  5007. data["sick_name"] = sickConfig.ClassName
  5008. data["dept"] = strconv.FormatInt(department.ID, 10)
  5009. data["config"] = config
  5010. data["begin_time"] = begin_time
  5011. bytesData, _ := json.Marshal(data)
  5012. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5013. resp, _ := client.Do(req)
  5014. defer resp.Body.Close()
  5015. body, ioErr := ioutil.ReadAll(resp.Body)
  5016. if ioErr != nil {
  5017. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5019. return
  5020. }
  5021. var respJSON map[string]interface{}
  5022. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5023. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5025. return
  5026. }
  5027. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5028. userJSONBytes, _ := json.Marshal(respJSON)
  5029. fmt.Println("log")
  5030. fmt.Println(string(userJSONBytes))
  5031. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5032. utils.ErrorLog("解析失败:%v", err)
  5033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5034. return
  5035. }
  5036. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5037. //江苏地区国家医保医疗类别
  5038. //职工透析:医疗类别选特殊情况门诊9933
  5039. //居民血透门慢: 医疗类别选门诊慢病1402
  5040. //var med_type string
  5041. //if his.Insutype == "310" {
  5042. // if reg_type == 14 {
  5043. // med_type = "9933"
  5044. // } else if reg_type == 11 {
  5045. // med_type = "11"
  5046. //
  5047. // }
  5048. //} else if his.Insutype == "390" {
  5049. // if reg_type == 14 {
  5050. // med_type = "1402"
  5051. // } else if reg_type == 11 {
  5052. // med_type = "11"
  5053. // }
  5054. //}
  5055. data := make(map[string]interface{})
  5056. client := &http.Client{}
  5057. data["psn_no"] = his.PsnNo
  5058. data["mdtrt_id"] = his.Number
  5059. data["doctor"] = roles.UserName
  5060. data["department"] = department.Name
  5061. data["org_name"] = miConfig.OrgName
  5062. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5063. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5064. data["fixmedins_code"] = miConfig.Code
  5065. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5066. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5067. data["secret_key"] = miConfig.SecretKey
  5068. data["sick_code"] = sickConfig.CountryCode
  5069. data["sick_name"] = sickConfig.ClassName
  5070. data["url"] = miConfig.Url
  5071. data["ak"] = miConfig.AccessKey
  5072. data["begin_time"] = begin_time
  5073. data["cainfo"] = miConfig.Cainfo
  5074. data["dept"] = strconv.FormatInt(department.ID, 10)
  5075. data["config"] = config
  5076. bytesData, _ := json.Marshal(data)
  5077. var req *http.Request
  5078. if miConfig.MdtrtareaAdmvs == "320921" {
  5079. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5080. //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 +
  5081. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  5082. } else {
  5083. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5084. }
  5085. resp, _ := client.Do(req)
  5086. defer resp.Body.Close()
  5087. body, ioErr := ioutil.ReadAll(resp.Body)
  5088. if ioErr != nil {
  5089. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5091. return
  5092. }
  5093. var respJSON map[string]interface{}
  5094. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5095. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5097. return
  5098. }
  5099. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5100. userJSONBytes, _ := json.Marshal(respJSON)
  5101. fmt.Println("log")
  5102. fmt.Println(string(userJSONBytes))
  5103. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5104. utils.ErrorLog("解析失败:%v", err)
  5105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5106. return
  5107. }
  5108. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5109. res2.Output = ressix10265.Output
  5110. res2.ErrMsg = ressix10265.ErrMsg
  5111. res2.Cainfo = ressix10265.Cainfo
  5112. res2.WarnMsg = ressix10265.WarnMsg
  5113. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5114. res2.Infcode = infocode
  5115. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5116. 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)
  5117. } else {
  5118. if miConfig.MdtrtareaAdmvs == "440781" { //
  5119. 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)
  5120. } else {
  5121. if miConfig.Code == "H15049901371" {
  5122. //赤峰地区国家医保医疗类别
  5123. //职工透析:医疗类别选特殊情况门诊990502
  5124. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5125. var med_type string
  5126. if his.Insutype == "390" {
  5127. if reg_type == 14 {
  5128. med_type = "9933"
  5129. } else if reg_type == 11 {
  5130. med_type = "11"
  5131. }
  5132. } else if his.Insutype == "310" {
  5133. if reg_type == 14 {
  5134. med_type = "990502"
  5135. } else if reg_type == 11 {
  5136. med_type = "11"
  5137. }
  5138. }
  5139. 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)
  5140. } else {
  5141. 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)
  5142. }
  5143. }
  5144. saveLog(result, requestLog, "2203", "上传就诊信息")
  5145. var respJSON2 map[string]interface{}
  5146. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5147. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5149. return
  5150. }
  5151. userJSONBytes2, _ := json.Marshal(respJSON2)
  5152. if miConfig.Code == "H15049901371" {
  5153. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  5154. utils.ErrorLog("解析失败:%v", err)
  5155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5156. return
  5157. }
  5158. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5159. res2.Output = ressix10265.Output
  5160. res2.ErrMsg = ressix10265.ErrMsg
  5161. res2.Cainfo = ressix10265.Cainfo
  5162. res2.WarnMsg = ressix10265.WarnMsg
  5163. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5164. res2.Infcode = infocode
  5165. } else {
  5166. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5167. utils.ErrorLog("解析失败:%v", err)
  5168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5169. return
  5170. }
  5171. }
  5172. }
  5173. if res2.Infcode != 0 {
  5174. adminUser := c.GetAdminUserInfo()
  5175. errlog := &models.HisOrderError{
  5176. UserOrgId: adminUser.CurrentOrgId,
  5177. Ctime: time.Now().Unix(),
  5178. Mtime: time.Now().Unix(),
  5179. ErrMsg: res2.ErrMsg,
  5180. Status: 1,
  5181. PatientId: id,
  5182. RecordTime: recordDateTime,
  5183. Stage: 3,
  5184. }
  5185. service.CreateErrMsgLog(errlog)
  5186. c.ServeSuccessJSON(map[string]interface{}{
  5187. "failed_code": -10,
  5188. "msg": res2.ErrMsg,
  5189. })
  5190. return
  5191. } else {
  5192. his.Diagnosis = diagnosis_id
  5193. his.SickType = sickConfig.ID
  5194. //var p_type int64
  5195. //if reg_type == 1111 || reg_type == 1112 {
  5196. // p_type = 11
  5197. //
  5198. //}
  5199. his.PType = fmt.Sprintf("%d", reg_type)
  5200. service.UpdateHisPatientThree(&his)
  5201. data := make(map[string]interface{})
  5202. if settle_accounts_type == 1 { //日结
  5203. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5204. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5205. } else {
  5206. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5207. }
  5208. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  5209. data["pre"] = prescriptions
  5210. } else { //月结
  5211. start_time_str := c.GetString("start_time")
  5212. end_time_str := c.GetString("end_time")
  5213. timeLayout := "2006-01-02"
  5214. loc, _ := time.LoadLocation("Local")
  5215. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5216. if err != nil {
  5217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5218. return
  5219. }
  5220. recordStartTime := theStartTime.Unix()
  5221. start_time = recordStartTime
  5222. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5223. if err != nil {
  5224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5225. return
  5226. }
  5227. recordEndTime := theEndTime.Unix()
  5228. end_time = recordEndTime
  5229. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5230. data["pre"] = prescriptions
  5231. }
  5232. timestamp := time.Now().Unix()
  5233. tempTime := time.Unix(timestamp, 0)
  5234. timeFormat := tempTime.Format("20060102150405")
  5235. chrgBchno := rand.Intn(100000) + 10000
  5236. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5237. strconv.FormatInt(his.PatientId, 10)
  5238. client := &http.Client{}
  5239. data["psn_no"] = his.PsnNo
  5240. data["mdtrt_id"] = his.Number
  5241. data["chrg_bchno"] = chrg_bchno
  5242. data["org_name"] = miConfig.OrgName
  5243. data["doctor"] = doctor_info.UserName
  5244. data["doctor_id"] = doctor_info.DoctorNumber
  5245. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5246. data["fixmedins_code"] = miConfig.Code
  5247. data["opter"] = roles.UserName
  5248. data["dept_code"] = department.Number
  5249. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5250. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5251. data["secret_key"] = miConfig.SecretKey
  5252. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5253. data["url"] = miConfig.Url
  5254. data["ak"] = miConfig.AccessKey
  5255. data["new_doctor_name"] = patientPrescription.Doctor
  5256. data["diag_code"] = sickConfig.CountryCode
  5257. data["cainfo"] = miConfig.Cainfo
  5258. var ids []int64
  5259. for _, item := range prescriptions {
  5260. ids = append(ids, item.ID)
  5261. }
  5262. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5263. if config.IsOpen == 1 { //对接了医保,走医保流程
  5264. var res ResultFour
  5265. var resFour10265 ResultFour10265
  5266. if miConfig.MdtrtareaAdmvs == "421300" {
  5267. bytesData, _ := json.Marshal(data)
  5268. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5269. resp, _ := client.Do(req)
  5270. defer resp.Body.Close()
  5271. body, ioErr := ioutil.ReadAll(resp.Body)
  5272. if ioErr != nil {
  5273. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5275. return
  5276. }
  5277. var respJSON map[string]interface{}
  5278. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5279. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5281. return
  5282. }
  5283. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5284. userJSONBytes, _ := json.Marshal(respJSON)
  5285. fmt.Println("log")
  5286. fmt.Println(string(userJSONBytes))
  5287. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5288. utils.ErrorLog("解析失败:%v", err)
  5289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5290. return
  5291. }
  5292. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5293. bytesData, _ := json.Marshal(data)
  5294. var req *http.Request
  5295. if miConfig.MdtrtareaAdmvs == "320921" {
  5296. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5297. } else {
  5298. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5299. }
  5300. resp, _ := client.Do(req)
  5301. defer resp.Body.Close()
  5302. body, ioErr := ioutil.ReadAll(resp.Body)
  5303. if ioErr != nil {
  5304. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5306. return
  5307. }
  5308. var respJSON map[string]interface{}
  5309. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5310. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5312. return
  5313. }
  5314. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5315. userJSONBytes, _ := json.Marshal(respJSON)
  5316. fmt.Println("log")
  5317. fmt.Println(string(userJSONBytes))
  5318. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5319. utils.ErrorLog("解析失败:%v", err)
  5320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5321. return
  5322. }
  5323. res.InfRefmsgid = resFour10265.InfRefmsgid
  5324. res.Output = resFour10265.Output
  5325. res.ErrMsg = resFour10265.ErrMsg
  5326. res.Cainfo = resFour10265.Cainfo
  5327. res.WarnMsg = resFour10265.WarnMsg
  5328. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5329. res.Infcode = infocode
  5330. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5331. //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), patientPrescription.DoctorId, sickConfig.CountryCode)
  5332. } else {
  5333. if miConfig.Code == "H15049901371" {
  5334. 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)
  5335. var dat map[string]interface{}
  5336. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5337. fmt.Println(dat)
  5338. } else {
  5339. fmt.Println(err)
  5340. }
  5341. saveLog(result, request_log, "2204", "上传费用明细")
  5342. userJSONBytes, _ := json.Marshal(dat)
  5343. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5344. utils.ErrorLog("解析失败:%v", err)
  5345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5346. return
  5347. }
  5348. res.InfRefmsgid = resFour10265.InfRefmsgid
  5349. res.Output = resFour10265.Output
  5350. res.ErrMsg = resFour10265.ErrMsg
  5351. res.Cainfo = resFour10265.Cainfo
  5352. res.WarnMsg = resFour10265.WarnMsg
  5353. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5354. res.Infcode = infocode
  5355. } else {
  5356. 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)
  5357. var dat map[string]interface{}
  5358. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5359. fmt.Println(dat)
  5360. } else {
  5361. fmt.Println(err)
  5362. }
  5363. saveLog(result, request_log, "2204", "上传费用明细")
  5364. userJSONBytes, _ := json.Marshal(dat)
  5365. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5366. utils.ErrorLog("解析失败:%v", err)
  5367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5368. return
  5369. }
  5370. }
  5371. }
  5372. if res.Infcode == 0 {
  5373. order := &models.HisOrder{
  5374. UserOrgId: adminUser.CurrentOrgId,
  5375. HisPatientId: his.ID,
  5376. PatientId: his.PatientId,
  5377. SettleAccountsDate: recordDateTime,
  5378. MdtrtId: his.Number,
  5379. PsnNo: his.PsnNo,
  5380. MedType: strconv.FormatInt(reg_type, 10),
  5381. Ctime: time.Now().Unix(),
  5382. Mtime: time.Now().Unix(),
  5383. Status: 1,
  5384. Number: chrg_bchno,
  5385. Infcode: res.Infcode,
  5386. WarnMsg: res.WarnMsg,
  5387. Cainfo: res.Cainfo,
  5388. ErrMsg: res.ErrMsg,
  5389. RespondTime: res.RefmsgTime,
  5390. InfRefmsgid: res.InfRefmsgid,
  5391. OrderStatus: 1,
  5392. PayWay: pay_way,
  5393. PayPrice: pay_price,
  5394. PayCardNo: pay_card_no,
  5395. DiscountPrice: discount_price,
  5396. PreferentialPrice: preferential_price,
  5397. RealityPrice: reality_price,
  5398. FoundPrice: found_price,
  5399. MedicalInsurancePrice: medical_insurance_price,
  5400. PrivatePrice: private_price,
  5401. IsMedicineInsurance: 1,
  5402. SettleType: settle_accounts_type,
  5403. SettleStartTime: start_time,
  5404. SettleEndTime: end_time,
  5405. Creator: roles.AdminUserId,
  5406. Modify: roles.AdminUserId,
  5407. FaPiaoNumber: fapiao_number,
  5408. FaPiaoCode: fapiao_code,
  5409. PType: 2,
  5410. Diagnosis: diagnosis_id,
  5411. }
  5412. err = service.CreateOrder(order)
  5413. if err != nil {
  5414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5415. return
  5416. }
  5417. for _, item := range res.Output.Result {
  5418. temp := strings.Split(item.FeedetlSn, "-")
  5419. var advice_id int64 = 0
  5420. var project_id int64 = 0
  5421. var types int64 = 0
  5422. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5423. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5424. if temp[1] == "1" {
  5425. advice_id = id
  5426. project_id = 0
  5427. } else if temp[1] == "2" {
  5428. advice_id = 0
  5429. project_id = id
  5430. }
  5431. info := &models.HisOrderInfo{
  5432. OrderNumber: order.Number,
  5433. FeedetlSn: item.FeedetlSn,
  5434. UploadDate: time.Now().Unix(),
  5435. AdviceId: advice_id,
  5436. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5437. Cnt: item.Cnt,
  5438. Pric: float64(item.Pric),
  5439. PatientId: his.PatientId,
  5440. PricUplmtAmt: item.PricUplmtAmt,
  5441. SelfpayProp: item.SelfpayProp,
  5442. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5443. OverlmtAmt: item.OverlmtAmt,
  5444. PreselfpayAmt: item.PreselfpayAmt,
  5445. BasMednFlag: item.BasMednFlag,
  5446. MedChrgitmType: item.MedChrgitmType,
  5447. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5448. Status: 1,
  5449. Memo: item.Memo,
  5450. Mtime: time.Now().Unix(),
  5451. InscpScpAmt: item.InscpScpAmt,
  5452. DrtReimFlag: item.DrtReimFlag,
  5453. Ctime: time.Now().Unix(),
  5454. ListSpItemFlag: item.ListSpItemFlag,
  5455. ChldMedcFlag: item.ChldMedcFlag,
  5456. LmtUsedFlag: item.LmtUsedFlag,
  5457. ChrgitmLv: item.ChrgitmLv,
  5458. UserOrgId: adminUser.CurrentOrgId,
  5459. HisPatientId: his.ID,
  5460. OrderId: order.ID,
  5461. ProjectId: project_id,
  5462. Type: types,
  5463. }
  5464. service.CreateOrderInfo(info)
  5465. }
  5466. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5467. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5468. var total float64
  5469. for _, item := range prescriptions {
  5470. if item.Type == 1 { //药品
  5471. for _, subItem := range item.HisDoctorAdviceInfo {
  5472. total = total + (subItem.Price * subItem.PrescribingNumber)
  5473. }
  5474. }
  5475. if item.Type == 2 { //项目
  5476. for _, subItem := range item.HisPrescriptionProject {
  5477. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5478. total = total + (subItem.Price * cnt)
  5479. }
  5480. }
  5481. }
  5482. for _, item := range prescriptions {
  5483. for _, subItem := range item.HisAdditionalCharge {
  5484. total = total + (subItem.Price * float64(subItem.Count))
  5485. }
  5486. }
  5487. var allTotal string
  5488. if adminUser.CurrentOrgId == 9919 {
  5489. allTotal = fmt.Sprintf("%.4f", total)
  5490. } else {
  5491. allTotal = fmt.Sprintf("%.4f", total)
  5492. }
  5493. if res.Infcode == 0 {
  5494. var rf []*ResultFive
  5495. json.Unmarshal([]byte(his.Iinfo), &rf)
  5496. chrg_bchno := chrg_bchno
  5497. cert_no := his.Certno
  5498. var insutypes []string
  5499. var insutype string
  5500. var is390 int = 0
  5501. var is310 int = 0
  5502. for _, item := range rf {
  5503. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5504. insutypes = append(insutypes, item.Insutype)
  5505. }
  5506. }
  5507. if len(insutypes) == 1 {
  5508. insutype = insutypes[0]
  5509. } else {
  5510. for _, i := range insutypes {
  5511. if i == "390" {
  5512. is390 = 1
  5513. }
  5514. if i == "310" {
  5515. is310 = 1
  5516. }
  5517. }
  5518. }
  5519. if is390 == 1 {
  5520. insutype = "390"
  5521. }
  5522. if is310 == 1 {
  5523. insutype = "310"
  5524. }
  5525. if len(insutypes) == 0 {
  5526. insutype = "310"
  5527. }
  5528. if len(insutypes) == 2 {
  5529. insutype = strconv.FormatInt(his.SocialType, 10)
  5530. }
  5531. insutype = strconv.FormatInt(his.SocialType, 10)
  5532. //insutype = "390"
  5533. if his.IdCardType == 1 {
  5534. // cert_no = his.MedicalInsuranceNumber
  5535. cert_no = his.Certno
  5536. } else {
  5537. cert_no = his.Certno
  5538. }
  5539. var res ResultSeven
  5540. var resSeven10265 ResultSeven10265
  5541. var src_resquest string
  5542. var result2 string
  5543. var acct_used_flag string
  5544. fmt.Println("pay_way")
  5545. fmt.Println(pay_way)
  5546. fmt.Println("pay_way")
  5547. if pay_way == 4 {
  5548. acct_used_flag = "1"
  5549. } else {
  5550. acct_used_flag = "0"
  5551. }
  5552. if miConfig.MdtrtareaAdmvs == "421300" {
  5553. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5554. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5555. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5556. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5557. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5558. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5559. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5560. resp, requestErr := http.Get(api)
  5561. if requestErr != nil {
  5562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5563. return
  5564. }
  5565. body, ioErr := ioutil.ReadAll(resp.Body)
  5566. if ioErr != nil {
  5567. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5569. return
  5570. }
  5571. var respJSON map[string]interface{}
  5572. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5573. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5575. return
  5576. }
  5577. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5578. result, _ := json.Marshal(respJSON)
  5579. if miConfig.Code == "H15049901371" {
  5580. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5581. utils.ErrorLog("解析失败:%v", err)
  5582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5583. return
  5584. }
  5585. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5586. res.Output = resSeven10265.Output
  5587. res.ErrMsg = resSeven10265.ErrMsg
  5588. res.Cainfo = resSeven10265.Cainfo
  5589. res.WarnMsg = resSeven10265.WarnMsg
  5590. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5591. res.Infcode = infocode
  5592. } else {
  5593. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5594. utils.ErrorLog("解析失败:%v", err)
  5595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5596. return
  5597. }
  5598. }
  5599. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5600. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5601. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5602. bas := strings.Split(psn_info.CardInfo, "|")
  5603. if his.IdCardType == 1 {
  5604. cert_no = bas[2]
  5605. } else if his.IdCardType == 3 {
  5606. cert_no = his.Certno
  5607. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  5608. } else if his.IdCardType == 4 {
  5609. cert_no = his.Certno
  5610. psn_info.VerifyNumber = token
  5611. }
  5612. var api string
  5613. if miConfig.MdtrtareaAdmvs == "320921" {
  5614. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5615. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5616. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5617. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5618. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5619. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5620. "&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
  5621. } else {
  5622. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5623. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5624. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5625. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5626. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5627. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5628. "&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
  5629. }
  5630. resp, requestErr := http.Get(api)
  5631. if requestErr != nil {
  5632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5633. return
  5634. }
  5635. body, ioErr := ioutil.ReadAll(resp.Body)
  5636. if ioErr != nil {
  5637. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5639. return
  5640. }
  5641. var respJSON map[string]interface{}
  5642. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5643. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5645. return
  5646. }
  5647. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5648. result, _ := json.Marshal(respJSON)
  5649. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5650. utils.ErrorLog("解析失败:%v", err)
  5651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5652. return
  5653. }
  5654. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5655. res.Output = resSeven10265.Output
  5656. res.ErrMsg = resSeven10265.ErrMsg
  5657. res.Cainfo = resSeven10265.Cainfo
  5658. res.WarnMsg = resSeven10265.WarnMsg
  5659. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5660. res.Infcode = infocode
  5661. } else {
  5662. if miConfig.Code == "H15049901371" {
  5663. //赤峰地区国家医保医疗类别
  5664. //职工透析:医疗类别选特殊情况门诊990502
  5665. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5666. var med_type string
  5667. if his.Insutype == "390" {
  5668. if reg_type == 14 {
  5669. med_type = "9933"
  5670. } else if reg_type == 11 {
  5671. med_type = "11"
  5672. }
  5673. } else if his.Insutype == "310" {
  5674. if reg_type == 14 {
  5675. med_type = "990502"
  5676. } else if reg_type == 11 {
  5677. med_type = "11"
  5678. }
  5679. }
  5680. 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)
  5681. } else {
  5682. 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)
  5683. }
  5684. //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)
  5685. var dat map[string]interface{}
  5686. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5687. fmt.Println(dat)
  5688. } else {
  5689. fmt.Println(err)
  5690. }
  5691. saveLog(result2, src_resquest, "2207", "结算")
  5692. userJSONBytes, _ := json.Marshal(dat)
  5693. if miConfig.Code == "H15049901371" {
  5694. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5695. utils.ErrorLog("解析失败:%v", err)
  5696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5697. return
  5698. }
  5699. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5700. res.Output = resSeven10265.Output
  5701. res.ErrMsg = resSeven10265.ErrMsg
  5702. res.Cainfo = resSeven10265.Cainfo
  5703. res.WarnMsg = resSeven10265.WarnMsg
  5704. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5705. res.Infcode = infocode
  5706. } else {
  5707. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5708. utils.ErrorLog("解析失败:%v", err)
  5709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5710. return
  5711. }
  5712. }
  5713. }
  5714. if res.Infcode != 0 {
  5715. errlog := &models.HisOrderError{
  5716. UserOrgId: adminUser.CurrentOrgId,
  5717. Ctime: time.Now().Unix(),
  5718. Mtime: time.Now().Unix(),
  5719. Number: chrg_bchno,
  5720. ErrMsg: res.ErrMsg,
  5721. Status: 1,
  5722. PatientId: id,
  5723. RecordTime: recordDateTime,
  5724. Stage: 6,
  5725. }
  5726. service.CreateErrMsgLog(errlog)
  5727. c.ServeSuccessJSON(map[string]interface{}{
  5728. "failed_code": -10,
  5729. "msg": res.ErrMsg,
  5730. })
  5731. return
  5732. } else {
  5733. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5734. order.OrderStatus = 2
  5735. order.Status = 1
  5736. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5737. order.SetlId = res.Output.Setlinfo.SetlID
  5738. order.PsnNo = res.Output.Setlinfo.PsnNo
  5739. order.PsnName = res.Output.Setlinfo.PsnName
  5740. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5741. order.Certno = res.Output.Setlinfo.Certno
  5742. order.Gend = res.Output.Setlinfo.Gend
  5743. order.Naty = res.Output.Setlinfo.Naty
  5744. order.Age = res.Output.Setlinfo.Age
  5745. order.Insutype = res.Output.Setlinfo.Insutype
  5746. order.PsnType = res.Output.Setlinfo.PsnType
  5747. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5748. order.SetlTime = res.Output.Setlinfo.SetlTime
  5749. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5750. if res.Output.Setlinfo.MedType == "140101" {
  5751. order.MedType = "14"
  5752. } else {
  5753. order.MedType = res.Output.Setlinfo.MedType
  5754. }
  5755. if reg_type == 1112 {
  5756. order.MedType = "1112"
  5757. }
  5758. if reg_type == 1111 {
  5759. order.MedType = "1111"
  5760. }
  5761. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5762. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5763. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5764. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5765. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5766. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5767. order.HifpPay = res.Output.Setlinfo.HifpPay
  5768. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5769. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5770. order.HifesPay = res.Output.Setlinfo.HifesPay
  5771. order.HifobPay = res.Output.Setlinfo.HifobPay
  5772. order.MafPay = res.Output.Setlinfo.MafPay
  5773. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5774. order.OthPay = res.Output.Setlinfo.OthPay
  5775. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5776. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5777. order.AcctPay = res.Output.Setlinfo.AcctPay
  5778. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5779. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5780. order.Balc = res.Output.Setlinfo.Balc
  5781. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5782. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5783. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5784. order.ClrType = res.Output.Setlinfo.ClrType
  5785. order.ClrWay = res.Output.Setlinfo.ClrWay
  5786. order.Creator = order.Creator
  5787. order.Modify = roles.AdminUserId
  5788. order.RequestLog = src_resquest
  5789. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5790. detailStr := string(setlDetail)
  5791. order.SetlDetail = detailStr
  5792. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5793. err = service.UpDateOrder(order)
  5794. if err == nil {
  5795. //判断是否使用了押金
  5796. if dec_way == "true" {
  5797. tmpstring := strconv.FormatInt(order.ID, 10)
  5798. order.Decimal = decimal
  5799. service.UpDateOrder(order)
  5800. //扣押金
  5801. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  5802. if errmsg != nil {
  5803. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  5804. return
  5805. }
  5806. }
  5807. c.ServeSuccessJSON(map[string]interface{}{
  5808. "msg": "结算成功",
  5809. })
  5810. } else {
  5811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5812. return
  5813. }
  5814. }
  5815. } else {
  5816. adminUser := c.GetAdminUserInfo()
  5817. errlog := &models.HisOrderError{
  5818. UserOrgId: adminUser.CurrentOrgId,
  5819. Ctime: time.Now().Unix(),
  5820. Mtime: time.Now().Unix(),
  5821. ErrMsg: res.ErrMsg,
  5822. Status: 1,
  5823. PatientId: id,
  5824. RecordTime: recordDateTime,
  5825. Stage: 4,
  5826. }
  5827. service.CreateErrMsgLog(errlog)
  5828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5829. return
  5830. }
  5831. } else {
  5832. adminUser := c.GetAdminUserInfo()
  5833. errlog := &models.HisOrderError{
  5834. UserOrgId: adminUser.CurrentOrgId,
  5835. Ctime: time.Now().Unix(),
  5836. Mtime: time.Now().Unix(),
  5837. ErrMsg: res.ErrMsg,
  5838. Status: 1,
  5839. PatientId: id,
  5840. RecordTime: recordDateTime,
  5841. Stage: 4,
  5842. }
  5843. service.CreateErrMsgLog(errlog)
  5844. c.ServeSuccessJSON(map[string]interface{}{
  5845. "failed_code": -10,
  5846. "msg": res.ErrMsg,
  5847. })
  5848. return
  5849. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5850. //return
  5851. }
  5852. }
  5853. }
  5854. } else if tempOrder.ID > 0 {
  5855. if tempOrder.IsPre == 1 {
  5856. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  5857. var rf []*ResultFive
  5858. json.Unmarshal([]byte(his.Iinfo), &rf)
  5859. chrg_bchno := tempOrder.Number
  5860. cert_no := his.Certno
  5861. var insutypes []string
  5862. var insutype string
  5863. var is390 int = 0
  5864. var is310 int = 0
  5865. for _, item := range rf {
  5866. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5867. insutypes = append(insutypes, item.Insutype)
  5868. }
  5869. }
  5870. if len(insutypes) == 1 {
  5871. insutype = insutypes[0]
  5872. } else {
  5873. for _, i := range insutypes {
  5874. if i == "390" {
  5875. is390 = 1
  5876. }
  5877. if i == "310" {
  5878. is310 = 1
  5879. }
  5880. }
  5881. }
  5882. if is390 == 1 {
  5883. insutype = "390"
  5884. }
  5885. if is310 == 1 {
  5886. insutype = "310"
  5887. }
  5888. if len(insutypes) == 0 {
  5889. insutype = "310"
  5890. }
  5891. if len(insutypes) == 2 {
  5892. insutype = strconv.FormatInt(his.SocialType, 64)
  5893. }
  5894. //insutype = "390"
  5895. if his.IdCardType == 1 {
  5896. // cert_no = his.MedicalInsuranceNumber
  5897. cert_no = his.Certno
  5898. } else {
  5899. cert_no = his.Certno
  5900. }
  5901. var res ResultSeven
  5902. var resSeven10265 ResultSeven10265
  5903. var src_resquest string
  5904. var result2 string
  5905. var acct_used_flag string
  5906. fmt.Println("pay_way")
  5907. fmt.Println(pay_way)
  5908. fmt.Println("pay_way")
  5909. if pay_way == 4 {
  5910. acct_used_flag = "1"
  5911. } else {
  5912. acct_used_flag = "0"
  5913. }
  5914. if miConfig.MdtrtareaAdmvs == "421300" {
  5915. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5916. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5917. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5918. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5919. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5920. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5921. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5922. resp, requestErr := http.Get(api)
  5923. if requestErr != nil {
  5924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5925. return
  5926. }
  5927. body, ioErr := ioutil.ReadAll(resp.Body)
  5928. if ioErr != nil {
  5929. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5931. return
  5932. }
  5933. var respJSON map[string]interface{}
  5934. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5935. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5937. return
  5938. }
  5939. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5940. result, _ := json.Marshal(respJSON)
  5941. fmt.Println("log")
  5942. fmt.Println(string(result))
  5943. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5944. utils.ErrorLog("解析失败:%v", err)
  5945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5946. return
  5947. }
  5948. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5949. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5950. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5951. //psn_info, _ := service.GetPsnByPatientId(id)
  5952. bas := strings.Split(psn_info.CardInfo, "|")
  5953. if his.IdCardType == 1 {
  5954. cert_no = bas[2]
  5955. } else {
  5956. cert_no = bas[1]
  5957. }
  5958. //江苏地区国家医保医疗类别
  5959. //职工透析:医疗类别选特殊情况门诊9933
  5960. //居民血透门慢: 医疗类别选门诊慢病1402
  5961. //var med_type string
  5962. //if his.Insutype == "310" {
  5963. // if reg_type == 14 {
  5964. // med_type = "9933"
  5965. // } else if reg_type == 11 {
  5966. // med_type = "11"
  5967. //
  5968. // }
  5969. //} else if his.Insutype == "390" {
  5970. // if reg_type == 14 {
  5971. // med_type = "1402"
  5972. // } else if reg_type == 11 {
  5973. // med_type = "11"
  5974. // }
  5975. //}
  5976. var api string
  5977. if miConfig.MdtrtareaAdmvs == "320921" {
  5978. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5979. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5980. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5981. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5982. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5983. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5984. "&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
  5985. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5986. } else {
  5987. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5988. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5989. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5990. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5991. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5992. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5993. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5994. "&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
  5995. }
  5996. resp, requestErr := http.Get(api)
  5997. if requestErr != nil {
  5998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5999. return
  6000. }
  6001. body, ioErr := ioutil.ReadAll(resp.Body)
  6002. if ioErr != nil {
  6003. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6005. return
  6006. }
  6007. var respJSON map[string]interface{}
  6008. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6009. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6011. return
  6012. }
  6013. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6014. result, _ := json.Marshal(respJSON)
  6015. fmt.Println("log")
  6016. fmt.Println(string(result))
  6017. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6018. utils.ErrorLog("解析失败:%v", err)
  6019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6020. return
  6021. }
  6022. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6023. res.Output = resSeven10265.Output
  6024. res.ErrMsg = resSeven10265.ErrMsg
  6025. res.Cainfo = resSeven10265.Cainfo
  6026. res.WarnMsg = resSeven10265.WarnMsg
  6027. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6028. res.Infcode = infocode
  6029. } else {
  6030. var src_resquest string
  6031. if miConfig.Code == "H15049901371" {
  6032. //赤峰地区国家医保医疗类别
  6033. //职工透析:医疗类别选特殊情况门诊990502
  6034. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6035. var med_type string
  6036. if his.Insutype == "390" {
  6037. if reg_type == 14 {
  6038. med_type = "9933"
  6039. } else if reg_type == 11 {
  6040. med_type = "11"
  6041. }
  6042. } else if his.Insutype == "310" {
  6043. if reg_type == 14 {
  6044. med_type = "990502"
  6045. } else if reg_type == 11 {
  6046. med_type = "11"
  6047. }
  6048. }
  6049. 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)
  6050. } else {
  6051. 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)
  6052. }
  6053. var dat map[string]interface{}
  6054. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6055. fmt.Println(dat)
  6056. } else {
  6057. fmt.Println(err)
  6058. }
  6059. saveLog(result2, src_resquest, "2207", "结算")
  6060. userJSONBytes, _ := json.Marshal(dat)
  6061. if miConfig.Code == "H15049901371" {
  6062. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6063. utils.ErrorLog("解析失败:%v", err)
  6064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6065. return
  6066. }
  6067. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6068. res.Output = resSeven10265.Output
  6069. res.ErrMsg = resSeven10265.ErrMsg
  6070. res.Cainfo = resSeven10265.Cainfo
  6071. res.WarnMsg = resSeven10265.WarnMsg
  6072. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6073. res.Infcode = infocode
  6074. } else {
  6075. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6076. utils.ErrorLog("解析失败:%v", err)
  6077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6078. return
  6079. }
  6080. }
  6081. }
  6082. if res.Infcode != 0 {
  6083. errlog := &models.HisOrderError{
  6084. UserOrgId: adminUser.CurrentOrgId,
  6085. Ctime: time.Now().Unix(),
  6086. Mtime: time.Now().Unix(),
  6087. Number: chrg_bchno,
  6088. ErrMsg: res.ErrMsg,
  6089. Status: 1,
  6090. PatientId: id,
  6091. RecordTime: recordDateTime,
  6092. Stage: 6,
  6093. }
  6094. service.CreateErrMsgLog(errlog)
  6095. c.ServeSuccessJSON(map[string]interface{}{
  6096. "failed_code": -10,
  6097. "msg": res.ErrMsg,
  6098. })
  6099. return
  6100. } else {
  6101. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6102. order.OrderStatus = 2
  6103. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6104. order.SetlId = res.Output.Setlinfo.SetlID
  6105. order.PsnNo = res.Output.Setlinfo.PsnNo
  6106. order.PsnName = res.Output.Setlinfo.PsnName
  6107. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6108. order.Certno = res.Output.Setlinfo.Certno
  6109. order.Gend = res.Output.Setlinfo.Gend
  6110. order.Naty = res.Output.Setlinfo.Naty
  6111. order.Age = res.Output.Setlinfo.Age
  6112. order.Insutype = res.Output.Setlinfo.Insutype
  6113. order.PsnType = res.Output.Setlinfo.PsnType
  6114. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6115. order.SetlTime = res.Output.Setlinfo.SetlTime
  6116. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6117. //order.MedType = res.Output.Setlinfo.MedType
  6118. if reg_type == 1112 {
  6119. order.MedType = "1112"
  6120. }
  6121. if reg_type == 1111 {
  6122. order.MedType = "1111"
  6123. }
  6124. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6125. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6126. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6127. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6128. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6129. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6130. order.HifpPay = res.Output.Setlinfo.HifpPay
  6131. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6132. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6133. order.HifesPay = res.Output.Setlinfo.HifesPay
  6134. order.HifobPay = res.Output.Setlinfo.HifobPay
  6135. order.MafPay = res.Output.Setlinfo.MafPay
  6136. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6137. order.OthPay = res.Output.Setlinfo.OthPay
  6138. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6139. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6140. order.AcctPay = res.Output.Setlinfo.AcctPay
  6141. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6142. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6143. order.Balc = res.Output.Setlinfo.Balc
  6144. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6145. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6146. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6147. order.ClrWay = res.Output.Setlinfo.ClrWay
  6148. order.Creator = order.Creator
  6149. order.Modify = roles.AdminUserId
  6150. order.RequestLog = src_resquest
  6151. order.Diagnosis = diagnosis_id
  6152. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6153. detailStr := string(setlDetail)
  6154. order.SetlDetail = detailStr
  6155. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6156. err = service.UpDateOrder(order)
  6157. if err == nil {
  6158. //判断是否使用了押金
  6159. if dec_way == "true" {
  6160. tmpstring := strconv.FormatInt(order.ID, 10)
  6161. //扣押金
  6162. order.Decimal = decimal
  6163. service.UpDateOrder(order)
  6164. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6165. if errmsg != nil {
  6166. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6167. return
  6168. }
  6169. }
  6170. c.ServeSuccessJSON(map[string]interface{}{
  6171. "msg": "结算成功",
  6172. })
  6173. } else {
  6174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6175. return
  6176. }
  6177. }
  6178. }
  6179. }
  6180. }
  6181. //func (c *HisApiController) GetPreUploadInfo() {
  6182. // id, _ := c.GetInt64("id")
  6183. // record_time := c.GetString("record_time")
  6184. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6185. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6186. //
  6187. // timeLayout := "2006-01-02"
  6188. // loc, _ := time.LoadLocation("Local")
  6189. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6190. // if err != nil {
  6191. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6192. // return
  6193. // }
  6194. // recordDateTime := theTime.Unix()
  6195. // adminUser := c.GetAdminUserInfo()
  6196. //
  6197. // var prescriptions []*models.HisPrescription
  6198. //
  6199. // var start_time int64
  6200. // var end_time int64
  6201. //
  6202. // data := make(map[string]interface{})
  6203. // if settle_accounts_type == 1 { //日结
  6204. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6205. // data["pre"] = prescriptions
  6206. //
  6207. // } else { //月结
  6208. // start_time_str := c.GetString("start_time")
  6209. // end_time_str := c.GetString("end_time")
  6210. // timeLayout := "2006-01-02"
  6211. // loc, _ := time.LoadLocation("Local")
  6212. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6213. // if err != nil {
  6214. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6215. // return
  6216. // }
  6217. // recordStartTime := theStartTime.Unix()
  6218. // start_time = recordStartTime
  6219. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6220. // if err != nil {
  6221. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6222. // return
  6223. // }
  6224. // recordEndTime := theEndTime.Unix()
  6225. // end_time = recordEndTime
  6226. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6227. // data["pre"] = prescriptions
  6228. //
  6229. // }
  6230. //
  6231. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6232. //
  6233. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6234. // timestamp := time.Now().Unix()
  6235. // tempTime := time.Unix(timestamp, 0)
  6236. // timeFormat := tempTime.Format("20060102150405")
  6237. // chrgBchno := rand.Intn(100000) + 10000
  6238. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6239. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6240. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6241. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6242. // strconv.FormatInt(his.PatientId, 10)
  6243. // client := &http.Client{}
  6244. // data["psn_no"] = his.PsnNo
  6245. // data["mdtrt_id"] = his.Number
  6246. // data["chrg_bchno"] = chrg_bchno
  6247. // data["org_name"] = miConfig.OrgName
  6248. // data["doctor"] = roles.UserName
  6249. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6250. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6251. // data["fixmedins_code"] = miConfig.Code
  6252. // data["dept_code"] = department.Number
  6253. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6254. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6255. // data["secret_key"] = miConfig.SecretKey
  6256. // var ids []int64
  6257. //
  6258. // for _, item := range prescriptions {
  6259. // ids = append(ids, item.ID)
  6260. // }
  6261. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6262. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6263. // bytesData, _ := json.Marshal(data)
  6264. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  6265. // resp, _ := client.Do(req)
  6266. // defer resp.Body.Close()
  6267. // body, ioErr := ioutil.ReadAll(resp.Body)
  6268. // if ioErr != nil {
  6269. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6270. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6271. // return
  6272. // }
  6273. // var respJSON map[string]interface{}
  6274. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6275. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6276. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6277. // return
  6278. // }
  6279. //
  6280. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6281. // userJSONBytes, _ := json.Marshal(respJSON)
  6282. // var res ResultFour
  6283. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6284. // utils.ErrorLog("解析失败:%v", err)
  6285. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6286. // return
  6287. // }
  6288. //
  6289. // if res.Infcode == 0 {
  6290. // order := &models.HisOrder{
  6291. // UserOrgId: adminUser.CurrentOrgId,
  6292. // HisPatientId: his.ID,
  6293. // PatientId: his.PatientId,
  6294. // SettleAccountsDate: recordDateTime,
  6295. // Ctime: time.Now().Unix(),
  6296. // Mtime: time.Now().Unix(),
  6297. // Status: 1,
  6298. // Number: chrg_bchno,
  6299. // Infcode: res.Infcode,
  6300. // WarnMsg: res.WarnMsg,
  6301. // Cainfo: res.Cainfo,
  6302. // ErrMsg: res.ErrMsg,
  6303. // RespondTime: res.RefmsgTime,
  6304. // InfRefmsgid: res.InfRefmsgid,
  6305. // OrderStatus: 1,
  6306. // IsMedicineInsurance: 1,
  6307. // SettleType: settle_accounts_type,
  6308. // SettleStartTime: start_time,
  6309. // SettleEndTime: end_time,
  6310. // Creator: roles.ID,
  6311. // Modify: roles.ID,
  6312. // PType: 2,
  6313. // }
  6314. // err = service.CreateOrder(order)
  6315. // if err != nil {
  6316. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6317. // return
  6318. // }
  6319. //
  6320. // for _, item := range res.Output.Result {
  6321. // temp := strings.Split(item.FeedetlSn, "-")
  6322. // var advice_id int64 = 0
  6323. // var project_id int64 = 0
  6324. // var types int64 = 0
  6325. //
  6326. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  6327. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  6328. //
  6329. // if temp[1] == "1" {
  6330. // advice_id = id
  6331. // project_id = 0
  6332. // } else if temp[1] == "2" {
  6333. // advice_id = 0
  6334. // project_id = id
  6335. // }
  6336. //
  6337. // info := &models.HisOrderInfo{
  6338. // OrderNumber: order.Number,
  6339. // FeedetlSn: item.FeedetlSn,
  6340. // UploadDate: time.Now().Unix(),
  6341. // AdviceId: advice_id,
  6342. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  6343. // Cnt: item.Cnt,
  6344. // Pric: float64(item.Pric),
  6345. // PatientId: his.PatientId,
  6346. // PricUplmtAmt: item.PricUplmtAmt,
  6347. // SelfpayProp: item.SelfpayProp,
  6348. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6349. // OverlmtAmt: item.OverlmtAmt,
  6350. // PreselfpayAmt: item.PreselfpayAmt,
  6351. // BasMednFlag: item.BasMednFlag,
  6352. // MedChrgitmType: item.MedChrgitmType,
  6353. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  6354. // Status: 1,
  6355. // Memo: item.Memo,
  6356. // Mtime: time.Now().Unix(),
  6357. // InscpScpAmt: item.InscpScpAmt,
  6358. // DrtReimFlag: item.DrtReimFlag,
  6359. // Ctime: time.Now().Unix(),
  6360. // ListSpItemFlag: item.ListSpItemFlag,
  6361. // ChldMedcFlag: item.ChldMedcFlag,
  6362. // LmtUsedFlag: item.LmtUsedFlag,
  6363. // ChrgitmLv: item.ChrgitmLv,
  6364. // UserOrgId: adminUser.CurrentOrgId,
  6365. // HisPatientId: his.ID,
  6366. // OrderId: order.ID,
  6367. // ProjectId: project_id,
  6368. // Type: types,
  6369. // }
  6370. // service.CreateOrderInfo(info)
  6371. //
  6372. // }
  6373. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6374. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  6375. //
  6376. // var total float64
  6377. // for _, item := range prescriptions {
  6378. // if item.Type == 1 { //药品
  6379. // for _, subItem := range item.HisDoctorAdviceInfo {
  6380. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6381. // }
  6382. // }
  6383. // if item.Type == 2 { //项目
  6384. // for _, subItem := range item.HisPrescriptionProject {
  6385. // total = total + (subItem.Price * float64(subItem.Count))
  6386. // }
  6387. // }
  6388. // }
  6389. //
  6390. // for _, item := range prescriptions {
  6391. // for _, subItem := range item.HisAdditionalCharge {
  6392. // total = total + (subItem.Price * float64(subItem.Count))
  6393. // }
  6394. // }
  6395. //
  6396. // allTotal := fmt.Sprintf("%.2f", total)
  6397. // if res.Infcode == 0 {
  6398. // var rf []*ResultFive
  6399. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6400. // psn_no := his.PsnNo
  6401. // mdtrt_id := his.Number
  6402. // chrg_bchno := chrg_bchno
  6403. // cert_no := his.Certno
  6404. // insutype := rf[0].Insutype
  6405. //
  6406. // if his.IdCardType == 1 {
  6407. // cert_no = his.MedicalInsuranceNumber
  6408. //
  6409. // } else {
  6410. //
  6411. // cert_no = his.Certno
  6412. //
  6413. // }
  6414. //
  6415. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  6416. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  6417. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  6418. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  6419. // resp, requestErr := http.Get(api)
  6420. // if requestErr != nil {
  6421. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6422. // return
  6423. // }
  6424. // defer resp.Body.Close()
  6425. // body, ioErr := ioutil.ReadAll(resp.Body)
  6426. // if ioErr != nil {
  6427. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6428. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6429. // return
  6430. // }
  6431. // var respJSON map[string]interface{}
  6432. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6433. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6434. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6435. // return
  6436. // }
  6437. // fmt.Println(respJSON)
  6438. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6439. // userJSONBytes, _ := json.Marshal(respJSON)
  6440. // var res ResultSeven
  6441. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6442. // utils.ErrorLog("解析失败:%v", err)
  6443. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6444. // return
  6445. // }
  6446. // if res.Infcode != 0 {
  6447. // errlog := &models.HisOrderError{
  6448. // UserOrgId: adminUser.CurrentOrgId,
  6449. // Ctime: time.Now().Unix(),
  6450. // Mtime: time.Now().Unix(),
  6451. // Number: chrg_bchno,
  6452. // ErrMsg: res.ErrMsg,
  6453. // Status: 1,
  6454. // PatientId: id,
  6455. // RecordTime: recordDateTime,
  6456. // Stage: 7,
  6457. // }
  6458. // service.CreateErrMsgLog(errlog)
  6459. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6460. // return
  6461. // } else {
  6462. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6463. // order.OrderStatus = 1
  6464. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6465. // order.SetlId = res.Output.Setlinfo.SetlID
  6466. // order.PsnNo = res.Output.Setlinfo.PsnNo
  6467. // order.PsnName = res.Output.Setlinfo.PsnName
  6468. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6469. // order.Certno = res.Output.Setlinfo.Certno
  6470. // order.Gend = res.Output.Setlinfo.Gend
  6471. // order.Naty = res.Output.Setlinfo.Naty
  6472. // order.Age = res.Output.Setlinfo.Age
  6473. // order.Insutype = res.Output.Setlinfo.Insutype
  6474. // order.PsnType = res.Output.Setlinfo.PsnType
  6475. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6476. // order.SetlTime = res.Output.Setlinfo.SetlTime
  6477. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6478. // order.MedType = res.Output.Setlinfo.MedType
  6479. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6480. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6481. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6482. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6483. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6484. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6485. // order.HifpPay = res.Output.Setlinfo.HifpPay
  6486. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6487. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6488. // order.HifesPay = res.Output.Setlinfo.HifesPay
  6489. // order.HifobPay = res.Output.Setlinfo.HifobPay
  6490. // order.MafPay = res.Output.Setlinfo.MafPay
  6491. // order.OthPay = res.Output.Setlinfo.OthPay
  6492. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6493. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6494. // order.AcctPay = res.Output.Setlinfo.AcctPay
  6495. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6496. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6497. // order.Balc = res.Output.Setlinfo.Balc
  6498. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6499. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6500. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6501. // order.ClrWay = res.Output.Setlinfo.ClrWay
  6502. // order.Creator = order.Creator
  6503. // order.Modify = roles.ID
  6504. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6505. // detailStr := string(setlDetail)
  6506. // order.SetlDetail = detailStr
  6507. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6508. // err = service.UpDateOrder(order)
  6509. // if err == nil {
  6510. // c.ServeSuccessJSON(map[string]interface{}{
  6511. // "msg": "预结算成功",
  6512. // })
  6513. // } else {
  6514. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6515. // return
  6516. // }
  6517. // }
  6518. // } else {
  6519. // adminUser := c.GetAdminUserInfo()
  6520. // errlog := &models.HisOrderError{
  6521. // UserOrgId: adminUser.CurrentOrgId,
  6522. // Ctime: time.Now().Unix(),
  6523. // Mtime: time.Now().Unix(),
  6524. // ErrMsg: res.ErrMsg,
  6525. // Status: 1,
  6526. // PatientId: id,
  6527. // RecordTime: recordDateTime,
  6528. // Stage: 4,
  6529. // }
  6530. // service.CreateErrMsgLog(errlog)
  6531. //
  6532. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6533. // return
  6534. // }
  6535. // } else {
  6536. // adminUser := c.GetAdminUserInfo()
  6537. // errlog := &models.HisOrderError{
  6538. // UserOrgId: adminUser.CurrentOrgId,
  6539. // Ctime: time.Now().Unix(),
  6540. // Mtime: time.Now().Unix(),
  6541. // ErrMsg: res.ErrMsg,
  6542. // Status: 1,
  6543. // PatientId: id,
  6544. // RecordTime: recordDateTime,
  6545. // Stage: 4,
  6546. // }
  6547. // service.CreateErrMsgLog(errlog)
  6548. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6549. // return
  6550. // }
  6551. //
  6552. // } else {
  6553. // var total float64
  6554. // for _, item := range prescriptions {
  6555. // if item.Type == 1 { //药品
  6556. // for _, subItem := range item.HisDoctorAdviceInfo {
  6557. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6558. // }
  6559. // }
  6560. // if item.Type == 2 { //项目
  6561. // for _, subItem := range item.HisPrescriptionProject {
  6562. // total = total + (subItem.Price * float64(subItem.Count))
  6563. // }
  6564. // }
  6565. //
  6566. // for _, subItem := range item.HisAdditionalCharge {
  6567. // total = total + (subItem.Price * float64(subItem.Count))
  6568. // }
  6569. // }
  6570. //
  6571. // allTotal := fmt.Sprintf("%.2f", total)
  6572. // totals, _ := strconv.ParseFloat(allTotal, 64)
  6573. // order := &models.HisOrder{
  6574. // UserOrgId: adminUser.CurrentOrgId,
  6575. // HisPatientId: his.ID,
  6576. // PatientId: id,
  6577. // SettleAccountsDate: recordDateTime,
  6578. // Ctime: time.Now().Unix(),
  6579. // Mtime: time.Now().Unix(),
  6580. // Status: 1,
  6581. // OrderStatus: 2,
  6582. // Number: chrg_bchno,
  6583. // MedfeeSumamt: totals,
  6584. // }
  6585. // err = service.CreateOrder(order)
  6586. // if err != nil {
  6587. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6588. // return
  6589. // }
  6590. //
  6591. // var customs []*Custom
  6592. // for _, item := range prescriptions {
  6593. //
  6594. // if item.Type == 1 { //药品
  6595. // for _, subItem := range item.HisDoctorAdviceInfo {
  6596. // cus := &Custom{
  6597. // AdviceId: subItem.ID,
  6598. // ProjectId: 0,
  6599. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  6600. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  6601. // FeedetlSn: subItem.FeedetlSn,
  6602. // Price: fmt.Sprintf("%.2f", subItem.Price),
  6603. // MedListCodg: subItem.MedListCodg,
  6604. // Type: 1,
  6605. // }
  6606. // customs = append(customs, cus)
  6607. // }
  6608. // }
  6609. //
  6610. // if item.Type == 2 { //项目
  6611. // for _, subItem := range item.HisPrescriptionProject {
  6612. //
  6613. // cus := &Custom{
  6614. // AdviceId: 0,
  6615. // ProjectId: subItem.ID,
  6616. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  6617. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  6618. // FeedetlSn: subItem.FeedetlSn,
  6619. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  6620. // MedListCodg: subItem.MedListCodg,
  6621. // Type: 2,
  6622. // }
  6623. //
  6624. // customs = append(customs, cus)
  6625. // }
  6626. // }
  6627. //
  6628. // for _, item := range item.HisAdditionalCharge {
  6629. // cus := &Custom{
  6630. // ItemId: item.ID,
  6631. // AdviceId: 0,
  6632. // ProjectId: 0,
  6633. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  6634. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  6635. // FeedetlSn: item.FeedetlSn,
  6636. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  6637. // MedListCodg: item.XtHisAddtionConfig.Code,
  6638. // Type: 3,
  6639. // }
  6640. //
  6641. // customs = append(customs, cus)
  6642. // }
  6643. //
  6644. // }
  6645. //
  6646. // for _, item := range customs {
  6647. // var advice_id int64 = 0
  6648. // var project_id int64 = 0
  6649. // var item_id int64 = 0
  6650. //
  6651. // var types int64 = 0
  6652. //
  6653. // if item.Type == 1 {
  6654. // advice_id = item.AdviceId
  6655. // project_id = 0
  6656. // item_id = 0
  6657. // } else if item.Type == 2 {
  6658. // advice_id = 0
  6659. // item_id = 0
  6660. //
  6661. // project_id = item.ProjectId
  6662. // } else if item.Type == 3 {
  6663. // advice_id = 0
  6664. // item_id = item.ItemId
  6665. // project_id = 0
  6666. // }
  6667. //
  6668. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  6669. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  6670. // pric, _ := strconv.ParseFloat(item.Price, 32)
  6671. //
  6672. // info := &models.HisOrderInfo{
  6673. // OrderNumber: order.Number,
  6674. // UploadDate: time.Now().Unix(),
  6675. // AdviceId: advice_id,
  6676. // DetItemFeeSumamt: detItemFeeSumamt,
  6677. // Cnt: cut,
  6678. // Pric: pric,
  6679. // PatientId: id,
  6680. // Status: 1,
  6681. // Mtime: time.Now().Unix(),
  6682. // Ctime: time.Now().Unix(),
  6683. // UserOrgId: adminUser.CurrentOrgId,
  6684. // HisPatientId: his.ID,
  6685. // OrderId: order.ID,
  6686. // ProjectId: project_id,
  6687. // Type: types,
  6688. // ItemId: item_id,
  6689. // }
  6690. // service.CreateOrderInfo(info)
  6691. // }
  6692. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6693. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6694. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  6695. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6696. // if err == nil {
  6697. // c.ServeSuccessJSON(map[string]interface{}{
  6698. // "msg": "结算成功",
  6699. // })
  6700. // } else {
  6701. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6702. // return
  6703. // }
  6704. // }
  6705. //}
  6706. //上传明细-预结算-
  6707. func (c *HisApiController) GetPreUploadInfo() {
  6708. id, _ := c.GetInt64("id")
  6709. record_time := c.GetString("record_time")
  6710. his_patient_id, _ := c.GetInt64("his_patient_id")
  6711. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6712. admin_user_id, _ := c.GetInt64("admin_user_id")
  6713. diagnosis_id := c.GetString("diagnosis")
  6714. sick_type, _ := c.GetInt64("sick_type")
  6715. reg_type, _ := c.GetInt64("p_type")
  6716. begin_time := c.GetString("begin_time")
  6717. id_str := c.GetString("ids")
  6718. ids_arr := strings.Split(id_str, ",")
  6719. timeLayout := "2006-01-02"
  6720. loc, _ := time.LoadLocation("Local")
  6721. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6722. if err != nil {
  6723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6724. return
  6725. }
  6726. recordDateTime := theTime.Unix()
  6727. adminUser := c.GetAdminUserInfo()
  6728. diagnosis_ids := strings.Split(diagnosis_id, ",")
  6729. var config []*models.HisXtDiagnoseConfig
  6730. for _, item := range diagnosis_ids {
  6731. id, _ := strconv.ParseInt(item, 10, 64)
  6732. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6733. config = append(config, &diagnosisConfig)
  6734. }
  6735. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  6736. sickConfig, _ := service.FindSickById(sick_type)
  6737. var prescriptions []*models.HisPrescription
  6738. var start_time int64
  6739. var end_time int64
  6740. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6741. fmt.Println(his_patient_id)
  6742. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6743. timestamp := time.Now().Unix()
  6744. tempTime := time.Unix(timestamp, 0)
  6745. timeFormat := tempTime.Format("20060102150405")
  6746. chrgBchno := rand.Intn(100000) + 10000
  6747. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6748. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6749. var patientPrescription models.HisPrescriptionInfo
  6750. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6751. if patientPrescription.ID == 0 {
  6752. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6753. }
  6754. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6755. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6756. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6757. strconv.FormatInt(his.PatientId, 10)
  6758. var res2 ResultSix
  6759. var resSix10265 ResultSix10265
  6760. var time_stamp string
  6761. if miConfig.MdtrtareaAdmvs == "421300" {
  6762. data := make(map[string]interface{})
  6763. client := &http.Client{}
  6764. data["psn_no"] = his.PsnNo
  6765. data["mdtrt_id"] = his.Number
  6766. data["department"] = department.Name
  6767. data["org_name"] = miConfig.OrgName
  6768. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6769. data["doctor_id"] = doctor_info.DoctorNumber
  6770. data["doctor_name"] = roles.UserName
  6771. data["fixmedins_code"] = miConfig.Code
  6772. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6773. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6774. data["secret_key"] = miConfig.SecretKey
  6775. data["sick_code"] = sickConfig.CountryCode
  6776. data["sick_name"] = sickConfig.ClassName
  6777. data["begin_time"] = begin_time
  6778. data["dept"] = strconv.FormatInt(department.ID, 10)
  6779. data["config"] = config
  6780. data["opter"] = roles.UserName
  6781. fmt.Println(data)
  6782. bytesData, _ := json.Marshal(data)
  6783. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  6784. resp, _ := client.Do(req)
  6785. defer resp.Body.Close()
  6786. body, ioErr := ioutil.ReadAll(resp.Body)
  6787. if ioErr != nil {
  6788. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6790. return
  6791. }
  6792. var respJSON map[string]interface{}
  6793. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6794. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6796. return
  6797. }
  6798. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6799. userJSONBytes, _ := json.Marshal(respJSON)
  6800. fmt.Println("log")
  6801. fmt.Println(string(userJSONBytes))
  6802. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6803. utils.ErrorLog("解析失败:%v", err)
  6804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6805. return
  6806. }
  6807. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6808. //江苏地区国家医保医疗类别
  6809. //职工透析:医疗类别选特殊情况门诊9933
  6810. //居民血透门慢: 医疗类别选门诊慢病1402
  6811. //var med_type string
  6812. //if his.Insutype == "310" {
  6813. // if reg_type == 14 {
  6814. // med_type = "9933"
  6815. // } else if reg_type == 11 {
  6816. // med_type = "11"
  6817. //
  6818. // }
  6819. //} else if his.Insutype == "390" {
  6820. // if reg_type == 14 {
  6821. // med_type = "1402"
  6822. // } else if reg_type == 11 {
  6823. // med_type = "11"
  6824. // }
  6825. //}
  6826. data := make(map[string]interface{})
  6827. client := &http.Client{}
  6828. data["psn_no"] = his.PsnNo
  6829. data["mdtrt_id"] = his.Number
  6830. data["doctor"] = roles.UserName
  6831. data["department"] = department.Name
  6832. data["org_name"] = miConfig.OrgName
  6833. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6834. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6835. data["fixmedins_code"] = miConfig.Code
  6836. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6837. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6838. data["secret_key"] = miConfig.SecretKey
  6839. data["sick_code"] = sickConfig.CountryCode
  6840. data["sick_name"] = sickConfig.ClassName
  6841. data["begin_time"] = begin_time
  6842. data["dept"] = strconv.FormatInt(department.ID, 10)
  6843. data["config"] = config
  6844. data["url"] = miConfig.Url
  6845. data["ak"] = miConfig.AccessKey
  6846. data["cainfo"] = miConfig.Cainfo
  6847. bytesData, _ := json.Marshal(data)
  6848. var req *http.Request
  6849. if miConfig.MdtrtareaAdmvs == "320921" {
  6850. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6851. //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 +
  6852. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  6853. } else {
  6854. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6855. }
  6856. resp, _ := client.Do(req)
  6857. defer resp.Body.Close()
  6858. body, ioErr := ioutil.ReadAll(resp.Body)
  6859. if ioErr != nil {
  6860. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6862. return
  6863. }
  6864. var respJSON map[string]interface{}
  6865. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6866. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6868. return
  6869. }
  6870. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  6871. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  6872. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  6873. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6874. userJSONBytes, _ := json.Marshal(respJSON)
  6875. fmt.Println("log")
  6876. fmt.Println(string(userJSONBytes))
  6877. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6878. utils.ErrorLog("解析失败:%v", err)
  6879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6880. return
  6881. }
  6882. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6883. res2.Output = resSix10265.Output
  6884. res2.ErrMsg = resSix10265.ErrMsg
  6885. res2.Cainfo = resSix10265.Cainfo
  6886. res2.WarnMsg = resSix10265.WarnMsg
  6887. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6888. res2.Infcode = infocode
  6889. } else {
  6890. var result string
  6891. var requestLog string
  6892. if miConfig.MdtrtareaAdmvs == "440781" { //
  6893. 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)
  6894. } else {
  6895. if miConfig.Code == "H15049901371" {
  6896. //赤峰地区国家医保医疗类别
  6897. //职工透析:医疗类别选特殊情况门诊990502
  6898. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6899. var med_type string
  6900. if his.Insutype == "390" {
  6901. if reg_type == 14 {
  6902. med_type = "9933"
  6903. } else if reg_type == 11 {
  6904. med_type = "11"
  6905. }
  6906. } else if his.Insutype == "310" {
  6907. if reg_type == 14 {
  6908. med_type = "990502"
  6909. } else if reg_type == 11 {
  6910. med_type = "11"
  6911. }
  6912. }
  6913. 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)
  6914. } else {
  6915. 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)
  6916. }
  6917. saveLog(result, requestLog, "2203", "上传就诊信息")
  6918. var respJSON2 map[string]interface{}
  6919. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6920. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6922. return
  6923. }
  6924. userJSONBytes2, _ := json.Marshal(respJSON2)
  6925. if miConfig.Code == "H15049901371" {
  6926. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  6927. utils.ErrorLog("解析失败:%v", err)
  6928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6929. return
  6930. }
  6931. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6932. res2.Output = resSix10265.Output
  6933. res2.ErrMsg = resSix10265.ErrMsg
  6934. res2.Cainfo = resSix10265.Cainfo
  6935. res2.WarnMsg = resSix10265.WarnMsg
  6936. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6937. res2.Infcode = infocode
  6938. } else {
  6939. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  6940. utils.ErrorLog("解析失败:%v", err)
  6941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6942. return
  6943. }
  6944. }
  6945. }
  6946. }
  6947. if res2.Infcode != 0 {
  6948. adminUser := c.GetAdminUserInfo()
  6949. errlog := &models.HisOrderError{
  6950. UserOrgId: adminUser.CurrentOrgId,
  6951. Ctime: time.Now().Unix(),
  6952. Mtime: time.Now().Unix(),
  6953. ErrMsg: res2.ErrMsg,
  6954. Status: 1,
  6955. PatientId: id,
  6956. RecordTime: recordDateTime,
  6957. Stage: 3,
  6958. }
  6959. service.CreateErrMsgLog(errlog)
  6960. c.ServeSuccessJSON(map[string]interface{}{
  6961. "failed_code": -10,
  6962. "msg": res2.ErrMsg,
  6963. })
  6964. return
  6965. } else {
  6966. his.Diagnosis = diagnosis_id
  6967. his.SickType = sickConfig.ID
  6968. his.PType = fmt.Sprintf("%d", reg_type)
  6969. service.UpdateHisPatientThree(&his)
  6970. data := make(map[string]interface{})
  6971. if settle_accounts_type == 1 { //日结
  6972. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  6973. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  6974. } else {
  6975. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  6976. }
  6977. data["pre"] = prescriptions
  6978. } else { //月结
  6979. start_time_str := c.GetString("start_time")
  6980. end_time_str := c.GetString("end_time")
  6981. timeLayout := "2006-01-02"
  6982. loc, _ := time.LoadLocation("Local")
  6983. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6984. if err != nil {
  6985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6986. return
  6987. }
  6988. recordStartTime := theStartTime.Unix()
  6989. start_time = recordStartTime
  6990. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6991. if err != nil {
  6992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6993. return
  6994. }
  6995. recordEndTime := theEndTime.Unix()
  6996. end_time = recordEndTime
  6997. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  6998. data["pre"] = prescriptions
  6999. }
  7000. client := &http.Client{}
  7001. data["psn_no"] = his.PsnNo
  7002. data["mdtrt_id"] = his.Number
  7003. data["chrg_bchno"] = chrg_bchno
  7004. data["org_name"] = miConfig.OrgName
  7005. data["doctor"] = roles.UserName
  7006. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  7007. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  7008. data["fixmedins_code"] = miConfig.Code
  7009. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  7010. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  7011. data["dept_code"] = "15"
  7012. } else {
  7013. data["dept_code"] = department.Number
  7014. }
  7015. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7016. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7017. data["secret_key"] = miConfig.SecretKey
  7018. data["url"] = miConfig.Url
  7019. data["ak"] = miConfig.AccessKey
  7020. data["new_doctor_name"] = patientPrescription.Doctor
  7021. data["diag_code"] = sickConfig.CountryCode
  7022. data["time_stamp"] = time_stamp
  7023. data["cainfo"] = miConfig.Cainfo
  7024. var ids []int64
  7025. for _, item := range prescriptions {
  7026. ids = append(ids, item.ID)
  7027. }
  7028. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7029. if config.IsOpen == 1 { //对接了医保,走医保流程
  7030. var res ResultFour
  7031. var resFour10265 ResultFour10265
  7032. if miConfig.MdtrtareaAdmvs == "421300" {
  7033. bytesData, _ := json.Marshal(data)
  7034. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  7035. resp, _ := client.Do(req)
  7036. defer resp.Body.Close()
  7037. body, ioErr := ioutil.ReadAll(resp.Body)
  7038. if ioErr != nil {
  7039. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7041. return
  7042. }
  7043. var respJSON map[string]interface{}
  7044. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7045. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7047. return
  7048. }
  7049. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7050. userJSONBytes, _ := json.Marshal(respJSON)
  7051. fmt.Println("log")
  7052. fmt.Println(string(userJSONBytes))
  7053. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7054. utils.ErrorLog("解析失败:%v", err)
  7055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7056. return
  7057. }
  7058. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7059. bytesData, _ := json.Marshal(data)
  7060. var req *http.Request
  7061. if miConfig.MdtrtareaAdmvs == "320921" {
  7062. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7063. } else {
  7064. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", 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. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7081. userJSONBytes, _ := json.Marshal(respJSON)
  7082. fmt.Println("log")
  7083. fmt.Println(string(userJSONBytes))
  7084. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7085. utils.ErrorLog("解析失败:%v", err)
  7086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7087. return
  7088. }
  7089. res.InfRefmsgid = resFour10265.InfRefmsgid
  7090. res.Output = resFour10265.Output
  7091. res.ErrMsg = resFour10265.ErrMsg
  7092. res.Cainfo = resFour10265.Cainfo
  7093. res.WarnMsg = resFour10265.WarnMsg
  7094. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7095. res.Infcode = infocode
  7096. } else {
  7097. if miConfig.Code == "H15049901371" {
  7098. 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)
  7099. var dat map[string]interface{}
  7100. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7101. fmt.Println(dat)
  7102. } else {
  7103. fmt.Println(err)
  7104. }
  7105. saveLog(result, request_log, "2204", "上传费用明细")
  7106. userJSONBytes, _ := json.Marshal(dat)
  7107. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7108. utils.ErrorLog("解析失败:%v", err)
  7109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7110. return
  7111. }
  7112. res.InfRefmsgid = resFour10265.InfRefmsgid
  7113. res.Output = resFour10265.Output
  7114. res.ErrMsg = resFour10265.ErrMsg
  7115. res.Cainfo = resFour10265.Cainfo
  7116. res.WarnMsg = resFour10265.WarnMsg
  7117. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7118. res.Infcode = infocode
  7119. } else {
  7120. 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)
  7121. var dat map[string]interface{}
  7122. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7123. fmt.Println(dat)
  7124. } else {
  7125. fmt.Println(err)
  7126. }
  7127. saveLog(result, request_log, "2204", "上传费用明细")
  7128. userJSONBytes, _ := json.Marshal(dat)
  7129. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7130. utils.ErrorLog("解析失败:%v", err)
  7131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7132. return
  7133. }
  7134. }
  7135. }
  7136. if res.Infcode == 0 {
  7137. order := &models.HisOrder{
  7138. UserOrgId: adminUser.CurrentOrgId,
  7139. HisPatientId: his.ID,
  7140. PatientId: his.PatientId,
  7141. SettleAccountsDate: recordDateTime,
  7142. Ctime: time.Now().Unix(),
  7143. Mtime: time.Now().Unix(),
  7144. MdtrtId: his.Number,
  7145. PsnNo: his.PsnNo,
  7146. MedType: strconv.FormatInt(reg_type, 10),
  7147. Status: 1,
  7148. Number: chrg_bchno,
  7149. Infcode: res.Infcode,
  7150. WarnMsg: res.WarnMsg,
  7151. Cainfo: res.Cainfo,
  7152. ErrMsg: res.ErrMsg,
  7153. RespondTime: res.RefmsgTime,
  7154. InfRefmsgid: res.InfRefmsgid,
  7155. OrderStatus: 1,
  7156. IsMedicineInsurance: 1,
  7157. SettleType: settle_accounts_type,
  7158. SettleStartTime: start_time,
  7159. SettleEndTime: end_time,
  7160. Creator: roles.AdminUserId,
  7161. Modify: roles.AdminUserId,
  7162. PType: 2,
  7163. Diagnosis: diagnosis_id,
  7164. }
  7165. err = service.CreateOrder(order)
  7166. if err != nil {
  7167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7168. return
  7169. }
  7170. for _, item := range res.Output.Result {
  7171. temp := strings.Split(item.FeedetlSn, "-")
  7172. var advice_id int64 = 0
  7173. var project_id int64 = 0
  7174. var types int64 = 0
  7175. id, _ := strconv.ParseInt(temp[2], 10, 64)
  7176. types, _ = strconv.ParseInt(temp[1], 10, 64)
  7177. if temp[1] == "1" {
  7178. advice_id = id
  7179. project_id = 0
  7180. } else if temp[1] == "2" {
  7181. advice_id = 0
  7182. project_id = id
  7183. }
  7184. info := &models.HisOrderInfo{
  7185. OrderNumber: order.Number,
  7186. FeedetlSn: item.FeedetlSn,
  7187. UploadDate: time.Now().Unix(),
  7188. AdviceId: advice_id,
  7189. DetItemFeeSumamt: item.DetItemFeeSumamt,
  7190. Cnt: item.Cnt,
  7191. Pric: float64(item.Pric),
  7192. PatientId: his.PatientId,
  7193. PricUplmtAmt: item.PricUplmtAmt,
  7194. SelfpayProp: item.SelfpayProp,
  7195. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7196. OverlmtAmt: item.OverlmtAmt,
  7197. PreselfpayAmt: item.PreselfpayAmt,
  7198. BasMednFlag: item.BasMednFlag,
  7199. MedChrgitmType: item.MedChrgitmType,
  7200. HiNegoDrugFlag: item.HiNegoDrugFlag,
  7201. Status: 1,
  7202. Memo: item.Memo,
  7203. Mtime: time.Now().Unix(),
  7204. InscpScpAmt: item.InscpScpAmt,
  7205. DrtReimFlag: item.DrtReimFlag,
  7206. Ctime: time.Now().Unix(),
  7207. ListSpItemFlag: item.ListSpItemFlag,
  7208. ChldMedcFlag: item.ChldMedcFlag,
  7209. LmtUsedFlag: item.LmtUsedFlag,
  7210. ChrgitmLv: item.ChrgitmLv,
  7211. UserOrgId: adminUser.CurrentOrgId,
  7212. HisPatientId: his.ID,
  7213. OrderId: order.ID,
  7214. ProjectId: project_id,
  7215. Type: types,
  7216. }
  7217. service.CreateOrderInfo(info)
  7218. }
  7219. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7220. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  7221. var total float64
  7222. for _, item := range prescriptions {
  7223. if item.Type == 1 { //药品
  7224. for _, subItem := range item.HisDoctorAdviceInfo {
  7225. total = total + (subItem.Price * subItem.PrescribingNumber)
  7226. }
  7227. }
  7228. if item.Type == 2 { //项目
  7229. for _, subItem := range item.HisPrescriptionProject {
  7230. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7231. total = total + (subItem.Price * cnt)
  7232. }
  7233. }
  7234. }
  7235. for _, item := range prescriptions {
  7236. for _, subItem := range item.HisAdditionalCharge {
  7237. total = total + (subItem.Price * float64(subItem.Count))
  7238. }
  7239. }
  7240. allTotal := fmt.Sprintf("%.4f", total)
  7241. if res.Infcode == 0 {
  7242. var rf []*ResultFive
  7243. json.Unmarshal([]byte(his.Iinfo), &rf)
  7244. chrg_bchno := chrg_bchno
  7245. cert_no := his.Certno
  7246. var insutypes []string
  7247. var insutype string
  7248. var is390 int = 0
  7249. var is310 int = 0
  7250. for _, item := range rf {
  7251. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7252. insutypes = append(insutypes, item.Insutype)
  7253. }
  7254. }
  7255. if len(insutypes) == 1 {
  7256. insutype = insutypes[0]
  7257. } else {
  7258. for _, i := range insutypes {
  7259. if i == "390" {
  7260. is390 = 1
  7261. }
  7262. if i == "310" {
  7263. is310 = 1
  7264. }
  7265. }
  7266. }
  7267. if is390 == 1 {
  7268. insutype = "390"
  7269. }
  7270. if is310 == 1 {
  7271. insutype = "310"
  7272. }
  7273. if len(insutypes) == 0 {
  7274. insutype = "310"
  7275. }
  7276. if len(insutypes) == 2 {
  7277. insutype = strconv.FormatInt(his.SocialType, 64)
  7278. }
  7279. //insutype = "390"
  7280. if his.IdCardType == 1 {
  7281. cert_no = his.MedicalInsuranceNumber
  7282. } else {
  7283. cert_no = his.Certno
  7284. }
  7285. var res ResultSeven
  7286. var resSeven10265 ResultSeven10265
  7287. if miConfig.MdtrtareaAdmvs == "421300" {
  7288. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7289. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7290. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7291. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7292. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7293. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7294. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  7295. resp, requestErr := http.Get(api)
  7296. if requestErr != nil {
  7297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7298. return
  7299. }
  7300. body, ioErr := ioutil.ReadAll(resp.Body)
  7301. if ioErr != nil {
  7302. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7304. return
  7305. }
  7306. var respJSON map[string]interface{}
  7307. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7308. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7310. return
  7311. }
  7312. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7313. result, _ := json.Marshal(respJSON)
  7314. fmt.Println("log")
  7315. fmt.Println(string(result))
  7316. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7317. utils.ErrorLog("解析失败:%v", err)
  7318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7319. return
  7320. }
  7321. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7322. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7323. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7324. bas := strings.Split(psn_info.CardInfo, "|")
  7325. if his.IdCardType == 1 {
  7326. cert_no = bas[2]
  7327. } else {
  7328. cert_no = bas[1]
  7329. }
  7330. //江苏地区国家医保医疗类别
  7331. //职工透析:医疗类别选特殊情况门诊9933
  7332. //居民血透门慢: 医疗类别选门诊慢病1402
  7333. //var med_type string
  7334. //if his.Insutype == "310" {
  7335. // if reg_type == 14 {
  7336. // med_type = "9933"
  7337. // } else if reg_type == 11 {
  7338. // med_type = "11"
  7339. //
  7340. // }
  7341. //} else if his.Insutype == "390" {
  7342. // if reg_type == 14 {
  7343. // med_type = "1402"
  7344. // } else if reg_type == 11 {
  7345. // med_type = "11"
  7346. // }
  7347. //}
  7348. var api string
  7349. if miConfig.MdtrtareaAdmvs == "320921" {
  7350. api = "http://192.168.2.110:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7351. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7352. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7353. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7354. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7355. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7356. "&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
  7357. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7358. } else {
  7359. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7360. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7361. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7362. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7363. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7364. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7365. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7366. "&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
  7367. }
  7368. resp, requestErr := http.Get(api)
  7369. if requestErr != nil {
  7370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7371. return
  7372. }
  7373. body, ioErr := ioutil.ReadAll(resp.Body)
  7374. if ioErr != nil {
  7375. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7377. return
  7378. }
  7379. var respJSON map[string]interface{}
  7380. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7381. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7383. return
  7384. }
  7385. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7386. result, _ := json.Marshal(respJSON)
  7387. fmt.Println("log")
  7388. fmt.Println(string(result))
  7389. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7390. utils.ErrorLog("解析失败:%v", err)
  7391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7392. return
  7393. }
  7394. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7395. res.Output = resSeven10265.Output
  7396. res.ErrMsg = resSeven10265.ErrMsg
  7397. res.Cainfo = resSeven10265.Cainfo
  7398. res.WarnMsg = resSeven10265.WarnMsg
  7399. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7400. res.Infcode = infocode
  7401. } else {
  7402. var result string
  7403. var request_log string
  7404. if miConfig.Code == "H15049901371" {
  7405. //赤峰地区国家医保医疗类别
  7406. //职工透析:医疗类别选特殊情况门诊990502
  7407. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7408. var med_type string
  7409. if his.Insutype == "390" {
  7410. if reg_type == 14 {
  7411. med_type = "9933"
  7412. } else if reg_type == 11 {
  7413. med_type = "11"
  7414. }
  7415. } else if his.Insutype == "310" {
  7416. if reg_type == 14 {
  7417. med_type = "990502"
  7418. } else if reg_type == 11 {
  7419. med_type = "11"
  7420. }
  7421. }
  7422. 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)
  7423. } else {
  7424. 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)
  7425. }
  7426. var dat map[string]interface{}
  7427. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7428. fmt.Println(dat)
  7429. } else {
  7430. fmt.Println(err)
  7431. }
  7432. saveLog(result, request_log, "2206", "预结算")
  7433. //userJSONBytes, _ := json.Marshal(dat)
  7434. //
  7435. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7436. // utils.ErrorLog("解析失败:%v", err)
  7437. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7438. // return
  7439. //}
  7440. userJSONBytes, _ := json.Marshal(dat)
  7441. if miConfig.Code == "H15049901371" {
  7442. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7443. utils.ErrorLog("解析失败:%v", err)
  7444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7445. return
  7446. }
  7447. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7448. res.Output = resSeven10265.Output
  7449. res.ErrMsg = resSeven10265.ErrMsg
  7450. res.Cainfo = resSeven10265.Cainfo
  7451. res.WarnMsg = resSeven10265.WarnMsg
  7452. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7453. res.Infcode = infocode
  7454. } else {
  7455. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7456. utils.ErrorLog("解析失败:%v", err)
  7457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7458. return
  7459. }
  7460. }
  7461. }
  7462. if res.Infcode != 0 {
  7463. errlog := &models.HisOrderError{
  7464. UserOrgId: adminUser.CurrentOrgId,
  7465. Ctime: time.Now().Unix(),
  7466. Mtime: time.Now().Unix(),
  7467. Number: chrg_bchno,
  7468. ErrMsg: res.ErrMsg,
  7469. Status: 1,
  7470. PatientId: id,
  7471. RecordTime: recordDateTime,
  7472. Stage: 20,
  7473. }
  7474. service.CreateErrMsgLog(errlog)
  7475. c.ServeSuccessJSON(map[string]interface{}{
  7476. "failed_code": -10,
  7477. "msg": res.ErrMsg,
  7478. })
  7479. return
  7480. } else {
  7481. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7482. order.OrderStatus = 1
  7483. order.IsPre = 1
  7484. order.Status = 1
  7485. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7486. order.SetlId = res.Output.Setlinfo.SetlID
  7487. order.PsnNo = res.Output.Setlinfo.PsnNo
  7488. order.PsnName = res.Output.Setlinfo.PsnName
  7489. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7490. order.Certno = res.Output.Setlinfo.Certno
  7491. order.Gend = res.Output.Setlinfo.Gend
  7492. order.Naty = res.Output.Setlinfo.Naty
  7493. order.Age = res.Output.Setlinfo.Age
  7494. order.Insutype = res.Output.Setlinfo.Insutype
  7495. order.PsnType = res.Output.Setlinfo.PsnType
  7496. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7497. order.SetlTime = res.Output.Setlinfo.SetlTime
  7498. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7499. if res.Output.Setlinfo.MedType == "140101" {
  7500. order.MedType = "14"
  7501. } else {
  7502. order.MedType = res.Output.Setlinfo.MedType
  7503. }
  7504. if reg_type == 1112 {
  7505. order.MedType = "1112"
  7506. }
  7507. if reg_type == 1111 {
  7508. order.MedType = "1111"
  7509. }
  7510. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7511. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7512. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7513. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7514. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7515. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7516. order.HifpPay = res.Output.Setlinfo.HifpPay
  7517. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7518. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7519. order.HifesPay = res.Output.Setlinfo.HifesPay
  7520. order.HifobPay = res.Output.Setlinfo.HifobPay
  7521. order.MafPay = res.Output.Setlinfo.MafPay
  7522. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  7523. order.OthPay = res.Output.Setlinfo.OthPay
  7524. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7525. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7526. order.AcctPay = res.Output.Setlinfo.AcctPay
  7527. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7528. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7529. order.Balc = res.Output.Setlinfo.Balc
  7530. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7531. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7532. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7533. order.ClrWay = res.Output.Setlinfo.ClrWay
  7534. order.Creator = order.Creator
  7535. order.Modify = roles.AdminUserId
  7536. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7537. detailStr := string(setlDetail)
  7538. order.SetlDetail = detailStr
  7539. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7540. err = service.UpDateOrder(order)
  7541. if err == nil {
  7542. c.ServeSuccessJSON(map[string]interface{}{
  7543. "msg": "预结算成功",
  7544. })
  7545. } else {
  7546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7547. return
  7548. }
  7549. }
  7550. } else {
  7551. adminUser := c.GetAdminUserInfo()
  7552. errlog := &models.HisOrderError{
  7553. UserOrgId: adminUser.CurrentOrgId,
  7554. Ctime: time.Now().Unix(),
  7555. Mtime: time.Now().Unix(),
  7556. ErrMsg: res.ErrMsg,
  7557. Status: 1,
  7558. PatientId: id,
  7559. RecordTime: recordDateTime,
  7560. Stage: 4,
  7561. }
  7562. service.CreateErrMsgLog(errlog)
  7563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7564. return
  7565. }
  7566. } else {
  7567. adminUser := c.GetAdminUserInfo()
  7568. errlog := &models.HisOrderError{
  7569. UserOrgId: adminUser.CurrentOrgId,
  7570. Ctime: time.Now().Unix(),
  7571. Mtime: time.Now().Unix(),
  7572. ErrMsg: res.ErrMsg,
  7573. Status: 1,
  7574. PatientId: id,
  7575. RecordTime: recordDateTime,
  7576. Stage: 4,
  7577. }
  7578. service.CreateErrMsgLog(errlog)
  7579. c.ServeSuccessJSON(map[string]interface{}{
  7580. "failed_code": -10,
  7581. "msg": res.ErrMsg,
  7582. })
  7583. return
  7584. }
  7585. }
  7586. }
  7587. }
  7588. //func (c *HisApiController) GetSettleInfo() {
  7589. // id, _ := c.GetInt64("id")
  7590. // order_id, _ := c.GetInt64("order_id")
  7591. //
  7592. // record_time := c.GetString("record_time")
  7593. // pay_way, _ := c.GetInt64("pay_way")
  7594. // pay_price, _ := c.GetFloat("pay_price")
  7595. // pay_card_no := c.GetString("pay_card_no")
  7596. // discount_price, _ := c.GetFloat("discount_price")
  7597. // preferential_price, _ := c.GetFloat("preferential_price")
  7598. // reality_price, _ := c.GetFloat("reality_price")
  7599. // found_price, _ := c.GetFloat("found_price")
  7600. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  7601. // private_price, _ := c.GetFloat("private_price")
  7602. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7603. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7604. //
  7605. // timeLayout := "2006-01-02"
  7606. // loc, _ := time.LoadLocation("Local")
  7607. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7608. // if err != nil {
  7609. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7610. // return
  7611. // }
  7612. // recordDateTime := theTime.Unix()
  7613. // adminUser := c.GetAdminUserInfo()
  7614. //
  7615. // var prescriptions []*models.HisPrescription
  7616. //
  7617. // data := make(map[string]interface{})
  7618. // if settle_accounts_type == 1 { //日结
  7619. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  7620. // data["pre"] = prescriptions
  7621. //
  7622. // } else { //月结
  7623. // start_time_str := c.GetString("start_time")
  7624. // end_time_str := c.GetString("end_time")
  7625. // timeLayout := "2006-01-02"
  7626. // loc, _ := time.LoadLocation("Local")
  7627. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7628. // if err != nil {
  7629. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7630. // return
  7631. // }
  7632. // recordStartTime := theStartTime.Unix()
  7633. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7634. // if err != nil {
  7635. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7636. // return
  7637. // }
  7638. // recordEndTime := theEndTime.Unix()
  7639. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  7640. // data["pre"] = prescriptions
  7641. //
  7642. // }
  7643. //
  7644. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7645. //
  7646. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7647. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7648. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7649. // strconv.FormatInt(his.PatientId, 10)
  7650. //
  7651. // order_src, _ := service.GetHisOrderByID(order_id)
  7652. //
  7653. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7654. // if config.IsOpen == 1 { //对接了医保,走医保流程
  7655. //
  7656. // var total float64
  7657. // for _, item := range prescriptions {
  7658. // if item.Type == 1 { //药品
  7659. // for _, subItem := range item.HisDoctorAdviceInfo {
  7660. // total = total + (subItem.Price * subItem.PrescribingNumber)
  7661. // }
  7662. // }
  7663. // if item.Type == 2 { //项目
  7664. // for _, subItem := range item.HisPrescriptionProject {
  7665. // total = total + (subItem.Price * float64(subItem.Count))
  7666. // }
  7667. // }
  7668. // }
  7669. //
  7670. // for _, item := range prescriptions {
  7671. // for _, subItem := range item.HisAdditionalCharge {
  7672. // total = total + (subItem.Price * float64(subItem.Count))
  7673. // }
  7674. // }
  7675. //
  7676. // allTotal := fmt.Sprintf("%.2f", total)
  7677. // var rf []*ResultFive
  7678. // json.Unmarshal([]byte(his.Iinfo), &rf)
  7679. // psn_no := order_src.PsnNo
  7680. // mdtrt_id := order_src.MdtrtId
  7681. // chrg_bchno := order_src.Number
  7682. // cert_no := order_src.Certno
  7683. // insutype := rf[0].Insutype
  7684. //
  7685. // if his.IdCardType == 1 {
  7686. // cert_no = his.MedicalInsuranceNumber
  7687. // } else {
  7688. // cert_no = his.Certno
  7689. // }
  7690. //
  7691. // result, src_resquest := service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, strconv.FormatFloat(total, 'E', -1, 64) ,miConfig.OrgName,roles.UserName,miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(patientPrescription.RegisterType, 10),his.IdCardType, order_src.FulamtOwnpayAmt,order_src.OverlmtSelfPay,order_src.PreselfpayAmt,order_src.InscpScpAmt)
  7692. // var dat map[string]interface{}
  7693. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7694. // fmt.Println(dat)
  7695. // } else {
  7696. // fmt.Println(err)
  7697. // }
  7698. //
  7699. // userJSONBytes, _ := json.Marshal(dat)
  7700. //
  7701. //
  7702. //
  7703. // var res ResultSeven
  7704. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7705. // utils.ErrorLog("解析失败:%v", err)
  7706. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7707. // return
  7708. // }
  7709. // if res.Infcode == -1 {
  7710. // errlog := &models.HisOrderError{
  7711. // UserOrgId: adminUser.CurrentOrgId,
  7712. // Ctime: time.Now().Unix(),
  7713. // Mtime: time.Now().Unix(),
  7714. // Number: chrg_bchno,
  7715. // ErrMsg: res.ErrMsg,
  7716. // Status: 1,
  7717. // PatientId: id,
  7718. // RecordTime: recordDateTime,
  7719. // Stage: 6,
  7720. // }
  7721. // service.CreateErrMsgLog(errlog)
  7722. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7723. // return
  7724. // } else {
  7725. // order_src.OrderStatus = 2
  7726. // order_src.PayWay = pay_way
  7727. // order_src.PayPrice = pay_price
  7728. // order_src.PayCardNo = pay_card_no
  7729. // order_src.DiscountPrice = discount_price
  7730. // order_src.PreferentialPrice = preferential_price
  7731. // order_src.RealityPrice = reality_price
  7732. // order_src.FoundPrice = found_price
  7733. // order_src.MedicalInsurancePrice = medical_insurance_price
  7734. // order_src.PrivatePrice = private_price
  7735. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  7736. // order_src.SetlId = res.Output.Setlinfo.SetlID
  7737. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  7738. // order_src.PsnName = res.Output.Setlinfo.PsnName
  7739. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  7740. // order_src.Certno = res.Output.Setlinfo.Certno
  7741. // order_src.Gend = res.Output.Setlinfo.Gend
  7742. // order_src.Naty = res.Output.Setlinfo.Naty
  7743. // order_src.Age = res.Output.Setlinfo.Age
  7744. // order_src.Insutype = res.Output.Setlinfo.Insutype
  7745. // order_src.PsnType = res.Output.Setlinfo.PsnType
  7746. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7747. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  7748. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7749. // order_src.MedType = res.Output.Setlinfo.MedType
  7750. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7751. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7752. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7753. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7754. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7755. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7756. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  7757. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  7758. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7759. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  7760. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  7761. // order_src.MafPay = res.Output.Setlinfo.MafPay
  7762. // order_src.OthPay = res.Output.Setlinfo.OthPay
  7763. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7764. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7765. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  7766. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7767. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7768. // order_src.Balc = res.Output.Setlinfo.Balc
  7769. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7770. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7771. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  7772. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  7773. // order_src.Creator = order_src.Creator
  7774. // order_src.Modify = roles.ID
  7775. // order_src.RequestLog = src_resquest
  7776. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7777. // detailStr := string(setlDetail)
  7778. // order_src.SetlDetail = detailStr
  7779. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7780. // err = service.UpDateOrder(order_src)
  7781. //
  7782. // if err == nil {
  7783. // c.ServeSuccessJSON(map[string]interface{}{
  7784. // "msg": "结算成功",
  7785. // })
  7786. // } else {
  7787. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7788. // return
  7789. // }
  7790. // }
  7791. // }
  7792. //}
  7793. //退款
  7794. func (c *HisApiController) Refund() {
  7795. order_id, _ := c.GetInt64("order_id")
  7796. admin_user_id, _ := c.GetInt64("admin_user_id")
  7797. adminUser := c.GetAdminUserInfo()
  7798. var order models.HisOrder
  7799. order, _ = service.GetHisOrderByID(order_id)
  7800. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7801. if order.ID == 0 {
  7802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7803. return
  7804. }
  7805. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7806. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7807. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7808. if config.IsOpen == 1 { //对接了医保,走医保流程
  7809. var res ResultSixteen
  7810. var resSixteen10265 ResultSixteen10265
  7811. var src_resquest string
  7812. var result string
  7813. if miConfig.MdtrtareaAdmvs == "421300" {
  7814. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  7815. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7816. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7817. resp3, requestErr3 := http.Get(api3)
  7818. if requestErr3 != nil {
  7819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7820. return
  7821. }
  7822. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7823. if ioErr3 != nil {
  7824. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7826. return
  7827. }
  7828. var respJSON3 map[string]interface{}
  7829. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7830. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7832. return
  7833. }
  7834. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7835. userJSONBytes3, _ := json.Marshal(respJSON3)
  7836. fmt.Println("log")
  7837. fmt.Println(string(userJSONBytes3))
  7838. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  7839. utils.ErrorLog("解析失败:%v", err)
  7840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7841. return
  7842. }
  7843. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7844. var api3 string
  7845. if miConfig.MdtrtareaAdmvs == "320921" {
  7846. api3 = "http://192.168.2.110:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7847. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7848. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7849. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7850. } else {
  7851. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7852. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7853. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7854. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7855. }
  7856. resp3, requestErr3 := http.Get(api3)
  7857. if requestErr3 != nil {
  7858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7859. return
  7860. }
  7861. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7862. if ioErr3 != nil {
  7863. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7865. return
  7866. }
  7867. var respJSON3 map[string]interface{}
  7868. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7869. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7871. return
  7872. }
  7873. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7874. userJSONBytes3, _ := json.Marshal(respJSON3)
  7875. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  7876. utils.ErrorLog("解析失败:%v", err)
  7877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7878. return
  7879. }
  7880. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7881. res.Output = resSixteen10265.Output
  7882. res.ErrMsg = resSixteen10265.ErrMsg
  7883. res.Cainfo = resSixteen10265.Cainfo
  7884. res.WarnMsg = resSixteen10265.WarnMsg
  7885. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7886. res.Infcode = infocode
  7887. } else {
  7888. if miConfig.Code == "H15049901371" {
  7889. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7890. var dat map[string]interface{}
  7891. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7892. fmt.Println(dat)
  7893. } else {
  7894. fmt.Println(err)
  7895. }
  7896. saveLog(result, src_resquest, "2208", "退费")
  7897. userJSONBytes, _ := json.Marshal(dat)
  7898. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  7899. utils.ErrorLog("解析失败:%v", err)
  7900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7901. return
  7902. }
  7903. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7904. res.Output = resSixteen10265.Output
  7905. res.ErrMsg = resSixteen10265.ErrMsg
  7906. res.Cainfo = resSixteen10265.Cainfo
  7907. res.WarnMsg = resSixteen10265.WarnMsg
  7908. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7909. res.Infcode = infocode
  7910. } else {
  7911. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7912. var dat map[string]interface{}
  7913. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7914. fmt.Println(dat)
  7915. } else {
  7916. fmt.Println(err)
  7917. }
  7918. saveLog(result, src_resquest, "2208", "退费")
  7919. userJSONBytes, _ := json.Marshal(dat)
  7920. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7921. utils.ErrorLog("解析失败:%v", err)
  7922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7923. return
  7924. }
  7925. }
  7926. }
  7927. if res.Infcode == 0 {
  7928. var res2 ResultSix
  7929. var resSix10265 ResultSix10265
  7930. if miConfig.MdtrtareaAdmvs == "421300" {
  7931. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7932. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7933. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7934. resp3, requestErr3 := http.Get(api3)
  7935. if requestErr3 != nil {
  7936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7937. return
  7938. }
  7939. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7940. if ioErr3 != nil {
  7941. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7943. return
  7944. }
  7945. var respJSON3 map[string]interface{}
  7946. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7947. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7949. return
  7950. }
  7951. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7952. userJSONBytes3, _ := json.Marshal(respJSON3)
  7953. fmt.Println("log")
  7954. fmt.Println(string(userJSONBytes3))
  7955. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7956. utils.ErrorLog("解析失败:%v", err)
  7957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7958. return
  7959. }
  7960. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7961. var api3 string
  7962. if miConfig.MdtrtareaAdmvs == "320921" {
  7963. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7964. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7965. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7966. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7967. } else {
  7968. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7969. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7970. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7971. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7972. }
  7973. resp3, requestErr3 := http.Get(api3)
  7974. if requestErr3 != nil {
  7975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7976. return
  7977. }
  7978. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7979. if ioErr3 != nil {
  7980. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7982. return
  7983. }
  7984. var respJSON3 map[string]interface{}
  7985. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7986. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7988. return
  7989. }
  7990. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7991. userJSONBytes3, _ := json.Marshal(respJSON3)
  7992. fmt.Println("log")
  7993. fmt.Println(string(userJSONBytes3))
  7994. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7995. utils.ErrorLog("解析失败:%v", err)
  7996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7997. return
  7998. }
  7999. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8000. res2.Output = resSix10265.Output
  8001. res2.ErrMsg = resSix10265.ErrMsg
  8002. res2.Cainfo = resSix10265.Cainfo
  8003. res2.WarnMsg = resSix10265.WarnMsg
  8004. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8005. res2.Infcode = infocode
  8006. } else {
  8007. if miConfig.Code == "H15049901371" {
  8008. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8009. var dat map[string]interface{}
  8010. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8011. fmt.Println(dat)
  8012. } else {
  8013. fmt.Println(err)
  8014. }
  8015. saveLog(result2, src_request, "2205", "撤销明细")
  8016. userJSONBytes, _ := json.Marshal(dat)
  8017. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  8018. utils.ErrorLog("解析失败:%v", err)
  8019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8020. return
  8021. }
  8022. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8023. res2.Output = resSix10265.Output
  8024. res2.ErrMsg = resSix10265.ErrMsg
  8025. res2.Cainfo = resSix10265.Cainfo
  8026. res2.WarnMsg = resSix10265.WarnMsg
  8027. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8028. res2.Infcode = infocode
  8029. } else {
  8030. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8031. var dat map[string]interface{}
  8032. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8033. fmt.Println(dat)
  8034. } else {
  8035. fmt.Println(err)
  8036. }
  8037. saveLog(result2, src_request, "2205", "撤销明细")
  8038. userJSONBytes, _ := json.Marshal(dat)
  8039. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8040. utils.ErrorLog("解析失败:%v", err)
  8041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8042. return
  8043. }
  8044. }
  8045. }
  8046. if res2.Infcode == 0 {
  8047. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  8048. if err == nil {
  8049. //当押金不为零时产生退费记录
  8050. if order.Decimal != 0 {
  8051. tmp := strconv.FormatInt(order.ID, 10)
  8052. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  8053. if err != nil {
  8054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8055. return
  8056. }
  8057. }
  8058. c.ServeSuccessJSON(map[string]interface{}{
  8059. "msg": "退费成功",
  8060. })
  8061. } else {
  8062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8063. return
  8064. }
  8065. } else {
  8066. c.ServeSuccessJSON(map[string]interface{}{
  8067. "code": -10,
  8068. "msg": res2.ErrMsg,
  8069. })
  8070. }
  8071. } else {
  8072. c.ServeSuccessJSON(map[string]interface{}{
  8073. "code": -10,
  8074. "msg": res.ErrMsg,
  8075. })
  8076. }
  8077. }
  8078. }
  8079. func (c *HisApiController) RefundNumber() {
  8080. record_time := c.GetString("record_time")
  8081. //patient_id, _ := c.GetInt64("patient_id")
  8082. admin_user_id, _ := c.GetInt64("admin_user_id")
  8083. his_patient_id, _ := c.GetInt64("id")
  8084. timeLayout := "2006-01-02"
  8085. loc, _ := time.LoadLocation("Local")
  8086. adminUser := c.GetAdminUserInfo()
  8087. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8088. fmt.Println(err)
  8089. if err != nil {
  8090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8091. return
  8092. }
  8093. recordDateTime := theTime.Unix()
  8094. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8095. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  8096. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8097. //order, _ := service.GetHisOrderByID(order_id)
  8098. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8099. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8100. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8101. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  8102. if count > 0 {
  8103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  8104. return
  8105. }
  8106. if config.IsOpen == 1 { //对接了医保,走医保流程
  8107. var res2 ResultSix
  8108. var resSix10265 ResultSix10265
  8109. if miConfig.MdtrtareaAdmvs == "421300" {
  8110. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  8111. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8112. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8113. resp3, requestErr3 := http.Get(api3)
  8114. if requestErr3 != nil {
  8115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8116. return
  8117. }
  8118. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8119. if ioErr3 != nil {
  8120. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8122. return
  8123. }
  8124. var respJSON3 map[string]interface{}
  8125. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8126. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8128. return
  8129. }
  8130. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8131. userJSONBytes3, _ := json.Marshal(respJSON3)
  8132. fmt.Println("log")
  8133. fmt.Println(string(userJSONBytes3))
  8134. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8135. utils.ErrorLog("解析失败:%v", err)
  8136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8137. return
  8138. }
  8139. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8140. var api3 string
  8141. if miConfig.MdtrtareaAdmvs == "320921" {
  8142. api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8143. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8144. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8145. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8146. } else {
  8147. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8148. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8149. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8150. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8151. }
  8152. resp3, requestErr3 := http.Get(api3)
  8153. if requestErr3 != nil {
  8154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8155. return
  8156. }
  8157. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8158. if ioErr3 != nil {
  8159. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8161. return
  8162. }
  8163. var respJSON3 map[string]interface{}
  8164. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8165. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8167. return
  8168. }
  8169. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8170. userJSONBytes3, _ := json.Marshal(respJSON3)
  8171. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8172. utils.ErrorLog("解析失败:%v", err)
  8173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8174. return
  8175. }
  8176. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8177. res2.Output = resSix10265.Output
  8178. res2.ErrMsg = resSix10265.ErrMsg
  8179. res2.Cainfo = resSix10265.Cainfo
  8180. res2.WarnMsg = resSix10265.WarnMsg
  8181. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8182. res2.Infcode = infocode
  8183. } else {
  8184. var api3 string
  8185. if miConfig.Code == "H15049901371" {
  8186. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8187. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8188. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8189. } else {
  8190. api3 = "http://127.0.0.1:9532/" + "gdyb/three?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. }
  8194. resp3, requestErr3 := http.Get(api3)
  8195. if requestErr3 != nil {
  8196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8197. return
  8198. }
  8199. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8200. if ioErr3 != nil {
  8201. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8203. return
  8204. }
  8205. var respJSON3 map[string]interface{}
  8206. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8207. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8209. return
  8210. }
  8211. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8212. userJSONBytes3, _ := json.Marshal(respJSON3)
  8213. if miConfig.Code == "H15049901371" {
  8214. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8215. utils.ErrorLog("解析失败:%v", err)
  8216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8217. return
  8218. }
  8219. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8220. res2.Output = resSix10265.Output
  8221. res2.ErrMsg = resSix10265.ErrMsg
  8222. res2.Cainfo = resSix10265.Cainfo
  8223. res2.WarnMsg = resSix10265.WarnMsg
  8224. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8225. res2.Infcode = infocode
  8226. } else {
  8227. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8228. utils.ErrorLog("解析失败:%v", err)
  8229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8230. return
  8231. }
  8232. }
  8233. }
  8234. if res2.Infcode == 0 {
  8235. if err == nil {
  8236. c.ServeSuccessJSON(map[string]interface{}{
  8237. "msg": "退号成功",
  8238. })
  8239. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  8240. } else {
  8241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8242. return
  8243. }
  8244. } else {
  8245. c.ServeSuccessJSON(map[string]interface{}{
  8246. "code": -10,
  8247. "msg": res2.ErrMsg,
  8248. })
  8249. }
  8250. } else {
  8251. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  8252. //if err == nil {
  8253. // c.ServeSuccessJSON(map[string]interface{}{
  8254. // "msg": "退费成功",
  8255. // })
  8256. //} else {
  8257. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8258. // return
  8259. //}
  8260. }
  8261. }
  8262. func (c *HisApiController) RefundDetail() {
  8263. order_id, _ := c.GetInt64("order_id")
  8264. //admin_user_id, _ := c.GetInt64("admin_user_id")
  8265. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8266. number := c.GetString("number")
  8267. record_time := c.GetString("record_time")
  8268. patient_id, _ := c.GetInt64("patient_id")
  8269. //med_type, _ := c.GetInt64("med_type")
  8270. timeLayout := "2006-01-02"
  8271. loc, _ := time.LoadLocation("Local")
  8272. adminUser := c.GetAdminUserInfo()
  8273. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8274. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8275. fmt.Println(err)
  8276. if err != nil {
  8277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8278. return
  8279. }
  8280. recordDateTime := theTime.Unix()
  8281. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8282. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8283. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8284. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8285. var order models.HisOrder
  8286. order, _ = service.GetHisOrderByID(order_id)
  8287. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8288. if config.IsOpen == 1 { //对接了医保,走医保流程
  8289. var res2 ResultSix
  8290. if miConfig.MdtrtareaAdmvs == "421300" {
  8291. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8292. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8293. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8294. resp3, requestErr3 := http.Get(api3)
  8295. if requestErr3 != nil {
  8296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8297. return
  8298. }
  8299. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8300. if ioErr3 != nil {
  8301. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8303. return
  8304. }
  8305. var respJSON3 map[string]interface{}
  8306. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8307. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8309. return
  8310. }
  8311. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8312. userJSONBytes3, _ := json.Marshal(respJSON3)
  8313. fmt.Println("log")
  8314. fmt.Println(string(userJSONBytes3))
  8315. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8316. utils.ErrorLog("解析失败:%v", err)
  8317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8318. return
  8319. }
  8320. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8321. if err == nil {
  8322. c.ServeSuccessJSON(map[string]interface{}{
  8323. "msg": "撤销明细成功",
  8324. })
  8325. return
  8326. } else {
  8327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8328. return
  8329. }
  8330. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8331. var resSix10265 ResultSix10265
  8332. var api3 string
  8333. if miConfig.MdtrtareaAdmvs == "320921" {
  8334. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8335. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8336. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8337. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8338. } else {
  8339. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8340. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8341. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8342. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8343. }
  8344. resp3, requestErr3 := http.Get(api3)
  8345. if requestErr3 != nil {
  8346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8347. return
  8348. }
  8349. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8350. if ioErr3 != nil {
  8351. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8353. return
  8354. }
  8355. var respJSON3 map[string]interface{}
  8356. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8357. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8359. return
  8360. }
  8361. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8362. userJSONBytes3, _ := json.Marshal(respJSON3)
  8363. fmt.Println("log")
  8364. fmt.Println(string(userJSONBytes3))
  8365. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8366. utils.ErrorLog("解析失败:%v", err)
  8367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8368. return
  8369. }
  8370. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8371. res2.Output = resSix10265.Output
  8372. res2.ErrMsg = resSix10265.ErrMsg
  8373. res2.Cainfo = resSix10265.Cainfo
  8374. res2.WarnMsg = resSix10265.WarnMsg
  8375. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8376. res2.Infcode = infocode
  8377. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8378. if err == nil {
  8379. c.ServeSuccessJSON(map[string]interface{}{
  8380. "msg": "撤销明细成功",
  8381. })
  8382. return
  8383. } else {
  8384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8385. return
  8386. }
  8387. } else {
  8388. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  8389. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8390. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8391. resp2, requestErr2 := http.Get(api2)
  8392. if requestErr2 != nil {
  8393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8394. return
  8395. }
  8396. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8397. if ioErr2 != nil {
  8398. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8400. return
  8401. }
  8402. var respJSON2 map[string]interface{}
  8403. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8404. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8406. return
  8407. }
  8408. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8409. if err == nil {
  8410. c.ServeSuccessJSON(map[string]interface{}{
  8411. "msg": "撤销明细成功",
  8412. })
  8413. return
  8414. } else {
  8415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8416. return
  8417. }
  8418. }
  8419. } else {
  8420. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8421. if err == nil {
  8422. c.ServeSuccessJSON(map[string]interface{}{
  8423. "msg": "退费成功",
  8424. })
  8425. } else {
  8426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8427. return
  8428. }
  8429. }
  8430. }
  8431. //对账
  8432. func (c *HisApiController) GetCheckAccount() {
  8433. start_time := c.GetString("start_time")
  8434. end_time := c.GetString("end_time")
  8435. insutype := c.GetString("insutype")
  8436. clr_type := c.GetString("clr_type")
  8437. clr_org := c.GetString("clr_optins")
  8438. admin_user_id, _ := c.GetInt64("admin_user_id")
  8439. adminUser := c.GetAdminUserInfo()
  8440. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8441. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8442. if len(clr_org) == 0 {
  8443. clr_org = miConfig.MdtrtareaAdmvs
  8444. }
  8445. timeLayout := "2006-01-02"
  8446. loc, _ := time.LoadLocation("Local")
  8447. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8448. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8449. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  8450. fixmedins_setl_cnt := int64(len(orders))
  8451. var medfee_sumamt float64
  8452. var acct_pay float64
  8453. var fund_pay_sumamt float64
  8454. for _, item := range orders {
  8455. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8456. acct_pay = acct_pay + item.AcctPay
  8457. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8458. }
  8459. var user_name string
  8460. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8461. if role.ID == 0 {
  8462. user_name = "xxx"
  8463. } else {
  8464. user_name = role.UserName
  8465. }
  8466. var res ResultEight
  8467. var res10188 ResultEightFor10188
  8468. if config.IsOpen == 1 {
  8469. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8470. api := "http://192.168.2.110:9532/" + "jsyb/3201?" +
  8471. "insutype=" + insutype +
  8472. "&clr_type=" + clr_type +
  8473. "&setl_optins=" + clr_org +
  8474. "&stmt_begndate=" + start_time +
  8475. "&stm_enddate=" + end_time +
  8476. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8477. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8478. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8479. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8480. "&fixmedins_code=" + miConfig.Code +
  8481. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8482. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8483. "&secret_key=" + miConfig.SecretKey +
  8484. "&org_name=" + miConfig.OrgName +
  8485. "&doctor=" + user_name +
  8486. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8487. fmt.Println(api)
  8488. resp, requestErr := http.Get(api)
  8489. if requestErr != nil {
  8490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8491. return
  8492. }
  8493. body, ioErr := ioutil.ReadAll(resp.Body)
  8494. fmt.Println(body)
  8495. if ioErr != nil {
  8496. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8498. return
  8499. }
  8500. var respJSON map[string]interface{}
  8501. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8502. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8504. return
  8505. }
  8506. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8507. userJSONBytes, _ := json.Marshal(respJSON)
  8508. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8509. utils.ErrorLog("解析失败:%v", err)
  8510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8511. return
  8512. }
  8513. res.InfRefmsgid = res10188.InfRefmsgid
  8514. res.Output = res10188.Output
  8515. res.ErrMsg = res10188.ErrMsg
  8516. res.Cainfo = res10188.Cainfo
  8517. res.WarnMsg = res10188.WarnMsg
  8518. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8519. res.Infcode = infocode
  8520. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8521. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  8522. "insutype=" + insutype +
  8523. "&clr_type=" + clr_type +
  8524. "&setl_optins=" + clr_org +
  8525. "&stmt_begndate=" + start_time +
  8526. "&stm_enddate=" + end_time +
  8527. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8528. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8529. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8530. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8531. "&fixmedins_code=" + miConfig.Code +
  8532. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8533. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8534. "&secret_key=" + miConfig.SecretKey +
  8535. "&org_name=" + miConfig.OrgName +
  8536. "&doctor=" + user_name
  8537. resp, requestErr := http.Get(api)
  8538. if requestErr != nil {
  8539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8540. return
  8541. }
  8542. body, ioErr := ioutil.ReadAll(resp.Body)
  8543. if ioErr != nil {
  8544. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8546. return
  8547. }
  8548. var respJSON map[string]interface{}
  8549. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8550. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8552. return
  8553. }
  8554. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8555. result, _ := json.Marshal(respJSON)
  8556. fmt.Println("log")
  8557. fmt.Println(string(result))
  8558. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  8559. utils.ErrorLog("解析失败:%v", err)
  8560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8561. return
  8562. }
  8563. res.InfRefmsgid = res10188.InfRefmsgid
  8564. res.Output = res10188.Output
  8565. res.ErrMsg = res10188.ErrMsg
  8566. res.Cainfo = res10188.Cainfo
  8567. res.WarnMsg = res10188.WarnMsg
  8568. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8569. res.Infcode = infocode
  8570. } else {
  8571. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8572. "insutype=" + insutype +
  8573. "&clr_type=" + clr_type +
  8574. "&setl_optins=" + clr_org +
  8575. "&stmt_begndate=" + start_time +
  8576. "&stm_enddate=" + end_time +
  8577. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8578. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8579. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8580. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8581. "&fixmedins_code=" + miConfig.Code +
  8582. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8583. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8584. "&secret_key=" + miConfig.SecretKey +
  8585. "&org_name=" + miConfig.OrgName +
  8586. "&doctor=" + user_name
  8587. fmt.Println(api)
  8588. resp, requestErr := http.Get(api)
  8589. if requestErr != nil {
  8590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8591. return
  8592. }
  8593. body, ioErr := ioutil.ReadAll(resp.Body)
  8594. fmt.Println(body)
  8595. if ioErr != nil {
  8596. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8598. return
  8599. }
  8600. var respJSON map[string]interface{}
  8601. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8602. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8604. return
  8605. }
  8606. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8607. userJSONBytes, _ := json.Marshal(respJSON)
  8608. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8609. utils.ErrorLog("解析失败:%v", err)
  8610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8611. return
  8612. }
  8613. }
  8614. if res.Infcode == 0 {
  8615. if res.Output.Stmtinfo.StmtRslt == "0" {
  8616. micc := &models.MedicalInsuranceCostCompare{
  8617. StartTime: startime.Unix(),
  8618. EndTime: endtime.Unix(),
  8619. Insutype: insutype,
  8620. CheckType: 1,
  8621. Num: fixmedins_setl_cnt,
  8622. Mtime: time.Now().Unix(),
  8623. Status: 1,
  8624. UserOrgId: adminUser.CurrentOrgId,
  8625. CostTotal: medfee_sumamt,
  8626. FuncTotal: fund_pay_sumamt,
  8627. PsnPay: acct_pay,
  8628. Creator: admin_user_id,
  8629. Ctime: time.Now().Unix(),
  8630. ClrType: clr_type,
  8631. }
  8632. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  8633. if err == nil {
  8634. c.ServeSuccessJSON(map[string]interface{}{
  8635. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8636. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8637. })
  8638. } else {
  8639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8640. }
  8641. } else {
  8642. c.ServeSuccessJSON(map[string]interface{}{
  8643. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8644. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8645. })
  8646. }
  8647. } else {
  8648. c.ServeSuccessJSON(map[string]interface{}{
  8649. "code": -10,
  8650. "msg": res.ErrMsg,
  8651. })
  8652. }
  8653. }
  8654. }
  8655. func (c *HisApiController) Check310() {
  8656. adminUser := c.GetAdminUserInfo()
  8657. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8658. var user_name string
  8659. user_name = "高慧裕"
  8660. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8661. "insutype=" + "310" +
  8662. "&clr_type=" + "" +
  8663. "&setl_optins=" + "441202" +
  8664. "&stmt_begndate=" + "2022-03-01" +
  8665. "&stm_enddate=" + "2022-03-31" +
  8666. "&medfee_sumamt=" + "194930.12" +
  8667. "&fund_pay_sumamt=" + "188741.46" +
  8668. "&acct_pay=" + "0" +
  8669. "&fixmedins_setl_cnt=" + "452" +
  8670. "&fixmedins_code=" + miConfig.Code +
  8671. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8672. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8673. "&secret_key=" + miConfig.SecretKey +
  8674. "&org_name=" + miConfig.OrgName +
  8675. "&doctor=" + user_name
  8676. fmt.Println(api)
  8677. resp, requestErr := http.Get(api)
  8678. if requestErr != nil {
  8679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8680. return
  8681. }
  8682. body, ioErr := ioutil.ReadAll(resp.Body)
  8683. fmt.Println(body)
  8684. if ioErr != nil {
  8685. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8687. return
  8688. }
  8689. var respJSON map[string]interface{}
  8690. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8691. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8693. return
  8694. }
  8695. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8696. userJSONBytes, _ := json.Marshal(respJSON)
  8697. var res ResultEight
  8698. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8699. utils.ErrorLog("解析失败:%v", err)
  8700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8701. return
  8702. }
  8703. }
  8704. func (c *HisApiController) Check390() {
  8705. adminUser := c.GetAdminUserInfo()
  8706. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8707. var user_name string
  8708. user_name = "高慧裕"
  8709. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8710. "insutype=" + "390" +
  8711. "&clr_type=" + "" +
  8712. "&setl_optins=" + "441202" +
  8713. "&stmt_begndate=" + "2022-03-01" +
  8714. "&stm_enddate=" + "2022-03-31" +
  8715. "&medfee_sumamt=" + "1068448.89" +
  8716. "&fund_pay_sumamt=" + "1014677.62" +
  8717. "&acct_pay=" + "0" +
  8718. "&fixmedins_setl_cnt=" + "1950" +
  8719. "&fixmedins_code=" + miConfig.Code +
  8720. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8721. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8722. "&secret_key=" + miConfig.SecretKey +
  8723. "&org_name=" + miConfig.OrgName +
  8724. "&doctor=" + user_name
  8725. fmt.Println(api)
  8726. resp, requestErr := http.Get(api)
  8727. if requestErr != nil {
  8728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8729. return
  8730. }
  8731. body, ioErr := ioutil.ReadAll(resp.Body)
  8732. fmt.Println(body)
  8733. if ioErr != nil {
  8734. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8736. return
  8737. }
  8738. var respJSON map[string]interface{}
  8739. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8740. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8742. return
  8743. }
  8744. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8745. userJSONBytes, _ := json.Marshal(respJSON)
  8746. var res ResultEight
  8747. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8748. utils.ErrorLog("解析失败:%v", err)
  8749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8750. return
  8751. }
  8752. }
  8753. //对账明细
  8754. func (c *HisApiController) GetCheckDetailAccount() {
  8755. start_time := c.GetString("start_time")
  8756. end_time := c.GetString("end_time")
  8757. admin_user_id, _ := c.GetInt64("admin_user_id")
  8758. adminUser := c.GetAdminUserInfo()
  8759. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8760. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8761. timeLayout := "2006-01-02"
  8762. loc, _ := time.LoadLocation("Local")
  8763. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8764. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8765. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  8766. rand.Seed(time.Now().UnixNano())
  8767. num := rand.Intn(30000)
  8768. Mkdir(miConfig.OrgName)
  8769. file := strconv.FormatInt(int64(num), 10)
  8770. file_name := file + ".txt"
  8771. zip_name := file + ".zip"
  8772. zip_path := miConfig.OrgName + "/" + zip_name
  8773. file_path := miConfig.OrgName + "/" + file_name
  8774. decimal.DivisionPrecision = 2
  8775. var medfee_sumamt float64
  8776. var psn_cash_pay float64
  8777. var fund_pay_sumamt float64
  8778. fixmedins_setl_cnt := int64(len(orders))
  8779. for _, item := range orders {
  8780. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8781. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  8782. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8783. }
  8784. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  8785. defer f.Close()
  8786. if err != nil {
  8787. fmt.Println(err.Error())
  8788. } else {
  8789. for _, item := range orders {
  8790. var refd_setl_flag string
  8791. if item.OrderStatus == 2 {
  8792. refd_setl_flag = "0"
  8793. var str string
  8794. str = item.SetlId + " " +
  8795. item.MdtrtId + " " +
  8796. item.PsnNo + " " +
  8797. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8798. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8799. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  8800. _, err = f.Write([]byte(str))
  8801. }
  8802. if item.OrderStatus == 3 {
  8803. var str string
  8804. str = item.SetlId + " " +
  8805. item.MdtrtId + " " +
  8806. item.PsnNo + " " +
  8807. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8808. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8809. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  8810. _, err = f.Write([]byte(str))
  8811. var str2 string
  8812. str2 = item.SetlId + " " +
  8813. item.MdtrtId + " " +
  8814. item.PsnNo + " " +
  8815. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  8816. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  8817. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  8818. _, err = f.Write([]byte(str2))
  8819. }
  8820. }
  8821. }
  8822. Zip(file_path, zip_path)
  8823. fmt.Println(ReadFile(zip_path))
  8824. fmt.Println(string(ReadFile(zip_path)))
  8825. if config.IsOpen == 1 {
  8826. var user_name string
  8827. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8828. if role.ID == 0 {
  8829. user_name = "管理员"
  8830. } else {
  8831. user_name = role.UserName
  8832. }
  8833. baseParams := models.BaseParams{
  8834. SecretKey: miConfig.SecretKey,
  8835. FixmedinsCode: miConfig.Code,
  8836. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8837. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8838. OrgName: miConfig.OrgName,
  8839. Doctor: user_name,
  8840. }
  8841. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  8842. var dat map[string]interface{}
  8843. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8844. fmt.Println(dat)
  8845. } else {
  8846. fmt.Println(err)
  8847. }
  8848. userJSONBytes, _ := json.Marshal(dat)
  8849. var res ResultNine
  8850. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8851. utils.ErrorLog("解析失败:%v", err)
  8852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8853. return
  8854. }
  8855. if res.Infcode == 0 {
  8856. fileNo := res.Output.FileQuryNo
  8857. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  8858. "file_qury_no=" + fileNo +
  8859. "&setl_optins=" + "定点医保中心" +
  8860. "&stmt_begndate=" + start_time +
  8861. "&stm_enddate=" + end_time +
  8862. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8863. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8864. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  8865. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8866. "&fixmedins_code=" + miConfig.Code +
  8867. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8868. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8869. "&secret_key=" + miConfig.SecretKey +
  8870. "&org_name=" + miConfig.OrgName +
  8871. "&doctor=" + user_name
  8872. resp, requestErr := http.Get(api)
  8873. if requestErr != nil {
  8874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8875. return
  8876. }
  8877. body, ioErr := ioutil.ReadAll(resp.Body)
  8878. if ioErr != nil {
  8879. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8881. return
  8882. }
  8883. var respJSON map[string]interface{}
  8884. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8885. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8887. return
  8888. }
  8889. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8890. userJSONBytes, _ := json.Marshal(respJSON)
  8891. var res ResultTen
  8892. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8893. utils.ErrorLog("解析失败:%v", err)
  8894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8895. return
  8896. }
  8897. if res.Infcode == 0 {
  8898. service.Gdyb9102(baseParams, zip_name, fileNo)
  8899. micc := &models.MedicalInsuranceCostCompare{
  8900. StartTime: startime.Unix(),
  8901. EndTime: endtime.Unix(),
  8902. Insutype: "0",
  8903. CheckType: 2,
  8904. Num: fixmedins_setl_cnt,
  8905. Mtime: time.Now().Unix(),
  8906. Status: 1,
  8907. UserOrgId: adminUser.CurrentOrgId,
  8908. CostTotal: medfee_sumamt,
  8909. FuncTotal: fund_pay_sumamt,
  8910. PsnPay: psn_cash_pay,
  8911. Creator: admin_user_id,
  8912. Ctime: time.Now().Unix(),
  8913. }
  8914. service.CreateMedicalInsuranceCostCompareRecord(micc)
  8915. c.ServeSuccessJSON(map[string]interface{}{
  8916. "msg": "明细对账成功",
  8917. })
  8918. }
  8919. } else {
  8920. }
  8921. }
  8922. }
  8923. type CustomOrderInfo struct {
  8924. Name string
  8925. Spec string
  8926. Unit string
  8927. Count float64
  8928. Price float64
  8929. Total float64
  8930. }
  8931. func (c *HisApiController) GetSettleAccounts() {
  8932. //id, _ := c.GetInt64("id")
  8933. //record_time := c.GetString("record_time")
  8934. order_id, _ := c.GetInt64("order_id")
  8935. admin_user_id, _ := c.GetInt64("admin_user_id")
  8936. //timeLayout := "2006-01-02"
  8937. //loc, _ := time.LoadLocation("Local")
  8938. //
  8939. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8940. //if err != nil {
  8941. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8942. // return
  8943. //}
  8944. //recordDateTime := theTime.Unix()
  8945. adminUser := c.GetAdminUserInfo()
  8946. order, _ := service.GetHisOrderByID(order_id)
  8947. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8948. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  8949. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8950. orderInfos = append(orderInfos, orderInfos_two...)
  8951. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8952. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  8953. var diagnosis_ids []string
  8954. if his.ID > 0 {
  8955. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  8956. } else {
  8957. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  8958. }
  8959. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  8960. var dia_config []*models.HisXtDiagnoseConfig
  8961. var name string
  8962. for _, item := range diagnosis_ids {
  8963. id, _ := strconv.ParseInt(item, 10, 64)
  8964. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8965. dia_config = append(dia_config, &diagnosisConfig)
  8966. if len(name) == 0 {
  8967. name = diagnosisConfig.ClassName
  8968. } else {
  8969. name = name + "," + diagnosisConfig.ClassName
  8970. }
  8971. }
  8972. var bedCostTotal float64 = 0 //床位总费
  8973. var bedCostSelfTotal float64 = 0 //床位自费
  8974. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  8975. var operationCostTotal float64 = 0 //手术费
  8976. var operationCostSelfTotal float64 = 0 //手术费
  8977. var operationCostPartSelfTotal float64 = 0 //手术费
  8978. var otherCostTotal float64 = 0 //其他费用
  8979. var otherCostSelfTotal float64 = 0 //其他费用
  8980. var otherCostPartSelfTotal float64 = 0 //其他费用
  8981. var materialCostTotal float64 = 0 //材料费
  8982. var materialCostSelfTotal float64 = 0 //材料费
  8983. var materialCostPartSelfTotal float64 = 0 //材料费
  8984. var westernMedicineCostTotal float64 = 0 //西药费
  8985. var westernMedicineCostSelfTotal float64 = 0 //西药费
  8986. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  8987. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  8988. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  8989. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  8990. var checkCostTotal float64 = 0 //检查费
  8991. var checkCostSelfTotal float64 = 0 //检查费
  8992. var checkCostPartSelfTotal float64 = 0 //检查费
  8993. var laboratoryCostTotal float64 = 0 //化验费
  8994. var laboratoryCostSelfTotal float64 = 0 //化验费
  8995. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  8996. var treatCostTotal float64 = 0 //治疗费用
  8997. var treatCostSelfTotal float64 = 0 //治疗费用
  8998. var treatCostPartSelfTotal float64 = 0 //治疗费用
  8999. decimal.DivisionPrecision = 2
  9000. for _, item := range orderInfos {
  9001. if item.MedChrgitmType == "01" { //床位费
  9002. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9003. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9004. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9005. }
  9006. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  9007. if item.MedChrgitmType == "03" { //检查费
  9008. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9009. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9010. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9011. }
  9012. } else {
  9013. if item.MedChrgitmType == "03" { //检查费
  9014. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9015. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9016. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9017. }
  9018. }
  9019. if item.MedChrgitmType == "04" { //化验费
  9020. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9021. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9022. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9023. }
  9024. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  9025. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9026. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9027. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9028. }
  9029. if item.MedChrgitmType == "06" { //手术费
  9030. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9031. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9032. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9033. }
  9034. if item.MedChrgitmType == "08" { //材料费
  9035. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9036. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9037. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9038. }
  9039. if item.MedChrgitmType == "09" { //西药费
  9040. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9041. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9042. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9043. }
  9044. if item.MedChrgitmType == "11" { //中成费
  9045. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9046. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9047. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9048. }
  9049. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  9050. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9051. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9052. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9053. }
  9054. }
  9055. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9056. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9057. var user_name string
  9058. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9059. if role.ID == 0 {
  9060. user_name = "管理员"
  9061. } else {
  9062. user_name = role.UserName
  9063. }
  9064. baseParams := models.BaseParams{
  9065. SecretKey: miConfig.SecretKey,
  9066. FixmedinsCode: miConfig.Code,
  9067. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9068. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9069. OrgName: miConfig.OrgName,
  9070. Doctor: user_name,
  9071. }
  9072. businessParams := models.BusinessParams{
  9073. PsnNo: order.PsnNo,
  9074. MdtrtId: order.MdtrtId,
  9075. SetlId: order.SetlId,
  9076. }
  9077. var res ResultEleven
  9078. var resEleven10265 ResultEleven10265
  9079. if config.IsOpen == 1 {
  9080. if miConfig.MdtrtareaAdmvs == "421300" {
  9081. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9082. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9083. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9084. resp, requestErr := http.Get(api)
  9085. if requestErr != nil {
  9086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9087. return
  9088. }
  9089. body, ioErr := ioutil.ReadAll(resp.Body)
  9090. if ioErr != nil {
  9091. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9093. return
  9094. }
  9095. var respJSON map[string]interface{}
  9096. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9097. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9099. return
  9100. }
  9101. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9102. result, _ := json.Marshal(respJSON)
  9103. fmt.Println("log")
  9104. fmt.Println(string(result))
  9105. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9106. utils.ErrorLog("解析失败:%v", err)
  9107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9108. return
  9109. }
  9110. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9111. var api string
  9112. if miConfig.MdtrtareaAdmvs == "320921" {
  9113. api = "http://192.168.2.110:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9114. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9115. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9116. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9117. } else {
  9118. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9119. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9120. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9121. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9122. }
  9123. resp, requestErr := http.Get(api)
  9124. if requestErr != nil {
  9125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9126. return
  9127. }
  9128. body, ioErr := ioutil.ReadAll(resp.Body)
  9129. if ioErr != nil {
  9130. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9132. return
  9133. }
  9134. var respJSON map[string]interface{}
  9135. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9136. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9138. return
  9139. }
  9140. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9141. result, _ := json.Marshal(respJSON)
  9142. fmt.Println("log")
  9143. fmt.Println(string(result))
  9144. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9145. utils.ErrorLog("解析失败:%v", err)
  9146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9147. return
  9148. }
  9149. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9150. res.Output = resEleven10265.Output
  9151. res.ErrMsg = resEleven10265.ErrMsg
  9152. res.Cainfo = resEleven10265.Cainfo
  9153. res.WarnMsg = resEleven10265.WarnMsg
  9154. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9155. res.Infcode = infocode
  9156. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9157. fmt.Println("~~~~~~~")
  9158. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9159. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9160. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9161. resp, requestErr := http.Get(api)
  9162. if requestErr != nil {
  9163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9164. return
  9165. }
  9166. body, ioErr := ioutil.ReadAll(resp.Body)
  9167. if ioErr != nil {
  9168. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9170. return
  9171. }
  9172. var respJSON map[string]interface{}
  9173. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9174. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9176. return
  9177. }
  9178. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9179. result, _ := json.Marshal(respJSON)
  9180. fmt.Println("log")
  9181. fmt.Println(string(result))
  9182. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9183. utils.ErrorLog("解析失败:%v", err)
  9184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9185. return
  9186. }
  9187. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9188. res.Output = resEleven10265.Output
  9189. res.ErrMsg = resEleven10265.ErrMsg
  9190. res.Cainfo = resEleven10265.Cainfo
  9191. res.WarnMsg = resEleven10265.WarnMsg
  9192. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9193. res.Infcode = infocode
  9194. } else {
  9195. result := service.Gdyb5203(baseParams, businessParams)
  9196. //service.Gdyb5204(baseParams, businessParams)
  9197. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  9198. var dat map[string]interface{}
  9199. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9200. fmt.Println(dat)
  9201. } else {
  9202. fmt.Println(err)
  9203. }
  9204. userJSONBytes, _ := json.Marshal(dat)
  9205. if miConfig.Code == "H15049901371" {
  9206. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  9207. utils.ErrorLog("解析失败:%v", err)
  9208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9209. return
  9210. }
  9211. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9212. res.Output = resEleven10265.Output
  9213. res.ErrMsg = resEleven10265.ErrMsg
  9214. res.Cainfo = resEleven10265.Cainfo
  9215. res.WarnMsg = resEleven10265.WarnMsg
  9216. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9217. res.Infcode = infocode
  9218. } else {
  9219. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9220. utils.ErrorLog("解析失败:%v", err)
  9221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9222. return
  9223. }
  9224. }
  9225. }
  9226. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9227. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  9228. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  9229. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9230. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  9231. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9232. var doctor_name string
  9233. if roles.ID == 0 {
  9234. doctor_name = "管理员"
  9235. } else {
  9236. doctor_name = roles.UserName
  9237. }
  9238. yiliao_leibie := ""
  9239. switch order.MedType {
  9240. case "11":
  9241. yiliao_leibie = "普通门诊"
  9242. break
  9243. case "12":
  9244. yiliao_leibie = "门诊挂号"
  9245. break
  9246. case "13":
  9247. yiliao_leibie = "急诊"
  9248. break
  9249. case "14":
  9250. yiliao_leibie = "门诊特殊病"
  9251. break
  9252. case "15":
  9253. yiliao_leibie = "门诊统筹"
  9254. break
  9255. case "16":
  9256. yiliao_leibie = "门诊慢性病"
  9257. break
  9258. case "21":
  9259. yiliao_leibie = "普通住院"
  9260. break
  9261. }
  9262. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9263. if res.Infcode == 0 {
  9264. c.ServeSuccessJSON(map[string]interface{}{
  9265. "diagnosis": name,
  9266. "order_infos": orderInfos,
  9267. "number": order.MdtrtId,
  9268. "date": order.SettleAccountsDate,
  9269. "charge_admin": charge_admin,
  9270. "printor_admin": printor_admin,
  9271. "info": res.Output.Setlinfo,
  9272. "order": order,
  9273. "bedCostTotal": bedCostTotal,
  9274. "bedCostSelfTotal": bedCostSelfTotal,
  9275. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  9276. "operationCostTotal": operationCostTotal,
  9277. "operationCostSelfTotal": operationCostSelfTotal,
  9278. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  9279. "otherCostTotal": otherCostTotal,
  9280. "otherCostSelfTotal": otherCostSelfTotal,
  9281. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  9282. "materialCostTotal": materialCostTotal,
  9283. "materialCostSelfTotal": materialCostSelfTotal,
  9284. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  9285. "westernMedicineCostTotal": westernMedicineCostTotal,
  9286. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  9287. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  9288. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  9289. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  9290. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  9291. "checkCostTotal": checkCostTotal,
  9292. "checkCostSelfTotal": checkCostSelfTotal,
  9293. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  9294. "laboratoryCostTotal": laboratoryCostTotal,
  9295. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  9296. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  9297. "treatCostTotal": treatCostTotal,
  9298. "treatCostSelfTotal": treatCostSelfTotal,
  9299. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  9300. "doctor_info": doctor_info,
  9301. "doctor_code": adminRole_two.DoctorCode,
  9302. "doctor_name": doctor_name,
  9303. "health_card_no": order.PsnNo,
  9304. "department": departments.Name,
  9305. "yiliao_leibie": yiliao_leibie,
  9306. "after_money": order.AccountPrice,
  9307. "patient": patient,
  9308. "org_name": miConfig.OrgName,
  9309. "org_code": miConfig.Code,
  9310. "order_number": order.Number,
  9311. "his_hospital": his_hospital,
  9312. "his": his,
  9313. "dia_config": dia_config,
  9314. //"check_order_info": cus_slice,
  9315. })
  9316. }
  9317. }
  9318. }
  9319. func (c *HisApiController) CheckTreatment() {
  9320. patient_id, _ := c.GetInt64("patient_id")
  9321. id_card_no := c.GetString("id_card_no")
  9322. insutype := c.GetString("insutype")
  9323. med_type := c.GetString("med_type")
  9324. admin_user_id, _ := c.GetInt64("admin_user_id")
  9325. adminUser := c.GetAdminUserInfo()
  9326. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9327. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9328. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9329. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9330. if miConfig.MdtrtareaAdmvs == "421300" {
  9331. var res ResultTwo
  9332. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  9333. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9334. "&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)
  9335. resp, requestErr := http.Get(api)
  9336. if requestErr != nil {
  9337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9338. return
  9339. }
  9340. body, ioErr := ioutil.ReadAll(resp.Body)
  9341. if ioErr != nil {
  9342. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9344. return
  9345. }
  9346. var respJSON map[string]interface{}
  9347. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9348. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9350. return
  9351. }
  9352. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9353. result, _ := json.Marshal(respJSON)
  9354. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9355. utils.ErrorLog("解析失败:%v", err)
  9356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9357. return
  9358. }
  9359. if res.Infcode == 0 {
  9360. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  9361. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9362. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  9363. resp, requestErr := http.Get(api)
  9364. if requestErr != nil {
  9365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9366. return
  9367. }
  9368. body, ioErr := ioutil.ReadAll(resp.Body)
  9369. if ioErr != nil {
  9370. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9372. return
  9373. }
  9374. var respJSON map[string]interface{}
  9375. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9376. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9378. return
  9379. }
  9380. var res Result2001
  9381. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9382. result2, _ := json.Marshal(respJSON)
  9383. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9384. utils.ErrorLog("解析失败:%v", err)
  9385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9386. return
  9387. }
  9388. if res.Infcode == 0 {
  9389. c.ServeSuccessJSON(map[string]interface{}{
  9390. "msg": res.Output.Trtinfo,
  9391. })
  9392. }
  9393. } else {
  9394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9395. return
  9396. }
  9397. } else {
  9398. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9399. var dat map[string]interface{}
  9400. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9401. fmt.Println(dat)
  9402. } else {
  9403. fmt.Println(err)
  9404. }
  9405. userJSONBytes, _ := json.Marshal(dat)
  9406. var res ResultTwo
  9407. var res10265 ResultTwo10265
  9408. if miConfig.Code == "H15049901371" {
  9409. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9410. utils.ErrorLog("解析失败:%v", err)
  9411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9412. return
  9413. }
  9414. res.ErrMsg = res10265.ErrMsg
  9415. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9416. res.Infcode = infocode
  9417. res.Output = res10265.Output
  9418. res.InfRefmsgid = res10265.InfRefmsgid
  9419. } else {
  9420. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9421. utils.ErrorLog("解析失败:%v", err)
  9422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9423. return
  9424. }
  9425. }
  9426. var user_name string
  9427. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  9428. if role.ID == 0 {
  9429. user_name = "xxx"
  9430. } else {
  9431. user_name = role.UserName
  9432. }
  9433. baseParams := models.BaseParams{
  9434. SecretKey: miConfig.SecretKey,
  9435. FixmedinsCode: miConfig.Code,
  9436. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9437. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9438. OrgName: miConfig.OrgName,
  9439. Doctor: user_name,
  9440. }
  9441. if config.IsOpen == 1 {
  9442. if miConfig.Code == "H15049901371" {
  9443. if med_type == "14" {
  9444. if insutype == "390" {
  9445. med_type = "9933"
  9446. } else if insutype == "310" {
  9447. med_type = "990502"
  9448. }
  9449. } else if med_type == "11" {
  9450. med_type = "11"
  9451. }
  9452. }
  9453. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  9454. var dat map[string]interface{}
  9455. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9456. fmt.Println(dat)
  9457. } else {
  9458. fmt.Println(err)
  9459. }
  9460. var res Result2001
  9461. var res10265 Result2001Org10265
  9462. if miConfig.Code == "H15049901371" {
  9463. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9464. utils.ErrorLog("解析失败:%v", err)
  9465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9466. return
  9467. }
  9468. res.ErrMsg = res10265.ErrMsg
  9469. res.Output = res10265.Output
  9470. res.InfRefmsgid = res10265.InfRefmsgid
  9471. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9472. res.Infcode = infocode
  9473. } else {
  9474. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9475. utils.ErrorLog("解析失败:%v", err)
  9476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9477. return
  9478. }
  9479. }
  9480. if res.Infcode == 0 {
  9481. c.ServeSuccessJSON(map[string]interface{}{
  9482. "msg": res.Output.Trtinfo,
  9483. })
  9484. }
  9485. }
  9486. }
  9487. }
  9488. //func (c *HisApiController) PutRecord() {
  9489. // id, _ := c.GetInt64("id")
  9490. // record_time := c.GetString("record_time")
  9491. // timeLayout := "2006-01-02"
  9492. // loc, _ := time.LoadLocation("Local")
  9493. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9494. // if err != nil {
  9495. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9496. // return
  9497. // }
  9498. // recordDateTime := theTime.Unix()
  9499. //
  9500. // adminInfo := c.GetAdminUserInfo()
  9501. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  9502. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9503. //
  9504. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9505. //
  9506. // fmt.Println(miConfig.SecretKey)
  9507. //
  9508. // if patient == nil {
  9509. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9510. // return
  9511. // }
  9512. // if len(patient.IdCardNo) == 0 {
  9513. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  9514. // return
  9515. // }
  9516. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  9517. // if config.IsOpen == 1 {
  9518. // 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
  9519. // resp, requestErr := http.Get(api)
  9520. // if requestErr != nil {
  9521. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9522. // return
  9523. // }
  9524. // defer resp.Body.Close()
  9525. // body, ioErr := ioutil.ReadAll(resp.Body)
  9526. // if ioErr != nil {
  9527. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9528. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9529. // return
  9530. // }
  9531. // var respJSON map[string]interface{}
  9532. //
  9533. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9534. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9535. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9536. // return
  9537. // }
  9538. //
  9539. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9540. // userJSONBytes, _ := json.Marshal(userJSON)
  9541. // var res ResultTwo
  9542. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9543. // utils.ErrorLog("解析失败:%v", err)
  9544. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9545. // return
  9546. // }
  9547. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9548. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9549. // infoStr := string(Iinfos)
  9550. // idetinfoStr := string(Idetinfos)
  9551. //
  9552. // if res.Infcode == 0 {
  9553. // his := models.VMHisPatient{
  9554. // Status: 1,
  9555. // Ctime: time.Now().Unix(),
  9556. // Mtime: time.Now().Unix(),
  9557. // PsnNo: res.Output.Baseinfo.PsnNo,
  9558. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  9559. // Certno: res.Output.Baseinfo.Certno,
  9560. // PsnName: res.Output.Baseinfo.PsnName,
  9561. // Gend: res.Output.Baseinfo.Gend,
  9562. // Naty: res.Output.Baseinfo.Naty,
  9563. // Brdy: res.Output.Baseinfo.Brdy,
  9564. // Age: res.Output.Baseinfo.Age,
  9565. // Iinfo: infoStr,
  9566. // Idetinfo: idetinfoStr,
  9567. // PatientId: patient.ID,
  9568. // RecordDate: theTime.Unix(),
  9569. // UserOrgId: adminInfo.CurrentOrgId,
  9570. // AdminUserId: adminInfo.AdminUser.Id,
  9571. // IsReturn: 1,
  9572. // }
  9573. //
  9574. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  9575. // //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")
  9576. // //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")
  9577. //
  9578. // //var dat map[string]interface{}
  9579. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9580. // // fmt.Println(dat)
  9581. // //} else {
  9582. // // fmt.Println(err)
  9583. // //}
  9584. //
  9585. // var dat2 map[string]interface{}
  9586. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9587. // fmt.Println(dat2)
  9588. // } else {
  9589. // fmt.Println(err)
  9590. // }
  9591. //
  9592. // } else {
  9593. // adminUser := c.GetAdminUserInfo()
  9594. // errlog := &models.HisOrderError{
  9595. // UserOrgId: adminUser.CurrentOrgId,
  9596. // Ctime: time.Now().Unix(),
  9597. // Mtime: time.Now().Unix(),
  9598. // ErrMsg: res.ErrMsg,
  9599. // Status: 1,
  9600. // PatientId: id,
  9601. // RecordTime: recordDateTime,
  9602. // Stage: 1,
  9603. // }
  9604. // service.CreateErrMsgLog(errlog)
  9605. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  9606. // return
  9607. // }
  9608. // }
  9609. //
  9610. //}
  9611. //func (c *HisApiController) GetUploadDiag() {
  9612. // id, _ := c.GetInt64("id")
  9613. // record_time := c.GetString("record_time")
  9614. //
  9615. // diagnosis_id, _ := c.GetInt64("diagnosis")
  9616. // sick_type, _ := c.GetInt64("sick_type")
  9617. // reg_type, _ := c.GetInt64("reg_type")
  9618. //
  9619. // timeLayout := "2006-01-02"
  9620. // loc, _ := time.LoadLocation("Local")
  9621. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9622. // if err != nil {
  9623. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9624. // return
  9625. // }
  9626. //
  9627. // var patientPrescription models.HisPrescriptionInfo
  9628. // recordDateTime := theTime.Unix()
  9629. // adminInfo := c.GetAdminUserInfo()
  9630. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9631. //
  9632. // if patientPrescription.ID == 0 {
  9633. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9634. // }
  9635. //
  9636. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9637. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9638. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9639. // sickConfig, _ := service.FindSickById(sick_type)
  9640. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9641. //
  9642. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  9643. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  9644. // "&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 +
  9645. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  9646. // resp2, requestErr2 := http.Get(api2)
  9647. // if requestErr2 != nil {
  9648. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9649. // return
  9650. // }
  9651. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  9652. // if ioErr2 != nil {
  9653. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  9654. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9655. // return
  9656. // }
  9657. // var respJSON2 map[string]interface{}
  9658. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  9659. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9660. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9661. // return
  9662. // }
  9663. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9664. // userJSONBytes2, _ := json.Marshal(respJSON2)
  9665. //
  9666. // var res2 ResultSix
  9667. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9668. // utils.ErrorLog("解析失败:%v", err)
  9669. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9670. // return
  9671. // }
  9672. // if res2.Infcode != 0 {
  9673. // adminUser := c.GetAdminUserInfo()
  9674. // errlog := &models.HisOrderError{
  9675. // UserOrgId: adminUser.CurrentOrgId,
  9676. // Ctime: time.Now().Unix(),
  9677. // Mtime: time.Now().Unix(),
  9678. // ErrMsg: res2.ErrMsg,
  9679. // Status: 1,
  9680. // PatientId: id,
  9681. // RecordTime: recordDateTime,
  9682. // Stage: 3,
  9683. // }
  9684. // service.CreateErrMsgLog(errlog)
  9685. //
  9686. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  9687. // return
  9688. // }
  9689. //
  9690. // c.ServeSuccessJSON(map[string]interface{}{
  9691. // "msg": "上传成功",
  9692. // })
  9693. //
  9694. //}
  9695. type QueryResult struct {
  9696. ID int64
  9697. Name string
  9698. Code string
  9699. List_type_code string
  9700. }
  9701. func (c *HisApiController) GetCheckCode() {
  9702. ids_str := c.GetString("ids")
  9703. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9704. ids_arr := strings.Split(ids_str, ",")
  9705. var queryResult []QueryResult
  9706. ids := make([]int64, 0)
  9707. for _, item := range ids_arr {
  9708. id, _ := strconv.ParseInt(item, 10, 64)
  9709. ids = append(ids, id)
  9710. }
  9711. if record_type == 1 {
  9712. drugs, _ := service.GetBatchDrugList(ids)
  9713. for _, item := range drugs {
  9714. result := QueryResult{
  9715. ID: item.ID,
  9716. Name: item.DrugName,
  9717. Code: item.MedicalInsuranceNumber,
  9718. List_type_code: "101",
  9719. }
  9720. queryResult = append(queryResult, result)
  9721. }
  9722. } else if record_type == 2 {
  9723. goods, _ := service.GetBatchGoodInformationList(ids)
  9724. for _, item := range goods {
  9725. result := QueryResult{
  9726. ID: item.ID,
  9727. Name: item.GoodName,
  9728. Code: item.MedicalInsuranceNumber,
  9729. List_type_code: "301",
  9730. }
  9731. queryResult = append(queryResult, result)
  9732. }
  9733. } else if record_type == 3 {
  9734. projects, _ := service.GetBathchMyPorjecgList(ids)
  9735. for _, item := range projects {
  9736. result := QueryResult{
  9737. ID: item.ID,
  9738. Name: item.ProjectName,
  9739. Code: item.MedicalCode,
  9740. List_type_code: "201",
  9741. }
  9742. queryResult = append(queryResult, result)
  9743. }
  9744. }
  9745. admin_user_id, _ := c.GetInt64("admin_user_id")
  9746. adminUser := c.GetAdminUserInfo()
  9747. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9748. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9749. var user_name string
  9750. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9751. if role.ID == 0 {
  9752. user_name = "xxx"
  9753. } else {
  9754. user_name = role.UserName
  9755. }
  9756. baseParams := &models.BaseParams{
  9757. SecretKey: miConfig.SecretKey,
  9758. FixmedinsCode: miConfig.Code,
  9759. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9760. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9761. OrgName: miConfig.OrgName,
  9762. Doctor: user_name,
  9763. }
  9764. if config.IsOpen == 1 {
  9765. for _, item := range queryResult {
  9766. var result string
  9767. if record_type == 1 {
  9768. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9769. } else if record_type == 2 {
  9770. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9771. } else if record_type == 3 {
  9772. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9773. }
  9774. var dat map[string]interface{}
  9775. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9776. fmt.Println(dat)
  9777. } else {
  9778. fmt.Println(err)
  9779. }
  9780. userJSONBytes, _ := json.Marshal(dat)
  9781. var res ResultSix
  9782. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9783. utils.ErrorLog("解析失败:%v", err)
  9784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9785. return
  9786. }
  9787. if res.Infcode == 0 {
  9788. if record_type == 1 {
  9789. service.UpdateBaseDrugById(item.ID)
  9790. } else if record_type == 2 {
  9791. service.UpdateGoodInformaitonByDetail(item.ID)
  9792. } else if record_type == 3 {
  9793. service.UpdateProjectById(item.ID)
  9794. }
  9795. c.ServeSuccessJSON(map[string]interface{}{
  9796. "failed_code": 0,
  9797. "msg": "目录对照成功",
  9798. })
  9799. } else {
  9800. c.ServeSuccessJSON(map[string]interface{}{
  9801. "failed_code": -10,
  9802. "msg": res.ErrMsg,
  9803. })
  9804. }
  9805. }
  9806. }
  9807. }
  9808. func (c *HisApiController) UnCheckCode() {
  9809. ids_str := c.GetString("ids")
  9810. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9811. admin_user_id, _ := c.GetInt64("admin_user_id")
  9812. ids_arr := strings.Split(ids_str, ",")
  9813. var queryResult []QueryResult
  9814. ids := make([]int64, 0)
  9815. for _, item := range ids_arr {
  9816. id, _ := strconv.ParseInt(item, 10, 64)
  9817. ids = append(ids, id)
  9818. }
  9819. if record_type == 1 {
  9820. drugs, _ := service.GetBatchDrugList(ids)
  9821. for _, item := range drugs {
  9822. result := QueryResult{
  9823. ID: item.ID,
  9824. Name: item.DrugName,
  9825. Code: item.MedicalInsuranceNumber,
  9826. List_type_code: "101",
  9827. }
  9828. queryResult = append(queryResult, result)
  9829. }
  9830. } else if record_type == 2 {
  9831. goods, _ := service.GetBatchGoodInformationList(ids)
  9832. for _, item := range goods {
  9833. result := QueryResult{
  9834. ID: item.ID,
  9835. Name: item.GoodName,
  9836. Code: item.MedicalInsuranceNumber,
  9837. List_type_code: "301",
  9838. }
  9839. queryResult = append(queryResult, result)
  9840. }
  9841. } else if record_type == 3 {
  9842. projects, _ := service.GetBathchMyPorjecgList(ids)
  9843. for _, item := range projects {
  9844. result := QueryResult{
  9845. ID: item.ID,
  9846. Name: item.ProjectName,
  9847. Code: item.MedicalCode,
  9848. List_type_code: "201",
  9849. }
  9850. queryResult = append(queryResult, result)
  9851. }
  9852. }
  9853. adminUser := c.GetAdminUserInfo()
  9854. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9855. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9856. var user_name string
  9857. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9858. if role.ID == 0 {
  9859. user_name = "xxx"
  9860. } else {
  9861. user_name = role.UserName
  9862. }
  9863. baseParams := &models.BaseParams{
  9864. SecretKey: miConfig.SecretKey,
  9865. FixmedinsCode: miConfig.Code,
  9866. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9867. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9868. OrgName: miConfig.OrgName,
  9869. Doctor: user_name,
  9870. }
  9871. if config.IsOpen == 1 {
  9872. for _, item := range queryResult {
  9873. var result string
  9874. if record_type == 1 {
  9875. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9876. } else if record_type == 2 {
  9877. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9878. } else if record_type == 3 {
  9879. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9880. }
  9881. var dat2 map[string]interface{}
  9882. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  9883. fmt.Println(dat2)
  9884. } else {
  9885. fmt.Println(err)
  9886. }
  9887. userJSONBytes, _ := json.Marshal(dat2)
  9888. var res ResultSix
  9889. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9890. utils.ErrorLog("解析失败:%v", err)
  9891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9892. return
  9893. }
  9894. if res.Infcode == 0 {
  9895. if record_type == 1 {
  9896. service.UpdateDrugByIdDetail(item.ID)
  9897. } else if record_type == 2 {
  9898. service.UpdateGoodInfoById(item.ID)
  9899. } else if record_type == 3 {
  9900. service.UpdateMyProjectById(item.ID)
  9901. }
  9902. c.ServeSuccessJSON(map[string]interface{}{
  9903. "failed_code": 0,
  9904. "msg": "撤销目录对照成功",
  9905. })
  9906. } else {
  9907. c.ServeSuccessJSON(map[string]interface{}{
  9908. "failed_code": -10,
  9909. "msg": res.ErrMsg,
  9910. })
  9911. }
  9912. }
  9913. }
  9914. }
  9915. func (c *HisApiController) GetPatientInfo() {
  9916. id_card_no := c.GetString("id_card_no")
  9917. admin_user_id, _ := c.GetInt64("admin_user_id")
  9918. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  9919. if patient.ID == 0 {
  9920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9921. return
  9922. }
  9923. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9924. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9925. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  9926. if config.IsOpen == 1 {
  9927. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9928. var dat map[string]interface{}
  9929. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9930. fmt.Println(dat)
  9931. } else {
  9932. fmt.Println(err)
  9933. }
  9934. userJSONBytes, _ := json.Marshal(dat)
  9935. var res ResultTwo
  9936. var res10265 ResultTwo10265
  9937. if miConfig.Code == "H15049901371" {
  9938. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9939. utils.ErrorLog("解析失败:%v", err)
  9940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9941. return
  9942. }
  9943. res.ErrMsg = res10265.ErrMsg
  9944. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9945. res.Infcode = infocode
  9946. res.Output = res10265.Output
  9947. res.InfRefmsgid = res10265.InfRefmsgid
  9948. } else {
  9949. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9950. utils.ErrorLog("解析失败:%v", err)
  9951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9952. return
  9953. }
  9954. }
  9955. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9956. // utils.ErrorLog("解析失败:%v", err)
  9957. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9958. // return
  9959. //}
  9960. if res.Infcode != 0 {
  9961. c.ServeSuccessJSON(map[string]interface{}{
  9962. "failed_code": -10,
  9963. "msg": res.ErrMsg,
  9964. })
  9965. } else {
  9966. c.ServeSuccessJSON(map[string]interface{}{
  9967. "failed_code": 0,
  9968. "info": res,
  9969. })
  9970. }
  9971. }
  9972. }
  9973. func (c *HisApiController) PsnPutOnRecord() {
  9974. record_type, _ := c.GetInt64("type")
  9975. patient_id, _ := c.GetInt64("patient_id")
  9976. admin_user_id, _ := c.GetInt64("admin_user_id")
  9977. start_time := c.GetString("start_time")
  9978. end_time := c.GetString("end_time")
  9979. adminUser := c.GetAdminUserInfo()
  9980. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9981. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9982. var patients []*models.Patients
  9983. if record_type == 1 { //全部备案
  9984. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  9985. patients = append(patients, patient...)
  9986. } else { //单个备案
  9987. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9988. patients = append(patients, patient)
  9989. }
  9990. var user_name string
  9991. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9992. if role.ID == 0 {
  9993. user_name = "xxx"
  9994. } else {
  9995. user_name = role.UserName
  9996. }
  9997. if config.IsOpen == 1 {
  9998. for _, item := range patients {
  9999. 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
  10000. resp, requestErr := http.Get(api)
  10001. if requestErr != nil {
  10002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10003. return
  10004. }
  10005. defer resp.Body.Close()
  10006. body, ioErr := ioutil.ReadAll(resp.Body)
  10007. if ioErr != nil {
  10008. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10010. return
  10011. }
  10012. var respJSON map[string]interface{}
  10013. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10014. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10016. return
  10017. }
  10018. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10019. userJSONBytes, _ := json.Marshal(userJSON)
  10020. var res ResultTwo
  10021. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10022. utils.ErrorLog("解析失败:%v", err)
  10023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10024. return
  10025. }
  10026. if res.Infcode == 0 {
  10027. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  10028. var dat map[string]interface{}
  10029. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10030. fmt.Println(dat)
  10031. } else {
  10032. fmt.Println(err)
  10033. }
  10034. userJSONBytes, _ := json.Marshal(dat)
  10035. var res2 ResultThirteen
  10036. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10037. utils.ErrorLog("解析失败:%v", err)
  10038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10039. return
  10040. }
  10041. if res2.Infcode == 0 {
  10042. psnResult := &models.GdybPsnRecord{
  10043. UserOrgId: adminUser.CurrentOrgId,
  10044. PatientId: item.ID,
  10045. PsnNo: res.Output.Baseinfo.PsnNo,
  10046. Ctime: time.Now().Unix(),
  10047. Mtime: time.Now().Unix(),
  10048. Status: 1,
  10049. IsCancel: 1,
  10050. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10051. }
  10052. service.CreatePsnRecord(psnResult)
  10053. } else {
  10054. c.ServeSuccessJSON(map[string]interface{}{
  10055. "failed_code": -10,
  10056. "msg": res2.ErrMsg,
  10057. })
  10058. return
  10059. }
  10060. }
  10061. }
  10062. }
  10063. }
  10064. func (c *HisApiController) PsnUnPutOnRecord() {
  10065. id, _ := c.GetInt64("id")
  10066. //record_type, _ := c.GetInt64("type")
  10067. admin_user_id, _ := c.GetInt64("admin_user_id")
  10068. adminUser := c.GetAdminUserInfo()
  10069. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10070. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10071. var user_name string
  10072. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10073. if role.ID == 0 {
  10074. user_name = "xxx"
  10075. } else {
  10076. user_name = role.UserName
  10077. }
  10078. psn_record, _ := service.GetPsnRecordById(id)
  10079. if psn_record.ID == 0 {
  10080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10081. return
  10082. }
  10083. if config.IsOpen == 1 {
  10084. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10085. var dat map[string]interface{}
  10086. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10087. fmt.Println(dat)
  10088. } else {
  10089. fmt.Println(err)
  10090. }
  10091. userJSONBytes, _ := json.Marshal(dat)
  10092. var res ResultFourteen
  10093. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10094. utils.ErrorLog("解析失败:%v", err)
  10095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10096. return
  10097. }
  10098. if res.Infcode == 0 {
  10099. psn_record.IsCancel = 2
  10100. service.CreatePsnRecord(&psn_record)
  10101. } else {
  10102. c.ServeSuccessJSON(map[string]interface{}{
  10103. "failed_code": -10,
  10104. "msg": res.ErrMsg,
  10105. })
  10106. return
  10107. }
  10108. }
  10109. }
  10110. func (c *HisApiController) PsnPutNCDSOnRecord() {
  10111. patient_id, _ := c.GetInt64("patient_id")
  10112. insutype_two := c.GetString("insutype")
  10113. psn_no := c.GetString("psn_no")
  10114. doctor_id, _ := c.GetInt64("doctor_id")
  10115. sick_id, _ := c.GetInt64("sick_id")
  10116. department_id, _ := c.GetInt64("department_id")
  10117. start_time := c.GetString("start_time")
  10118. end_time := c.GetString("end_time")
  10119. check_time := c.GetString("check_time")
  10120. adminUser := c.GetAdminUserInfo()
  10121. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10122. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10123. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10124. sick, _ := service.FindSickById(sick_id)
  10125. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10126. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10127. var res ResultTwo
  10128. var res10265 ResultTwo10265
  10129. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10130. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  10131. api := "http://192.168.2.110:9532/" + "hbyb/1101?cert_no=" + "" +
  10132. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  10133. "&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
  10134. resp, requestErr := http.Get(api)
  10135. if requestErr != nil {
  10136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10137. return
  10138. }
  10139. body, ioErr := ioutil.ReadAll(resp.Body)
  10140. if ioErr != nil {
  10141. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10143. return
  10144. }
  10145. var respJSON map[string]interface{}
  10146. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10147. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10149. return
  10150. }
  10151. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10152. result, _ := json.Marshal(respJSON)
  10153. fmt.Println("log")
  10154. fmt.Println(string(result))
  10155. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10156. utils.ErrorLog("解析失败:%v", err)
  10157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10158. return
  10159. }
  10160. res.ErrMsg = res10265.ErrMsg
  10161. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10162. res.Infcode = infocode
  10163. res.Output = res10265.Output
  10164. res.InfRefmsgid = res10265.InfRefmsgid
  10165. } else {
  10166. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10167. if miConfig.Code == "H15049901371" {
  10168. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10169. utils.ErrorLog("解析失败:%v", err)
  10170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10171. return
  10172. }
  10173. res.ErrMsg = res10265.ErrMsg
  10174. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10175. res.Infcode = infocode
  10176. res.Output = res10265.Output
  10177. res.InfRefmsgid = res10265.InfRefmsgid
  10178. } else {
  10179. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10180. utils.ErrorLog("解析失败:%v", err)
  10181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10182. return
  10183. }
  10184. }
  10185. }
  10186. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10187. infoStr := string(Iinfos)
  10188. var rf []*ResultFive
  10189. json.Unmarshal([]byte(infoStr), &rf)
  10190. var insuplc_admdvs string
  10191. var insutype string
  10192. var is390 int = 0
  10193. var is310 int = 0
  10194. var insutypes []*ResultFive
  10195. for _, item := range rf {
  10196. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10197. insutypes = append(insutypes, item)
  10198. }
  10199. }
  10200. if len(insutypes) == 1 {
  10201. insutype = insutypes[0].Insutype
  10202. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10203. } else {
  10204. for _, i := range insutypes {
  10205. if i.Insutype == "390" {
  10206. is390 = 1
  10207. }
  10208. if i.Insutype == "310" {
  10209. is310 = 1
  10210. }
  10211. }
  10212. }
  10213. if is390 == 1 {
  10214. insutype = "390"
  10215. }
  10216. if is310 == 1 {
  10217. insutype = "310"
  10218. }
  10219. if len(insutypes) == 2 {
  10220. insutype = insutype_two
  10221. }
  10222. if len(insutypes) == 0 {
  10223. insutype = "310"
  10224. }
  10225. insutype = insutype_two
  10226. fmt.Println(insutype)
  10227. for _, item := range rf {
  10228. fmt.Println(item.Insutype)
  10229. fmt.Println(insutype)
  10230. if item.Insutype == insutype {
  10231. fmt.Println(item.Insutype)
  10232. fmt.Println(insutype)
  10233. insuplc_admdvs = item.InsuplcAdmdvs
  10234. }
  10235. }
  10236. fmt.Println(insuplc_admdvs)
  10237. var res2 ResultThirteen
  10238. var res10265_2 ResultThirteen10265
  10239. if config.IsOpen == 1 {
  10240. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10241. } else {
  10242. 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)
  10243. var dat map[string]interface{}
  10244. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10245. fmt.Println(dat)
  10246. } else {
  10247. fmt.Println(err)
  10248. }
  10249. userJSONBytes, _ := json.Marshal(dat)
  10250. if miConfig.Code == "H15049901371" {
  10251. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  10252. utils.ErrorLog("解析失败:%v", err)
  10253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10254. return
  10255. }
  10256. res2.ErrMsg = res10265_2.ErrMsg
  10257. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  10258. res2.Infcode = infocode
  10259. res2.Output = res10265_2.Output
  10260. res2.InfRefmsgid = res10265_2.InfRefmsgid
  10261. } else {
  10262. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10263. utils.ErrorLog("解析失败:%v", err)
  10264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10265. return
  10266. }
  10267. }
  10268. }
  10269. if res2.Infcode == 0 {
  10270. psnResult := &models.GdybPsnNcdsRecord{
  10271. UserOrgId: adminUser.CurrentOrgId,
  10272. PatientId: patient.ID,
  10273. PsnNo: psn_no,
  10274. DoctorId: doctor.AdminUserId,
  10275. DepartmentId: department_id,
  10276. SickType: sick_id,
  10277. Insutype: insutype,
  10278. Ctime: time.Now().Unix(),
  10279. Mtime: time.Now().Unix(),
  10280. Status: 1,
  10281. IsCancel: 1,
  10282. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10283. }
  10284. service.CreatePsnNCDSRecord(psnResult)
  10285. c.ServeSuccessJSON(map[string]interface{}{
  10286. "failed_code": 0,
  10287. "msg": "备案成功",
  10288. "result": psnResult,
  10289. })
  10290. } else {
  10291. c.ServeSuccessJSON(map[string]interface{}{
  10292. "failed_code": -10,
  10293. "msg": res2.ErrMsg,
  10294. })
  10295. return
  10296. }
  10297. }
  10298. }
  10299. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  10300. id, _ := c.GetInt64("id")
  10301. admin_user_id, _ := c.GetInt64("admin_user_id")
  10302. adminUser := c.GetAdminUserInfo()
  10303. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10304. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10305. //config, _ := service.Ge(adminUser.CurrentOrgId)
  10306. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  10307. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10308. //var user_name string
  10309. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10310. //if role.ID == 0 {
  10311. // user_name = "xxx"
  10312. //} else {
  10313. // user_name = role.UserName
  10314. //}
  10315. psn_record, _ := service.GetPsnNCDSRecordById(id)
  10316. if psn_record.ID == 0 {
  10317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10318. return
  10319. }
  10320. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10321. var res ResultTwo
  10322. var res10265 ResultTwo10265
  10323. if miConfig.Code == "H15049901371" {
  10324. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10325. utils.ErrorLog("解析失败:%v", err)
  10326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10327. return
  10328. }
  10329. res.ErrMsg = res10265.ErrMsg
  10330. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10331. res.Infcode = infocode
  10332. res.Output = res10265.Output
  10333. res.InfRefmsgid = res10265.InfRefmsgid
  10334. } else {
  10335. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10336. utils.ErrorLog("解析失败:%v", err)
  10337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10338. return
  10339. }
  10340. }
  10341. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10342. infoStr := string(Iinfos)
  10343. var rf []*ResultFive
  10344. json.Unmarshal([]byte(infoStr), &rf)
  10345. var insuplc_admdvs string
  10346. var insutype string
  10347. var is390 int = 0
  10348. var is310 int = 0
  10349. var insutypes []*ResultFive
  10350. for _, item := range rf {
  10351. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10352. insutypes = append(insutypes, item)
  10353. }
  10354. }
  10355. if len(insutypes) == 1 {
  10356. insutype = insutypes[0].Insutype
  10357. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10358. } else {
  10359. for _, i := range insutypes {
  10360. if i.Insutype == "390" {
  10361. is390 = 1
  10362. }
  10363. if i.Insutype == "310" {
  10364. is310 = 1
  10365. }
  10366. }
  10367. }
  10368. if is390 == 1 {
  10369. insutype = "390"
  10370. }
  10371. if is310 == 1 {
  10372. insutype = "310"
  10373. }
  10374. if len(insutypes) == 0 {
  10375. insutype = "310"
  10376. }
  10377. insutype = psn_record.Insutype
  10378. for _, item := range rf {
  10379. if item.Insutype == insutype {
  10380. insuplc_admdvs = item.InsuplcAdmdvs
  10381. }
  10382. }
  10383. if config.IsOpen == 1 {
  10384. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10385. var dat map[string]interface{}
  10386. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10387. fmt.Println(dat)
  10388. } else {
  10389. fmt.Println(err)
  10390. }
  10391. userJSONBytes, _ := json.Marshal(dat)
  10392. var res ResultFourteen
  10393. var res10265 ResultFourteen10265
  10394. if miConfig.Code == "H15049901371" {
  10395. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10396. utils.ErrorLog("解析失败:%v", err)
  10397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10398. return
  10399. }
  10400. res.ErrMsg = res10265.ErrMsg
  10401. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10402. res.Infcode = infocode
  10403. res.Output = res10265.Output
  10404. res.InfRefmsgid = res10265.InfRefmsgid
  10405. } else {
  10406. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10407. utils.ErrorLog("解析失败:%v", err)
  10408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10409. return
  10410. }
  10411. }
  10412. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10413. // utils.ErrorLog("解析失败:%v", err)
  10414. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10415. // return
  10416. //}
  10417. if res.Infcode == 0 {
  10418. psn_record.IsCancel = 2
  10419. service.CreatePsnNCDSRecord(&psn_record)
  10420. c.ServeSuccessJSON(map[string]interface{}{
  10421. "failed_code": 0,
  10422. "msg": "撤销备案成功",
  10423. })
  10424. } else {
  10425. c.ServeSuccessJSON(map[string]interface{}{
  10426. "failed_code": -10,
  10427. "msg": res.ErrMsg,
  10428. })
  10429. return
  10430. }
  10431. }
  10432. }
  10433. func (c *HisApiController) TestTest() {
  10434. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  10435. fmt.Println(patient.Iinfo)
  10436. }
  10437. type CustomData struct {
  10438. MsgId string
  10439. PsnNo string
  10440. Info string
  10441. }
  10442. func (c *HisApiController) ReversalData() {
  10443. var customData []*CustomData
  10444. custom := &CustomData{
  10445. MsgId: "H44022900158202103301714472004",
  10446. PsnNo: "44020000001101329945",
  10447. Info: "2207",
  10448. }
  10449. customData = append(customData, custom)
  10450. custom1 := &CustomData{
  10451. MsgId: "H4402290015820210330172057803",
  10452. PsnNo: "44020000001101161813",
  10453. Info: "2207",
  10454. }
  10455. customData = append(customData, custom1)
  10456. custom2 := &CustomData{
  10457. MsgId: "H44022900158202103301705198813",
  10458. PsnNo: "44190000133097375417",
  10459. Info: "2207",
  10460. }
  10461. customData = append(customData, custom2)
  10462. custom3 := &CustomData{
  10463. MsgId: "H44022900158202103301715524756",
  10464. PsnNo: "44020000001100187221",
  10465. Info: "2207",
  10466. }
  10467. customData = append(customData, custom3)
  10468. custom4 := &CustomData{
  10469. MsgId: "H44022900158202103301730376224",
  10470. PsnNo: "44020000001101959155",
  10471. Info: "2207",
  10472. }
  10473. customData = append(customData, custom4)
  10474. custom5 := &CustomData{
  10475. MsgId: "H44022900158202103301748008725",
  10476. PsnNo: "44020000001104246641",
  10477. Info: "2207",
  10478. }
  10479. customData = append(customData, custom5)
  10480. custom6 := &CustomData{
  10481. MsgId: "H44022900158202103301718096755",
  10482. PsnNo: "44020000001102211860",
  10483. Info: "2207",
  10484. }
  10485. customData = append(customData, custom6)
  10486. custom7 := &CustomData{
  10487. MsgId: "H44022900158202103301736551640",
  10488. PsnNo: "44020000001102687718",
  10489. Info: "2207",
  10490. }
  10491. customData = append(customData, custom7)
  10492. custom8 := &CustomData{
  10493. MsgId: "H44022900158202103301743097676",
  10494. PsnNo: "44020000001102127785",
  10495. Info: "2207",
  10496. }
  10497. customData = append(customData, custom8)
  10498. custom9 := &CustomData{
  10499. MsgId: "H44022900158202103301712304203",
  10500. PsnNo: "44020000001101518097",
  10501. Info: "2207",
  10502. }
  10503. customData = append(customData, custom9)
  10504. custom10 := &CustomData{
  10505. MsgId: "H44022900158202103301738448785",
  10506. PsnNo: "44020000001100500813",
  10507. Info: "2207",
  10508. }
  10509. customData = append(customData, custom10)
  10510. custom11 := &CustomData{
  10511. MsgId: "H44022900158202103301732455843",
  10512. PsnNo: "44020000001102690557",
  10513. Info: "2207",
  10514. }
  10515. customData = append(customData, custom11)
  10516. custom12 := &CustomData{
  10517. MsgId: "H44022900158202103301745421708",
  10518. PsnNo: "44020000001102211928",
  10519. Info: "2207",
  10520. }
  10521. customData = append(customData, custom12)
  10522. custom1212 := &CustomData{
  10523. MsgId: "H440229001582021033017351627",
  10524. PsnNo: "44020000001102481733",
  10525. Info: "2207",
  10526. }
  10527. customData = append(customData, custom1212)
  10528. custom13 := &CustomData{
  10529. MsgId: "H44022900158202103301740327951",
  10530. PsnNo: "44020000001103174866",
  10531. Info: "2207",
  10532. }
  10533. customData = append(customData, custom13)
  10534. custom14 := &CustomData{
  10535. MsgId: "H4402290015820210330174922668",
  10536. PsnNo: "44020000001102927272",
  10537. Info: "2207",
  10538. }
  10539. customData = append(customData, custom14)
  10540. custom15 := &CustomData{
  10541. MsgId: "H44022900158202103301752362273",
  10542. PsnNo: "44020000001102942890",
  10543. Info: "2207",
  10544. }
  10545. customData = append(customData, custom15)
  10546. custom16 := &CustomData{
  10547. MsgId: "H44022900158202103301751082917",
  10548. PsnNo: "44020000001101662162",
  10549. Info: "2207",
  10550. }
  10551. customData = append(customData, custom16)
  10552. custom17 := &CustomData{
  10553. MsgId: "H44022900158202103301754147728",
  10554. PsnNo: "44020000000229014511",
  10555. Info: "2207",
  10556. }
  10557. customData = append(customData, custom17)
  10558. adminUser := c.GetAdminUserInfo()
  10559. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10560. for _, item := range customData {
  10561. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10562. fmt.Println(result)
  10563. }
  10564. }
  10565. //func (c *HisApiController) GetAllopatry() {
  10566. // year := c.GetString("year")
  10567. // month := c.GetString("month")
  10568. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10569. // adminUser := c.GetAdminUserInfo()
  10570. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10571. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10572. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10573. //
  10574. // var dat map[string]interface{}
  10575. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10576. // fmt.Println(dat)
  10577. // } else {
  10578. // fmt.Println(err)
  10579. // }
  10580. // userJSONBytes, _ := json.Marshal(dat)
  10581. // var res models.Result9001
  10582. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10583. // utils.ErrorLog("解析失败:%v", err)
  10584. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10585. // return
  10586. // }
  10587. //
  10588. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10589. // var dat2 map[string]interface{}
  10590. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10591. // fmt.Println(dat)
  10592. // } else {
  10593. // fmt.Println(err)
  10594. // }
  10595. // userJSONBytes2, _ := json.Marshal(dat2)
  10596. // var res2 models.Result3260
  10597. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10598. // utils.ErrorLog("解析失败:%v", err)
  10599. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10600. // return
  10601. // }
  10602. // if res2.Infcode == 0 {
  10603. // c.ServeSuccessJSON(map[string]interface{}{
  10604. // "list": res2.Output.Data,
  10605. // })
  10606. // return
  10607. // } else {
  10608. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10609. // return
  10610. // }
  10611. //
  10612. //}
  10613. //func (c *HisApiController) ComfirmAllopatry() {
  10614. // year := c.GetString("year")
  10615. // month := c.GetString("month")
  10616. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10617. // adminUser := c.GetAdminUserInfo()
  10618. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10619. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10620. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10621. // var dat map[string]interface{}
  10622. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10623. // fmt.Println(dat)
  10624. // } else {
  10625. // fmt.Println(err)
  10626. // }
  10627. // userJSONBytes, _ := json.Marshal(dat)
  10628. // var res models.Result9001
  10629. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10630. // utils.ErrorLog("解析失败:%v", err)
  10631. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10632. // return
  10633. // }
  10634. //
  10635. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10636. // var dat2 map[string]interface{}
  10637. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10638. // fmt.Println(dat)
  10639. // } else {
  10640. // fmt.Println(err)
  10641. // }
  10642. // userJSONBytes2, _ := json.Marshal(dat2)
  10643. // var res2 models.Result3260
  10644. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10645. // utils.ErrorLog("解析失败:%v", err)
  10646. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10647. // return
  10648. // }
  10649. //
  10650. // if res2.Infcode == 0 {
  10651. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  10652. // var dat map[string]interface{}
  10653. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10654. // fmt.Println(dat)
  10655. // } else {
  10656. // fmt.Println(err)
  10657. // }
  10658. // userJSONBytes, _ := json.Marshal(dat)
  10659. // var res3 models.Result3261
  10660. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  10661. // utils.ErrorLog("解析失败:%v", err)
  10662. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10663. // return
  10664. // }
  10665. //
  10666. // if res3.Infcode == 0 {
  10667. // record := &models.HisYidiClearRecord{
  10668. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10669. // Ctime: time.Now().Unix(),
  10670. // Mtime: time.Now().Unix(),
  10671. // Status: 1,
  10672. // MsgId: msgId,
  10673. // }
  10674. // service.SaveClearRecord(record)
  10675. // c.ServeSuccessJSON(map[string]interface{}{
  10676. // "msg": "提取成功",
  10677. // })
  10678. // }
  10679. // }
  10680. //}
  10681. func (c *HisApiController) RefundAllopatry() {
  10682. year := c.GetString("year")
  10683. month := c.GetString("month")
  10684. id, _ := c.GetInt64("id")
  10685. admin_user_id, _ := c.GetInt64("admin_user_id")
  10686. adminUser := c.GetAdminUserInfo()
  10687. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10688. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10689. record, _ := service.GetClearRecordById(id)
  10690. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  10691. var dat map[string]interface{}
  10692. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10693. fmt.Println(dat)
  10694. } else {
  10695. fmt.Println(err)
  10696. }
  10697. userJSONBytes, _ := json.Marshal(dat)
  10698. var empty ResultFourteen
  10699. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  10700. utils.ErrorLog("解析失败:%v", err)
  10701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10702. return
  10703. }
  10704. if empty.Infcode == 0 {
  10705. c.ServeSuccessJSON(map[string]interface{}{
  10706. "msg": "撤销成功",
  10707. })
  10708. return
  10709. }
  10710. }
  10711. func (c *HisApiController) ReversalOtherData() {
  10712. var customData []*CustomData
  10713. custom := &CustomData{
  10714. MsgId: "H44022900158202103301714472004",
  10715. PsnNo: "44020000001101329945",
  10716. Info: "2208",
  10717. }
  10718. customData = append(customData, custom)
  10719. custom1 := &CustomData{
  10720. MsgId: "H4402290015820210330172057803",
  10721. PsnNo: "44020000001101161813",
  10722. Info: "2208",
  10723. }
  10724. customData = append(customData, custom1)
  10725. custom2 := &CustomData{
  10726. MsgId: "H44022900158202103301705198813",
  10727. PsnNo: "44190000133097375417",
  10728. Info: "2208",
  10729. }
  10730. customData = append(customData, custom2)
  10731. custom3 := &CustomData{
  10732. MsgId: "H44022900158202103301715524756",
  10733. PsnNo: "44020000001100187221",
  10734. Info: "2208",
  10735. }
  10736. customData = append(customData, custom3)
  10737. custom4 := &CustomData{
  10738. MsgId: "H44022900158202103301730376224",
  10739. PsnNo: "44020000001101959155",
  10740. Info: "2208",
  10741. }
  10742. customData = append(customData, custom4)
  10743. custom5 := &CustomData{
  10744. MsgId: "H44022900158202103301748008725",
  10745. PsnNo: "44020000001104246641",
  10746. Info: "2208",
  10747. }
  10748. customData = append(customData, custom5)
  10749. custom6 := &CustomData{
  10750. MsgId: "H44022900158202103301718096755",
  10751. PsnNo: "44020000001102211860",
  10752. Info: "2208",
  10753. }
  10754. customData = append(customData, custom6)
  10755. custom7 := &CustomData{
  10756. MsgId: "H44022900158202103301736551640",
  10757. PsnNo: "44020000001102687718",
  10758. Info: "2208",
  10759. }
  10760. customData = append(customData, custom7)
  10761. custom8 := &CustomData{
  10762. MsgId: "H44022900158202103301743097676",
  10763. PsnNo: "44020000001102127785",
  10764. Info: "2208",
  10765. }
  10766. customData = append(customData, custom8)
  10767. custom9 := &CustomData{
  10768. MsgId: "H44022900158202103301712304203",
  10769. PsnNo: "44020000001101518097",
  10770. Info: "2208",
  10771. }
  10772. customData = append(customData, custom9)
  10773. custom10 := &CustomData{
  10774. MsgId: "H44022900158202103301738448785",
  10775. PsnNo: "44020000001100500813",
  10776. Info: "2208",
  10777. }
  10778. customData = append(customData, custom10)
  10779. custom11 := &CustomData{
  10780. MsgId: "H44022900158202103301732455843",
  10781. PsnNo: "44020000001102690557",
  10782. Info: "2208",
  10783. }
  10784. customData = append(customData, custom11)
  10785. custom12 := &CustomData{
  10786. MsgId: "H44022900158202103301745421708",
  10787. PsnNo: "44020000001102211928",
  10788. Info: "2208",
  10789. }
  10790. customData = append(customData, custom12)
  10791. custom1212 := &CustomData{
  10792. MsgId: "H440229001582021033017351627",
  10793. PsnNo: "44020000001102481733",
  10794. Info: "2208",
  10795. }
  10796. customData = append(customData, custom1212)
  10797. custom13 := &CustomData{
  10798. MsgId: "H44022900158202103301740327951",
  10799. PsnNo: "44020000001103174866",
  10800. Info: "2208",
  10801. }
  10802. customData = append(customData, custom13)
  10803. custom14 := &CustomData{
  10804. MsgId: "H4402290015820210330174922668",
  10805. PsnNo: "44020000001102927272",
  10806. Info: "2208",
  10807. }
  10808. customData = append(customData, custom14)
  10809. custom15 := &CustomData{
  10810. MsgId: "H44022900158202103301752362273",
  10811. PsnNo: "44020000001102942890",
  10812. Info: "2208",
  10813. }
  10814. customData = append(customData, custom15)
  10815. custom16 := &CustomData{
  10816. MsgId: "H44022900158202103301751082917",
  10817. PsnNo: "44020000001101662162",
  10818. Info: "2208",
  10819. }
  10820. customData = append(customData, custom16)
  10821. custom17 := &CustomData{
  10822. MsgId: "H44022900158202103301754147728",
  10823. PsnNo: "44020000000229014511",
  10824. Info: "2208",
  10825. }
  10826. customData = append(customData, custom17)
  10827. adminUser := c.GetAdminUserInfo()
  10828. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10829. for _, item := range customData {
  10830. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10831. fmt.Println(result)
  10832. }
  10833. }
  10834. func PathExists(path string) (bool, error) {
  10835. _, err := os.Stat(path)
  10836. if err == nil {
  10837. return true, nil
  10838. }
  10839. if os.IsNotExist(err) {
  10840. return false, nil
  10841. }
  10842. return false, err
  10843. }
  10844. //创建文件夹
  10845. func Mkdir(dir string) {
  10846. // 创建文件夹
  10847. exist, err := PathExists(dir)
  10848. if err != nil {
  10849. fmt.Println(err.Error())
  10850. } else {
  10851. if exist {
  10852. fmt.Println(dir + "文件夹已存在!")
  10853. } else {
  10854. // 文件夹名称,权限
  10855. err := os.Mkdir(dir, os.ModePerm)
  10856. if err != nil {
  10857. fmt.Println(dir+"文件夹创建失败:", err.Error())
  10858. } else {
  10859. fmt.Println(dir + "文件夹创建成功!")
  10860. }
  10861. }
  10862. }
  10863. }
  10864. //压缩文件
  10865. func Zip(srcFile string, destZip string) error {
  10866. zipfile, err := os.Create(destZip)
  10867. if err != nil {
  10868. return err
  10869. }
  10870. defer zipfile.Close()
  10871. archive := zip.NewWriter(zipfile)
  10872. defer archive.Close()
  10873. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  10874. if err != nil {
  10875. return err
  10876. }
  10877. header, err := zip.FileInfoHeader(info)
  10878. if err != nil {
  10879. return err
  10880. }
  10881. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  10882. // header.Name = path
  10883. if info.IsDir() {
  10884. header.Name += "/"
  10885. } else {
  10886. header.Method = zip.Deflate
  10887. }
  10888. writer, err := archive.CreateHeader(header)
  10889. if err != nil {
  10890. return err
  10891. }
  10892. if !info.IsDir() {
  10893. file, err := os.Open(path)
  10894. if err != nil {
  10895. return err
  10896. }
  10897. defer file.Close()
  10898. _, err = io.Copy(writer, file)
  10899. }
  10900. return err
  10901. })
  10902. return err
  10903. }
  10904. func ReadFile(filePath string) []byte {
  10905. f, err := os.Open(filePath)
  10906. if err != nil {
  10907. fmt.Println("read file fail", err)
  10908. return nil
  10909. }
  10910. defer f.Close()
  10911. fd, err := ioutil.ReadAll(f)
  10912. if err != nil {
  10913. fmt.Println("read to fd fail", err)
  10914. return nil
  10915. }
  10916. return fd
  10917. }
  10918. func saveLog(result string, request string, infno string, desc string) {
  10919. org_id, _ := beego.AppConfig.Int64("org_id")
  10920. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  10921. dir := miConfig.OrgName + "日志"
  10922. utils.Mkdir(dir)
  10923. month := time.Unix(1557042972, 0).Format("1")
  10924. year := time.Now().Format("2006")
  10925. month = time.Now().Format("01")
  10926. day := time.Now().Format("02")
  10927. hour := time.Now().Format("15")
  10928. min := time.Now().Format("04")
  10929. sec := time.Now().Format("05")
  10930. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  10931. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  10932. file_name := file + ".txt"
  10933. file_path := miConfig.OrgName + "日志" + "/" + file_name
  10934. exist, _ := utils.PathExists(file_path)
  10935. if exist { //存在
  10936. fmt.Println("存在")
  10937. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  10938. if err != nil {
  10939. fmt.Println("read fail")
  10940. }
  10941. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  10942. n, _ := f.Seek(0, 2)
  10943. _, err = f.WriteAt([]byte(content), n)
  10944. } else { //不存在
  10945. fmt.Println("文件不存在,创建文件")
  10946. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  10947. defer f.Close()
  10948. if err != nil {
  10949. } else {
  10950. _, err = f.Write([]byte("记录日志"))
  10951. }
  10952. }
  10953. }
  10954. type Charset string
  10955. const (
  10956. UTF8 = Charset("UTF-8")
  10957. GB18030 = Charset("GB18030")
  10958. )
  10959. func ConvertToString(src string, srcCode string, tagCode string) string {
  10960. srcCoder := mahonia.NewDecoder(srcCode)
  10961. srcResult := srcCoder.ConvertString(src)
  10962. tagCoder := mahonia.NewDecoder(tagCode)
  10963. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  10964. result := string(cdata)
  10965. return result
  10966. }
  10967. func (c *HisApiController) ReadEleCard() {
  10968. id_card_type, _ := c.GetInt64("id_card_type")
  10969. admin_user_id, _ := c.GetInt64("admin_user_id")
  10970. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  10971. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10972. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10973. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10974. var api string
  10975. if miConfig.MdtrtareaAdmvs == "320921" {
  10976. 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 +
  10977. "&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
  10978. fmt.Println(api)
  10979. } else {
  10980. 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 +
  10981. "&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)
  10982. }
  10983. resp, requestErr := http.Get(api)
  10984. if requestErr != nil {
  10985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10986. return
  10987. }
  10988. body, ioErr := ioutil.ReadAll(resp.Body)
  10989. if ioErr != nil {
  10990. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10992. return
  10993. }
  10994. var respJSON map[string]interface{}
  10995. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10996. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10998. return
  10999. }
  11000. var status string
  11001. status = respJSON["data"].(map[string]interface{})["status"].(string)
  11002. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  11003. var token string
  11004. var res ResultTwo //1101结果
  11005. var res10265 ResultTwo10265 //1101结果
  11006. if status == "0" { //读卡成功
  11007. var card_info string //卡信息
  11008. var busi_card_info string
  11009. token = respJSON["data"].(map[string]interface{})["token"].(string)
  11010. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  11011. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  11012. fmt.Println(card_info)
  11013. fmt.Println(busi_card_info)
  11014. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  11015. result, _ := json.Marshal(respJSON)
  11016. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11017. utils.ErrorLog("解析失败:%v", err)
  11018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11019. return
  11020. }
  11021. res.ErrMsg = res10265.ErrMsg
  11022. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11023. res.Infcode = infocode
  11024. res.Output = res10265.Output
  11025. res.InfRefmsgid = res10265.InfRefmsgid
  11026. if res.Infcode == 0 {
  11027. c.ServeSuccessJSON(map[string]interface{}{
  11028. "number": token,
  11029. })
  11030. }
  11031. } else {
  11032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11033. return
  11034. }
  11035. } else { //读卡失败
  11036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11037. return
  11038. }
  11039. }
  11040. func DeleteExtraSpaceTwo(s string) string {
  11041. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11042. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11043. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11044. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11045. s2 := make([]byte, len(s1)) //定义字符数组切片
  11046. copy(s2, s1) //将字符串复制到切片
  11047. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11048. for len(spc_index) > 0 { //找到适配项
  11049. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11050. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11051. }
  11052. return string(s2)
  11053. }
  11054. func Remove0000(s string) string {
  11055. str := make([]rune, 0, len(s))
  11056. for _, v := range []rune(s) {
  11057. if v == 0 {
  11058. continue
  11059. }
  11060. str = append(str, v)
  11061. }
  11062. return string(str)
  11063. }