his_api_controller.go 432KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/json"
  6. "fmt"
  7. "gdyb/controllers"
  8. "gdyb/enums"
  9. "gdyb/models"
  10. "gdyb/service"
  11. "gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/axgle/mahonia"
  14. "github.com/jinzhu/gorm"
  15. "github.com/shopspring/decimal"
  16. "io"
  17. "io/ioutil"
  18. "math/rand"
  19. "net/http"
  20. "os"
  21. "path/filepath"
  22. "strconv"
  23. "strings"
  24. "syscall"
  25. "time"
  26. "unsafe"
  27. )
  28. type HisApiController struct {
  29. controllers.BaseAuthAPIController
  30. }
  31. func HisManagerApiRegistRouters() {
  32. //挂号
  33. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  34. //上传就诊信息-上传明细-结算
  35. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  36. //查询
  37. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  38. //对总账
  39. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  40. //对明细
  41. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  42. //退费,退明细
  43. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  44. //退号
  45. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  46. //退明细
  47. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  48. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  49. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  50. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  51. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  52. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  53. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  54. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  55. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  56. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  57. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  58. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  59. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  60. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  61. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  62. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  63. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  64. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  65. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  66. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  67. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  68. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  69. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  70. beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  71. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  72. beego.Router("/api/check", &HisApiController{}, "get:Check")
  73. beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  74. beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  75. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  76. }
  77. func (c *HisApiController) Check3101() {
  78. patient_id, _ := c.GetInt64("patient_id")
  79. his_patient_id, _ := c.GetInt64("his_patient_id")
  80. admin_user_id, _ := c.GetInt64("admin_user_id")
  81. adminUser := c.GetAdminUserInfo()
  82. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  83. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  84. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  85. record_time := c.GetString("record_time")
  86. trig_scen := c.GetString("trig_scen")
  87. timeLayout := "2006-01-02"
  88. loc, _ := time.LoadLocation("Local")
  89. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  90. if err != nil {
  91. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  92. return
  93. }
  94. recordDateTime := theTime.Unix()
  95. var patientPrescription models.HisPrescriptionInfo
  96. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  97. if patientPrescription.ID == 0 {
  98. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  99. }
  100. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  101. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  102. //
  103. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  104. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  105. var pp models.PublicParams
  106. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  107. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  108. pp.FixmedinsName = miConfig.OrgName
  109. pp.FixmedinsCode = miConfig.Code
  110. pp.RequestUrl = miConfig.Url
  111. pp.Cainfo = miConfig.Cainfo
  112. pp.SecretKey = miConfig.SecretKey
  113. pp.AccessKey = miConfig.AccessKey
  114. pp.OpterName = roles.UserName
  115. var config []*models.HisXtDiagnoseConfig
  116. for _, item := range diagnosis_ids {
  117. id, _ := strconv.ParseInt(item, 10, 64)
  118. diagnosisConfig, _ := service.FindDiagnoseById(id)
  119. config = append(config, &diagnosisConfig)
  120. }
  121. var pd models.PatientDtos
  122. pd.PatnID = his.PsnNo
  123. pd.PatnName = his.Name
  124. pd.Gend = his.Gend
  125. pd.Brdy = his.Brdy
  126. pd.Poolarea = his.InsuplcAdmdvs
  127. pd.CurrMdtrtID = his.Number
  128. var fed models.FsiEncounterDtos
  129. fed.MdtrtID = his.Number
  130. fed.MedinsID = miConfig.Code
  131. fed.MedinsName = miConfig.OrgName
  132. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  133. fed.MedMdtrtType = "1"
  134. fed.MedinsType = "1"
  135. fed.MedinsLv = "11"
  136. tm := time.Unix(his.RecordDate, 0)
  137. s_tm := tm.Format("2006-01-02 15:04:05")
  138. fed.AdmDate = s_tm
  139. fed.DscgDate = s_tm
  140. fed.DscgMainDiseCodg = config[0].CountryCode
  141. fed.DscgMainDiseName = config[0].CountryContentName
  142. //诊断信息
  143. var fdds []*models.FsiDiagnoseDtos
  144. for index, item := range config {
  145. if index == 0 {
  146. var fdd models.FsiDiagnoseDtos
  147. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  148. fdd.InoutDiseType = "1"
  149. fdd.MaindiseFlag = "1"
  150. fdd.DiseDate = s_tm
  151. fdd.DiasSrtNo = "1"
  152. fdd.DiseName = item.CountryContentName
  153. fdd.DiseCodg = item.CountryCode
  154. fdds = append(fdds, &fdd)
  155. } else {
  156. var fdd models.FsiDiagnoseDtos
  157. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  158. fdd.InoutDiseType = "1"
  159. fdd.MaindiseFlag = "1"
  160. fdd.DiseDate = s_tm
  161. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  162. fdd.DiseName = item.CountryContentName
  163. fdd.DiseCodg = item.CountryCode
  164. fdds = append(fdds, &fdd)
  165. }
  166. }
  167. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  168. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  169. fed.AdmDeptName = department.Name
  170. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  171. fed.DscgDeptName = department.Name
  172. fed.MedMdtrtType = "1"
  173. fed.MedType = "11"
  174. //if his.Insutype == "390" {
  175. // fed.MedType = "1402"
  176. //} else {
  177. // fed.MedType = "9933"
  178. //}
  179. var orders []*models.FsiOrderDtos
  180. if trig_scen == "2" {
  181. //处方医嘱信息
  182. for _, item := range prescriptions {
  183. for _, subItem := range item.HisDoctorAdviceInfo {
  184. var order models.FsiOrderDtos
  185. order.RxID = strconv.FormatInt(item.ID, 10)
  186. order.Rxno = strconv.FormatInt(item.ID, 10)
  187. order.LongDrordFlag = "0"
  188. order.HilistType = "1"
  189. order.ChrgType = "1"
  190. order.DrordBhvr = "-"
  191. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  192. order.HosplistName = subItem.BaseDrugLib.DrugName
  193. order.HilistLv = "1"
  194. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  195. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  196. order.HosplistName = subItem.BaseDrugLib.DrugName
  197. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  198. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  199. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  200. order.OwnpayAmt = ""
  201. order.SelfpayAmt = ""
  202. order.Spec = ""
  203. order.SpecUnt = ""
  204. order.DrordBegnDate = s_tm
  205. order.DrordStopDate = ""
  206. order.DrordDrCodg = "1"
  207. order.DrordDeptName = department.Name
  208. order.DrordDrCodg = "1"
  209. order.DrordDrName = doctor_info.UserName
  210. order.DrordDrProfttl = ""
  211. order.CurrDrordFlag = "1"
  212. orders = append(orders, &order)
  213. }
  214. for _, subItem := range item.HisPrescriptionProject {
  215. if subItem.Type == 2 {
  216. var order models.FsiOrderDtos
  217. order.RxID = strconv.FormatInt(item.ID, 10)
  218. order.Rxno = strconv.FormatInt(item.ID, 10)
  219. order.LongDrordFlag = "0"
  220. order.HilistType = "1"
  221. order.ChrgType = "1"
  222. order.DrordBhvr = "-"
  223. order.HilistCode = subItem.HisProject.MedicalCode
  224. order.HosplistName = subItem.HisProject.ProjectName
  225. order.HilistLv = "1"
  226. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  227. order.HosplistCode = subItem.HisProject.MedicalCode
  228. order.HosplistName = subItem.HisProject.ProjectName
  229. order.Cnt = subItem.Count
  230. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  231. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  232. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  233. order.OwnpayAmt = ""
  234. order.SelfpayAmt = ""
  235. order.Spec = ""
  236. order.SpecUnt = ""
  237. order.DrordBegnDate = s_tm
  238. order.DrordStopDate = ""
  239. order.DrordDrCodg = "1"
  240. order.DrordDeptName = department.Name
  241. order.DrordDrCodg = "1"
  242. order.DrordDrName = doctor_info.UserName
  243. order.DrordDrProfttl = ""
  244. order.CurrDrordFlag = "1"
  245. orders = append(orders, &order)
  246. }
  247. if subItem.Type == 3 {
  248. var order models.FsiOrderDtos
  249. order.RxID = strconv.FormatInt(item.ID, 10)
  250. order.Rxno = strconv.FormatInt(item.ID, 10)
  251. order.LongDrordFlag = "0"
  252. order.HilistType = "1"
  253. order.ChrgType = "1"
  254. order.DrordBhvr = "-"
  255. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  256. order.HosplistName = subItem.GoodInfo.GoodName
  257. order.HilistLv = "1"
  258. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  259. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  260. order.HosplistName = subItem.GoodInfo.GoodName
  261. order.Cnt = subItem.Count
  262. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  263. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  264. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  265. order.OwnpayAmt = ""
  266. order.SelfpayAmt = ""
  267. order.Spec = ""
  268. order.SpecUnt = ""
  269. order.DrordBegnDate = s_tm
  270. order.DrordStopDate = ""
  271. order.DrordDrCodg = "1"
  272. order.DrordDeptName = department.Name
  273. order.DrordDrCodg = "1"
  274. order.DrordDrName = doctor_info.UserName
  275. order.DrordDrProfttl = ""
  276. order.CurrDrordFlag = "1"
  277. orders = append(orders, &order)
  278. }
  279. }
  280. }
  281. //处方医嘱信息
  282. }
  283. fed.MatnStas = "0"
  284. fed.MedfeeSumamt = "0"
  285. fed.OwnpayAmt = "0"
  286. fed.SelfpayAmt = "0"
  287. fed.AcctPayamt = "0"
  288. fed.MaAmt = "0"
  289. fed.HifpPayamt = "0"
  290. fed.SetlTotlnum = "1"
  291. fed.Insutype = his.Insutype
  292. fed.ReimFlag = "0"
  293. fed.OutSetlFlag = "0"
  294. var fopd []*models.FsiOperationDtosData
  295. data := make(map[string]interface{})
  296. data["fed"] = fed
  297. data["fdd"] = fdds
  298. data["fod"] = orders
  299. data["pd"] = pd
  300. data["pp"] = pp
  301. data["fopd"] = fopd
  302. data["trig_scen"] = trig_scen
  303. fmt.Println(data)
  304. fmt.Println(fed)
  305. fmt.Println(fdds)
  306. fmt.Println(orders)
  307. fmt.Println(pd)
  308. fmt.Println(pp)
  309. fmt.Println(fopd)
  310. client := &http.Client{}
  311. bytesData, _ := json.Marshal(data)
  312. var req *http.Request
  313. if miConfig.MdtrtareaAdmvs == "320921" {
  314. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  315. } else {
  316. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  317. }
  318. resp, _ := client.Do(req)
  319. defer resp.Body.Close()
  320. body, ioErr := ioutil.ReadAll(resp.Body)
  321. if ioErr != nil {
  322. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  324. return
  325. }
  326. var respJSON map[string]interface{}
  327. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  328. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  330. return
  331. }
  332. //手术操作集合
  333. //手术操作集合
  334. }
  335. func (c *HisApiController) Check3102() {
  336. patient_id, _ := c.GetInt64("patient_id")
  337. order_id, _ := c.GetInt64("order_id")
  338. his_patient_id, _ := c.GetInt64("his_patient_id")
  339. admin_user_id, _ := c.GetInt64("admin_user_id")
  340. trig_scen := c.GetString("trig_scen")
  341. adminUser := c.GetAdminUserInfo()
  342. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  343. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  344. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  345. record_time := c.GetString("record_time")
  346. order, _ := service.GetHisOrderByID(order_id)
  347. timeLayout := "2006-01-02"
  348. loc, _ := time.LoadLocation("Local")
  349. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  350. if err != nil {
  351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  352. return
  353. }
  354. recordDateTime := theTime.Unix()
  355. var patientPrescription models.HisPrescriptionInfo
  356. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  357. if patientPrescription.ID == 0 {
  358. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  359. }
  360. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  361. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  362. //
  363. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  364. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  365. var pp models.PublicParams
  366. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  367. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  368. pp.FixmedinsName = miConfig.OrgName
  369. pp.FixmedinsCode = miConfig.Code
  370. pp.RequestUrl = miConfig.Url
  371. pp.Cainfo = miConfig.Cainfo
  372. pp.SecretKey = miConfig.SecretKey
  373. pp.AccessKey = miConfig.AccessKey
  374. pp.OpterName = roles.UserName
  375. var config []*models.HisXtDiagnoseConfig
  376. for _, item := range diagnosis_ids {
  377. id, _ := strconv.ParseInt(item, 10, 64)
  378. diagnosisConfig, _ := service.FindDiagnoseById(id)
  379. config = append(config, &diagnosisConfig)
  380. }
  381. var pd models.PatientDtos
  382. pd.PatnID = his.PsnNo
  383. pd.PatnName = his.Name
  384. pd.Gend = his.Gend
  385. pd.Brdy = his.Brdy
  386. pd.Poolarea = his.InsuplcAdmdvs
  387. pd.CurrMdtrtID = his.Number
  388. var fed models.FsiEncounterDtos
  389. fed.MdtrtID = his.Number
  390. fed.MedinsID = miConfig.Code
  391. fed.MedinsName = miConfig.OrgName
  392. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  393. fed.MedMdtrtType = "1"
  394. fed.MedinsType = "1"
  395. fed.MedinsLv = "11"
  396. tm := time.Unix(his.RecordDate, 0)
  397. s_tm := tm.Format("2006-01-02 15:04:05")
  398. fed.AdmDate = s_tm
  399. fed.DscgDate = s_tm
  400. fed.DscgMainDiseCodg = config[0].CountryCode
  401. fed.DscgMainDiseName = config[0].CountryContentName
  402. //诊断信息
  403. var fdds []*models.FsiDiagnoseDtos
  404. for index, item := range config {
  405. if index == 0 {
  406. var fdd models.FsiDiagnoseDtos
  407. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  408. fdd.InoutDiseType = "1"
  409. fdd.MaindiseFlag = "1"
  410. fdd.DiseDate = s_tm
  411. fdd.DiasSrtNo = "1"
  412. fdd.DiseName = item.CountryContentName
  413. fdd.DiseCodg = item.CountryCode
  414. fdds = append(fdds, &fdd)
  415. } else {
  416. var fdd models.FsiDiagnoseDtos
  417. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  418. fdd.InoutDiseType = "1"
  419. fdd.MaindiseFlag = "1"
  420. fdd.DiseDate = s_tm
  421. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  422. fdd.DiseName = item.CountryContentName
  423. fdd.DiseCodg = item.CountryCode
  424. fdds = append(fdds, &fdd)
  425. }
  426. }
  427. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  428. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  429. fed.AdmDeptName = department.Name
  430. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  431. fed.DscgDeptName = department.Name
  432. fed.MedType = order.MedType
  433. //处方医嘱信息
  434. var orders []*models.FsiOrderDtos
  435. //for _, item := range prescriptions {
  436. // for _, subItem := range item.HisDoctorAdviceInfo {
  437. // var order models.FsiOrderDtos
  438. // order.RxID = strconv.FormatInt(item.ID, 10)
  439. // order.Rxno = strconv.FormatInt(item.ID, 10)
  440. // order.LongDrordFlag = "0"
  441. // order.HilistType = "1"
  442. // order.ChrgType = "1"
  443. // order.DrordBhvr = "-"
  444. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  445. // order.HosplistName = subItem.BaseDrugLib.DrugName
  446. // order.HilistLv = "1"
  447. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  448. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  449. // order.HosplistName = subItem.BaseDrugLib.DrugName
  450. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  451. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  452. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  453. // order.OwnpayAmt = ""
  454. // order.SelfpayAmt = ""
  455. // order.Spec = ""
  456. // order.SpecUnt = ""
  457. // order.DrordBegnDate = s_tm
  458. // order.DrordStopDate = ""
  459. // order.DrordDrCodg = "1"
  460. // order.DrordDeptName = department.Name
  461. // order.DrordDrCodg = "1"
  462. // order.DrordDrName = doctor_info.UserName
  463. // order.DrordDrProfttl = ""
  464. // order.CurrDrordFlag = "1"
  465. // orders = append(orders, &order)
  466. // }
  467. // for _, subItem := range item.HisPrescriptionProject {
  468. // if subItem.Type == 2 {
  469. // var order models.FsiOrderDtos
  470. // order.RxID = strconv.FormatInt(item.ID, 10)
  471. // order.Rxno = strconv.FormatInt(item.ID, 10)
  472. // order.LongDrordFlag = "0"
  473. // order.HilistType = "1"
  474. // order.ChrgType = "1"
  475. // order.DrordBhvr = "-"
  476. // order.HilistCode = subItem.HisProject.MedicalCode
  477. // order.HosplistName = subItem.HisProject.ProjectName
  478. // order.HilistLv = "1"
  479. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  480. // order.HosplistCode = subItem.HisProject.MedicalCode
  481. // order.HosplistName = subItem.HisProject.ProjectName
  482. // order.Cnt = subItem.Count
  483. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  484. //
  485. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  486. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  487. // order.OwnpayAmt = ""
  488. // order.SelfpayAmt = ""
  489. // order.Spec = ""
  490. // order.SpecUnt = ""
  491. // order.DrordBegnDate = s_tm
  492. // order.DrordStopDate = ""
  493. // order.DrordDrCodg = "1"
  494. // order.DrordDeptName = department.Name
  495. // order.DrordDrCodg = "1"
  496. // order.DrordDrName = doctor_info.UserName
  497. // order.DrordDrProfttl = ""
  498. // order.CurrDrordFlag = "1"
  499. // orders = append(orders, &order)
  500. //
  501. // }
  502. // if subItem.Type == 3 {
  503. //
  504. // var order models.FsiOrderDtos
  505. // order.RxID = strconv.FormatInt(item.ID, 10)
  506. // order.Rxno = strconv.FormatInt(item.ID, 10)
  507. // order.LongDrordFlag = "0"
  508. // order.HilistType = "1"
  509. // order.ChrgType = "1"
  510. // order.DrordBhvr = "-"
  511. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  512. // order.HosplistName = subItem.GoodInfo.GoodName
  513. // order.HilistLv = "1"
  514. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  515. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  516. // order.HosplistName = subItem.GoodInfo.GoodName
  517. // order.Cnt = subItem.Count
  518. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  519. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  520. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  521. // order.OwnpayAmt = ""
  522. // order.SelfpayAmt = ""
  523. // order.Spec = ""
  524. // order.SpecUnt = ""
  525. // order.DrordBegnDate = s_tm
  526. // order.DrordStopDate = ""
  527. // order.DrordDrCodg = "1"
  528. // order.DrordDeptName = department.Name
  529. // order.DrordDrCodg = "1"
  530. // order.DrordDrName = doctor_info.UserName
  531. // order.DrordDrProfttl = ""
  532. // order.CurrDrordFlag = "1"
  533. // orders = append(orders, &order)
  534. //
  535. // }
  536. // }
  537. //}
  538. for _, item := range prescriptions {
  539. for _, subItem := range item.HisDoctorAdviceInfo {
  540. var order models.FsiOrderDtos
  541. order.RxID = strconv.FormatInt(item.ID, 10)
  542. order.Rxno = strconv.FormatInt(item.ID, 10)
  543. order.LongDrordFlag = "0"
  544. order.HilistType = "1"
  545. order.ChrgType = "1"
  546. order.DrordBhvr = "-"
  547. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  548. order.HosplistName = subItem.BaseDrugLib.DrugName
  549. order.HilistLv = "1"
  550. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  551. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  552. order.HosplistName = subItem.BaseDrugLib.DrugName
  553. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  554. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  555. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  556. order.OwnpayAmt = ""
  557. order.SelfpayAmt = ""
  558. order.Spec = ""
  559. order.SpecUnt = ""
  560. order.DrordBegnDate = s_tm
  561. order.DrordStopDate = ""
  562. order.DrordDrCodg = "1"
  563. order.DrordDeptName = department.Name
  564. order.DrordDrCodg = "1"
  565. order.DrordDrName = doctor_info.UserName
  566. order.DrordDrProfttl = ""
  567. order.CurrDrordFlag = "1"
  568. orders = append(orders, &order)
  569. }
  570. for _, subItem := range item.HisPrescriptionProject {
  571. if subItem.Type == 2 {
  572. var order models.FsiOrderDtos
  573. order.RxID = strconv.FormatInt(item.ID, 10)
  574. order.Rxno = strconv.FormatInt(item.ID, 10)
  575. order.LongDrordFlag = "0"
  576. order.HilistType = "1"
  577. order.ChrgType = "1"
  578. order.DrordBhvr = "-"
  579. order.HilistCode = subItem.HisProject.MedicalCode
  580. order.HosplistName = subItem.HisProject.ProjectName
  581. order.HilistLv = "1"
  582. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  583. order.HosplistCode = subItem.HisProject.MedicalCode
  584. order.HosplistName = subItem.HisProject.ProjectName
  585. order.Cnt = subItem.Count
  586. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  587. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  588. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  589. order.OwnpayAmt = ""
  590. order.SelfpayAmt = ""
  591. order.Spec = ""
  592. order.SpecUnt = ""
  593. order.DrordBegnDate = s_tm
  594. order.DrordStopDate = ""
  595. order.DrordDrCodg = "1"
  596. order.DrordDeptName = department.Name
  597. order.DrordDrCodg = "1"
  598. order.DrordDrName = doctor_info.UserName
  599. order.DrordDrProfttl = ""
  600. order.CurrDrordFlag = "1"
  601. orders = append(orders, &order)
  602. }
  603. if subItem.Type == 3 {
  604. var order models.FsiOrderDtos
  605. order.RxID = strconv.FormatInt(item.ID, 10)
  606. order.Rxno = strconv.FormatInt(item.ID, 10)
  607. order.LongDrordFlag = "0"
  608. order.HilistType = "1"
  609. order.ChrgType = "1"
  610. order.DrordBhvr = "-"
  611. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  612. order.HosplistName = subItem.GoodInfo.GoodName
  613. order.HilistLv = "1"
  614. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  615. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  616. order.HosplistName = subItem.GoodInfo.GoodName
  617. order.Cnt = subItem.Count
  618. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  619. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  620. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  621. order.OwnpayAmt = ""
  622. order.SelfpayAmt = ""
  623. order.Spec = ""
  624. order.SpecUnt = ""
  625. order.DrordBegnDate = s_tm
  626. order.DrordStopDate = ""
  627. order.DrordDrCodg = "1"
  628. order.DrordDeptName = department.Name
  629. order.DrordDrCodg = "1"
  630. order.DrordDrName = doctor_info.UserName
  631. order.DrordDrProfttl = ""
  632. order.CurrDrordFlag = "1"
  633. orders = append(orders, &order)
  634. }
  635. }
  636. }
  637. //处方医嘱信息
  638. fed.MatnStas = "0"
  639. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  640. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  641. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  642. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  643. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  644. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  645. fed.SetlTotlnum = "1"
  646. fed.Insutype = his.Insutype
  647. fed.ReimFlag = "0"
  648. fed.OutSetlFlag = "0"
  649. var fopd []*models.FsiOperationDtosData
  650. data := make(map[string]interface{})
  651. data["fed"] = fed
  652. data["fdd"] = fdds
  653. data["fod"] = orders
  654. data["pd"] = pd
  655. data["pp"] = pp
  656. data["fopd"] = fopd
  657. data["trig_scen"] = trig_scen
  658. client := &http.Client{}
  659. bytesData, _ := json.Marshal(data)
  660. var req *http.Request
  661. if miConfig.MdtrtareaAdmvs == "320921" {
  662. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  663. } else {
  664. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  665. }
  666. resp, _ := client.Do(req)
  667. defer resp.Body.Close()
  668. body, ioErr := ioutil.ReadAll(resp.Body)
  669. if ioErr != nil {
  670. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  672. return
  673. }
  674. var respJSON map[string]interface{}
  675. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  676. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  678. return
  679. }
  680. //手术操作集合
  681. //手术操作集合
  682. }
  683. func (c *HisApiController) Check() {
  684. psn_no := c.GetString("psn_no")
  685. in := c.GetString("in")
  686. mt := c.GetString("mt")
  687. baseParams := models.BaseParams{
  688. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  689. FixmedinsCode: "H15049901371",
  690. InsuplcAdmdvs: "150499",
  691. MdtrtareaAdmvs: "150499",
  692. OrgName: "赤峰费森血液透析中心",
  693. Doctor: "1111",
  694. }
  695. service.Gdyb2001(baseParams, psn_no, in, mt)
  696. }
  697. func (c *HisApiController) GetPsnNcdsInfo() {
  698. admin_user_id, _ := c.GetInt64("admin_user_id")
  699. patient_id, _ := c.GetInt64("patient_id")
  700. id, _ := c.GetInt64("id")
  701. adminUser := c.GetAdminUserInfo()
  702. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  703. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  704. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  705. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  706. psn_record, _ := service.GetPsnNCDSRecordById(id)
  707. //
  708. //if psn_record.ID == 0 {
  709. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  710. // return
  711. //}
  712. var res Result5301
  713. var res10265 Result5301For10265
  714. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  715. psn_info, _ := service.GetPsnByPatientId(patient_id)
  716. var api string
  717. if miConfig.MdtrtareaAdmvs == "320921" {
  718. api = "http://192.168.3.111:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  719. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  720. } else {
  721. 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 +
  722. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  723. }
  724. resp, requestErr := http.Get(api)
  725. if requestErr != nil {
  726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  727. return
  728. }
  729. body, ioErr := ioutil.ReadAll(resp.Body)
  730. if ioErr != nil {
  731. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  733. return
  734. }
  735. var respJSON map[string]interface{}
  736. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  737. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  739. return
  740. }
  741. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  742. result, _ := json.Marshal(respJSON)
  743. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  744. utils.ErrorLog("解析失败:%v", err)
  745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  746. return
  747. }
  748. res.ErrMsg = res10265.ErrMsg
  749. res.Output = res10265.Output
  750. res.InfRefmsgid = res10265.InfRefmsgid
  751. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  752. res.Infcode = infocode
  753. } else {
  754. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  755. var dat map[string]interface{}
  756. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  757. fmt.Println(dat)
  758. } else {
  759. fmt.Println(err)
  760. }
  761. userJSONBytes, _ := json.Marshal(dat)
  762. if miConfig.Code == "H15049901371" {
  763. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  764. utils.ErrorLog("解析失败:%v", err)
  765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  766. return
  767. }
  768. res.InfRefmsgid = res10265.InfRefmsgid
  769. res.Output = res10265.Output
  770. res.ErrMsg = res10265.ErrMsg
  771. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  772. res.Infcode = infocode
  773. } else {
  774. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  775. utils.ErrorLog("解析失败:%v", err)
  776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  777. return
  778. }
  779. }
  780. }
  781. if res.Infcode == 0 {
  782. c.ServeSuccessJSON(map[string]interface{}{
  783. "result": res.Output.Result,
  784. })
  785. }
  786. }
  787. func (c *HisApiController) CheckInsutype() {
  788. his_patient_id, _ := c.GetInt64("his_patient_id")
  789. admin_user_id, _ := c.GetInt64("admin_user_id")
  790. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  791. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  792. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  793. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  794. var dat map[string]interface{}
  795. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  796. fmt.Println(dat)
  797. } else {
  798. fmt.Println(err)
  799. }
  800. userJSONBytes, _ := json.Marshal(dat)
  801. var res Result90100
  802. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  803. utils.ErrorLog("解析失败:%v", err)
  804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  805. return
  806. }
  807. if res.Infcode != 0 {
  808. c.ServeSuccessJSON(map[string]interface{}{
  809. "failed_code": -10,
  810. "msg": res.ErrMsg,
  811. })
  812. return
  813. } else {
  814. fmt.Println(res)
  815. }
  816. }
  817. func (c *HisApiController) CheckCardPWD() {
  818. card_pwd := c.GetString("card_pwd")
  819. his_patient_id, _ := c.GetInt64("his_patient_id")
  820. admin_user_id, _ := c.GetInt64("admin_user_id")
  821. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  822. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  823. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  824. psn, _ := service.GetPsnByPatientId(his.PatientId)
  825. bas := strings.Split(psn.CardInfo, "|")
  826. basNumber := bas[2]
  827. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  828. var dat map[string]interface{}
  829. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  830. fmt.Println(dat)
  831. } else {
  832. fmt.Println(err)
  833. }
  834. userJSONBytes, _ := json.Marshal(dat)
  835. var res Result90991
  836. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  837. utils.ErrorLog("解析失败:%v", err)
  838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  839. return
  840. }
  841. if res.Infcode != 0 {
  842. c.ServeSuccessJSON(map[string]interface{}{
  843. "failed_code": -10,
  844. "msg": res.ErrMsg,
  845. })
  846. return
  847. } else {
  848. if res.Output.Result.SscnoCheckStat == "0" {
  849. var msg string
  850. switch res.Output.Result.CardStat {
  851. case "00":
  852. msg = "未激活"
  853. break
  854. case "10":
  855. msg = "激活"
  856. break
  857. case "20":
  858. msg = "窗口挂失"
  859. break
  860. case "21":
  861. msg = "电话挂失"
  862. break
  863. case "22":
  864. msg = "单位网上申报挂失"
  865. break
  866. case "23":
  867. msg = "保健办挂失"
  868. break
  869. case "24":
  870. msg = "个人网上挂失"
  871. break
  872. case "25":
  873. msg = "网上服务大厅挂失"
  874. break
  875. case "30":
  876. msg = "注销"
  877. break
  878. case "40":
  879. msg = "回收"
  880. break
  881. case "99":
  882. msg = "制卡中(无效卡)"
  883. break
  884. }
  885. c.ServeSuccessJSON(map[string]interface{}{
  886. "failed_code": -10,
  887. "msg": msg,
  888. })
  889. return
  890. } else {
  891. c.ServeSuccessJSON(map[string]interface{}{
  892. "msg": "校验成功",
  893. })
  894. return
  895. }
  896. }
  897. }
  898. func (c *HisApiController) CheckCardPWDTwo() {
  899. //card_pwd := c.GetString("card_pwd")
  900. //his_patient_id, _ := c.GetInt64("his_patient_id")
  901. admin_user_id, _ := c.GetInt64("admin_user_id")
  902. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  903. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  904. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "220881198702101914")
  905. var dat map[string]interface{}
  906. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  907. fmt.Println(dat)
  908. } else {
  909. fmt.Println(err)
  910. }
  911. userJSONBytes, _ := json.Marshal(dat)
  912. var res Result90991
  913. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  914. utils.ErrorLog("解析失败:%v", err)
  915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  916. return
  917. }
  918. if res.Infcode != 0 {
  919. c.ServeSuccessJSON(map[string]interface{}{
  920. "failed_code": -10,
  921. "msg": res.ErrMsg,
  922. })
  923. return
  924. } else {
  925. if res.Output.Result.SscnoCheckStat == "0" {
  926. var msg string
  927. switch res.Output.Result.CardStat {
  928. case "00":
  929. msg = "未激活"
  930. break
  931. case "10":
  932. msg = "激活"
  933. break
  934. case "20":
  935. msg = "窗口挂失"
  936. break
  937. case "21":
  938. msg = "电话挂失"
  939. break
  940. case "22":
  941. msg = "单位网上申报挂失"
  942. break
  943. case "23":
  944. msg = "保健办挂失"
  945. break
  946. case "24":
  947. msg = "个人网上挂失"
  948. break
  949. case "25":
  950. msg = "网上服务大厅挂失"
  951. break
  952. case "30":
  953. msg = "注销"
  954. break
  955. case "40":
  956. msg = "回收"
  957. break
  958. case "99":
  959. msg = "制卡中(无效卡)"
  960. break
  961. }
  962. c.ServeSuccessJSON(map[string]interface{}{
  963. "failed_code": -10,
  964. "msg": msg,
  965. })
  966. return
  967. } else {
  968. c.ServeSuccessJSON(map[string]interface{}{
  969. "msg": "校验成功",
  970. })
  971. return
  972. }
  973. }
  974. }
  975. func (c *HisApiController) ReadCard() {
  976. id_card_type, _ := c.GetInt64("id_card_type")
  977. admin_user_id, _ := c.GetInt64("admin_user_id")
  978. certificates, _ := c.GetInt64("certificates")
  979. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  980. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  981. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  982. switch id_card_type {
  983. case 1:
  984. if miConfig.MdtrtareaAdmvs == "421300" {
  985. var res ResultTwo
  986. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  987. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  988. "&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)
  989. resp, requestErr := http.Get(api)
  990. if requestErr != nil {
  991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  992. return
  993. }
  994. body, ioErr := ioutil.ReadAll(resp.Body)
  995. if ioErr != nil {
  996. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  998. return
  999. }
  1000. var respJSON map[string]interface{}
  1001. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1002. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1004. return
  1005. }
  1006. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1007. result, _ := json.Marshal(respJSON)
  1008. fmt.Println("log")
  1009. fmt.Println(string(result))
  1010. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1011. utils.ErrorLog("解析失败:%v", err)
  1012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1013. return
  1014. }
  1015. if res.Infcode == 0 {
  1016. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1017. if err == gorm.ErrRecordNotFound {
  1018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1019. return
  1020. } else if err != nil {
  1021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1022. return
  1023. } else {
  1024. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1025. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1026. infoStr := string(Iinfos)
  1027. idetinfoStr := string(Idetinfos)
  1028. psn := &models.HisPsn{
  1029. PsnNo: res.Output.Baseinfo.PsnNo,
  1030. Age: res.Output.Baseinfo.Age,
  1031. PatientId: patient.ID,
  1032. Certno: res.Output.Baseinfo.Certno,
  1033. Brdy: res.Output.Baseinfo.Brdy,
  1034. Gend: res.Output.Baseinfo.Gend,
  1035. Naty: res.Output.Baseinfo.Naty,
  1036. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1037. PsnName: res.Output.Baseinfo.PsnName,
  1038. Idetinfo: idetinfoStr,
  1039. Insuinfo: infoStr,
  1040. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1041. }
  1042. service.CreateHisPsn(psn)
  1043. c.ServeSuccessJSON(map[string]interface{}{
  1044. "patient": patient,
  1045. "number": res.Output.Baseinfo.Certno,
  1046. })
  1047. }
  1048. } else {
  1049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1050. return
  1051. }
  1052. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1053. var api string
  1054. if miConfig.MdtrtareaAdmvs == "320921" {
  1055. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1056. "&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
  1057. fmt.Println(api)
  1058. } else {
  1059. 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 +
  1060. "&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)
  1061. }
  1062. resp, requestErr := http.Get(api)
  1063. if requestErr != nil {
  1064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1065. return
  1066. }
  1067. body, ioErr := ioutil.ReadAll(resp.Body)
  1068. if ioErr != nil {
  1069. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1071. return
  1072. }
  1073. var respJSON map[string]interface{}
  1074. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1075. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1077. return
  1078. }
  1079. var status string
  1080. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1081. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1082. //console.log()
  1083. fmt.Println("type===")
  1084. fmt.Println(card_type)
  1085. var token string
  1086. var res ResultTwo //1101结果
  1087. var res10265 ResultTwo10265 //1101结果
  1088. var card_info string //卡信息
  1089. var busi_card_info string
  1090. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1091. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1092. if status == "0" { //读卡成功
  1093. if card_type == "1" {
  1094. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1095. result, _ := json.Marshal(respJSON)
  1096. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1097. utils.ErrorLog("解析失败:%v", err)
  1098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1099. return
  1100. }
  1101. res.ErrMsg = res10265.ErrMsg
  1102. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1103. res.Infcode = infocode
  1104. res.Output = res10265.Output
  1105. res.InfRefmsgid = res10265.InfRefmsgid
  1106. } else {
  1107. //var card_info string //卡信息
  1108. //var busi_card_info string
  1109. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1110. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1111. //fmt.Println(card_info)
  1112. //fmt.Println(busi_card_info)
  1113. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1114. result, _ := json.Marshal(respJSON)
  1115. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1116. utils.ErrorLog("解析失败:%v", err)
  1117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1118. return
  1119. }
  1120. res.ErrMsg = res10265.ErrMsg
  1121. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1122. res.Infcode = infocode
  1123. res.Output = res10265.Output
  1124. res.InfRefmsgid = res10265.InfRefmsgid
  1125. }
  1126. if res.Infcode == 0 {
  1127. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1128. if err == gorm.ErrRecordNotFound {
  1129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1130. return
  1131. } else if err != nil {
  1132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1133. return
  1134. } else {
  1135. if card_type == "1" {
  1136. bas := strings.Split(card_info, "|")
  1137. basNumber := bas[2]
  1138. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1139. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1140. infoStr := string(Iinfos)
  1141. idetinfoStr := string(Idetinfos)
  1142. psn := &models.HisPsn{
  1143. PsnNo: res.Output.Baseinfo.PsnNo,
  1144. Age: res.Output.Baseinfo.Age,
  1145. PatientId: patient.ID,
  1146. Certno: res.Output.Baseinfo.Certno,
  1147. Brdy: res.Output.Baseinfo.Brdy,
  1148. Gend: res.Output.Baseinfo.Gend,
  1149. Naty: res.Output.Baseinfo.Naty,
  1150. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1151. PsnName: res.Output.Baseinfo.PsnName,
  1152. Idetinfo: idetinfoStr,
  1153. Insuinfo: infoStr,
  1154. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1155. CardInfo: card_info,
  1156. VerifyNumber: busi_card_info,
  1157. }
  1158. service.CreateHisPsn(psn)
  1159. c.ServeSuccessJSON(map[string]interface{}{
  1160. "patient": patient,
  1161. "number": basNumber,
  1162. })
  1163. } else {
  1164. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1165. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1166. infoStr := string(Iinfos)
  1167. idetinfoStr := string(Idetinfos)
  1168. psn := &models.HisPsn{
  1169. PsnNo: res.Output.Baseinfo.PsnNo,
  1170. Age: res.Output.Baseinfo.Age,
  1171. PatientId: patient.ID,
  1172. Certno: res.Output.Baseinfo.Certno,
  1173. Brdy: res.Output.Baseinfo.Brdy,
  1174. Gend: res.Output.Baseinfo.Gend,
  1175. Naty: res.Output.Baseinfo.Naty,
  1176. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1177. PsnName: res.Output.Baseinfo.PsnName,
  1178. Idetinfo: idetinfoStr,
  1179. Insuinfo: infoStr,
  1180. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1181. CardInfo: card_info,
  1182. VerifyNumber: token,
  1183. }
  1184. service.CreateHisPsn(psn)
  1185. c.ServeSuccessJSON(map[string]interface{}{
  1186. "patient": patient,
  1187. "number": token,
  1188. })
  1189. }
  1190. }
  1191. } else {
  1192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1193. return
  1194. }
  1195. } else { //读卡失败
  1196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1197. return
  1198. }
  1199. } else {
  1200. if initFlag == 0 {
  1201. c.TestGetBasBaseInit()
  1202. }
  1203. basStr := c.GetBasBaseInfo()
  1204. if len(basStr) == 0 {
  1205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1206. return
  1207. }
  1208. fmt.Println(basStr)
  1209. bas := strings.Split(basStr, "|")
  1210. basNumber := bas[1]
  1211. fmt.Println(basNumber)
  1212. card_sn := bas[3]
  1213. fmt.Println(card_sn)
  1214. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1215. var dat map[string]interface{}
  1216. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1217. fmt.Println(dat)
  1218. } else {
  1219. fmt.Println(err)
  1220. }
  1221. userJSONBytes, _ := json.Marshal(dat)
  1222. var res ResultTwo
  1223. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1224. utils.ErrorLog("解析失败:%v", err)
  1225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1226. return
  1227. }
  1228. if res.Infcode == 0 {
  1229. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1230. if err == gorm.ErrRecordNotFound {
  1231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1232. return
  1233. } else if err != nil {
  1234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1235. return
  1236. } else {
  1237. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1238. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1239. infoStr := string(Iinfos)
  1240. idetinfoStr := string(Idetinfos)
  1241. psn := &models.HisPsn{
  1242. PsnNo: res.Output.Baseinfo.PsnNo,
  1243. Age: res.Output.Baseinfo.Age,
  1244. PatientId: patient.ID,
  1245. Certno: res.Output.Baseinfo.Certno,
  1246. Brdy: res.Output.Baseinfo.Brdy,
  1247. Gend: res.Output.Baseinfo.Gend,
  1248. Naty: res.Output.Baseinfo.Naty,
  1249. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1250. PsnName: res.Output.Baseinfo.PsnName,
  1251. Idetinfo: idetinfoStr,
  1252. Insuinfo: infoStr,
  1253. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1254. CardInfo: basStr,
  1255. VerifyNumber: "",
  1256. }
  1257. service.CreateHisPsn(psn)
  1258. c.ServeSuccessJSON(map[string]interface{}{
  1259. "patient": patient,
  1260. "number": basNumber,
  1261. })
  1262. }
  1263. } else {
  1264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1265. return
  1266. }
  1267. break
  1268. }
  1269. case 2:
  1270. SFZStr := c.GetSFZBaseInfo()
  1271. id_card_str := strings.Split(SFZStr, "^")
  1272. id_card_number := id_card_str[0]
  1273. card_sn := ""
  1274. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1275. var dat map[string]interface{}
  1276. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1277. fmt.Println(dat)
  1278. } else {
  1279. fmt.Println(err)
  1280. }
  1281. userJSONBytes, _ := json.Marshal(dat)
  1282. var res ResultTwo
  1283. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1284. utils.ErrorLog("解析失败:%v", err)
  1285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1286. return
  1287. }
  1288. if res.Infcode == 0 {
  1289. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1290. if err == gorm.ErrRecordNotFound {
  1291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1292. return
  1293. } else if err != nil {
  1294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1295. return
  1296. } else {
  1297. c.ServeSuccessJSON(map[string]interface{}{
  1298. "patient": patient,
  1299. "number": id_card_number,
  1300. })
  1301. }
  1302. } else {
  1303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1304. return
  1305. }
  1306. break
  1307. case 3:
  1308. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1309. var api string
  1310. if miConfig.MdtrtareaAdmvs == "320921" {
  1311. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1312. "&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
  1313. fmt.Println(api)
  1314. } else {
  1315. 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 +
  1316. "&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)
  1317. }
  1318. resp, requestErr := http.Get(api)
  1319. if requestErr != nil {
  1320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1321. return
  1322. }
  1323. body, ioErr := ioutil.ReadAll(resp.Body)
  1324. if ioErr != nil {
  1325. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1327. return
  1328. }
  1329. var respJSON map[string]interface{}
  1330. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1331. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1333. return
  1334. }
  1335. var status string
  1336. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1337. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1338. var token string
  1339. var res ResultTwo //1101结果
  1340. var res10265 ResultTwo10265 //1101结果
  1341. var card_info string //卡信息
  1342. var busi_card_info string
  1343. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1344. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1345. if status == "0" { //读卡成功
  1346. if card_type == "1" {
  1347. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1348. result, _ := json.Marshal(respJSON)
  1349. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1350. utils.ErrorLog("解析失败:%v", err)
  1351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1352. return
  1353. }
  1354. res.ErrMsg = res10265.ErrMsg
  1355. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1356. res.Infcode = infocode
  1357. res.Output = res10265.Output
  1358. res.InfRefmsgid = res10265.InfRefmsgid
  1359. } else {
  1360. //var card_info string //卡信息
  1361. //var busi_card_info string
  1362. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1363. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1364. //fmt.Println(card_info)
  1365. //fmt.Println(busi_card_info)
  1366. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1367. result, _ := json.Marshal(respJSON)
  1368. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1369. utils.ErrorLog("解析失败:%v", err)
  1370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1371. return
  1372. }
  1373. res.ErrMsg = res10265.ErrMsg
  1374. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1375. res.Infcode = infocode
  1376. res.Output = res10265.Output
  1377. res.InfRefmsgid = res10265.InfRefmsgid
  1378. }
  1379. if res.Infcode == 0 {
  1380. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1381. if err == gorm.ErrRecordNotFound {
  1382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1383. return
  1384. } else if err != nil {
  1385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1386. return
  1387. } else {
  1388. if card_type == "1" {
  1389. bas := strings.Split(card_info, "|")
  1390. basNumber := bas[2]
  1391. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1392. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1393. infoStr := string(Iinfos)
  1394. idetinfoStr := string(Idetinfos)
  1395. psn := &models.HisPsn{
  1396. PsnNo: res.Output.Baseinfo.PsnNo,
  1397. Age: res.Output.Baseinfo.Age,
  1398. PatientId: patient.ID,
  1399. Certno: res.Output.Baseinfo.Certno,
  1400. Brdy: res.Output.Baseinfo.Brdy,
  1401. Gend: res.Output.Baseinfo.Gend,
  1402. Naty: res.Output.Baseinfo.Naty,
  1403. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1404. PsnName: res.Output.Baseinfo.PsnName,
  1405. Idetinfo: idetinfoStr,
  1406. Insuinfo: infoStr,
  1407. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1408. CardInfo: card_info,
  1409. VerifyNumber: busi_card_info,
  1410. }
  1411. service.CreateHisPsn(psn)
  1412. c.ServeSuccessJSON(map[string]interface{}{
  1413. "patient": patient,
  1414. "number": basNumber,
  1415. })
  1416. } else {
  1417. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1418. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1419. infoStr := string(Iinfos)
  1420. idetinfoStr := string(Idetinfos)
  1421. psn := &models.HisPsn{
  1422. PsnNo: res.Output.Baseinfo.PsnNo,
  1423. Age: res.Output.Baseinfo.Age,
  1424. PatientId: patient.ID,
  1425. Certno: res.Output.Baseinfo.Certno,
  1426. Brdy: res.Output.Baseinfo.Brdy,
  1427. Gend: res.Output.Baseinfo.Gend,
  1428. Naty: res.Output.Baseinfo.Naty,
  1429. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1430. PsnName: res.Output.Baseinfo.PsnName,
  1431. Idetinfo: idetinfoStr,
  1432. Insuinfo: infoStr,
  1433. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1434. CardInfo: card_info,
  1435. VerifyNumber: token,
  1436. }
  1437. service.CreateHisPsn(psn)
  1438. c.ServeSuccessJSON(map[string]interface{}{
  1439. "patient": patient,
  1440. "number": token,
  1441. })
  1442. }
  1443. }
  1444. } else {
  1445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1446. return
  1447. }
  1448. } else { //读卡失败
  1449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1450. return
  1451. }
  1452. }
  1453. break
  1454. case 4:
  1455. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1456. var api string
  1457. if miConfig.MdtrtareaAdmvs == "320921" {
  1458. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1459. "&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
  1460. fmt.Println(api)
  1461. } else {
  1462. 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 +
  1463. "&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)
  1464. }
  1465. resp, requestErr := http.Get(api)
  1466. if requestErr != nil {
  1467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1468. return
  1469. }
  1470. body, ioErr := ioutil.ReadAll(resp.Body)
  1471. if ioErr != nil {
  1472. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1474. return
  1475. }
  1476. var respJSON map[string]interface{}
  1477. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1478. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1480. return
  1481. }
  1482. var status string
  1483. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1484. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1485. var token string
  1486. var res ResultTwo //1101结果
  1487. var res10265 ResultTwo10265 //1101结果
  1488. if status == "0" { //读卡成功
  1489. var card_info string //卡信息
  1490. var busi_card_info string
  1491. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1492. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1493. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1494. fmt.Println(card_info)
  1495. fmt.Println(busi_card_info)
  1496. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1497. result, _ := json.Marshal(respJSON)
  1498. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1499. utils.ErrorLog("解析失败:%v", err)
  1500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1501. return
  1502. }
  1503. res.ErrMsg = res10265.ErrMsg
  1504. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1505. res.Infcode = infocode
  1506. res.Output = res10265.Output
  1507. res.InfRefmsgid = res10265.InfRefmsgid
  1508. if res.Infcode == 0 {
  1509. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1510. if err == gorm.ErrRecordNotFound {
  1511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1512. return
  1513. } else if err != nil {
  1514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1515. return
  1516. } else {
  1517. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1518. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1519. infoStr := string(Iinfos)
  1520. idetinfoStr := string(Idetinfos)
  1521. psn := &models.HisPsn{
  1522. PsnNo: res.Output.Baseinfo.PsnNo,
  1523. Age: res.Output.Baseinfo.Age,
  1524. PatientId: patient.ID,
  1525. Certno: res.Output.Baseinfo.Certno,
  1526. Brdy: res.Output.Baseinfo.Brdy,
  1527. Gend: res.Output.Baseinfo.Gend,
  1528. Naty: res.Output.Baseinfo.Naty,
  1529. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1530. PsnName: res.Output.Baseinfo.PsnName,
  1531. Idetinfo: idetinfoStr,
  1532. Insuinfo: infoStr,
  1533. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1534. CardInfo: card_info,
  1535. VerifyNumber: token,
  1536. }
  1537. service.CreateHisPsn(psn)
  1538. c.ServeSuccessJSON(map[string]interface{}{
  1539. "patient": patient,
  1540. "number": token,
  1541. })
  1542. }
  1543. } else {
  1544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1545. return
  1546. }
  1547. } else { //读卡失败
  1548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1549. return
  1550. }
  1551. }
  1552. break
  1553. }
  1554. }
  1555. var initFlag int64 = 0
  1556. func (c *HisApiController) TestGetBasBaseInit() {
  1557. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1558. Iinit := DllDef.MustFindProc("Init")
  1559. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1560. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  1561. if ret != 0 {
  1562. fmt.Println("SSCard的报错原因:", err)
  1563. fmt.Println("SSCard的运算结果为:", ret)
  1564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1565. return
  1566. }
  1567. result := int(ret)
  1568. fmt.Println("SSCard的运算结果为1:", result)
  1569. initFlag = 1
  1570. return
  1571. }
  1572. func (c *HisApiController) GetSFZBaseInfo() string {
  1573. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1574. readCard := DllDef.MustFindProc("ReadSFZ")
  1575. if readCard == nil {
  1576. fmt.Println("readcard is nil")
  1577. readCard = DllDef.MustFindProc("ReadSFZ")
  1578. }
  1579. str := make([]byte, 256)
  1580. str1 := make([]byte, 256)
  1581. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1582. fmt.Println(r)
  1583. return string(str)
  1584. }
  1585. func (c *HisApiController) GetBasBaseInfo() string {
  1586. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1587. readCard := DllDef.MustFindProc("ReadCardBas")
  1588. if readCard == nil {
  1589. fmt.Println("readcard is nil")
  1590. readCard = DllDef.MustFindProc("ReadCardBas")
  1591. }
  1592. str := make([]byte, 1024)
  1593. str1 := make([]byte, 1024)
  1594. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  1595. fmt.Println(string(str1))
  1596. fmt.Println(string(str))
  1597. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1598. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1599. if ret2 != 0 {
  1600. return ""
  1601. }
  1602. return string(str)
  1603. }
  1604. type CustomFundPay struct {
  1605. FundPayType string `json:"fund_pay_type"`
  1606. FundPayamt float64 `json:"fund_payamt"`
  1607. }
  1608. func (c *HisApiController) GetSettleList() {
  1609. order_id, _ := c.GetInt64("order_id")
  1610. admin_user_id, _ := c.GetInt64("admin_user_id")
  1611. order, _ := service.GetHisOrderByIDTwo(order_id)
  1612. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1613. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1614. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1615. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1616. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1617. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1618. if order.ID == 0 {
  1619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1620. return
  1621. }
  1622. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1623. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1624. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1625. fmt.Println(count)
  1626. var zero string
  1627. number := count + 1
  1628. if number >= 1000 {
  1629. zero = "0000" + strconv.FormatInt(number, 10)
  1630. } else if number >= 10000 {
  1631. zero = "000" + strconv.FormatInt(number, 10)
  1632. } else if number >= 100000 {
  1633. zero = "00" + strconv.FormatInt(number, 10)
  1634. } else if number >= 1000000 {
  1635. zero = "0" + strconv.FormatInt(number, 10)
  1636. } else {
  1637. zero = strconv.FormatInt(number, 10)
  1638. }
  1639. fmt.Println(zero)
  1640. struct4101 := service.Struct4101{
  1641. PsnNo: order.PsnNo,
  1642. MdtrtId: order.MdtrtId,
  1643. SetlId: order.SetlId,
  1644. PsnName: order.PsnName,
  1645. Gend: order.Gend,
  1646. Brdy: his.Brdy,
  1647. Age: his.Age,
  1648. Naty: order.Naty,
  1649. PatnCertType: "01",
  1650. Certno: order.Certno,
  1651. Prfs: "90",
  1652. ConerName: roles[0].UserName,
  1653. PatnRlts: "99",
  1654. ConerAddr: miConfig.OrgName,
  1655. ConerTel: admin.Mobile,
  1656. HiType: order.Insutype,
  1657. Insuplc: miConfig.InsuplcAdmdvs,
  1658. MaindiagFlag: "1",
  1659. BillCode: last_order.FaPiaoCode,
  1660. BillNo: zero,
  1661. BizSn: order.Number,
  1662. PsnSelfPay: order.PsnPartAmt,
  1663. PsnOwnPay: order.PsnPartAmt,
  1664. AcctPay: order.AcctPay,
  1665. PsnCashpay: order.PsnCashPay,
  1666. HiPaymtd: "1",
  1667. Hsorg: miConfig.InsuplcAdmdvs,
  1668. HsorgOpter: miConfig.InsuplcAdmdvs,
  1669. MedinsFillPsn: curRoles.UserName,
  1670. MedinsFillDept: depart.Name,
  1671. IptMedType: "2",
  1672. }
  1673. struct4101.SetlBegnDate = order.SetlTime
  1674. struct4101.SetlEndDate = order.SetlTime
  1675. time_arr := strings.Split(order.SetlTime, " ")
  1676. struct4101.AdmTime = time_arr[0]
  1677. struct4101.AdmEndTime = time_arr[0]
  1678. var rf []CustomFundPay
  1679. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1680. var tempFunPays []service.CustomStruct
  1681. for _, item := range rf {
  1682. var tempFunPay service.CustomStruct
  1683. tempFunPay.FundPayamt = item.FundPayamt
  1684. tempFunPay.FundPayType = item.FundPayType
  1685. tempFunPays = append(tempFunPays, tempFunPay)
  1686. }
  1687. struct4101.CustomStruct = tempFunPays
  1688. var tempDiaginfos []service.DiaginfoStructTwo
  1689. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1690. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1691. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  1692. var config []*models.HisXtDiagnoseConfig
  1693. for _, item := range diagnosis_ids {
  1694. id, _ := strconv.ParseInt(item, 10, 64)
  1695. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1696. config = append(config, &diagnosisConfig)
  1697. }
  1698. for index, item := range config {
  1699. if index == 0 {
  1700. var tempDiaginfo service.DiaginfoStructTwo
  1701. tempDiaginfo.DiagCode = item.CountryCode
  1702. tempDiaginfo.DiagName = item.CountryContentName
  1703. tempDiaginfo.DiagType = "1"
  1704. tempDiaginfo.MaindiagFlag = "1"
  1705. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1706. } else {
  1707. var tempDiaginfo service.DiaginfoStructTwo
  1708. tempDiaginfo.DiagCode = item.CountryCode
  1709. tempDiaginfo.DiagName = item.CountryContentName
  1710. tempDiaginfo.DiagType = "2"
  1711. tempDiaginfo.MaindiagFlag = "0"
  1712. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1713. }
  1714. }
  1715. struct4101.Diseinfo = tempDiaginfos
  1716. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1717. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1718. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1719. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  1720. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  1721. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1722. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1723. var iteminfo service.IteminfoStruct
  1724. var bedCostTotal float64 = 0 //床位总费
  1725. var bedCostSelfTotal float64 = 0 //床位自费
  1726. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1727. var operationCostTotal float64 = 0 //手术费
  1728. var operationCostSelfTotal float64 = 0 //手术费
  1729. var operationCostPartSelfTotal float64 = 0 //手术费
  1730. var otherCostTotal float64 = 0 //其他费用
  1731. var otherCostSelfTotal float64 = 0 //其他费用
  1732. var otherCostPartSelfTotal float64 = 0 //其他费用
  1733. var materialCostTotal float64 = 0 //材料费
  1734. var materialCostSelfTotal float64 = 0 //材料费
  1735. var materialCostPartSelfTotal float64 = 0 //材料费
  1736. var westernMedicineCostTotal float64 = 0 //西药费
  1737. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1738. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1739. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1740. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1741. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1742. var checkCostTotal float64 = 0 //检查费
  1743. var checkCostSelfTotal float64 = 0 //检查费
  1744. var checkCostPartSelfTotal float64 = 0 //检查费
  1745. var laboratoryCostTotal float64 = 0 //化验费
  1746. var laboratoryCostSelfTotal float64 = 0 //化验费
  1747. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1748. var treatCostTotal float64 = 0 //治疗费用
  1749. var treatCostSelfTotal float64 = 0 //治疗费用
  1750. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1751. decimal.DivisionPrecision = 2
  1752. var bed_fulamt_ownpay_amt float64 = 0
  1753. var operation_fulamt_ownpay_amt float64 = 0
  1754. var other_fulamt_ownpay_amt float64 = 0
  1755. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1756. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1757. var check_fulamt_ownpay_amt float64 = 0
  1758. var material_fulamt_ownpay_amt float64 = 0
  1759. var laboratory_fulamt_ownpay_amt float64 = 0
  1760. var treat_fulamt_ownpay_amt float64 = 0
  1761. var bed_claa_sunmfee float64 = 0
  1762. var bed_clab_amt float64 = 0
  1763. var bed_other_amt float64 = 0
  1764. var operation_claa_sunmfee float64 = 0
  1765. var operation_clab_amt float64 = 0
  1766. var operation_other_amt float64 = 0
  1767. var other_claa_sunmfee float64 = 0
  1768. var other_clab_amt float64 = 0
  1769. var other_other_amt float64 = 0
  1770. var westernMedicine_claa_sunmfee float64 = 0
  1771. var westernMedicine_clab_amt float64 = 0
  1772. var westernMedicine_other_amt float64 = 0
  1773. var chineseTraditional_claa_sunmfee float64 = 0
  1774. var chineseTraditional_clab_amt float64 = 0
  1775. var chineseTraditional_other_amt float64 = 0
  1776. var check_claa_sunmfee float64 = 0
  1777. var check_clab_amt float64 = 0
  1778. var check_other_amt float64 = 0
  1779. var material_claa_sunmfee float64 = 0
  1780. var material_clab_amt float64 = 0
  1781. var material_other_amt float64 = 0
  1782. var laboratory_claa_sunmfee float64 = 0
  1783. var laboratory_clab_amt float64 = 0
  1784. var laboratory_other_amt float64 = 0
  1785. var treat_claa_sunmfee float64 = 0
  1786. var treat_clab_amt float64 = 0
  1787. var treat_other_amt float64 = 0
  1788. for _, item := range order.HisOrderInfo {
  1789. if item.MedChrgitmType == "01" { //床位费
  1790. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1791. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1792. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1793. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1794. if item.ChrgitmLv == "1" {
  1795. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1796. }
  1797. if item.ChrgitmLv == "2" {
  1798. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1799. }
  1800. if item.ChrgitmLv == "3" {
  1801. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1802. }
  1803. }
  1804. if item.MedChrgitmType == "03" { //检查费
  1805. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1806. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1807. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1808. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1809. if item.ChrgitmLv == "1" {
  1810. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1811. }
  1812. if item.ChrgitmLv == "2" {
  1813. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1814. }
  1815. if item.ChrgitmLv == "3" {
  1816. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1817. }
  1818. }
  1819. if item.MedChrgitmType == "04" { //化验费
  1820. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1821. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1822. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1823. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1824. if item.ChrgitmLv == "1" {
  1825. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1826. }
  1827. if item.ChrgitmLv == "2" {
  1828. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1829. }
  1830. if item.ChrgitmLv == "3" {
  1831. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1832. }
  1833. }
  1834. if item.MedChrgitmType == "05" { //治疗费
  1835. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1836. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1837. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1838. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1839. if item.ChrgitmLv == "1" {
  1840. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1841. }
  1842. if item.ChrgitmLv == "2" {
  1843. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1844. }
  1845. if item.ChrgitmLv == "3" {
  1846. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1847. }
  1848. }
  1849. if item.MedChrgitmType == "06" { //手术费
  1850. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1851. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1852. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1853. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1854. if item.ChrgitmLv == "1" {
  1855. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1856. }
  1857. if item.ChrgitmLv == "2" {
  1858. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1859. }
  1860. if item.ChrgitmLv == "3" {
  1861. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1862. }
  1863. }
  1864. if item.MedChrgitmType == "08" { //材料费
  1865. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1866. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1867. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1868. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1869. if item.ChrgitmLv == "1" {
  1870. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1871. }
  1872. if item.ChrgitmLv == "2" {
  1873. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1874. }
  1875. if item.ChrgitmLv == "3" {
  1876. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1877. }
  1878. }
  1879. if item.MedChrgitmType == "09" { //西药费
  1880. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1881. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1882. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1883. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1884. if item.ChrgitmLv == "1" {
  1885. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1886. }
  1887. if item.ChrgitmLv == "2" {
  1888. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1889. }
  1890. if item.ChrgitmLv == "3" {
  1891. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1892. }
  1893. }
  1894. if item.MedChrgitmType == "11" { //中成费
  1895. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1896. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1897. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1898. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1899. if item.ChrgitmLv == "1" {
  1900. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1901. }
  1902. if item.ChrgitmLv == "2" {
  1903. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1904. }
  1905. if item.ChrgitmLv == "3" {
  1906. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1907. }
  1908. }
  1909. if item.MedChrgitmType == "14" { //其他费
  1910. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1911. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1912. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1913. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1914. if item.ChrgitmLv == "1" {
  1915. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1916. }
  1917. if item.ChrgitmLv == "2" {
  1918. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1919. }
  1920. if item.ChrgitmLv == "3" {
  1921. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1922. }
  1923. }
  1924. }
  1925. var iteminfoStructs []service.IteminfoStruct
  1926. if bedCostTotal != 0 {
  1927. iteminfo.MedChrgitm = "01"
  1928. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1929. iteminfo.Amt = bedCostTotal
  1930. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1931. iteminfo.ClabAmt = bed_clab_amt
  1932. iteminfo.OthAmt = bed_other_amt
  1933. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1934. }
  1935. if checkCostTotal != 0 {
  1936. iteminfo.MedChrgitm = "03"
  1937. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1938. iteminfo.Amt = checkCostTotal
  1939. iteminfo.ClaaSumfee = check_claa_sunmfee
  1940. iteminfo.ClabAmt = check_clab_amt
  1941. iteminfo.OthAmt = check_other_amt
  1942. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1943. }
  1944. if laboratoryCostTotal != 0 {
  1945. iteminfo.MedChrgitm = "04"
  1946. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1947. iteminfo.Amt = laboratoryCostTotal
  1948. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1949. iteminfo.ClabAmt = laboratory_clab_amt
  1950. iteminfo.OthAmt = laboratory_other_amt
  1951. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1952. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1953. }
  1954. if treatCostTotal != 0 {
  1955. iteminfo.MedChrgitm = "05"
  1956. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1957. iteminfo.Amt = treatCostTotal
  1958. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1959. iteminfo.ClabAmt = treat_clab_amt
  1960. iteminfo.OthAmt = treat_other_amt
  1961. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1962. //(struct4101.IteminfoStruct, iteminfo)
  1963. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1964. }
  1965. if operationCostTotal != 0 {
  1966. iteminfo.MedChrgitm = "06"
  1967. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1968. iteminfo.Amt = operationCostTotal
  1969. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1970. iteminfo.ClabAmt = operation_clab_amt
  1971. iteminfo.OthAmt = operation_other_amt
  1972. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1973. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1974. }
  1975. if materialCostTotal != 0 {
  1976. iteminfo.MedChrgitm = "08"
  1977. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1978. iteminfo.Amt = materialCostTotal
  1979. iteminfo.ClaaSumfee = material_claa_sunmfee
  1980. iteminfo.ClabAmt = material_clab_amt
  1981. iteminfo.OthAmt = material_other_amt
  1982. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1983. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1984. }
  1985. if westernMedicineCostTotal != 0 {
  1986. iteminfo.MedChrgitm = "09"
  1987. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1988. iteminfo.Amt = westernMedicineCostTotal
  1989. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1990. iteminfo.ClabAmt = westernMedicine_clab_amt
  1991. iteminfo.OthAmt = westernMedicine_other_amt
  1992. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1993. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1994. }
  1995. if chineseTraditionalMedicineCostTotal != 0 {
  1996. iteminfo.MedChrgitm = "11"
  1997. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1998. iteminfo.Amt = westernMedicineCostTotal
  1999. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2000. iteminfo.ClabAmt = westernMedicine_clab_amt
  2001. iteminfo.OthAmt = westernMedicine_other_amt
  2002. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2003. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2004. }
  2005. if otherCostTotal != 0 {
  2006. iteminfo.MedChrgitm = "14"
  2007. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2008. iteminfo.Amt = otherCostTotal
  2009. iteminfo.ClaaSumfee = other_claa_sunmfee
  2010. iteminfo.ClabAmt = other_clab_amt
  2011. iteminfo.OthAmt = other_other_amt
  2012. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2013. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2014. }
  2015. struct4101.IteminfoStruct = iteminfoStructs
  2016. struct4101.Ntly = "中国"
  2017. struct4101.AdmCaty = "A03.06"
  2018. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2019. fmt.Println(result)
  2020. var dat map[string]interface{}
  2021. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2022. fmt.Println(dat)
  2023. } else {
  2024. fmt.Println(err)
  2025. }
  2026. userJSONBytes, _ := json.Marshal(dat)
  2027. var res ResultSeventeen
  2028. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2029. utils.ErrorLog("解析失败:%v", err)
  2030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2031. return
  2032. }
  2033. if res.Infcode != 0 {
  2034. c.ServeSuccessJSON(map[string]interface{}{
  2035. "failed_code": -10,
  2036. "msg": res.ErrMsg,
  2037. })
  2038. return
  2039. } else {
  2040. order.FaPiaoNumber = zero
  2041. order.FaPiaoCode = last_order.FaPiaoCode
  2042. service.UpdateOrder(order)
  2043. hisFundSettleListResult := &models.HisFundSettleListResult{
  2044. Number: res.Output.SetlListId,
  2045. Status: 1,
  2046. Ctime: time.Now().Unix(),
  2047. Mtime: time.Now().Unix(),
  2048. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2049. IsUpload: 1,
  2050. OrderId: order_id,
  2051. }
  2052. service.CreateUploadRecord(hisFundSettleListResult)
  2053. c.ServeSuccessJSON(map[string]interface{}{
  2054. "msg": "上传成功",
  2055. "result": hisFundSettleListResult,
  2056. })
  2057. return
  2058. }
  2059. }
  2060. func (c *HisApiController) GetSettleListHospital() {
  2061. order_id, _ := c.GetInt64("order_id")
  2062. admin_user_id, _ := c.GetInt64("admin_user_id")
  2063. order, _ := service.GetHisOrderByIDTwo(order_id)
  2064. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2065. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2066. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2067. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2068. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2069. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2070. if order.ID == 0 {
  2071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2072. return
  2073. }
  2074. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  2075. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  2076. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  2077. fmt.Println(count)
  2078. var zero string
  2079. number := count + 1
  2080. if number >= 1000 {
  2081. zero = "0000" + strconv.FormatInt(number, 10)
  2082. } else if number >= 10000 {
  2083. zero = "000" + strconv.FormatInt(number, 10)
  2084. } else if number >= 100000 {
  2085. zero = "00" + strconv.FormatInt(number, 10)
  2086. } else if number >= 1000000 {
  2087. zero = "0" + strconv.FormatInt(number, 10)
  2088. } else {
  2089. zero = strconv.FormatInt(number, 10)
  2090. }
  2091. fmt.Println(zero)
  2092. struct4101 := service.Struct4101{
  2093. PsnNo: order.PsnNo,
  2094. MdtrtId: order.MdtrtId,
  2095. SetlId: order.SetlId,
  2096. PsnName: order.PsnName,
  2097. Gend: order.Gend,
  2098. Brdy: his.Brdy,
  2099. Age: int64(order.Age),
  2100. Naty: order.Naty,
  2101. PatnCertType: "01",
  2102. Certno: order.Certno,
  2103. Prfs: "90",
  2104. ConerName: roles[0].UserName,
  2105. PatnRlts: "99",
  2106. ConerAddr: miConfig.OrgName,
  2107. ConerTel: admin.Mobile,
  2108. HiType: order.Insutype,
  2109. Insuplc: miConfig.InsuplcAdmdvs,
  2110. MaindiagFlag: "1",
  2111. BillCode: last_order.FaPiaoCode,
  2112. BillNo: zero,
  2113. BizSn: order.Number,
  2114. PsnSelfPay: order.PsnPartAmt,
  2115. PsnOwnPay: order.PsnPartAmt,
  2116. AcctPay: order.AcctPay,
  2117. PsnCashpay: order.PsnCashPay,
  2118. HiPaymtd: "1",
  2119. Hsorg: miConfig.InsuplcAdmdvs,
  2120. HsorgOpter: miConfig.InsuplcAdmdvs,
  2121. MedinsFillPsn: curRoles.UserName,
  2122. MedinsFillDept: depart.Name,
  2123. IptMedType: "2",
  2124. AdmTime: his.InHosptialTime,
  2125. AdmEndTime: his.OutHosptialTime,
  2126. }
  2127. struct4101.SetlBegnDate = order.SetlTime
  2128. struct4101.SetlEndDate = order.SetlTime
  2129. var rf []CustomFundPay
  2130. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2131. var tempFunPays []service.CustomStruct
  2132. for _, item := range rf {
  2133. var tempFunPay service.CustomStruct
  2134. tempFunPay.FundPayamt = item.FundPayamt
  2135. tempFunPay.FundPayType = item.FundPayType
  2136. tempFunPays = append(tempFunPays, tempFunPay)
  2137. }
  2138. struct4101.CustomStruct = tempFunPays
  2139. var tempDiaginfos []service.DiaginfoStructTwo
  2140. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2141. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2142. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2143. var config []*models.HisXtDiagnoseConfig
  2144. for _, item := range diagnosis_ids {
  2145. id, _ := strconv.ParseInt(item, 10, 64)
  2146. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2147. config = append(config, &diagnosisConfig)
  2148. }
  2149. for index, item := range config {
  2150. if index == 0 {
  2151. var tempDiaginfo service.DiaginfoStructTwo
  2152. tempDiaginfo.DiagCode = item.CountryCode
  2153. tempDiaginfo.DiagName = item.CountryContentName
  2154. tempDiaginfo.DiagType = "1"
  2155. tempDiaginfo.MaindiagFlag = "1"
  2156. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2157. } else {
  2158. var tempDiaginfo service.DiaginfoStructTwo
  2159. tempDiaginfo.DiagCode = item.CountryCode
  2160. tempDiaginfo.DiagName = item.CountryContentName
  2161. tempDiaginfo.DiagType = "2"
  2162. tempDiaginfo.MaindiagFlag = "0"
  2163. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2164. }
  2165. }
  2166. struct4101.Diseinfo = tempDiaginfos
  2167. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2168. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2169. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2170. tempOpspdiseinfo2.OprnOprtCode = ""
  2171. tempOpspdiseinfo2.OprnOprtName = ""
  2172. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2173. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2174. var iteminfo service.IteminfoStruct
  2175. var bedCostTotal float64 = 0 //床位总费
  2176. var bedCostSelfTotal float64 = 0 //床位自费
  2177. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2178. var operationCostTotal float64 = 0 //手术费
  2179. var operationCostSelfTotal float64 = 0 //手术费
  2180. var operationCostPartSelfTotal float64 = 0 //手术费
  2181. var otherCostTotal float64 = 0 //其他费用
  2182. var otherCostSelfTotal float64 = 0 //其他费用
  2183. var otherCostPartSelfTotal float64 = 0 //其他费用
  2184. var materialCostTotal float64 = 0 //材料费
  2185. var materialCostSelfTotal float64 = 0 //材料费
  2186. var materialCostPartSelfTotal float64 = 0 //材料费
  2187. var westernMedicineCostTotal float64 = 0 //西药费
  2188. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2189. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2190. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2191. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2192. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2193. var checkCostTotal float64 = 0 //检查费
  2194. var checkCostSelfTotal float64 = 0 //检查费
  2195. var checkCostPartSelfTotal float64 = 0 //检查费
  2196. var laboratoryCostTotal float64 = 0 //化验费
  2197. var laboratoryCostSelfTotal float64 = 0 //化验费
  2198. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2199. var treatCostTotal float64 = 0 //治疗费用
  2200. var treatCostSelfTotal float64 = 0 //治疗费用
  2201. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2202. decimal.DivisionPrecision = 2
  2203. var bed_fulamt_ownpay_amt float64 = 0
  2204. var operation_fulamt_ownpay_amt float64 = 0
  2205. var other_fulamt_ownpay_amt float64 = 0
  2206. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2207. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2208. var check_fulamt_ownpay_amt float64 = 0
  2209. var material_fulamt_ownpay_amt float64 = 0
  2210. var laboratory_fulamt_ownpay_amt float64 = 0
  2211. var treat_fulamt_ownpay_amt float64 = 0
  2212. var bed_claa_sunmfee float64 = 0
  2213. var bed_clab_amt float64 = 0
  2214. var bed_other_amt float64 = 0
  2215. var operation_claa_sunmfee float64 = 0
  2216. var operation_clab_amt float64 = 0
  2217. var operation_other_amt float64 = 0
  2218. var other_claa_sunmfee float64 = 0
  2219. var other_clab_amt float64 = 0
  2220. var other_other_amt float64 = 0
  2221. var westernMedicine_claa_sunmfee float64 = 0
  2222. var westernMedicine_clab_amt float64 = 0
  2223. var westernMedicine_other_amt float64 = 0
  2224. var chineseTraditional_claa_sunmfee float64 = 0
  2225. var chineseTraditional_clab_amt float64 = 0
  2226. var chineseTraditional_other_amt float64 = 0
  2227. var check_claa_sunmfee float64 = 0
  2228. var check_clab_amt float64 = 0
  2229. var check_other_amt float64 = 0
  2230. var material_claa_sunmfee float64 = 0
  2231. var material_clab_amt float64 = 0
  2232. var material_other_amt float64 = 0
  2233. var laboratory_claa_sunmfee float64 = 0
  2234. var laboratory_clab_amt float64 = 0
  2235. var laboratory_other_amt float64 = 0
  2236. var treat_claa_sunmfee float64 = 0
  2237. var treat_clab_amt float64 = 0
  2238. var treat_other_amt float64 = 0
  2239. for _, item := range order.HisOrderInfo {
  2240. if item.MedChrgitmType == "01" { //床位费
  2241. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2242. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2243. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2244. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2245. if item.ChrgitmLv == "1" {
  2246. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2247. }
  2248. if item.ChrgitmLv == "2" {
  2249. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2250. }
  2251. if item.ChrgitmLv == "3" {
  2252. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2253. }
  2254. }
  2255. if item.MedChrgitmType == "03" { //检查费
  2256. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2257. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2258. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2259. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2260. if item.ChrgitmLv == "1" {
  2261. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2262. }
  2263. if item.ChrgitmLv == "2" {
  2264. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2265. }
  2266. if item.ChrgitmLv == "3" {
  2267. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2268. }
  2269. }
  2270. if item.MedChrgitmType == "04" { //化验费
  2271. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2272. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2273. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2274. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2275. if item.ChrgitmLv == "1" {
  2276. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2277. }
  2278. if item.ChrgitmLv == "2" {
  2279. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2280. }
  2281. if item.ChrgitmLv == "3" {
  2282. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2283. }
  2284. }
  2285. if item.MedChrgitmType == "05" { //治疗费
  2286. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2287. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2288. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2289. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2290. if item.ChrgitmLv == "1" {
  2291. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2292. }
  2293. if item.ChrgitmLv == "2" {
  2294. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2295. }
  2296. if item.ChrgitmLv == "3" {
  2297. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2298. }
  2299. }
  2300. if item.MedChrgitmType == "06" { //手术费
  2301. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2302. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2303. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2304. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2305. if item.ChrgitmLv == "1" {
  2306. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2307. }
  2308. if item.ChrgitmLv == "2" {
  2309. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2310. }
  2311. if item.ChrgitmLv == "3" {
  2312. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2313. }
  2314. }
  2315. if item.MedChrgitmType == "08" { //材料费
  2316. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2317. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2318. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2319. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2320. if item.ChrgitmLv == "1" {
  2321. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2322. }
  2323. if item.ChrgitmLv == "2" {
  2324. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2325. }
  2326. if item.ChrgitmLv == "3" {
  2327. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2328. }
  2329. }
  2330. if item.MedChrgitmType == "09" { //西药费
  2331. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2332. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2333. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2334. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2335. if item.ChrgitmLv == "1" {
  2336. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2337. }
  2338. if item.ChrgitmLv == "2" {
  2339. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2340. }
  2341. if item.ChrgitmLv == "3" {
  2342. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2343. }
  2344. }
  2345. if item.MedChrgitmType == "11" { //中成费
  2346. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2347. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2348. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2349. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2350. if item.ChrgitmLv == "1" {
  2351. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2352. }
  2353. if item.ChrgitmLv == "2" {
  2354. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2355. }
  2356. if item.ChrgitmLv == "3" {
  2357. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2358. }
  2359. }
  2360. if item.MedChrgitmType == "14" { //其他费
  2361. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2362. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2363. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2364. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2365. if item.ChrgitmLv == "1" {
  2366. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2367. }
  2368. if item.ChrgitmLv == "2" {
  2369. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2370. }
  2371. if item.ChrgitmLv == "3" {
  2372. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2373. }
  2374. }
  2375. }
  2376. var iteminfoStructs []service.IteminfoStruct
  2377. if bedCostTotal != 0 {
  2378. iteminfo.MedChrgitm = "01"
  2379. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2380. iteminfo.Amt = bedCostTotal
  2381. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2382. iteminfo.ClabAmt = bed_clab_amt
  2383. iteminfo.OthAmt = bed_other_amt
  2384. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2385. }
  2386. if checkCostTotal != 0 {
  2387. iteminfo.MedChrgitm = "03"
  2388. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2389. iteminfo.Amt = checkCostTotal
  2390. iteminfo.ClaaSumfee = check_claa_sunmfee
  2391. iteminfo.ClabAmt = check_clab_amt
  2392. iteminfo.OthAmt = check_other_amt
  2393. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2394. }
  2395. if laboratoryCostTotal != 0 {
  2396. iteminfo.MedChrgitm = "04"
  2397. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2398. iteminfo.Amt = laboratoryCostTotal
  2399. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2400. iteminfo.ClabAmt = laboratory_clab_amt
  2401. iteminfo.OthAmt = laboratory_other_amt
  2402. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2403. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2404. }
  2405. if treatCostTotal != 0 {
  2406. iteminfo.MedChrgitm = "05"
  2407. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2408. iteminfo.Amt = treatCostTotal
  2409. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2410. iteminfo.ClabAmt = treat_clab_amt
  2411. iteminfo.OthAmt = treat_other_amt
  2412. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2413. //(struct4101.IteminfoStruct, iteminfo)
  2414. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2415. }
  2416. if operationCostTotal != 0 {
  2417. iteminfo.MedChrgitm = "06"
  2418. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2419. iteminfo.Amt = operationCostTotal
  2420. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2421. iteminfo.ClabAmt = operation_clab_amt
  2422. iteminfo.OthAmt = operation_other_amt
  2423. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2424. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2425. }
  2426. if materialCostTotal != 0 {
  2427. iteminfo.MedChrgitm = "08"
  2428. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2429. iteminfo.Amt = materialCostTotal
  2430. iteminfo.ClaaSumfee = material_claa_sunmfee
  2431. iteminfo.ClabAmt = material_clab_amt
  2432. iteminfo.OthAmt = material_other_amt
  2433. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2434. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2435. }
  2436. if westernMedicineCostTotal != 0 {
  2437. iteminfo.MedChrgitm = "09"
  2438. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2439. iteminfo.Amt = westernMedicineCostTotal
  2440. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2441. iteminfo.ClabAmt = westernMedicine_clab_amt
  2442. iteminfo.OthAmt = westernMedicine_other_amt
  2443. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2444. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2445. }
  2446. if chineseTraditionalMedicineCostTotal != 0 {
  2447. iteminfo.MedChrgitm = "11"
  2448. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2449. iteminfo.Amt = westernMedicineCostTotal
  2450. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2451. iteminfo.ClabAmt = westernMedicine_clab_amt
  2452. iteminfo.OthAmt = westernMedicine_other_amt
  2453. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2454. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2455. }
  2456. if otherCostTotal != 0 {
  2457. iteminfo.MedChrgitm = "14"
  2458. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2459. iteminfo.Amt = otherCostTotal
  2460. iteminfo.ClaaSumfee = other_claa_sunmfee
  2461. iteminfo.ClabAmt = other_clab_amt
  2462. iteminfo.OthAmt = other_other_amt
  2463. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2464. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2465. }
  2466. struct4101.IteminfoStruct = iteminfoStructs
  2467. struct4101.Ntly = "中国"
  2468. struct4101.AdmCaty = "A03.06"
  2469. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2470. fmt.Println(result)
  2471. var dat map[string]interface{}
  2472. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2473. fmt.Println(dat)
  2474. } else {
  2475. fmt.Println(err)
  2476. }
  2477. userJSONBytes, _ := json.Marshal(dat)
  2478. var res ResultSeventeen
  2479. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2480. utils.ErrorLog("解析失败:%v", err)
  2481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2482. return
  2483. }
  2484. if res.Infcode != 0 {
  2485. c.ServeSuccessJSON(map[string]interface{}{
  2486. "failed_code": -10,
  2487. "msg": res.ErrMsg,
  2488. })
  2489. return
  2490. } else {
  2491. order.FaPiaoNumber = zero
  2492. order.FaPiaoCode = last_order.FaPiaoCode
  2493. service.UpdateOrder(order)
  2494. hisFundSettleListResult := &models.HisFundSettleListResult{
  2495. Number: res.Output.SetlListId,
  2496. Status: 1,
  2497. Ctime: time.Now().Unix(),
  2498. Mtime: time.Now().Unix(),
  2499. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2500. IsUpload: 1,
  2501. OrderId: order_id,
  2502. }
  2503. service.CreateUploadRecord(hisFundSettleListResult)
  2504. c.ServeSuccessJSON(map[string]interface{}{
  2505. "msg": "上传成功",
  2506. "result": hisFundSettleListResult,
  2507. })
  2508. return
  2509. }
  2510. }
  2511. func (c *HisApiController) GetBatchSettleList() {
  2512. orders, _ := service.GetAllHisOrder(10106)
  2513. for _, item := range orders {
  2514. order_id := item.ID
  2515. order, _ := service.GetHisOrderByIDTwo(order_id)
  2516. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2517. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2518. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2519. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  2520. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2521. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2522. if order.ID == 0 {
  2523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2524. return
  2525. }
  2526. if his.BalanceAccountsType == 2 {
  2527. continue
  2528. }
  2529. struct4101 := service.Struct4101{
  2530. PsnNo: order.PsnNo,
  2531. MdtrtId: order.MdtrtId,
  2532. SetlId: order.SetlId,
  2533. PsnName: order.PsnName,
  2534. Gend: order.Gend,
  2535. Brdy: his.Brdy,
  2536. Age: his.Age,
  2537. Naty: order.Naty,
  2538. PatnCertType: "01",
  2539. Certno: order.Certno,
  2540. Prfs: "90",
  2541. ConerName: roles[0].UserName,
  2542. PatnRlts: "99",
  2543. ConerAddr: miConfig.OrgName,
  2544. ConerTel: admin.Mobile,
  2545. HiType: order.Insutype,
  2546. Insuplc: his.InsuplcAdmdvs,
  2547. MaindiagFlag: "1",
  2548. BillCode: order.FaPiaoCode,
  2549. BillNo: order.FaPiaoNumber,
  2550. BizSn: order.Number,
  2551. PsnSelfPay: order.PsnPartAmt,
  2552. PsnOwnPay: order.PsnPartAmt,
  2553. AcctPay: order.AcctPay,
  2554. PsnCashpay: order.PsnCashPay,
  2555. HiPaymtd: "1",
  2556. Hsorg: his.InsuplcAdmdvs,
  2557. HsorgOpter: his.InsuplcAdmdvs,
  2558. MedinsFillPsn: curRoles.UserName,
  2559. MedinsFillDept: depart.Name,
  2560. IptMedType: "2",
  2561. }
  2562. struct4101.SetlBegnDate = order.SetlTime
  2563. struct4101.SetlEndDate = order.SetlTime
  2564. //if order.SettleType == 1 {
  2565. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  2566. // dateStr := t.Format("2006-01-02")
  2567. // struct4101.SetlBegnDate = dateStr
  2568. // struct4101.SetlEndDate = dateStr
  2569. //} else {
  2570. // t := time.Unix(int64(order.SettleStartTime), 0)
  2571. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  2572. // dateStartStr := t.Format("2006-01-02")
  2573. // dateEndStr := t2.Format("2006-01-02")
  2574. // struct4101.SetlBegnDate = dateStartStr
  2575. // struct4101.SetlEndDate = dateEndStr
  2576. //}
  2577. var rf []CustomFundPay
  2578. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2579. var tempFunPays []service.CustomStruct
  2580. var tempFunPay610100 service.CustomStruct
  2581. for _, item := range rf {
  2582. if item.FundPayType == "610100" {
  2583. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  2584. tempFunPay610100.FundPayType = item.FundPayType
  2585. } else {
  2586. var tempFunPay service.CustomStruct
  2587. tempFunPay.FundPayamt = item.FundPayamt
  2588. tempFunPay.FundPayType = item.FundPayType
  2589. tempFunPays = append(tempFunPays, tempFunPay)
  2590. }
  2591. }
  2592. tempFunPays = append(tempFunPays, tempFunPay610100)
  2593. struct4101.CustomStruct = tempFunPays
  2594. var tempDiaginfos []service.DiaginfoStructTwo
  2595. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2596. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2597. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2598. var config []*models.HisXtDiagnoseConfig
  2599. for _, item := range diagnosis_ids {
  2600. id, _ := strconv.ParseInt(item, 10, 64)
  2601. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2602. config = append(config, &diagnosisConfig)
  2603. }
  2604. for index, item := range config {
  2605. if index == 0 {
  2606. var tempDiaginfo service.DiaginfoStructTwo
  2607. tempDiaginfo.DiagCode = item.CountryCode
  2608. tempDiaginfo.DiagName = item.CountryContentName
  2609. tempDiaginfo.DiagType = "1"
  2610. tempDiaginfo.MaindiagFlag = "1"
  2611. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2612. } else {
  2613. var tempDiaginfo service.DiaginfoStructTwo
  2614. tempDiaginfo.DiagCode = item.CountryCode
  2615. tempDiaginfo.DiagName = item.CountryContentName
  2616. tempDiaginfo.DiagType = "2"
  2617. tempDiaginfo.MaindiagFlag = "0"
  2618. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2619. }
  2620. }
  2621. struct4101.Diseinfo = tempDiaginfos
  2622. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2623. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2624. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2625. tempOpspdiseinfo2.OprnOprtCode = ""
  2626. tempOpspdiseinfo2.OprnOprtName = ""
  2627. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2628. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2629. var iteminfo service.IteminfoStruct
  2630. var bedCostTotal float64 = 0 //床位总费
  2631. var bedCostSelfTotal float64 = 0 //床位自费
  2632. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2633. var examineCostTotal float64 = 0 //诊查总费
  2634. var examineCostSelfTotal float64 = 0 //诊查自费
  2635. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  2636. var nursingCostTotal float64 = 0 //护理总费
  2637. var nursingCostSelfTotal float64 = 0 //护理自费
  2638. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  2639. var chineseMedicineCostTotal float64 = 0 //中成药
  2640. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  2641. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  2642. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  2643. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  2644. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  2645. var registerCostTotal float64 = 0 //一般诊疗费
  2646. var registerCostSelfTotal float64 = 0 //一般诊疗费
  2647. var registerPartSelfTotal float64 = 0 //一般诊疗费
  2648. var operationCostTotal float64 = 0 //手术费
  2649. var operationCostSelfTotal float64 = 0 //手术费
  2650. var operationCostPartSelfTotal float64 = 0 //手术费
  2651. var otherCostTotal float64 = 0 //其他费用
  2652. var otherCostSelfTotal float64 = 0 //其他费用
  2653. var otherCostPartSelfTotal float64 = 0 //其他费用
  2654. var materialCostTotal float64 = 0 //材料费
  2655. var materialCostSelfTotal float64 = 0 //材料费
  2656. var materialCostPartSelfTotal float64 = 0 //材料费
  2657. var westernMedicineCostTotal float64 = 0 //西药费
  2658. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2659. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2660. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2661. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2662. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2663. var checkCostTotal float64 = 0 //检查费
  2664. var checkCostSelfTotal float64 = 0 //检查费
  2665. var checkCostPartSelfTotal float64 = 0 //检查费
  2666. var laboratoryCostTotal float64 = 0 //化验费
  2667. var laboratoryCostSelfTotal float64 = 0 //化验费
  2668. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2669. var treatCostTotal float64 = 0 //治疗费用
  2670. var treatCostSelfTotal float64 = 0 //治疗费用
  2671. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2672. decimal.DivisionPrecision = 2
  2673. var bed_fulamt_ownpay_amt float64 = 0
  2674. var examine_fulamt_ownpay_amt float64 = 0
  2675. var nursing_fulamt_ownpay_amt float64 = 0
  2676. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  2677. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  2678. var register_fulamt_ownpay_amt float64 = 0
  2679. var operation_fulamt_ownpay_amt float64 = 0
  2680. var other_fulamt_ownpay_amt float64 = 0
  2681. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2682. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2683. var check_fulamt_ownpay_amt float64 = 0
  2684. var material_fulamt_ownpay_amt float64 = 0
  2685. var laboratory_fulamt_ownpay_amt float64 = 0
  2686. var treat_fulamt_ownpay_amt float64 = 0
  2687. var bed_claa_sunmfee float64 = 0
  2688. var bed_clab_amt float64 = 0
  2689. var bed_other_amt float64 = 0
  2690. var examine_claa_sunmfee float64 = 0
  2691. var examine_clab_amt float64 = 0
  2692. var examine_other_amt float64 = 0
  2693. var nursing_claa_sunmfee float64 = 0
  2694. var nursing_clab_amt float64 = 0
  2695. var nursing_other_amt float64 = 0
  2696. var chinese_medicine_claa_sunmfee float64 = 0
  2697. var chinese_medicine_clab_amt float64 = 0
  2698. var chinese_medicine_other_amt float64 = 0
  2699. var commonly_treatment_claa_sunmfee float64 = 0
  2700. var commonly_treatment_clab_amt float64 = 0
  2701. var commonly_treatment_other_amt float64 = 0
  2702. var operation_claa_sunmfee float64 = 0
  2703. var operation_clab_amt float64 = 0
  2704. var operation_other_amt float64 = 0
  2705. var other_claa_sunmfee float64 = 0
  2706. var other_clab_amt float64 = 0
  2707. var other_other_amt float64 = 0
  2708. var westernMedicine_claa_sunmfee float64 = 0
  2709. var westernMedicine_clab_amt float64 = 0
  2710. var westernMedicine_other_amt float64 = 0
  2711. var chineseTraditional_claa_sunmfee float64 = 0
  2712. var chineseTraditional_clab_amt float64 = 0
  2713. var chineseTraditional_other_amt float64 = 0
  2714. var check_claa_sunmfee float64 = 0
  2715. var check_clab_amt float64 = 0
  2716. var check_other_amt float64 = 0
  2717. var material_claa_sunmfee float64 = 0
  2718. var material_clab_amt float64 = 0
  2719. var material_other_amt float64 = 0
  2720. var laboratory_claa_sunmfee float64 = 0
  2721. var laboratory_clab_amt float64 = 0
  2722. var laboratory_other_amt float64 = 0
  2723. var treat_claa_sunmfee float64 = 0
  2724. var treat_clab_amt float64 = 0
  2725. var treat_other_amt float64 = 0
  2726. var register_claa_sunmfee float64 = 0
  2727. var register_clab_amt float64 = 0
  2728. var register_other_amt float64 = 0
  2729. for _, item := range order.HisOrderInfo {
  2730. if item.MedChrgitmType == "01" { //床位费
  2731. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2732. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2733. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2734. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2735. if item.ChrgitmLv == "1" {
  2736. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2737. }
  2738. if item.ChrgitmLv == "2" {
  2739. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2740. }
  2741. if item.ChrgitmLv == "3" {
  2742. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2743. }
  2744. }
  2745. if item.MedChrgitmType == "02" { //诊查
  2746. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2747. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2748. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2749. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2750. if item.ChrgitmLv == "1" {
  2751. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2752. }
  2753. if item.ChrgitmLv == "2" {
  2754. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2755. }
  2756. if item.ChrgitmLv == "3" {
  2757. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2758. }
  2759. }
  2760. if item.MedChrgitmType == "03" { //检查费
  2761. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2762. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2763. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2764. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2765. if item.ChrgitmLv == "1" {
  2766. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2767. }
  2768. if item.ChrgitmLv == "2" {
  2769. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2770. }
  2771. if item.ChrgitmLv == "3" {
  2772. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2773. }
  2774. }
  2775. if item.MedChrgitmType == "04" { //化验费
  2776. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2777. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2778. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2779. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2780. if item.ChrgitmLv == "1" {
  2781. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2782. }
  2783. if item.ChrgitmLv == "2" {
  2784. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2785. }
  2786. if item.ChrgitmLv == "3" {
  2787. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2788. }
  2789. }
  2790. if item.MedChrgitmType == "05" { //治疗费
  2791. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2792. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2793. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2794. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2795. if item.ChrgitmLv == "1" {
  2796. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2797. }
  2798. if item.ChrgitmLv == "2" {
  2799. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2800. }
  2801. if item.ChrgitmLv == "3" {
  2802. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2803. }
  2804. }
  2805. if item.MedChrgitmType == "06" { //手术费
  2806. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2807. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2808. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2809. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2810. if item.ChrgitmLv == "1" {
  2811. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2812. }
  2813. if item.ChrgitmLv == "2" {
  2814. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2815. }
  2816. if item.ChrgitmLv == "3" {
  2817. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2818. }
  2819. }
  2820. if item.MedChrgitmType == "07" { //手术费
  2821. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2822. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2823. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2824. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2825. if item.ChrgitmLv == "1" {
  2826. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2827. }
  2828. if item.ChrgitmLv == "2" {
  2829. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2830. }
  2831. if item.ChrgitmLv == "3" {
  2832. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2833. }
  2834. }
  2835. if item.MedChrgitmType == "08" { //材料费
  2836. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2837. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2838. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2839. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2840. if item.ChrgitmLv == "1" {
  2841. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2842. }
  2843. if item.ChrgitmLv == "2" {
  2844. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2845. }
  2846. if item.ChrgitmLv == "3" {
  2847. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2848. }
  2849. }
  2850. if item.MedChrgitmType == "09" { //西药费
  2851. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2852. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2853. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2854. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2855. if item.ChrgitmLv == "1" {
  2856. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2857. }
  2858. if item.ChrgitmLv == "2" {
  2859. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2860. }
  2861. if item.ChrgitmLv == "3" {
  2862. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2863. }
  2864. }
  2865. if item.MedChrgitmType == "10" { //中药饮片
  2866. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2867. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2868. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2869. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2870. if item.ChrgitmLv == "1" {
  2871. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2872. }
  2873. if item.ChrgitmLv == "2" {
  2874. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2875. }
  2876. if item.ChrgitmLv == "3" {
  2877. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2878. }
  2879. }
  2880. if item.MedChrgitmType == "11" { //中成费
  2881. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2882. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2883. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2884. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2885. if item.ChrgitmLv == "1" {
  2886. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2887. }
  2888. if item.ChrgitmLv == "2" {
  2889. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2890. }
  2891. if item.ChrgitmLv == "3" {
  2892. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2893. }
  2894. }
  2895. if item.MedChrgitmType == "12" { //中成费
  2896. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2897. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2898. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2899. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2900. if item.ChrgitmLv == "1" {
  2901. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2902. }
  2903. if item.ChrgitmLv == "2" {
  2904. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2905. }
  2906. if item.ChrgitmLv == "3" {
  2907. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2908. }
  2909. }
  2910. if item.MedChrgitmType == "13" { //中成费
  2911. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2912. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2913. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2914. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2915. if item.ChrgitmLv == "1" {
  2916. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2917. }
  2918. if item.ChrgitmLv == "2" {
  2919. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2920. }
  2921. if item.ChrgitmLv == "3" {
  2922. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2923. }
  2924. }
  2925. if item.MedChrgitmType == "14" { //其他费
  2926. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2927. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2928. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2929. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2930. if item.ChrgitmLv == "1" {
  2931. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2932. }
  2933. if item.ChrgitmLv == "2" {
  2934. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2935. }
  2936. if item.ChrgitmLv == "3" {
  2937. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2938. }
  2939. }
  2940. }
  2941. var iteminfoStructs []service.IteminfoStruct
  2942. if bedCostTotal != 0 {
  2943. iteminfo.MedChrgitm = "01"
  2944. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2945. iteminfo.Amt = bedCostTotal
  2946. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2947. iteminfo.ClabAmt = bed_clab_amt
  2948. iteminfo.OthAmt = bed_other_amt
  2949. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2950. }
  2951. if examineCostTotal != 0 {
  2952. iteminfo.MedChrgitm = "02"
  2953. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  2954. iteminfo.Amt = examineCostTotal
  2955. iteminfo.ClaaSumfee = examine_claa_sunmfee
  2956. iteminfo.ClabAmt = examine_clab_amt
  2957. iteminfo.OthAmt = examine_other_amt
  2958. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2959. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2960. }
  2961. if checkCostTotal != 0 {
  2962. iteminfo.MedChrgitm = "03"
  2963. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2964. iteminfo.Amt = checkCostTotal
  2965. iteminfo.ClaaSumfee = check_claa_sunmfee
  2966. iteminfo.ClabAmt = check_clab_amt
  2967. iteminfo.OthAmt = check_other_amt
  2968. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2969. }
  2970. if laboratoryCostTotal != 0 {
  2971. iteminfo.MedChrgitm = "04"
  2972. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2973. iteminfo.Amt = laboratoryCostTotal
  2974. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2975. iteminfo.ClabAmt = laboratory_clab_amt
  2976. iteminfo.OthAmt = laboratory_other_amt
  2977. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2978. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2979. }
  2980. if treatCostTotal != 0 {
  2981. iteminfo.MedChrgitm = "05"
  2982. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2983. iteminfo.Amt = treatCostTotal
  2984. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2985. iteminfo.ClabAmt = treat_clab_amt
  2986. iteminfo.OthAmt = treat_other_amt
  2987. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2988. //(struct4101.IteminfoStruct, iteminfo)
  2989. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2990. }
  2991. if operationCostTotal != 0 {
  2992. iteminfo.MedChrgitm = "06"
  2993. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2994. iteminfo.Amt = operationCostTotal
  2995. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2996. iteminfo.ClabAmt = operation_clab_amt
  2997. iteminfo.OthAmt = operation_other_amt
  2998. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2999. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3000. }
  3001. if nursingCostTotal != 0 {
  3002. iteminfo.MedChrgitm = "07"
  3003. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  3004. iteminfo.Amt = nursingCostTotal
  3005. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  3006. iteminfo.ClabAmt = nursing_clab_amt
  3007. iteminfo.OthAmt = nursing_other_amt
  3008. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3009. }
  3010. if materialCostTotal != 0 {
  3011. iteminfo.MedChrgitm = "08"
  3012. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3013. iteminfo.Amt = materialCostTotal
  3014. iteminfo.ClaaSumfee = material_claa_sunmfee
  3015. iteminfo.ClabAmt = material_clab_amt
  3016. iteminfo.OthAmt = material_other_amt
  3017. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3018. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3019. }
  3020. if westernMedicineCostTotal != 0 {
  3021. iteminfo.MedChrgitm = "09"
  3022. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3023. iteminfo.Amt = westernMedicineCostTotal
  3024. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3025. iteminfo.ClabAmt = westernMedicine_clab_amt
  3026. iteminfo.OthAmt = westernMedicine_other_amt
  3027. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3028. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3029. }
  3030. if chineseMedicineCostTotal != 0 {
  3031. iteminfo.MedChrgitm = "10"
  3032. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  3033. iteminfo.Amt = chineseMedicineCostTotal
  3034. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  3035. iteminfo.ClabAmt = chinese_medicine_clab_amt
  3036. iteminfo.OthAmt = chinese_medicine_other_amt
  3037. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3038. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3039. }
  3040. if chineseTraditionalMedicineCostTotal != 0 {
  3041. iteminfo.MedChrgitm = "11"
  3042. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3043. iteminfo.Amt = westernMedicineCostTotal
  3044. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3045. iteminfo.ClabAmt = westernMedicine_clab_amt
  3046. iteminfo.OthAmt = westernMedicine_other_amt
  3047. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3048. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3049. }
  3050. if commonlyTreatmentCostTotal != 0 {
  3051. iteminfo.MedChrgitm = "12"
  3052. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  3053. iteminfo.Amt = commonlyTreatmentCostTotal
  3054. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  3055. iteminfo.ClabAmt = commonly_treatment_clab_amt
  3056. iteminfo.OthAmt = commonly_treatment_other_amt
  3057. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3058. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3059. }
  3060. if registerCostTotal != 0 {
  3061. iteminfo.MedChrgitm = "13"
  3062. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  3063. iteminfo.Amt = registerCostTotal
  3064. iteminfo.ClaaSumfee = register_claa_sunmfee
  3065. iteminfo.ClabAmt = register_clab_amt
  3066. iteminfo.OthAmt = register_other_amt
  3067. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3068. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3069. }
  3070. if otherCostTotal != 0 {
  3071. iteminfo.MedChrgitm = "14"
  3072. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3073. iteminfo.Amt = otherCostTotal
  3074. iteminfo.ClaaSumfee = other_claa_sunmfee
  3075. iteminfo.ClabAmt = other_clab_amt
  3076. iteminfo.OthAmt = other_other_amt
  3077. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3078. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3079. }
  3080. struct4101.IteminfoStruct = iteminfoStructs
  3081. struct4101.Ntly = "中国"
  3082. struct4101.AdmCaty = "A03.06"
  3083. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  3084. fmt.Println(result)
  3085. var dat map[string]interface{}
  3086. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3087. fmt.Println(dat)
  3088. } else {
  3089. fmt.Println(err)
  3090. }
  3091. userJSONBytes, _ := json.Marshal(dat)
  3092. var res ResultSeventeen
  3093. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3094. utils.ErrorLog("解析失败:%v", err)
  3095. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3096. adminUser := c.GetAdminUserInfo()
  3097. errlog := &models.HisOrderError{
  3098. UserOrgId: adminUser.CurrentOrgId,
  3099. Ctime: time.Now().Unix(),
  3100. Mtime: time.Now().Unix(),
  3101. ErrMsg: res.ErrMsg + "解析失败",
  3102. Status: 1,
  3103. PatientId: order_id,
  3104. Stage: 10106,
  3105. }
  3106. service.CreateErrMsgLog(errlog)
  3107. continue
  3108. }
  3109. if res.Infcode != 0 {
  3110. adminUser := c.GetAdminUserInfo()
  3111. errlog := &models.HisOrderError{
  3112. UserOrgId: adminUser.CurrentOrgId,
  3113. Ctime: time.Now().Unix(),
  3114. Mtime: time.Now().Unix(),
  3115. ErrMsg: res.ErrMsg,
  3116. Status: 1,
  3117. PatientId: order_id,
  3118. Stage: 10106,
  3119. }
  3120. service.CreateErrMsgLog(errlog)
  3121. continue
  3122. } else {
  3123. hisFundSettleListResult := &models.HisFundSettleListResult{
  3124. Number: res.Output.SetlListId,
  3125. Status: 1,
  3126. Ctime: time.Now().Unix(),
  3127. Mtime: time.Now().Unix(),
  3128. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3129. IsUpload: 1,
  3130. OrderId: order_id,
  3131. }
  3132. service.CreateUploadRecord(hisFundSettleListResult)
  3133. continue
  3134. }
  3135. }
  3136. }
  3137. func (c *HisApiController) GetOrgInfo() {
  3138. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  3139. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  3140. }
  3141. func (c *HisApiController) GetHisPatientInfo() {
  3142. medical_insurance_card := c.GetString("medical_insurance_card")
  3143. id_card_type, _ := c.GetInt64("id_card_type")
  3144. id_card := c.GetString("id_card")
  3145. adminInfo := c.GetAdminUserInfo()
  3146. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3147. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3148. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  3149. IdCardNo := ""
  3150. if id_card_type == 1 {
  3151. IdCardNo = medical_insurance_card
  3152. } else if id_card_type == 2 {
  3153. IdCardNo = id_card
  3154. }
  3155. if config.IsOpen == 1 {
  3156. 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
  3157. resp, requestErr := http.Get(api)
  3158. if requestErr != nil {
  3159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3160. return
  3161. }
  3162. defer resp.Body.Close()
  3163. body, ioErr := ioutil.ReadAll(resp.Body)
  3164. if ioErr != nil {
  3165. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3167. return
  3168. }
  3169. var respJSON map[string]interface{}
  3170. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3171. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3173. return
  3174. }
  3175. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3176. userJSONBytes, _ := json.Marshal(userJSON)
  3177. var res ResultTwo
  3178. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3179. utils.ErrorLog("解析失败:%v", err)
  3180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3181. return
  3182. }
  3183. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3184. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3185. infoStr := string(Iinfos)
  3186. idetinfoStr := string(Idetinfos)
  3187. if res.Infcode == 0 {
  3188. his := models.VMHisPatient{
  3189. Status: 1,
  3190. Ctime: time.Now().Unix(),
  3191. Mtime: time.Now().Unix(),
  3192. PsnNo: res.Output.Baseinfo.PsnNo,
  3193. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3194. Certno: res.Output.Baseinfo.Certno,
  3195. PsnName: res.Output.Baseinfo.PsnName,
  3196. Gend: res.Output.Baseinfo.Gend,
  3197. Naty: res.Output.Baseinfo.Naty,
  3198. Brdy: res.Output.Baseinfo.Brdy,
  3199. Age: res.Output.Baseinfo.Age,
  3200. Iinfo: infoStr,
  3201. Idetinfo: idetinfoStr,
  3202. UserOrgId: adminInfo.CurrentOrgId,
  3203. IsReturn: 1,
  3204. IdCardType: id_card_type,
  3205. }
  3206. c.ServeSuccessJSON(map[string]interface{}{
  3207. "info": his,
  3208. })
  3209. } else {
  3210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3211. return
  3212. }
  3213. }
  3214. }
  3215. //func GetBasBaseInfo() (jsonStr string, err error) {
  3216. //
  3217. // handle := syscall.NewLazyDLL("SSCard.dll")
  3218. // add := handle.NewProc("ReadCardBas")
  3219. // str := make([]byte, 1024)
  3220. // str1 := make([]byte, 1024)
  3221. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3222. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3223. //
  3224. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3225. //
  3226. // fmt.Println("> Add(4,5)的结果为:", ret)
  3227. // handle.Release()
  3228. //
  3229. // return "", nil
  3230. //
  3231. //}
  3232. //func GetQRBaseInfo() (jsonStr string, err error) {
  3233. // handle := syscall.LoadDLL("SSCard.dll")
  3234. // ReadCardBas := handle.FindProc("GetQRBase")
  3235. //
  3236. // str := make([]byte, 256)
  3237. // str1 := make([]byte, 256)
  3238. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3239. //
  3240. // fmt.Println(string(str))
  3241. // fmt.Println(r)
  3242. // return string(str), nil
  3243. //}
  3244. //func CardInit() int {
  3245. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  3246. // add := DllTestDef.MustFindProc("Init")
  3247. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3248. // if err != nil {
  3249. // fmt.Println("SSCard的运算结果为:", ret)
  3250. // }
  3251. // result := int(ret)
  3252. // return result
  3253. //}
  3254. //func CardInit() int {
  3255. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3256. // if err != nil {
  3257. // fmt.Println("SSCard的运算结果为:", ret)
  3258. // }
  3259. // fmt.Println(err)
  3260. // result := int(ret)
  3261. // return result
  3262. //}
  3263. func IntPtr(n int) uintptr {
  3264. return uintptr(n)
  3265. }
  3266. func StrPtr(s string) uintptr {
  3267. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3268. }
  3269. type Result2001 struct {
  3270. Cainfo interface{} `json:"cainfo"`
  3271. ErrMsg string `json:"err_msg"`
  3272. InfRefmsgid string `json:"inf_refmsgid"`
  3273. Infcode int64 `json:"infcode"`
  3274. Output struct {
  3275. Trtinfo struct {
  3276. PsnNo string `json:"psn_no"`
  3277. TrtChkType string `json:"trt_chk_type"`
  3278. FundPayType string `json:"fund_pay_type"`
  3279. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3280. Begndate string `json:"begndate"`
  3281. Enddate string `json:"enddate"`
  3282. TrtChkRslt string `json:"trt_chk_rslt"`
  3283. } `json:"trtinfo"`
  3284. } `json:"output"`
  3285. RefmsgTime string `json:"refmsg_time"`
  3286. RespondTime string `json:"respond_time"`
  3287. Signtype interface{} `json:"signtype"`
  3288. WarnMsg interface{} `json:"warn_msg"`
  3289. }
  3290. type Result2001Org10265 struct {
  3291. Cainfo interface{} `json:"cainfo"`
  3292. ErrMsg string `json:"err_msg"`
  3293. InfRefmsgid string `json:"inf_refmsgid"`
  3294. Infcode string `json:"infcode"`
  3295. Output struct {
  3296. Trtinfo struct {
  3297. PsnNo string `json:"psn_no"`
  3298. TrtChkType string `json:"trt_chk_type"`
  3299. FundPayType string `json:"fund_pay_type"`
  3300. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3301. Begndate string `json:"begndate"`
  3302. Enddate string `json:"enddate"`
  3303. TrtChkRslt string `json:"trt_chk_rslt"`
  3304. } `json:"trtinfo"`
  3305. } `json:"output"`
  3306. RefmsgTime string `json:"refmsg_time"`
  3307. RespondTime string `json:"respond_time"`
  3308. Signtype interface{} `json:"signtype"`
  3309. WarnMsg interface{} `json:"warn_msg"`
  3310. }
  3311. type ResultTwo struct {
  3312. ErrMsg string `json:"err_msg"`
  3313. InfRefmsgid string `json:"inf_refmsgid"`
  3314. Infcode int64 `json:"infcode"`
  3315. Output struct {
  3316. Baseinfo struct {
  3317. Age float64 `json:"age"`
  3318. Brdy string `json:"brdy"`
  3319. Certno string `json:"certno"`
  3320. Gend string `json:"gend"`
  3321. Naty string `json:"naty"`
  3322. PsnCertType string `json:"psn_cert_type"`
  3323. PsnName string `json:"psn_name"`
  3324. PsnNo string `json:"psn_no"`
  3325. } `json:"baseinfo"`
  3326. Idetinfo []interface{} `json:"idetinfo"`
  3327. Iinfo []struct {
  3328. Balc float64 `json:"balc"`
  3329. CvlservFlag string `json:"cvlserv_flag"`
  3330. EmpName string `json:"emp_name"`
  3331. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3332. Insutype string `json:"insutype"`
  3333. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3334. PausInsuDate string `json:"paus_insu_date"`
  3335. PsnInsuDate string `json:"psn_insu_date"`
  3336. PsnInsuStas string `json:"psn_insu_stas"`
  3337. PsnType string `json:"psn_type"`
  3338. } `json:"insuinfo"`
  3339. } `json:"output"`
  3340. RefmsgTime string `json:"refmsg_time"`
  3341. RespondTime string `json:"respond_time"`
  3342. Signtype interface{} `json:"signtype"`
  3343. WarnInfo interface{} `json:"warn_info"`
  3344. }
  3345. type ResultTwo10265 struct {
  3346. ErrMsg string `json:"err_msg"`
  3347. InfRefmsgid string `json:"inf_refmsgid"`
  3348. Infcode string `json:"infcode"`
  3349. Output struct {
  3350. Baseinfo struct {
  3351. Age float64 `json:"age"`
  3352. Brdy string `json:"brdy"`
  3353. Certno string `json:"certno"`
  3354. Gend string `json:"gend"`
  3355. Naty string `json:"naty"`
  3356. PsnCertType string `json:"psn_cert_type"`
  3357. PsnName string `json:"psn_name"`
  3358. PsnNo string `json:"psn_no"`
  3359. } `json:"baseinfo"`
  3360. Idetinfo []interface{} `json:"idetinfo"`
  3361. Iinfo []struct {
  3362. Balc float64 `json:"balc"`
  3363. CvlservFlag string `json:"cvlserv_flag"`
  3364. EmpName string `json:"emp_name"`
  3365. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3366. Insutype string `json:"insutype"`
  3367. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3368. PausInsuDate string `json:"paus_insu_date"`
  3369. PsnInsuDate string `json:"psn_insu_date"`
  3370. PsnInsuStas string `json:"psn_insu_stas"`
  3371. PsnType string `json:"psn_type"`
  3372. } `json:"insuinfo"`
  3373. } `json:"output"`
  3374. RefmsgTime string `json:"refmsg_time"`
  3375. RespondTime string `json:"respond_time"`
  3376. Signtype interface{} `json:"signtype"`
  3377. WarnInfo interface{} `json:"warn_info"`
  3378. }
  3379. type ResultThree struct {
  3380. Cainfo interface{} `json:"cainfo"`
  3381. ErrMsg string `json:"err_msg"`
  3382. InfRefmsgid string `json:"inf_refmsgid"`
  3383. Infcode int64 `json:"infcode"`
  3384. Output struct {
  3385. Data struct {
  3386. IptOtpNo string `json:"ipt_otp_no"`
  3387. MdtrtID string `json:"mdtrt_id"`
  3388. PsnNo string `json:"psn_no"`
  3389. } `json:"data"`
  3390. } `json:"output"`
  3391. RefmsgTime string `json:"refmsg_time"`
  3392. RespondTime string `json:"respond_time"`
  3393. Signtype interface{} `json:"signtype"`
  3394. WarnMsg interface{} `json:"warn_msg"`
  3395. }
  3396. type ResultThree10265 struct {
  3397. Cainfo interface{} `json:"cainfo"`
  3398. ErrMsg string `json:"err_msg"`
  3399. InfRefmsgid string `json:"inf_refmsgid"`
  3400. Infcode string `json:"infcode"`
  3401. Output struct {
  3402. Data struct {
  3403. IptOtpNo string `json:"ipt_otp_no"`
  3404. MdtrtID string `json:"mdtrt_id"`
  3405. PsnNo string `json:"psn_no"`
  3406. } `json:"data"`
  3407. } `json:"output"`
  3408. RefmsgTime string `json:"refmsg_time"`
  3409. RespondTime string `json:"respond_time"`
  3410. Signtype interface{} `json:"signtype"`
  3411. WarnMsg interface{} `json:"warn_msg"`
  3412. }
  3413. type ResultFour struct {
  3414. Cainfo string `json:"cainfo"`
  3415. ErrMsg string `json:"err_msg"`
  3416. InfRefmsgid string `json:"inf_refmsgid"`
  3417. Infcode int64 `json:"infcode"`
  3418. Output struct {
  3419. Result []struct {
  3420. BasMednFlag string `json:"bas_medn_flag"`
  3421. ChldMedcFlag string `json:"chld_medc_flag"`
  3422. ChrgitmLv string `json:"chrgitm_lv"`
  3423. Cnt float64 `json:"cnt"`
  3424. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3425. DrtReimFlag string `json:"drt_reim_flag"`
  3426. FeedetlSn string `json:"feedetl_sn"`
  3427. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3428. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3429. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3430. ListSpItemFlag string `json:"list_sp_item_flag"`
  3431. LmtUsedFlag string `json:"lmt_used_flag"`
  3432. MedChrgitmType string `json:"med_chrgitm_type"`
  3433. Memo string `json:"memo"`
  3434. OverlmtAmt float64 `json:"overlmt_amt"`
  3435. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3436. Pric float64 `json:"pric"`
  3437. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3438. SelfpayProp float64 `json:"selfpay_prop"`
  3439. } `json:"result"`
  3440. } `json:"output"`
  3441. RefmsgTime string `json:"refmsg_time"`
  3442. RespondTime string `json:"respond_time"`
  3443. Signtype string `json:"signtype"`
  3444. WarnMsg string `json:"warn_msg"`
  3445. }
  3446. type ResultFour10265 struct {
  3447. Cainfo string `json:"cainfo"`
  3448. ErrMsg string `json:"err_msg"`
  3449. InfRefmsgid string `json:"inf_refmsgid"`
  3450. Infcode string `json:"infcode"`
  3451. Output struct {
  3452. Result []struct {
  3453. BasMednFlag string `json:"bas_medn_flag"`
  3454. ChldMedcFlag string `json:"chld_medc_flag"`
  3455. ChrgitmLv string `json:"chrgitm_lv"`
  3456. Cnt float64 `json:"cnt"`
  3457. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3458. DrtReimFlag string `json:"drt_reim_flag"`
  3459. FeedetlSn string `json:"feedetl_sn"`
  3460. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3461. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3462. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3463. ListSpItemFlag string `json:"list_sp_item_flag"`
  3464. LmtUsedFlag string `json:"lmt_used_flag"`
  3465. MedChrgitmType string `json:"med_chrgitm_type"`
  3466. Memo string `json:"memo"`
  3467. OverlmtAmt float64 `json:"overlmt_amt"`
  3468. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3469. Pric float64 `json:"pric"`
  3470. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3471. SelfpayProp float64 `json:"selfpay_prop"`
  3472. } `json:"result"`
  3473. } `json:"output"`
  3474. RefmsgTime string `json:"refmsg_time"`
  3475. RespondTime string `json:"respond_time"`
  3476. Signtype string `json:"signtype"`
  3477. WarnMsg string `json:"warn_msg"`
  3478. }
  3479. type ResultFive struct {
  3480. Balc float64 `json:"balc"`
  3481. CvlservFlag string `json:"cvlserv_flag"`
  3482. EmpName string `json:"emp_name"`
  3483. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3484. Insutype string `json:"insutype"`
  3485. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3486. PausInsuDate string `json:"paus_insu_date"`
  3487. PsnInsuDate string `json:"psn_insu_date"`
  3488. PsnInsuStas string `json:"psn_insu_stas"`
  3489. PsnType string `json:"psn_type"`
  3490. }
  3491. type ResultSix struct {
  3492. Cainfo interface{} `json:"cainfo"`
  3493. ErrMsg string `json:"err_msg"`
  3494. InfRefmsgid string `json:"inf_refmsgid"`
  3495. Infcode int64 `json:"infcode"`
  3496. Output struct {
  3497. } `json:"output"`
  3498. RefmsgTime string `json:"refmsg_time"`
  3499. RespondTime string `json:"respond_time"`
  3500. Signtype interface{} `json:"signtype"`
  3501. WarnMsg interface{} `json:"warn_msg"`
  3502. }
  3503. type ResultSix10265 struct {
  3504. Cainfo interface{} `json:"cainfo"`
  3505. ErrMsg string `json:"err_msg"`
  3506. InfRefmsgid string `json:"inf_refmsgid"`
  3507. Infcode string `json:"infcode"`
  3508. Output struct {
  3509. } `json:"output"`
  3510. RefmsgTime string `json:"refmsg_time"`
  3511. RespondTime string `json:"respond_time"`
  3512. Signtype interface{} `json:"signtype"`
  3513. WarnMsg interface{} `json:"warn_msg"`
  3514. }
  3515. type ResultSeven struct {
  3516. Cainfo string `json:"cainfo"`
  3517. ErrMsg string `json:"err_msg"`
  3518. InfRefmsgid string `json:"inf_refmsgid"`
  3519. Infcode int64 `json:"infcode"`
  3520. Output struct {
  3521. Setldetail []interface{} `json:"setldetail"`
  3522. Setlinfo struct {
  3523. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3524. AcctPay float64 `json:"acct_pay"`
  3525. ActPayDedc float64 `json:"act_pay_dedc"`
  3526. Age float64 `json:"age"`
  3527. Balc float64 `json:"balc"`
  3528. Brdy string `json:"brdy"`
  3529. Certno string `json:"certno"`
  3530. ClrOptins string `json:"clr_optins"`
  3531. ClrType string `json:"clr_type"`
  3532. ClrWay string `json:"clr_way"`
  3533. CvlservFlag string `json:"cvlserv_flag"`
  3534. CvlservPay float64 `json:"cvlserv_pay"`
  3535. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3536. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3537. Gend string `json:"gend"`
  3538. HifesPay float64 `json:"hifes_pay"`
  3539. HifmiPay float64 `json:"hifmi_pay"`
  3540. HifpPay float64 `json:"hifp_pay"`
  3541. HospPartAmt float64 `json:"hosp_part_amt"`
  3542. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3543. Insutype string `json:"insutype"`
  3544. MafPay float64 `json:"maf_pay"`
  3545. MdtrtCertType string `json:"mdtrt_cert_type"`
  3546. HifobPay float64 `json:"hifob_pay"`
  3547. MdtrtID string `json:"mdtrt_id"`
  3548. MedType string `json:"med_type"`
  3549. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3550. MedinsSetlID string `json:"medins_setl_id"`
  3551. Naty string `json:"naty"`
  3552. OthPay float64 `json:"oth_pay"`
  3553. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3554. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3555. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3556. PsnCashPay float64 `json:"psn_cash_pay"`
  3557. PsnCertType string `json:"psn_cert_type"`
  3558. PsnName string `json:"psn_name"`
  3559. PsnNo string `json:"psn_no"`
  3560. PsnPartAmt float64 `json:"psn_part_amt"`
  3561. PsnType string `json:"psn_type"`
  3562. SetlID string `json:"setl_id"`
  3563. SetlTime string `json:"setl_time"`
  3564. } `json:"setlinfo"`
  3565. } `json:"output"`
  3566. RefmsgTime string `json:"refmsg_time"`
  3567. RespondTime string `json:"respond_time"`
  3568. Signtype interface{} `json:"signtype"`
  3569. WarnMsg interface{} `json:"warn_msg"`
  3570. }
  3571. type ResultSeven10265 struct {
  3572. Cainfo string `json:"cainfo"`
  3573. ErrMsg string `json:"err_msg"`
  3574. InfRefmsgid string `json:"inf_refmsgid"`
  3575. Infcode string `json:"infcode"`
  3576. Output struct {
  3577. Setldetail []interface{} `json:"setldetail"`
  3578. Setlinfo struct {
  3579. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3580. AcctPay float64 `json:"acct_pay"`
  3581. ActPayDedc float64 `json:"act_pay_dedc"`
  3582. Age float64 `json:"age"`
  3583. Balc float64 `json:"balc"`
  3584. Brdy string `json:"brdy"`
  3585. Certno string `json:"certno"`
  3586. ClrOptins string `json:"clr_optins"`
  3587. ClrType string `json:"clr_type"`
  3588. ClrWay string `json:"clr_way"`
  3589. CvlservFlag string `json:"cvlserv_flag"`
  3590. CvlservPay float64 `json:"cvlserv_pay"`
  3591. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3592. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3593. Gend string `json:"gend"`
  3594. HifesPay float64 `json:"hifes_pay"`
  3595. HifmiPay float64 `json:"hifmi_pay"`
  3596. HifpPay float64 `json:"hifp_pay"`
  3597. HospPartAmt float64 `json:"hosp_part_amt"`
  3598. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3599. Insutype string `json:"insutype"`
  3600. MafPay float64 `json:"maf_pay"`
  3601. MdtrtCertType string `json:"mdtrt_cert_type"`
  3602. HifobPay float64 `json:"hifob_pay"`
  3603. MdtrtID string `json:"mdtrt_id"`
  3604. MedType string `json:"med_type"`
  3605. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3606. MedinsSetlID string `json:"medins_setl_id"`
  3607. Naty string `json:"naty"`
  3608. OthPay float64 `json:"oth_pay"`
  3609. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3610. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3611. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3612. PsnCashPay float64 `json:"psn_cash_pay"`
  3613. PsnCertType string `json:"psn_cert_type"`
  3614. PsnName string `json:"psn_name"`
  3615. PsnNo string `json:"psn_no"`
  3616. PsnPartAmt float64 `json:"psn_part_amt"`
  3617. PsnType string `json:"psn_type"`
  3618. SetlID string `json:"setl_id"`
  3619. SetlTime string `json:"setl_time"`
  3620. } `json:"setlinfo"`
  3621. } `json:"output"`
  3622. RefmsgTime string `json:"refmsg_time"`
  3623. RespondTime string `json:"respond_time"`
  3624. Signtype interface{} `json:"signtype"`
  3625. WarnMsg interface{} `json:"warn_msg"`
  3626. }
  3627. type ResultEight struct {
  3628. Cainfo string `json:"cainfo"`
  3629. ErrMsg string `json:"err_msg"`
  3630. InfRefmsgid string `json:"inf_refmsgid"`
  3631. Infcode int64 `json:"infcode"`
  3632. Output struct {
  3633. Stmtinfo struct {
  3634. SetlOptins string `json:"setl_optins"`
  3635. StmtRslt string `json:"stmt_rslt"`
  3636. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3637. } `json:"stmtinfo"`
  3638. } `json:"output"`
  3639. RefmsgTime string `json:"refmsg_time"`
  3640. RespondTime string `json:"respond_time"`
  3641. Signtype interface{} `json:"signtype"`
  3642. WarnMsg interface{} `json:"warn_msg"`
  3643. }
  3644. type ResultEightFor10188 struct {
  3645. Cainfo string `json:"cainfo"`
  3646. ErrMsg string `json:"err_msg"`
  3647. InfRefmsgid string `json:"inf_refmsgid"`
  3648. Infcode string `json:"infcode"`
  3649. Output struct {
  3650. Stmtinfo struct {
  3651. SetlOptins string `json:"setl_optins"`
  3652. StmtRslt string `json:"stmt_rslt"`
  3653. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3654. } `json:"stmtinfo"`
  3655. } `json:"output"`
  3656. RefmsgTime string `json:"refmsg_time"`
  3657. RespondTime string `json:"respond_time"`
  3658. Signtype interface{} `json:"signtype"`
  3659. WarnMsg interface{} `json:"warn_msg"`
  3660. }
  3661. type ResultNine struct {
  3662. Cainfo string `json:"cainfo"`
  3663. ErrMsg string `json:"err_msg"`
  3664. InfRefmsgid string `json:"inf_refmsgid"`
  3665. Infcode int64 `json:"infcode"`
  3666. Output struct {
  3667. FileQuryNo string `json:"file_qury_no"`
  3668. } `json:"output"`
  3669. RefmsgTime string `json:"refmsg_time"`
  3670. RespondTime string `json:"respond_time"`
  3671. Signtype interface{} `json:"signtype"`
  3672. WarnMsg interface{} `json:"warn_msg"`
  3673. }
  3674. type ResultTen struct {
  3675. Cainfo string `json:"cainfo"`
  3676. ErrMsg string `json:"err_msg"`
  3677. InfRefmsgid string `json:"inf_refmsgid"`
  3678. Infcode int64 `json:"infcode"`
  3679. Output struct {
  3680. DldEndtime string `json:"dld_endtime"`
  3681. FileQuryNo string `json:"file_qury_no"`
  3682. Filename string `json:"filename"`
  3683. } `json:"output"`
  3684. RefmsgTime string `json:"refmsg_time"`
  3685. RespondTime string `json:"respond_time"`
  3686. Signtype interface{} `json:"signtype"`
  3687. WarnMsg interface{} `json:"warn_msg"`
  3688. }
  3689. //type Autogenerated struct {
  3690. // Output struct {
  3691. // Setlinfo struct {
  3692. // SetlTime string `json:"setl_time"`
  3693. // CvlservPay float64 `json:"cvlserv_pay"`
  3694. // Year string `json:"year"`
  3695. // MedType string `json:"med_type"`
  3696. // PsnPay float64 `json:"psn_pay"`
  3697. // OpterID string `json:"opter_id"`
  3698. // Begndate string `json:"begndate"`
  3699. // FlxempeFlag string `json:"flxempe_flag"`
  3700. // HifmiPay float64 `json:"hifmi_pay"`
  3701. // PsnNo string `json:"psn_no"`
  3702. // ActPayDedc float64 `json:"act_pay_dedc"`
  3703. // MedinsSetlID interface{} `json:"medins_setl_id"`
  3704. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3705. // ClrWay string `json:"clr_way"`
  3706. // OthPay float64 `json:"oth_pay"`
  3707. // Gend string `json:"gend"`
  3708. // MdtrtID string `json:"mdtrt_id"`
  3709. // AcctPay float64 `json:"acct_pay"`
  3710. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  3711. // Insutype string `json:"insutype"`
  3712. // Invono interface{} `json:"invono"`
  3713. // Enddate string `json:"enddate"`
  3714. // CashPayamt float64 `json:"cash_payamt"`
  3715. // PsnType string `json:"psn_type"`
  3716. // FixmedinsName string `json:"fixmedins_name"`
  3717. // HifpPay float64 `json:"hifp_pay"`
  3718. // NewFlag interface{} `json:"new_flag"`
  3719. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3720. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  3721. // PayLoc string `json:"pay_loc"`
  3722. // ClrType string `json:"clr_type"`
  3723. // RefdSetlFlag string `json:"refd_setl_flag"`
  3724. // CvlservFlag string `json:"cvlserv_flag"`
  3725. // EmpName string `json:"emp_name"`
  3726. // Brdy string `json:"brdy"`
  3727. // Naty string `json:"naty"`
  3728. // Certno string `json:"certno"`
  3729. // DiseCode string `json:"dise_code"`
  3730. // FixmedinsCode string `json:"fixmedins_code"`
  3731. // DedcHospLv string `json:"dedc_hosp_lv"`
  3732. // OpterName string `json:"opter_name"`
  3733. // Balc float64 `json:"balc"`
  3734. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3735. // PsnCertType string `json:"psn_cert_type"`
  3736. // HifobPay float64 `json:"hifob_pay"`
  3737. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  3738. // HifesPay float64 `json:"hifes_pay"`
  3739. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3740. // OptTime string `json:"opt_time"`
  3741. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3742. // SetlID string `json:"setl_id"`
  3743. // MafPay float64 `json:"maf_pay"`
  3744. // PsnName string `json:"psn_name"`
  3745. // InsuOptins interface{} `json:"insu_optins"`
  3746. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3747. // ClrOptins string `json:"clr_optins"`
  3748. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3749. // DiseName string `json:"dise_name"`
  3750. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3751. // Age float64 `json:"age"`
  3752. // DtrtCertType string `json:"dtrt_cert_type"`
  3753. // HospLv string `json:"hosp_lv"`
  3754. // } `json:"setlinfo"`
  3755. // Setldetail []struct {
  3756. // FundPayType string `json:"fund_pay_type"`
  3757. // FundPayamt float64 `json:"fund_payamt"`
  3758. // SetlProcInfo interface{} `json:"setl_proc_info"`
  3759. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  3760. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  3761. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  3762. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3763. // } `json:"setldetail"`
  3764. // } `json:"output"`
  3765. // Infcode int `json:"infcode"`
  3766. // WarnMsg interface{} `json:"warn_msg"`
  3767. // Cainfo interface{} `json:"cainfo"`
  3768. // ErrMsg interface{} `json:"err_msg"`
  3769. // RefmsgTime string `json:"refmsg_time"`
  3770. // Signtype interface{} `json:"signtype"`
  3771. // RespondTime string `json:"respond_time"`
  3772. // InfRefmsgid string `json:"inf_refmsgid"`
  3773. //}
  3774. type ResultEleven struct {
  3775. Cainfo string `json:"cainfo"`
  3776. ErrMsg string `json:"err_msg"`
  3777. InfRefmsgid string `json:"inf_refmsgid"`
  3778. Infcode int64 `json:"infcode"`
  3779. Output struct {
  3780. Setlinfo struct {
  3781. SetlTime string `json:"setl_time"`
  3782. CvlservPay float64 `json:"cvlserv_pay"`
  3783. Year string `json:"year"`
  3784. MedType string `json:"med_type"`
  3785. PsnPay float64 `json:"psn_pay"`
  3786. OpterID string `json:"opter_id"`
  3787. Begndate string `json:"begndate"`
  3788. FlxempeFlag string `json:"flxempe_flag"`
  3789. HifmiPay float64 `json:"hifmi_pay"`
  3790. PsnNo string `json:"psn_no"`
  3791. ActPayDedc float64 `json:"act_pay_dedc"`
  3792. MedinsSetlID interface{} `json:"medins_setl_id"`
  3793. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3794. ClrWay string `json:"clr_way"`
  3795. OthPay float64 `json:"oth_pay"`
  3796. Gend string `json:"gend"`
  3797. MdtrtID string `json:"mdtrt_id"`
  3798. AcctPay float64 `json:"acct_pay"`
  3799. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3800. Insutype string `json:"insutype"`
  3801. Invono interface{} `json:"invono"`
  3802. Enddate string `json:"enddate"`
  3803. CashPayamt float64 `json:"cash_payamt"`
  3804. PsnType string `json:"psn_type"`
  3805. FixmedinsName string `json:"fixmedins_name"`
  3806. HifpPay float64 `json:"hifp_pay"`
  3807. NewFlag interface{} `json:"new_flag"`
  3808. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3809. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3810. PayLoc string `json:"pay_loc"`
  3811. ClrType string `json:"clr_type"`
  3812. RefdSetlFlag string `json:"refd_setl_flag"`
  3813. CvlservFlag string `json:"cvlserv_flag"`
  3814. EmpName string `json:"emp_name"`
  3815. Brdy string `json:"brdy"`
  3816. Naty string `json:"naty"`
  3817. Certno string `json:"certno"`
  3818. DiseCode string `json:"dise_code"`
  3819. FixmedinsCode string `json:"fixmedins_code"`
  3820. DedcHospLv string `json:"dedc_hosp_lv"`
  3821. OpterName string `json:"opter_name"`
  3822. Balc float64 `json:"balc"`
  3823. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3824. PsnCertType string `json:"psn_cert_type"`
  3825. HifobPay float64 `json:"hifob_pay"`
  3826. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3827. HifesPay float64 `json:"hifes_pay"`
  3828. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3829. OptTime string `json:"opt_time"`
  3830. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3831. SetlID string `json:"setl_id"`
  3832. MafPay float64 `json:"maf_pay"`
  3833. PsnName string `json:"psn_name"`
  3834. InsuOptins interface{} `json:"insu_optins"`
  3835. PrefFundPay interface{} `json:"pref_fund_pay"`
  3836. ClrOptins string `json:"clr_optins"`
  3837. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3838. DiseName string `json:"dise_name"`
  3839. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3840. Age float64 `json:"age"`
  3841. DtrtCertType string `json:"dtrt_cert_type"`
  3842. HospLv string `json:"hosp_lv"`
  3843. } `json:"setlinfo"`
  3844. } `json:"output"`
  3845. RefmsgTime string `json:"refmsg_time"`
  3846. RespondTime string `json:"respond_time"`
  3847. Signtype interface{} `json:"signtype"`
  3848. WarnMsg interface{} `json:"warn_msg"`
  3849. }
  3850. type ResultEleven10265 struct {
  3851. Cainfo string `json:"cainfo"`
  3852. ErrMsg string `json:"err_msg"`
  3853. InfRefmsgid string `json:"inf_refmsgid"`
  3854. Infcode string `json:"infcode"`
  3855. Output struct {
  3856. Setlinfo struct {
  3857. SetlTime string `json:"setl_time"`
  3858. CvlservPay float64 `json:"cvlserv_pay"`
  3859. Year string `json:"year"`
  3860. MedType string `json:"med_type"`
  3861. PsnPay float64 `json:"psn_pay"`
  3862. OpterID string `json:"opter_id"`
  3863. Begndate string `json:"begndate"`
  3864. FlxempeFlag string `json:"flxempe_flag"`
  3865. HifmiPay float64 `json:"hifmi_pay"`
  3866. PsnNo string `json:"psn_no"`
  3867. ActPayDedc float64 `json:"act_pay_dedc"`
  3868. MedinsSetlID interface{} `json:"medins_setl_id"`
  3869. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3870. ClrWay string `json:"clr_way"`
  3871. OthPay float64 `json:"oth_pay"`
  3872. Gend string `json:"gend"`
  3873. MdtrtID string `json:"mdtrt_id"`
  3874. AcctPay float64 `json:"acct_pay"`
  3875. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3876. Insutype string `json:"insutype"`
  3877. Invono interface{} `json:"invono"`
  3878. Enddate string `json:"enddate"`
  3879. CashPayamt float64 `json:"cash_payamt"`
  3880. PsnType string `json:"psn_type"`
  3881. FixmedinsName string `json:"fixmedins_name"`
  3882. HifpPay float64 `json:"hifp_pay"`
  3883. NewFlag interface{} `json:"new_flag"`
  3884. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3885. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3886. PayLoc string `json:"pay_loc"`
  3887. ClrType string `json:"clr_type"`
  3888. RefdSetlFlag string `json:"refd_setl_flag"`
  3889. CvlservFlag string `json:"cvlserv_flag"`
  3890. EmpName string `json:"emp_name"`
  3891. Brdy string `json:"brdy"`
  3892. Naty string `json:"naty"`
  3893. Certno string `json:"certno"`
  3894. DiseCode string `json:"dise_code"`
  3895. FixmedinsCode string `json:"fixmedins_code"`
  3896. DedcHospLv string `json:"dedc_hosp_lv"`
  3897. OpterName string `json:"opter_name"`
  3898. Balc float64 `json:"balc"`
  3899. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3900. PsnCertType string `json:"psn_cert_type"`
  3901. HifobPay float64 `json:"hifob_pay"`
  3902. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3903. HifesPay float64 `json:"hifes_pay"`
  3904. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3905. OptTime string `json:"opt_time"`
  3906. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3907. SetlID string `json:"setl_id"`
  3908. MafPay float64 `json:"maf_pay"`
  3909. PsnName string `json:"psn_name"`
  3910. InsuOptins interface{} `json:"insu_optins"`
  3911. PrefFundPay interface{} `json:"pref_fund_pay"`
  3912. ClrOptins string `json:"clr_optins"`
  3913. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3914. DiseName string `json:"dise_name"`
  3915. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3916. Age float64 `json:"age"`
  3917. DtrtCertType string `json:"dtrt_cert_type"`
  3918. HospLv string `json:"hosp_lv"`
  3919. } `json:"setlinfo"`
  3920. } `json:"output"`
  3921. RefmsgTime string `json:"refmsg_time"`
  3922. RespondTime string `json:"respond_time"`
  3923. Signtype interface{} `json:"signtype"`
  3924. WarnMsg interface{} `json:"warn_msg"`
  3925. }
  3926. type ResultTwelve struct {
  3927. Cainfo string `json:"cainfo"`
  3928. ErrMsg string `json:"err_msg"`
  3929. InfRefmsgid string `json:"inf_refmsgid"`
  3930. Infcode int64 `json:"infcode"`
  3931. Output struct {
  3932. MdtrtId string `json:"mdtrt_id"`
  3933. ChrgBchno string `json:"chrg_bchno"`
  3934. PsnNo string `json:"psn_no"`
  3935. } `json:"output"`
  3936. RefmsgTime string `json:"refmsg_time"`
  3937. RespondTime string `json:"respond_time"`
  3938. Signtype interface{} `json:"signtype"`
  3939. WarnMsg interface{} `json:"warn_msg"`
  3940. }
  3941. type ResultThirteen struct {
  3942. ErrMsg string `json:"err_msg"`
  3943. InfRefmsgid string `json:"inf_refmsgid"`
  3944. Infcode int64 `json:"infcode"`
  3945. Output struct {
  3946. Result struct {
  3947. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3948. } `json:"result"`
  3949. } `json:"output"`
  3950. RefmsgTime string `json:"refmsg_time"`
  3951. RespondTime string `json:"respond_time"`
  3952. Signtype interface{} `json:"signtype"`
  3953. WarnInfo interface{} `json:"warn_info"`
  3954. }
  3955. type ResultThirteen10265 struct {
  3956. ErrMsg string `json:"err_msg"`
  3957. InfRefmsgid string `json:"inf_refmsgid"`
  3958. Infcode string `json:"infcode"`
  3959. Output struct {
  3960. Result struct {
  3961. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3962. } `json:"result"`
  3963. } `json:"output"`
  3964. RefmsgTime string `json:"refmsg_time"`
  3965. RespondTime string `json:"respond_time"`
  3966. Signtype interface{} `json:"signtype"`
  3967. WarnInfo interface{} `json:"warn_info"`
  3968. }
  3969. type ResultFourteen struct {
  3970. ErrMsg string `json:"err_msg"`
  3971. InfRefmsgid string `json:"inf_refmsgid"`
  3972. Infcode int64 `json:"infcode"`
  3973. Output struct {
  3974. } `json:"output"`
  3975. RefmsgTime string `json:"refmsg_time"`
  3976. RespondTime string `json:"respond_time"`
  3977. Signtype interface{} `json:"signtype"`
  3978. WarnInfo interface{} `json:"warn_info"`
  3979. }
  3980. type ResultFourteen10265 struct {
  3981. ErrMsg string `json:"err_msg"`
  3982. InfRefmsgid string `json:"inf_refmsgid"`
  3983. Infcode string `json:"infcode"`
  3984. Output struct {
  3985. } `json:"output"`
  3986. RefmsgTime string `json:"refmsg_time"`
  3987. RespondTime string `json:"respond_time"`
  3988. Signtype interface{} `json:"signtype"`
  3989. WarnInfo interface{} `json:"warn_info"`
  3990. }
  3991. type ResultSixteen struct {
  3992. Cainfo string `json:"cainfo"`
  3993. ErrMsg string `json:"err_msg"`
  3994. InfRefmsgid string `json:"inf_refmsgid"`
  3995. Infcode int64 `json:"infcode"`
  3996. Output struct {
  3997. Setldetail []interface{} `json:"setldetail"`
  3998. Setlinfo struct {
  3999. MdtrtID string `json:"mdtrt_id"`
  4000. SetlID string `json:"setl_id"`
  4001. ClrOptins string `json:"clr_optins"`
  4002. SetlTime string `json:"setl_time"`
  4003. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4004. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4005. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4006. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4007. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4008. ActPayDedc float64 `json:"act_pay_dedc"`
  4009. HifpPay float64 `json:"hifp_pay"`
  4010. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4011. Lfpay float64 `json:"selfpay"`
  4012. CvlservPay float64 `json:"cvlserv_pay"`
  4013. HifesPay float64 `json:"hifes_pay"`
  4014. HifmiPay float64 `json:"hifmi_pay"`
  4015. HifobPay float64 `json:"hifob_pay"`
  4016. MafPay float64 `json:"maf_pay"`
  4017. OthPay float64 `json:"oth_pay"`
  4018. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4019. PsnPartAmt float64 `json:"psn_part_amt"`
  4020. AcctPay float64 `json:"acct_pay"`
  4021. Balc float64 `json:"balc"`
  4022. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4023. HospPartAmt float64 `json:"hosp_part_amt"`
  4024. MedinsSetlID string `json:"medins_setl_id"`
  4025. PdnCashPay string `json:"pdn_cash_pay"`
  4026. } `json:"setlinfo"`
  4027. } `json:"output"`
  4028. RefmsgTime string `json:"refmsg_time"`
  4029. RespondTime string `json:"respond_time"`
  4030. Signtype interface{} `json:"signtype"`
  4031. WarnMsg interface{} `json:"warn_msg"`
  4032. }
  4033. type ResultSixteen10265 struct {
  4034. Cainfo string `json:"cainfo"`
  4035. ErrMsg string `json:"err_msg"`
  4036. InfRefmsgid string `json:"inf_refmsgid"`
  4037. Infcode string `json:"infcode"`
  4038. Output struct {
  4039. Setldetail []interface{} `json:"setldetail"`
  4040. Setlinfo struct {
  4041. MdtrtID string `json:"mdtrt_id"`
  4042. SetlID string `json:"setl_id"`
  4043. ClrOptins string `json:"clr_optins"`
  4044. SetlTime string `json:"setl_time"`
  4045. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4046. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4047. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4048. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4049. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4050. ActPayDedc float64 `json:"act_pay_dedc"`
  4051. HifpPay float64 `json:"hifp_pay"`
  4052. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4053. Lfpay float64 `json:"selfpay"`
  4054. CvlservPay float64 `json:"cvlserv_pay"`
  4055. HifesPay float64 `json:"hifes_pay"`
  4056. HifmiPay float64 `json:"hifmi_pay"`
  4057. HifobPay float64 `json:"hifob_pay"`
  4058. MafPay float64 `json:"maf_pay"`
  4059. OthPay float64 `json:"oth_pay"`
  4060. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4061. PsnPartAmt float64 `json:"psn_part_amt"`
  4062. AcctPay float64 `json:"acct_pay"`
  4063. Balc float64 `json:"balc"`
  4064. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4065. HospPartAmt float64 `json:"hosp_part_amt"`
  4066. MedinsSetlID string `json:"medins_setl_id"`
  4067. PdnCashPay string `json:"pdn_cash_pay"`
  4068. } `json:"setlinfo"`
  4069. } `json:"output"`
  4070. RefmsgTime string `json:"refmsg_time"`
  4071. RespondTime string `json:"respond_time"`
  4072. Signtype interface{} `json:"signtype"`
  4073. WarnMsg interface{} `json:"warn_msg"`
  4074. }
  4075. type ResultSeventeen struct {
  4076. ErrMsg string `json:"err_msg"`
  4077. InfRefmsgid string `json:"inf_refmsgid"`
  4078. Infcode int64 `json:"infcode"`
  4079. Output struct {
  4080. SetlListId string `json:"setl_list_id"`
  4081. } `json:"output"`
  4082. RefmsgTime string `json:"refmsg_time"`
  4083. RespondTime string `json:"respond_time"`
  4084. Signtype string `json:"signtype"`
  4085. WarnInfo string `json:"warn_info"`
  4086. }
  4087. type Result90991 struct {
  4088. ErrMsg string `json:"err_msg"`
  4089. InfRefmsgid string `json:"inf_refmsgid"`
  4090. Infcode int64 `json:"infcode"`
  4091. Output struct {
  4092. Result struct {
  4093. PsnNo string `json:"psn_no"`
  4094. CardStat string `json:"card_stat"`
  4095. Certno string `json:"certno"`
  4096. PsnName string `json:"psn_name"`
  4097. CheckStat string `json:"check_stat"`
  4098. SscnoCheckStat string `json:"sscno_check_stat"`
  4099. } `json:"result"`
  4100. } `json:"output"`
  4101. RefmsgTime string `json:"refmsg_time"`
  4102. RespondTime string `json:"respond_time"`
  4103. Signtype interface{} `json:"signtype"`
  4104. WarnInfo interface{} `json:"warn_info"`
  4105. }
  4106. type Result90100 struct {
  4107. ErrMsg string `json:"err_msg"`
  4108. InfRefmsgid string `json:"inf_refmsgid"`
  4109. Infcode int64 `json:"infcode"`
  4110. Output struct {
  4111. PoolareaNo string `json:"poolarea_no"`
  4112. PoolareaNoName string `json:"poolarea_no_name"`
  4113. Insutype string `json:"insutype"`
  4114. InsutypeName string `json:"insutype_name"`
  4115. ClctType string `json:"clct_type"`
  4116. ClctTypeName string `json:"clct_type_name"`
  4117. ClctFlag string `json:"clct_flag"`
  4118. ClctFlagName string `json:"clct_flag_name"`
  4119. AccrymBegn string `json:"accrym_begn"`
  4120. AccrymEnd string `json:"accrym_end"`
  4121. ClctTime string `json:"clct_time"`
  4122. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  4123. } `json:"output"`
  4124. RefmsgTime string `json:"refmsg_time"`
  4125. RespondTime string `json:"respond_time"`
  4126. Signtype interface{} `json:"signtype"`
  4127. WarnInfo interface{} `json:"warn_info"`
  4128. }
  4129. type Custom struct {
  4130. DetItemFeeSumamt string
  4131. Cut string
  4132. FeedetlSn string
  4133. Price string
  4134. MedListCodg string
  4135. Type int64
  4136. AdviceId int64
  4137. ProjectId int64
  4138. ItemId int64
  4139. }
  4140. type Result5301 struct {
  4141. ErrMsg string `json:"err_msg"`
  4142. InfRefmsgid string `json:"inf_refmsgid"`
  4143. Infcode int64 `json:"infcode"`
  4144. Output struct {
  4145. Result []struct {
  4146. OpspDiseCode string `json:"opsp_dise_code"`
  4147. OpspDiseName string `json:"opsp_dise_name"`
  4148. Begndate string `json:"begndate"`
  4149. Enddate string `json:"enddate"`
  4150. } `json:"feedetail"`
  4151. } `json:"output"`
  4152. RefmsgTime string `json:"refmsg_time"`
  4153. RespondTime string `json:"respond_time"`
  4154. Signtype interface{} `json:"signtype"`
  4155. WarnInfo interface{} `json:"warn_info"`
  4156. }
  4157. type Result5301For10265 struct {
  4158. ErrMsg string `json:"err_msg"`
  4159. InfRefmsgid string `json:"inf_refmsgid"`
  4160. Infcode string `json:"infcode"`
  4161. Output struct {
  4162. Result []struct {
  4163. OpspDiseCode string `json:"opsp_dise_code"`
  4164. OpspDiseName string `json:"opsp_dise_name"`
  4165. Begndate string `json:"begndate"`
  4166. Enddate string `json:"enddate"`
  4167. } `json:"feedetail"`
  4168. } `json:"output"`
  4169. RefmsgTime string `json:"refmsg_time"`
  4170. RespondTime string `json:"respond_time"`
  4171. Signtype interface{} `json:"signtype"`
  4172. WarnInfo interface{} `json:"warn_info"`
  4173. }
  4174. //获取个人信息----挂号-----上传就诊信息
  4175. func (c *HisApiController) GetRegisterInfo() {
  4176. id, _ := c.GetInt64("id")
  4177. record_time := c.GetString("record_time")
  4178. settlementValue, _ := c.GetInt64("settlement_value")
  4179. medical_insurance_card := c.GetString("medical_insurance_card")
  4180. name := c.GetString("name")
  4181. id_card_type, _ := c.GetInt64("id_card_type")
  4182. certificates, _ := c.GetInt64("certificates")
  4183. medical_care, _ := c.GetInt64("medical_care")
  4184. birthday := c.GetString("birthday")
  4185. id_card := c.GetString("id_card")
  4186. register_type, _ := c.GetInt64("register")
  4187. doctor, _ := c.GetInt64("doctor")
  4188. department, _ := c.GetInt64("department")
  4189. gender, _ := c.GetInt64("sex")
  4190. registration_fee, _ := c.GetFloat("registration_fee")
  4191. medical_expenses, _ := c.GetFloat("medical_expenses")
  4192. social_type, _ := c.GetInt64("social_type")
  4193. med_type := c.GetString("social_type")
  4194. admin_user_id, _ := c.GetInt64("admin_user_id")
  4195. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4196. timeLayout := "2006-01-02"
  4197. loc, _ := time.LoadLocation("Local")
  4198. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4199. birthUnix := birthdays.Unix()
  4200. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4201. if err != nil {
  4202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4203. return
  4204. }
  4205. recordDateTime := theTime.Unix()
  4206. adminInfo := c.GetAdminUserInfo()
  4207. var patient service.Patients
  4208. if id == 0 {
  4209. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4210. } else {
  4211. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4212. }
  4213. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4214. if patientPrescription.ID == 0 {
  4215. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4216. }
  4217. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4218. if patient.ID == 0 {
  4219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4220. return
  4221. }
  4222. if len(patient.IdCardNo) == 0 {
  4223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4224. return
  4225. }
  4226. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4227. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4228. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4229. //就诊结算未完成,不能进行二次挂号
  4230. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4231. if len(his) >= 1 {
  4232. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  4233. if len(his) >= 1 && order.ID == 0 {
  4234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  4235. return
  4236. }
  4237. }
  4238. //var register_log string
  4239. if config.IsOpen == 1 {
  4240. var res ResultTwo
  4241. var res10265 ResultTwo10265
  4242. var PsnNo string
  4243. var PsnCertType string
  4244. var Certno string
  4245. var PsnName string
  4246. var Gend string
  4247. var Naty string
  4248. var Brdy string
  4249. var Age float64
  4250. var infoStr string
  4251. var idetinfoStr string
  4252. var infocode int64
  4253. var verify_number string
  4254. fmt.Println(verify_number)
  4255. if miConfig.MdtrtareaAdmvs == "421300" {
  4256. psn_info, _ := service.GetPsnByPatientId(id)
  4257. PsnNo = psn_info.PsnNo
  4258. PsnCertType = psn_info.PsnCertType
  4259. Certno = psn_info.Certno
  4260. PsnName = psn_info.PsnName
  4261. Gend = psn_info.Gend
  4262. Naty = psn_info.Naty
  4263. Brdy = psn_info.Brdy
  4264. Age = psn_info.Age
  4265. infoStr = psn_info.Insuinfo
  4266. idetinfoStr = psn_info.Idetinfo
  4267. infocode = 0
  4268. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4269. psn_info, _ := service.GetPsnByPatientId(id)
  4270. PsnNo = psn_info.PsnNo
  4271. PsnCertType = psn_info.PsnCertType
  4272. Certno = psn_info.Certno
  4273. PsnName = psn_info.PsnName
  4274. Gend = psn_info.Gend
  4275. Naty = psn_info.Naty
  4276. Brdy = psn_info.Brdy
  4277. Age = psn_info.Age
  4278. infoStr = psn_info.Insuinfo
  4279. idetinfoStr = psn_info.Idetinfo
  4280. infocode = 0
  4281. verify_number = psn_info.VerifyNumber
  4282. } else {
  4283. var result string
  4284. var requestLog string
  4285. if miConfig.UserOrgId == 10138 {
  4286. 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)
  4287. } else {
  4288. 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)
  4289. }
  4290. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4291. if miConfig.Code == "H15049901371" {
  4292. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4293. utils.ErrorLog("解析失败:%v", err)
  4294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4295. return
  4296. }
  4297. res.ErrMsg = res10265.ErrMsg
  4298. res.Output = res10265.Output
  4299. res.InfRefmsgid = res10265.InfRefmsgid
  4300. } else {
  4301. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4302. utils.ErrorLog("解析失败:%v", err)
  4303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4304. return
  4305. }
  4306. }
  4307. PsnNo = res.Output.Baseinfo.PsnNo
  4308. PsnCertType = res.Output.Baseinfo.PsnCertType
  4309. Certno = res.Output.Baseinfo.Certno
  4310. PsnName = res.Output.Baseinfo.PsnName
  4311. Gend = res.Output.Baseinfo.Gend
  4312. Naty = res.Output.Baseinfo.Naty
  4313. Brdy = res.Output.Baseinfo.Brdy
  4314. Age = res.Output.Baseinfo.Age
  4315. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4316. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4317. infoStr = string(Iinfos)
  4318. idetinfoStr = string(Idetinfos)
  4319. if miConfig.Code == "H15049901371" {
  4320. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  4321. } else {
  4322. infocode = res.Infcode
  4323. }
  4324. }
  4325. if infocode == 0 {
  4326. his := models.VMHisPatient{
  4327. Name: name,
  4328. Gender: gender,
  4329. Birthday: birthUnix,
  4330. MedicalTreatmentType: medical_care,
  4331. IdType: certificates,
  4332. IdCardNo: id_card,
  4333. BalanceAccountsType: settlementValue,
  4334. SocialType: social_type,
  4335. MedicalInsuranceNumber: medical_insurance_card,
  4336. RegisterType: register_type,
  4337. RegisterCost: registration_fee,
  4338. TreatmentCost: medical_expenses,
  4339. Status: 1,
  4340. Ctime: time.Now().Unix(),
  4341. Mtime: time.Now().Unix(),
  4342. PsnNo: PsnNo,
  4343. PsnCertType: PsnCertType,
  4344. Certno: Certno,
  4345. PsnName: PsnName,
  4346. Gend: Gend,
  4347. Naty: Naty,
  4348. Brdy: Brdy,
  4349. Age: Age,
  4350. Iinfo: infoStr,
  4351. Idetinfo: idetinfoStr,
  4352. PatientId: patient.ID,
  4353. RecordDate: theTime.Unix(),
  4354. UserOrgId: adminInfo.CurrentOrgId,
  4355. AdminUserId: admin_user_id,
  4356. IsReturn: 1,
  4357. IdCardType: id_card_type,
  4358. Doctor: doctor,
  4359. Departments: department,
  4360. }
  4361. timestamp := time.Now().Unix()
  4362. tempTime := time.Unix(timestamp, 0)
  4363. timeFormat := tempTime.Format("20060102150405")
  4364. chrgBchno := rand.Intn(100000) + 10000
  4365. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4366. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  4367. department, _ := service.GetDepartMentDetail(department)
  4368. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  4369. IdCardNo := ""
  4370. if id_card_type == 1 {
  4371. // IdCardNo = medical_insurance_card
  4372. IdCardNo = patient.IdCardNo
  4373. } else {
  4374. IdCardNo = patient.IdCardNo
  4375. }
  4376. var rf []*ResultFive
  4377. json.Unmarshal([]byte(his.Iinfo), &rf)
  4378. var insutypes []*ResultFive
  4379. var insutype string
  4380. var insuplc_admdvs_temp string
  4381. var is390 int = 0
  4382. var is310 int = 0
  4383. for _, item := range rf {
  4384. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4385. insutypes = append(insutypes, item)
  4386. }
  4387. }
  4388. if len(insutypes) == 1 {
  4389. insutype = insutypes[0].Insutype
  4390. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4391. } else {
  4392. for _, i := range insutypes {
  4393. if i.Insutype == "390" {
  4394. is390 = 1
  4395. }
  4396. if i.Insutype == "310" {
  4397. is310 = 1
  4398. }
  4399. }
  4400. }
  4401. if is390 == 1 {
  4402. insutype = "390"
  4403. }
  4404. if is310 == 1 {
  4405. insutype = "310"
  4406. }
  4407. if len(insutypes) == 0 {
  4408. insutype = "310"
  4409. }
  4410. if len(insutypes) == 2 {
  4411. insutype = med_type
  4412. }
  4413. if len(med_type) > 0 {
  4414. insutype = med_type
  4415. }
  4416. //for _, item := range rf {
  4417. // if item.Insutype == insutype {
  4418. // insuplc_admdvs = item.InsuplcAdmdvs
  4419. // }
  4420. //}
  4421. var infocode int64
  4422. var resThree ResultThree
  4423. var resThree10265 ResultThree10265
  4424. if len(insuplc_admdvs) == 0 {
  4425. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  4426. } else {
  4427. insuplc_admdvs_temp = insuplc_admdvs
  4428. }
  4429. if miConfig.MdtrtareaAdmvs == "421300" {
  4430. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  4431. "&org_name=" + miConfig.OrgName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4432. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&doctor_name=" + doctor_info.UserName
  4433. resp, requestErr := http.Get(api)
  4434. if requestErr != nil {
  4435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4436. return
  4437. }
  4438. body, ioErr := ioutil.ReadAll(resp.Body)
  4439. if ioErr != nil {
  4440. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4442. return
  4443. }
  4444. var respJSON map[string]interface{}
  4445. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4446. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4448. return
  4449. }
  4450. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4451. result, _ := json.Marshal(respJSON)
  4452. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4453. utils.ErrorLog("解析失败:%v", err)
  4454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4455. return
  4456. }
  4457. infocode = resThree.Infcode
  4458. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4459. psn_info, _ := service.GetPsnByPatientId(id)
  4460. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4461. var cert_no string
  4462. if id_card_type == 3 {
  4463. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  4464. cert_no = IdCardNo
  4465. } else {
  4466. bas := strings.Split(psn_info.CardInfo, "|")
  4467. cert_no = bas[2]
  4468. }
  4469. var api string
  4470. if miConfig.MdtrtareaAdmvs == "320921" {
  4471. api = "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4472. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4473. "&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
  4474. } else {
  4475. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4476. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4477. "&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
  4478. }
  4479. resp, requestErr := http.Get(api)
  4480. if requestErr != nil {
  4481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4482. return
  4483. }
  4484. body, ioErr := ioutil.ReadAll(resp.Body)
  4485. if ioErr != nil {
  4486. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4488. return
  4489. }
  4490. var respJSON map[string]interface{}
  4491. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4492. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4494. return
  4495. }
  4496. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4497. result, _ := json.Marshal(respJSON)
  4498. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4499. utils.ErrorLog("解析失败:%v", err)
  4500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4501. return
  4502. }
  4503. resThree.ErrMsg = resThree10265.ErrMsg
  4504. resThree.Output = resThree10265.Output
  4505. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4506. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4507. } else {
  4508. 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)
  4509. saveLog(result, requestLog, "2201A", "挂号")
  4510. if miConfig.Code == "H15049901371" {
  4511. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4512. utils.ErrorLog("解析失败:%v", err)
  4513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4514. return
  4515. }
  4516. resThree.ErrMsg = resThree10265.ErrMsg
  4517. resThree.Output = resThree10265.Output
  4518. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4519. } else {
  4520. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4521. utils.ErrorLog("解析失败:%v", err)
  4522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4523. return
  4524. }
  4525. }
  4526. if miConfig.Code == "H15049901371" {
  4527. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4528. } else {
  4529. infocode = resThree.Infcode
  4530. }
  4531. }
  4532. if infocode != 0 {
  4533. adminUser := c.GetAdminUserInfo()
  4534. errlog := &models.HisOrderError{
  4535. UserOrgId: adminUser.CurrentOrgId,
  4536. Ctime: time.Now().Unix(),
  4537. Mtime: time.Now().Unix(),
  4538. ErrMsg: resThree.ErrMsg,
  4539. Status: 1,
  4540. PatientId: id,
  4541. RecordTime: recordDateTime,
  4542. Stage: 2,
  4543. }
  4544. service.CreateErrMsgLog(errlog)
  4545. c.ServeSuccessJSON(map[string]interface{}{
  4546. "failed_code": -10,
  4547. "msg": resThree.ErrMsg,
  4548. })
  4549. return
  4550. }
  4551. his.Number = resThree.Output.Data.MdtrtID
  4552. his.PsnNo = resThree.Output.Data.PsnNo
  4553. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  4554. his.IdCardNo = patient.IdCardNo
  4555. his.PhoneNumber = patient.Phone
  4556. his.UserOrgId = adminInfo.CurrentOrgId
  4557. his.Insutype = insutype
  4558. his.Ctime = time.Now().Unix()
  4559. his.Mtime = time.Now().Unix()
  4560. his.InsuplcAdmdvs = insuplc_admdvs_temp
  4561. his.Status = 1
  4562. service.UpdateHisPatientStatus(&his)
  4563. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  4564. c.ServeSuccessJSON(map[string]interface{}{
  4565. "his_info": his,
  4566. })
  4567. } else {
  4568. adminUser := c.GetAdminUserInfo()
  4569. errlog := &models.HisOrderError{
  4570. UserOrgId: adminUser.CurrentOrgId,
  4571. Ctime: time.Now().Unix(),
  4572. Mtime: time.Now().Unix(),
  4573. ErrMsg: res.ErrMsg,
  4574. Status: 1,
  4575. PatientId: id,
  4576. RecordTime: recordDateTime,
  4577. Stage: 1,
  4578. }
  4579. service.CreateErrMsgLog(errlog)
  4580. c.ServeSuccessJSON(map[string]interface{}{
  4581. "failed_code": -10,
  4582. "msg": res.ErrMsg,
  4583. })
  4584. return
  4585. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  4586. }
  4587. }
  4588. }
  4589. //上传明细----预结算----确认订单
  4590. func (c *HisApiController) GetUploadInfo() {
  4591. id, _ := c.GetInt64("id")
  4592. record_time := c.GetString("record_time")
  4593. his_patient_id, _ := c.GetInt64("his_patient_id")
  4594. order_id, _ := c.GetInt64("order_id")
  4595. pay_way, _ := c.GetInt64("pay_way")
  4596. pay_price, _ := c.GetFloat("pay_price")
  4597. pay_card_no := c.GetString("pay_card_no")
  4598. discount_price, _ := c.GetFloat("discount_price")
  4599. preferential_price, _ := c.GetFloat("preferential_price")
  4600. reality_price, _ := c.GetFloat("reality_price")
  4601. found_price, _ := c.GetFloat("found_price")
  4602. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  4603. private_price, _ := c.GetFloat("private_price")
  4604. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4605. admin_user_id, _ := c.GetInt64("admin_user_id")
  4606. fapiao_code := c.GetString("fapiao_code")
  4607. fapiao_number := c.GetString("fapiao_number")
  4608. diagnosis_id := c.GetString("diagnosis")
  4609. sick_type, _ := c.GetInt64("sick_type")
  4610. reg_type, _ := c.GetInt64("p_type")
  4611. begin_time := c.GetString("begin_time")
  4612. id_str := c.GetString("ids")
  4613. ids_arr := strings.Split(id_str, ",")
  4614. timeLayout := "2006-01-02"
  4615. loc, _ := time.LoadLocation("Local")
  4616. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4617. if err != nil {
  4618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4619. return
  4620. }
  4621. recordDateTime := theTime.Unix()
  4622. adminUser := c.GetAdminUserInfo()
  4623. var tempOrder models.HisOrder
  4624. tempOrder, _ = service.GetHisOrderByID(order_id)
  4625. var prescriptions []*models.HisPrescription
  4626. var start_time int64
  4627. var end_time int64
  4628. //if adminUser.CurrentOrgId == 10106{
  4629. // if len(fapiao_code) == 0{
  4630. // fapiao_code = "144072080589"
  4631. // }
  4632. // if len(fapiao_number) == 0{
  4633. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  4634. // if order.ID == 0{
  4635. // fapiao_number = "00001520"
  4636. // }else{
  4637. // //fapiao_code = "00001520"
  4638. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  4639. // var zero string
  4640. // if fpNumber >= 1000{
  4641. // zero = "0000" + strconv.Itoa(fpNumber)
  4642. // }else if fpNumber >= 10000{
  4643. // zero = "000" + strconv.Itoa(fpNumber)
  4644. // } else if fpNumber >= 100000{
  4645. // zero = "00" + strconv.Itoa(fpNumber)
  4646. // } else if fpNumber >= 1000000{
  4647. // zero = "0" + strconv.Itoa(fpNumber)
  4648. // }else {
  4649. // zero = strconv.Itoa(fpNumber)
  4650. // }
  4651. // fapiao_number = zero
  4652. // }
  4653. // }
  4654. //}
  4655. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4656. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4657. var patientPrescription models.HisPrescriptionInfo
  4658. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4659. if patientPrescription.ID == 0 {
  4660. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4661. }
  4662. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4663. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4664. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4665. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4666. var config []*models.HisXtDiagnoseConfig
  4667. for _, item := range diagnosis_ids {
  4668. id, _ := strconv.ParseInt(item, 10, 64)
  4669. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4670. config = append(config, &diagnosisConfig)
  4671. }
  4672. sickConfig, _ := service.FindSickById(sick_type)
  4673. //if tempOrder.ID == 0 {
  4674. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  4675. //}
  4676. if tempOrder.ID == 0 {
  4677. var result string
  4678. var requestLog string
  4679. var res2 ResultSix
  4680. var ressix10265 ResultSix10265
  4681. if miConfig.MdtrtareaAdmvs == "421300" {
  4682. data := make(map[string]interface{})
  4683. client := &http.Client{}
  4684. data["psn_no"] = his.PsnNo
  4685. data["mdtrt_id"] = his.Number
  4686. data["doctor"] = roles.UserName
  4687. data["department"] = department.Name
  4688. data["org_name"] = miConfig.OrgName
  4689. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4690. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4691. data["fixmedins_code"] = miConfig.Code
  4692. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4693. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4694. data["secret_key"] = miConfig.SecretKey
  4695. data["sick_code"] = sickConfig.CountryCode
  4696. data["sick_name"] = sickConfig.ClassName
  4697. data["dept"] = strconv.FormatInt(department.ID, 10)
  4698. data["config"] = config
  4699. data["begin_time"] = begin_time
  4700. bytesData, _ := json.Marshal(data)
  4701. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  4702. resp, _ := client.Do(req)
  4703. defer resp.Body.Close()
  4704. body, ioErr := ioutil.ReadAll(resp.Body)
  4705. if ioErr != nil {
  4706. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4708. return
  4709. }
  4710. var respJSON map[string]interface{}
  4711. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4712. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4714. return
  4715. }
  4716. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4717. userJSONBytes, _ := json.Marshal(respJSON)
  4718. fmt.Println("log")
  4719. fmt.Println(string(userJSONBytes))
  4720. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4721. utils.ErrorLog("解析失败:%v", err)
  4722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4723. return
  4724. }
  4725. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4726. //江苏地区国家医保医疗类别
  4727. //职工透析:医疗类别选特殊情况门诊9933
  4728. //居民血透门慢: 医疗类别选门诊慢病1402
  4729. //var med_type string
  4730. //if his.Insutype == "310" {
  4731. // if reg_type == 14 {
  4732. // med_type = "9933"
  4733. // } else if reg_type == 11 {
  4734. // med_type = "11"
  4735. //
  4736. // }
  4737. //} else if his.Insutype == "390" {
  4738. // if reg_type == 14 {
  4739. // med_type = "1402"
  4740. // } else if reg_type == 11 {
  4741. // med_type = "11"
  4742. // }
  4743. //}
  4744. data := make(map[string]interface{})
  4745. client := &http.Client{}
  4746. data["psn_no"] = his.PsnNo
  4747. data["mdtrt_id"] = his.Number
  4748. data["doctor"] = roles.UserName
  4749. data["department"] = department.Name
  4750. data["org_name"] = miConfig.OrgName
  4751. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4752. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4753. data["fixmedins_code"] = miConfig.Code
  4754. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4755. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4756. data["secret_key"] = miConfig.SecretKey
  4757. data["sick_code"] = sickConfig.CountryCode
  4758. data["sick_name"] = sickConfig.ClassName
  4759. data["url"] = miConfig.Url
  4760. data["ak"] = miConfig.AccessKey
  4761. data["begin_time"] = begin_time
  4762. data["cainfo"] = miConfig.Cainfo
  4763. data["dept"] = strconv.FormatInt(department.ID, 10)
  4764. data["config"] = config
  4765. bytesData, _ := json.Marshal(data)
  4766. var req *http.Request
  4767. if miConfig.MdtrtareaAdmvs == "320921" {
  4768. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4769. //api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  4770. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  4771. } else {
  4772. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4773. }
  4774. resp, _ := client.Do(req)
  4775. defer resp.Body.Close()
  4776. body, ioErr := ioutil.ReadAll(resp.Body)
  4777. if ioErr != nil {
  4778. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4780. return
  4781. }
  4782. var respJSON map[string]interface{}
  4783. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4784. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4786. return
  4787. }
  4788. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4789. userJSONBytes, _ := json.Marshal(respJSON)
  4790. fmt.Println("log")
  4791. fmt.Println(string(userJSONBytes))
  4792. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  4793. utils.ErrorLog("解析失败:%v", err)
  4794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4795. return
  4796. }
  4797. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4798. res2.Output = ressix10265.Output
  4799. res2.ErrMsg = ressix10265.ErrMsg
  4800. res2.Cainfo = ressix10265.Cainfo
  4801. res2.WarnMsg = ressix10265.WarnMsg
  4802. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4803. res2.Infcode = infocode
  4804. } else {
  4805. if miConfig.MdtrtareaAdmvs == "440781" { //
  4806. 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)
  4807. } else {
  4808. if miConfig.Code == "H15049901371" {
  4809. //赤峰地区国家医保医疗类别
  4810. //职工透析:医疗类别选特殊情况门诊990502
  4811. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4812. var med_type string
  4813. if his.Insutype == "390" {
  4814. if reg_type == 14 {
  4815. med_type = "9933"
  4816. } else if reg_type == 11 {
  4817. med_type = "11"
  4818. }
  4819. } else if his.Insutype == "310" {
  4820. if reg_type == 14 {
  4821. med_type = "990502"
  4822. } else if reg_type == 11 {
  4823. med_type = "11"
  4824. }
  4825. }
  4826. 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)
  4827. } else {
  4828. 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)
  4829. }
  4830. }
  4831. saveLog(result, requestLog, "2203", "上传就诊信息")
  4832. var respJSON2 map[string]interface{}
  4833. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4834. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4836. return
  4837. }
  4838. userJSONBytes2, _ := json.Marshal(respJSON2)
  4839. if miConfig.Code == "H15049901371" {
  4840. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  4841. utils.ErrorLog("解析失败:%v", err)
  4842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4843. return
  4844. }
  4845. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4846. res2.Output = ressix10265.Output
  4847. res2.ErrMsg = ressix10265.ErrMsg
  4848. res2.Cainfo = ressix10265.Cainfo
  4849. res2.WarnMsg = ressix10265.WarnMsg
  4850. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4851. res2.Infcode = infocode
  4852. } else {
  4853. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4854. utils.ErrorLog("解析失败:%v", err)
  4855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4856. return
  4857. }
  4858. }
  4859. }
  4860. if res2.Infcode != 0 {
  4861. adminUser := c.GetAdminUserInfo()
  4862. errlog := &models.HisOrderError{
  4863. UserOrgId: adminUser.CurrentOrgId,
  4864. Ctime: time.Now().Unix(),
  4865. Mtime: time.Now().Unix(),
  4866. ErrMsg: res2.ErrMsg,
  4867. Status: 1,
  4868. PatientId: id,
  4869. RecordTime: recordDateTime,
  4870. Stage: 3,
  4871. }
  4872. service.CreateErrMsgLog(errlog)
  4873. c.ServeSuccessJSON(map[string]interface{}{
  4874. "failed_code": -10,
  4875. "msg": res2.ErrMsg,
  4876. })
  4877. return
  4878. } else {
  4879. his.Diagnosis = diagnosis_id
  4880. his.SickType = sickConfig.ID
  4881. //var p_type int64
  4882. //if reg_type == 1111 || reg_type == 1112 {
  4883. // p_type = 11
  4884. //
  4885. //}
  4886. his.PType = fmt.Sprintf("%d", reg_type)
  4887. service.UpdateHisPatientThree(&his)
  4888. data := make(map[string]interface{})
  4889. if settle_accounts_type == 1 { //日结
  4890. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  4891. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  4892. } else {
  4893. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  4894. }
  4895. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  4896. data["pre"] = prescriptions
  4897. } else { //月结
  4898. start_time_str := c.GetString("start_time")
  4899. end_time_str := c.GetString("end_time")
  4900. timeLayout := "2006-01-02"
  4901. loc, _ := time.LoadLocation("Local")
  4902. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4903. if err != nil {
  4904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4905. return
  4906. }
  4907. recordStartTime := theStartTime.Unix()
  4908. start_time = recordStartTime
  4909. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4910. if err != nil {
  4911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4912. return
  4913. }
  4914. recordEndTime := theEndTime.Unix()
  4915. end_time = recordEndTime
  4916. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  4917. data["pre"] = prescriptions
  4918. }
  4919. timestamp := time.Now().Unix()
  4920. tempTime := time.Unix(timestamp, 0)
  4921. timeFormat := tempTime.Format("20060102150405")
  4922. chrgBchno := rand.Intn(100000) + 10000
  4923. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4924. strconv.FormatInt(his.PatientId, 10)
  4925. client := &http.Client{}
  4926. data["psn_no"] = his.PsnNo
  4927. data["mdtrt_id"] = his.Number
  4928. data["chrg_bchno"] = chrg_bchno
  4929. data["org_name"] = miConfig.OrgName
  4930. data["doctor"] = roles.UserName
  4931. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4932. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4933. data["fixmedins_code"] = miConfig.Code
  4934. //if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  4935. // data["dept_code"] = "15"
  4936. //} else {
  4937. data["dept_code"] = department.Number
  4938. //}
  4939. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4940. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4941. data["secret_key"] = miConfig.SecretKey
  4942. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  4943. data["url"] = miConfig.Url
  4944. data["ak"] = miConfig.AccessKey
  4945. data["new_doctor_name"] = patientPrescription.Doctor
  4946. data["diag_code"] = sickConfig.CountryCode
  4947. data["cainfo"] = miConfig.Cainfo
  4948. var ids []int64
  4949. for _, item := range prescriptions {
  4950. ids = append(ids, item.ID)
  4951. }
  4952. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4953. if config.IsOpen == 1 { //对接了医保,走医保流程
  4954. var res ResultFour
  4955. var resFour10265 ResultFour10265
  4956. if miConfig.MdtrtareaAdmvs == "421300" {
  4957. bytesData, _ := json.Marshal(data)
  4958. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  4959. resp, _ := client.Do(req)
  4960. defer resp.Body.Close()
  4961. body, ioErr := ioutil.ReadAll(resp.Body)
  4962. if ioErr != nil {
  4963. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4965. return
  4966. }
  4967. var respJSON map[string]interface{}
  4968. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4969. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4971. return
  4972. }
  4973. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4974. userJSONBytes, _ := json.Marshal(respJSON)
  4975. fmt.Println("log")
  4976. fmt.Println(string(userJSONBytes))
  4977. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4978. utils.ErrorLog("解析失败:%v", err)
  4979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4980. return
  4981. }
  4982. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4983. bytesData, _ := json.Marshal(data)
  4984. var req *http.Request
  4985. if miConfig.MdtrtareaAdmvs == "320921" {
  4986. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4987. } else {
  4988. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4989. }
  4990. resp, _ := client.Do(req)
  4991. defer resp.Body.Close()
  4992. body, ioErr := ioutil.ReadAll(resp.Body)
  4993. if ioErr != nil {
  4994. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4996. return
  4997. }
  4998. var respJSON map[string]interface{}
  4999. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5000. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5002. return
  5003. }
  5004. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5005. userJSONBytes, _ := json.Marshal(respJSON)
  5006. fmt.Println("log")
  5007. fmt.Println(string(userJSONBytes))
  5008. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5009. utils.ErrorLog("解析失败:%v", err)
  5010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5011. return
  5012. }
  5013. res.InfRefmsgid = resFour10265.InfRefmsgid
  5014. res.Output = resFour10265.Output
  5015. res.ErrMsg = resFour10265.ErrMsg
  5016. res.Cainfo = resFour10265.Cainfo
  5017. res.WarnMsg = resFour10265.WarnMsg
  5018. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5019. res.Infcode = infocode
  5020. } else {
  5021. if miConfig.Code == "H15049901371" {
  5022. 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)
  5023. var dat map[string]interface{}
  5024. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5025. fmt.Println(dat)
  5026. } else {
  5027. fmt.Println(err)
  5028. }
  5029. saveLog(result, request_log, "2204", "上传费用明细")
  5030. userJSONBytes, _ := json.Marshal(dat)
  5031. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5032. utils.ErrorLog("解析失败:%v", err)
  5033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5034. return
  5035. }
  5036. res.InfRefmsgid = resFour10265.InfRefmsgid
  5037. res.Output = resFour10265.Output
  5038. res.ErrMsg = resFour10265.ErrMsg
  5039. res.Cainfo = resFour10265.Cainfo
  5040. res.WarnMsg = resFour10265.WarnMsg
  5041. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5042. res.Infcode = infocode
  5043. } else {
  5044. 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)
  5045. var dat map[string]interface{}
  5046. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5047. fmt.Println(dat)
  5048. } else {
  5049. fmt.Println(err)
  5050. }
  5051. saveLog(result, request_log, "2204", "上传费用明细")
  5052. userJSONBytes, _ := json.Marshal(dat)
  5053. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5054. utils.ErrorLog("解析失败:%v", err)
  5055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5056. return
  5057. }
  5058. }
  5059. }
  5060. if res.Infcode == 0 {
  5061. order := &models.HisOrder{
  5062. UserOrgId: adminUser.CurrentOrgId,
  5063. HisPatientId: his.ID,
  5064. PatientId: his.PatientId,
  5065. SettleAccountsDate: recordDateTime,
  5066. MdtrtId: his.Number,
  5067. PsnNo: his.PsnNo,
  5068. MedType: strconv.FormatInt(reg_type, 10),
  5069. Ctime: time.Now().Unix(),
  5070. Mtime: time.Now().Unix(),
  5071. Status: 1,
  5072. Number: chrg_bchno,
  5073. Infcode: res.Infcode,
  5074. WarnMsg: res.WarnMsg,
  5075. Cainfo: res.Cainfo,
  5076. ErrMsg: res.ErrMsg,
  5077. RespondTime: res.RefmsgTime,
  5078. InfRefmsgid: res.InfRefmsgid,
  5079. OrderStatus: 1,
  5080. PayWay: pay_way,
  5081. PayPrice: pay_price,
  5082. PayCardNo: pay_card_no,
  5083. DiscountPrice: discount_price,
  5084. PreferentialPrice: preferential_price,
  5085. RealityPrice: reality_price,
  5086. FoundPrice: found_price,
  5087. MedicalInsurancePrice: medical_insurance_price,
  5088. PrivatePrice: private_price,
  5089. IsMedicineInsurance: 1,
  5090. SettleType: settle_accounts_type,
  5091. SettleStartTime: start_time,
  5092. SettleEndTime: end_time,
  5093. Creator: roles.AdminUserId,
  5094. Modify: roles.AdminUserId,
  5095. FaPiaoNumber: fapiao_number,
  5096. FaPiaoCode: fapiao_code,
  5097. PType: 2,
  5098. Diagnosis: diagnosis_id,
  5099. }
  5100. err = service.CreateOrder(order)
  5101. if err != nil {
  5102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5103. return
  5104. }
  5105. for _, item := range res.Output.Result {
  5106. temp := strings.Split(item.FeedetlSn, "-")
  5107. var advice_id int64 = 0
  5108. var project_id int64 = 0
  5109. var types int64 = 0
  5110. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5111. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5112. if temp[1] == "1" {
  5113. advice_id = id
  5114. project_id = 0
  5115. } else if temp[1] == "2" {
  5116. advice_id = 0
  5117. project_id = id
  5118. }
  5119. info := &models.HisOrderInfo{
  5120. OrderNumber: order.Number,
  5121. FeedetlSn: item.FeedetlSn,
  5122. UploadDate: time.Now().Unix(),
  5123. AdviceId: advice_id,
  5124. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5125. Cnt: item.Cnt,
  5126. Pric: float64(item.Pric),
  5127. PatientId: his.PatientId,
  5128. PricUplmtAmt: item.PricUplmtAmt,
  5129. SelfpayProp: item.SelfpayProp,
  5130. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5131. OverlmtAmt: item.OverlmtAmt,
  5132. PreselfpayAmt: item.PreselfpayAmt,
  5133. BasMednFlag: item.BasMednFlag,
  5134. MedChrgitmType: item.MedChrgitmType,
  5135. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5136. Status: 1,
  5137. Memo: item.Memo,
  5138. Mtime: time.Now().Unix(),
  5139. InscpScpAmt: item.InscpScpAmt,
  5140. DrtReimFlag: item.DrtReimFlag,
  5141. Ctime: time.Now().Unix(),
  5142. ListSpItemFlag: item.ListSpItemFlag,
  5143. ChldMedcFlag: item.ChldMedcFlag,
  5144. LmtUsedFlag: item.LmtUsedFlag,
  5145. ChrgitmLv: item.ChrgitmLv,
  5146. UserOrgId: adminUser.CurrentOrgId,
  5147. HisPatientId: his.ID,
  5148. OrderId: order.ID,
  5149. ProjectId: project_id,
  5150. Type: types,
  5151. }
  5152. service.CreateOrderInfo(info)
  5153. }
  5154. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5155. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5156. var total float64
  5157. for _, item := range prescriptions {
  5158. if item.Type == 1 { //药品
  5159. for _, subItem := range item.HisDoctorAdviceInfo {
  5160. total = total + (subItem.Price * subItem.PrescribingNumber)
  5161. }
  5162. }
  5163. if item.Type == 2 { //项目
  5164. for _, subItem := range item.HisPrescriptionProject {
  5165. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5166. total = total + (subItem.Price * cnt)
  5167. }
  5168. }
  5169. }
  5170. for _, item := range prescriptions {
  5171. for _, subItem := range item.HisAdditionalCharge {
  5172. total = total + (subItem.Price * float64(subItem.Count))
  5173. }
  5174. }
  5175. var allTotal string
  5176. if adminUser.CurrentOrgId == 9919 {
  5177. allTotal = fmt.Sprintf("%.4f", total)
  5178. } else {
  5179. allTotal = fmt.Sprintf("%.4f", total)
  5180. }
  5181. if res.Infcode == 0 {
  5182. var rf []*ResultFive
  5183. json.Unmarshal([]byte(his.Iinfo), &rf)
  5184. chrg_bchno := chrg_bchno
  5185. cert_no := his.Certno
  5186. var insutypes []string
  5187. var insutype string
  5188. var is390 int = 0
  5189. var is310 int = 0
  5190. for _, item := range rf {
  5191. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5192. insutypes = append(insutypes, item.Insutype)
  5193. }
  5194. }
  5195. if len(insutypes) == 1 {
  5196. insutype = insutypes[0]
  5197. } else {
  5198. for _, i := range insutypes {
  5199. if i == "390" {
  5200. is390 = 1
  5201. }
  5202. if i == "310" {
  5203. is310 = 1
  5204. }
  5205. }
  5206. }
  5207. if is390 == 1 {
  5208. insutype = "390"
  5209. }
  5210. if is310 == 1 {
  5211. insutype = "310"
  5212. }
  5213. if len(insutypes) == 0 {
  5214. insutype = "310"
  5215. }
  5216. if len(insutypes) == 2 {
  5217. insutype = strconv.FormatInt(his.SocialType, 10)
  5218. }
  5219. insutype = strconv.FormatInt(his.SocialType, 10)
  5220. //insutype = "390"
  5221. if his.IdCardType == 1 {
  5222. // cert_no = his.MedicalInsuranceNumber
  5223. cert_no = his.Certno
  5224. } else {
  5225. cert_no = his.Certno
  5226. }
  5227. var res ResultSeven
  5228. var resSeven10265 ResultSeven10265
  5229. var src_resquest string
  5230. var result2 string
  5231. var acct_used_flag string
  5232. fmt.Println("pay_way")
  5233. fmt.Println(pay_way)
  5234. fmt.Println("pay_way")
  5235. if pay_way == 4 {
  5236. acct_used_flag = "1"
  5237. } else {
  5238. acct_used_flag = "0"
  5239. }
  5240. if miConfig.MdtrtareaAdmvs == "421300" {
  5241. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5242. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5243. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5244. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5245. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5246. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5247. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5248. resp, requestErr := http.Get(api)
  5249. if requestErr != nil {
  5250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5251. return
  5252. }
  5253. body, ioErr := ioutil.ReadAll(resp.Body)
  5254. if ioErr != nil {
  5255. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5257. return
  5258. }
  5259. var respJSON map[string]interface{}
  5260. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5261. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5263. return
  5264. }
  5265. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5266. result, _ := json.Marshal(respJSON)
  5267. if miConfig.Code == "H15049901371" {
  5268. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5269. utils.ErrorLog("解析失败:%v", err)
  5270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5271. return
  5272. }
  5273. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5274. res.Output = resSeven10265.Output
  5275. res.ErrMsg = resSeven10265.ErrMsg
  5276. res.Cainfo = resSeven10265.Cainfo
  5277. res.WarnMsg = resSeven10265.WarnMsg
  5278. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5279. res.Infcode = infocode
  5280. } else {
  5281. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5282. utils.ErrorLog("解析失败:%v", err)
  5283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5284. return
  5285. }
  5286. }
  5287. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5288. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5289. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5290. //psn_info, _ := service.GetPsnByPatientId(id)
  5291. bas := strings.Split(psn_info.CardInfo, "|")
  5292. if his.IdCardType == 1 {
  5293. cert_no = bas[2]
  5294. } else if his.IdCardType == 3 {
  5295. cert_no = his.Certno
  5296. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  5297. } else {
  5298. cert_no = bas[1]
  5299. }
  5300. //江苏地区国家医保医疗类别
  5301. //职工透析:医疗类别选特殊情况门诊9933
  5302. //居民血透门慢: 医疗类别选门诊慢病1402
  5303. //var med_type string
  5304. //if his.Insutype == "310" {
  5305. // if reg_type == 14 {
  5306. // med_type = "9933"
  5307. // } else if reg_type == 11 {
  5308. // med_type = "11"
  5309. //
  5310. // }
  5311. //} else if his.Insutype == "390" {
  5312. // if reg_type == 14 {
  5313. // med_type = "1402"
  5314. // } else if reg_type == 11 {
  5315. // med_type = "11"
  5316. // }
  5317. //}
  5318. //psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5319. var api string
  5320. if miConfig.MdtrtareaAdmvs == "320921" {
  5321. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5322. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5323. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5324. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5325. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5326. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5327. "&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
  5328. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5329. } else {
  5330. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5331. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5332. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5333. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5334. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5335. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5336. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5337. "&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
  5338. }
  5339. resp, requestErr := http.Get(api)
  5340. if requestErr != nil {
  5341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5342. return
  5343. }
  5344. body, ioErr := ioutil.ReadAll(resp.Body)
  5345. if ioErr != nil {
  5346. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5348. return
  5349. }
  5350. var respJSON map[string]interface{}
  5351. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5352. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5354. return
  5355. }
  5356. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5357. result, _ := json.Marshal(respJSON)
  5358. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5359. utils.ErrorLog("解析失败:%v", err)
  5360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5361. return
  5362. }
  5363. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5364. res.Output = resSeven10265.Output
  5365. res.ErrMsg = resSeven10265.ErrMsg
  5366. res.Cainfo = resSeven10265.Cainfo
  5367. res.WarnMsg = resSeven10265.WarnMsg
  5368. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5369. res.Infcode = infocode
  5370. } else {
  5371. if miConfig.Code == "H15049901371" {
  5372. //赤峰地区国家医保医疗类别
  5373. //职工透析:医疗类别选特殊情况门诊990502
  5374. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5375. var med_type string
  5376. if his.Insutype == "390" {
  5377. if reg_type == 14 {
  5378. med_type = "9933"
  5379. } else if reg_type == 11 {
  5380. med_type = "11"
  5381. }
  5382. } else if his.Insutype == "310" {
  5383. if reg_type == 14 {
  5384. med_type = "990502"
  5385. } else if reg_type == 11 {
  5386. med_type = "11"
  5387. }
  5388. }
  5389. 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)
  5390. } else {
  5391. 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)
  5392. }
  5393. //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)
  5394. var dat map[string]interface{}
  5395. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5396. fmt.Println(dat)
  5397. } else {
  5398. fmt.Println(err)
  5399. }
  5400. saveLog(result2, src_resquest, "2207", "结算")
  5401. userJSONBytes, _ := json.Marshal(dat)
  5402. if miConfig.Code == "H15049901371" {
  5403. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5404. utils.ErrorLog("解析失败:%v", err)
  5405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5406. return
  5407. }
  5408. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5409. res.Output = resSeven10265.Output
  5410. res.ErrMsg = resSeven10265.ErrMsg
  5411. res.Cainfo = resSeven10265.Cainfo
  5412. res.WarnMsg = resSeven10265.WarnMsg
  5413. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5414. res.Infcode = infocode
  5415. } else {
  5416. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5417. utils.ErrorLog("解析失败:%v", err)
  5418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5419. return
  5420. }
  5421. }
  5422. }
  5423. if res.Infcode != 0 {
  5424. errlog := &models.HisOrderError{
  5425. UserOrgId: adminUser.CurrentOrgId,
  5426. Ctime: time.Now().Unix(),
  5427. Mtime: time.Now().Unix(),
  5428. Number: chrg_bchno,
  5429. ErrMsg: res.ErrMsg,
  5430. Status: 1,
  5431. PatientId: id,
  5432. RecordTime: recordDateTime,
  5433. Stage: 6,
  5434. }
  5435. service.CreateErrMsgLog(errlog)
  5436. c.ServeSuccessJSON(map[string]interface{}{
  5437. "failed_code": -10,
  5438. "msg": res.ErrMsg,
  5439. })
  5440. return
  5441. } else {
  5442. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5443. order.OrderStatus = 2
  5444. order.Status = 1
  5445. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5446. order.SetlId = res.Output.Setlinfo.SetlID
  5447. order.PsnNo = res.Output.Setlinfo.PsnNo
  5448. order.PsnName = res.Output.Setlinfo.PsnName
  5449. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5450. order.Certno = res.Output.Setlinfo.Certno
  5451. order.Gend = res.Output.Setlinfo.Gend
  5452. order.Naty = res.Output.Setlinfo.Naty
  5453. order.Age = res.Output.Setlinfo.Age
  5454. order.Insutype = res.Output.Setlinfo.Insutype
  5455. order.PsnType = res.Output.Setlinfo.PsnType
  5456. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5457. order.SetlTime = res.Output.Setlinfo.SetlTime
  5458. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5459. if res.Output.Setlinfo.MedType == "140101" {
  5460. order.MedType = "14"
  5461. } else {
  5462. order.MedType = res.Output.Setlinfo.MedType
  5463. }
  5464. if reg_type == 1112 {
  5465. order.MedType = "1112"
  5466. }
  5467. if reg_type == 1111 {
  5468. order.MedType = "1111"
  5469. }
  5470. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5471. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5472. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5473. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5474. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5475. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5476. order.HifpPay = res.Output.Setlinfo.HifpPay
  5477. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5478. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5479. order.HifesPay = res.Output.Setlinfo.HifesPay
  5480. order.HifobPay = res.Output.Setlinfo.HifobPay
  5481. order.MafPay = res.Output.Setlinfo.MafPay
  5482. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5483. order.OthPay = res.Output.Setlinfo.OthPay
  5484. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5485. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5486. order.AcctPay = res.Output.Setlinfo.AcctPay
  5487. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5488. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5489. order.Balc = res.Output.Setlinfo.Balc
  5490. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5491. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5492. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5493. order.ClrType = res.Output.Setlinfo.ClrType
  5494. order.ClrWay = res.Output.Setlinfo.ClrWay
  5495. order.Creator = order.Creator
  5496. order.Modify = roles.AdminUserId
  5497. order.RequestLog = src_resquest
  5498. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5499. detailStr := string(setlDetail)
  5500. order.SetlDetail = detailStr
  5501. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5502. err = service.UpDateOrder(order)
  5503. if err == nil {
  5504. c.ServeSuccessJSON(map[string]interface{}{
  5505. "msg": "结算成功",
  5506. })
  5507. } else {
  5508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5509. return
  5510. }
  5511. }
  5512. } else {
  5513. adminUser := c.GetAdminUserInfo()
  5514. errlog := &models.HisOrderError{
  5515. UserOrgId: adminUser.CurrentOrgId,
  5516. Ctime: time.Now().Unix(),
  5517. Mtime: time.Now().Unix(),
  5518. ErrMsg: res.ErrMsg,
  5519. Status: 1,
  5520. PatientId: id,
  5521. RecordTime: recordDateTime,
  5522. Stage: 4,
  5523. }
  5524. service.CreateErrMsgLog(errlog)
  5525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5526. return
  5527. }
  5528. } else {
  5529. adminUser := c.GetAdminUserInfo()
  5530. errlog := &models.HisOrderError{
  5531. UserOrgId: adminUser.CurrentOrgId,
  5532. Ctime: time.Now().Unix(),
  5533. Mtime: time.Now().Unix(),
  5534. ErrMsg: res.ErrMsg,
  5535. Status: 1,
  5536. PatientId: id,
  5537. RecordTime: recordDateTime,
  5538. Stage: 4,
  5539. }
  5540. service.CreateErrMsgLog(errlog)
  5541. c.ServeSuccessJSON(map[string]interface{}{
  5542. "failed_code": -10,
  5543. "msg": res.ErrMsg,
  5544. })
  5545. return
  5546. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5547. //return
  5548. }
  5549. }
  5550. }
  5551. } else if tempOrder.ID > 0 {
  5552. if tempOrder.IsPre == 1 {
  5553. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  5554. var rf []*ResultFive
  5555. json.Unmarshal([]byte(his.Iinfo), &rf)
  5556. chrg_bchno := tempOrder.Number
  5557. cert_no := his.Certno
  5558. var insutypes []string
  5559. var insutype string
  5560. var is390 int = 0
  5561. var is310 int = 0
  5562. for _, item := range rf {
  5563. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5564. insutypes = append(insutypes, item.Insutype)
  5565. }
  5566. }
  5567. if len(insutypes) == 1 {
  5568. insutype = insutypes[0]
  5569. } else {
  5570. for _, i := range insutypes {
  5571. if i == "390" {
  5572. is390 = 1
  5573. }
  5574. if i == "310" {
  5575. is310 = 1
  5576. }
  5577. }
  5578. }
  5579. if is390 == 1 {
  5580. insutype = "390"
  5581. }
  5582. if is310 == 1 {
  5583. insutype = "310"
  5584. }
  5585. if len(insutypes) == 0 {
  5586. insutype = "310"
  5587. }
  5588. if len(insutypes) == 2 {
  5589. insutype = strconv.FormatInt(his.SocialType, 64)
  5590. }
  5591. //insutype = "390"
  5592. if his.IdCardType == 1 {
  5593. // cert_no = his.MedicalInsuranceNumber
  5594. cert_no = his.Certno
  5595. } else {
  5596. cert_no = his.Certno
  5597. }
  5598. var res ResultSeven
  5599. var resSeven10265 ResultSeven10265
  5600. var src_resquest string
  5601. var result2 string
  5602. var acct_used_flag string
  5603. fmt.Println("pay_way")
  5604. fmt.Println(pay_way)
  5605. fmt.Println("pay_way")
  5606. if pay_way == 4 {
  5607. acct_used_flag = "1"
  5608. } else {
  5609. acct_used_flag = "0"
  5610. }
  5611. if miConfig.MdtrtareaAdmvs == "421300" {
  5612. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5613. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5614. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5615. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5616. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5617. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5618. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5619. resp, requestErr := http.Get(api)
  5620. if requestErr != nil {
  5621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5622. return
  5623. }
  5624. body, ioErr := ioutil.ReadAll(resp.Body)
  5625. if ioErr != nil {
  5626. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5628. return
  5629. }
  5630. var respJSON map[string]interface{}
  5631. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5632. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5634. return
  5635. }
  5636. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5637. result, _ := json.Marshal(respJSON)
  5638. fmt.Println("log")
  5639. fmt.Println(string(result))
  5640. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5641. utils.ErrorLog("解析失败:%v", err)
  5642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5643. return
  5644. }
  5645. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5646. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5647. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5648. //psn_info, _ := service.GetPsnByPatientId(id)
  5649. bas := strings.Split(psn_info.CardInfo, "|")
  5650. if his.IdCardType == 1 {
  5651. cert_no = bas[2]
  5652. } else {
  5653. cert_no = bas[1]
  5654. }
  5655. //江苏地区国家医保医疗类别
  5656. //职工透析:医疗类别选特殊情况门诊9933
  5657. //居民血透门慢: 医疗类别选门诊慢病1402
  5658. //var med_type string
  5659. //if his.Insutype == "310" {
  5660. // if reg_type == 14 {
  5661. // med_type = "9933"
  5662. // } else if reg_type == 11 {
  5663. // med_type = "11"
  5664. //
  5665. // }
  5666. //} else if his.Insutype == "390" {
  5667. // if reg_type == 14 {
  5668. // med_type = "1402"
  5669. // } else if reg_type == 11 {
  5670. // med_type = "11"
  5671. // }
  5672. //}
  5673. var api string
  5674. if miConfig.MdtrtareaAdmvs == "320921" {
  5675. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5676. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5677. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5678. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5679. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5680. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5681. "&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
  5682. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5683. } else {
  5684. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5685. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5686. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5687. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5688. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5689. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5690. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5691. "&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
  5692. }
  5693. resp, requestErr := http.Get(api)
  5694. if requestErr != nil {
  5695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5696. return
  5697. }
  5698. body, ioErr := ioutil.ReadAll(resp.Body)
  5699. if ioErr != nil {
  5700. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5702. return
  5703. }
  5704. var respJSON map[string]interface{}
  5705. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5706. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5708. return
  5709. }
  5710. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5711. result, _ := json.Marshal(respJSON)
  5712. fmt.Println("log")
  5713. fmt.Println(string(result))
  5714. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5715. utils.ErrorLog("解析失败:%v", err)
  5716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5717. return
  5718. }
  5719. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5720. res.Output = resSeven10265.Output
  5721. res.ErrMsg = resSeven10265.ErrMsg
  5722. res.Cainfo = resSeven10265.Cainfo
  5723. res.WarnMsg = resSeven10265.WarnMsg
  5724. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5725. res.Infcode = infocode
  5726. } else {
  5727. var src_resquest string
  5728. if miConfig.Code == "H15049901371" {
  5729. //赤峰地区国家医保医疗类别
  5730. //职工透析:医疗类别选特殊情况门诊990502
  5731. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5732. var med_type string
  5733. if his.Insutype == "390" {
  5734. if reg_type == 14 {
  5735. med_type = "9933"
  5736. } else if reg_type == 11 {
  5737. med_type = "11"
  5738. }
  5739. } else if his.Insutype == "310" {
  5740. if reg_type == 14 {
  5741. med_type = "990502"
  5742. } else if reg_type == 11 {
  5743. med_type = "11"
  5744. }
  5745. }
  5746. 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)
  5747. } else {
  5748. 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)
  5749. }
  5750. var dat map[string]interface{}
  5751. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5752. fmt.Println(dat)
  5753. } else {
  5754. fmt.Println(err)
  5755. }
  5756. saveLog(result2, src_resquest, "2207", "结算")
  5757. userJSONBytes, _ := json.Marshal(dat)
  5758. if miConfig.Code == "H15049901371" {
  5759. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5760. utils.ErrorLog("解析失败:%v", err)
  5761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5762. return
  5763. }
  5764. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5765. res.Output = resSeven10265.Output
  5766. res.ErrMsg = resSeven10265.ErrMsg
  5767. res.Cainfo = resSeven10265.Cainfo
  5768. res.WarnMsg = resSeven10265.WarnMsg
  5769. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5770. res.Infcode = infocode
  5771. } else {
  5772. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5773. utils.ErrorLog("解析失败:%v", err)
  5774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5775. return
  5776. }
  5777. }
  5778. }
  5779. if res.Infcode != 0 {
  5780. errlog := &models.HisOrderError{
  5781. UserOrgId: adminUser.CurrentOrgId,
  5782. Ctime: time.Now().Unix(),
  5783. Mtime: time.Now().Unix(),
  5784. Number: chrg_bchno,
  5785. ErrMsg: res.ErrMsg,
  5786. Status: 1,
  5787. PatientId: id,
  5788. RecordTime: recordDateTime,
  5789. Stage: 6,
  5790. }
  5791. service.CreateErrMsgLog(errlog)
  5792. c.ServeSuccessJSON(map[string]interface{}{
  5793. "failed_code": -10,
  5794. "msg": res.ErrMsg,
  5795. })
  5796. return
  5797. } else {
  5798. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5799. order.OrderStatus = 2
  5800. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5801. order.SetlId = res.Output.Setlinfo.SetlID
  5802. order.PsnNo = res.Output.Setlinfo.PsnNo
  5803. order.PsnName = res.Output.Setlinfo.PsnName
  5804. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5805. order.Certno = res.Output.Setlinfo.Certno
  5806. order.Gend = res.Output.Setlinfo.Gend
  5807. order.Naty = res.Output.Setlinfo.Naty
  5808. order.Age = res.Output.Setlinfo.Age
  5809. order.Insutype = res.Output.Setlinfo.Insutype
  5810. order.PsnType = res.Output.Setlinfo.PsnType
  5811. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5812. order.SetlTime = res.Output.Setlinfo.SetlTime
  5813. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5814. //order.MedType = res.Output.Setlinfo.MedType
  5815. if reg_type == 1112 {
  5816. order.MedType = "1112"
  5817. }
  5818. if reg_type == 1111 {
  5819. order.MedType = "1111"
  5820. }
  5821. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5822. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5823. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5824. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5825. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5826. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5827. order.HifpPay = res.Output.Setlinfo.HifpPay
  5828. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5829. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5830. order.HifesPay = res.Output.Setlinfo.HifesPay
  5831. order.HifobPay = res.Output.Setlinfo.HifobPay
  5832. order.MafPay = res.Output.Setlinfo.MafPay
  5833. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5834. order.OthPay = res.Output.Setlinfo.OthPay
  5835. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5836. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5837. order.AcctPay = res.Output.Setlinfo.AcctPay
  5838. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5839. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5840. order.Balc = res.Output.Setlinfo.Balc
  5841. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5842. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5843. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5844. order.ClrWay = res.Output.Setlinfo.ClrWay
  5845. order.Creator = order.Creator
  5846. order.Modify = roles.AdminUserId
  5847. order.RequestLog = src_resquest
  5848. order.Diagnosis = diagnosis_id
  5849. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5850. detailStr := string(setlDetail)
  5851. order.SetlDetail = detailStr
  5852. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5853. err = service.UpDateOrder(order)
  5854. if err == nil {
  5855. c.ServeSuccessJSON(map[string]interface{}{
  5856. "msg": "结算成功",
  5857. })
  5858. } else {
  5859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5860. return
  5861. }
  5862. }
  5863. }
  5864. }
  5865. }
  5866. //func (c *HisApiController) GetPreUploadInfo() {
  5867. // id, _ := c.GetInt64("id")
  5868. // record_time := c.GetString("record_time")
  5869. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5870. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5871. //
  5872. // timeLayout := "2006-01-02"
  5873. // loc, _ := time.LoadLocation("Local")
  5874. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5875. // if err != nil {
  5876. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5877. // return
  5878. // }
  5879. // recordDateTime := theTime.Unix()
  5880. // adminUser := c.GetAdminUserInfo()
  5881. //
  5882. // var prescriptions []*models.HisPrescription
  5883. //
  5884. // var start_time int64
  5885. // var end_time int64
  5886. //
  5887. // data := make(map[string]interface{})
  5888. // if settle_accounts_type == 1 { //日结
  5889. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  5890. // data["pre"] = prescriptions
  5891. //
  5892. // } else { //月结
  5893. // start_time_str := c.GetString("start_time")
  5894. // end_time_str := c.GetString("end_time")
  5895. // timeLayout := "2006-01-02"
  5896. // loc, _ := time.LoadLocation("Local")
  5897. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5898. // if err != nil {
  5899. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5900. // return
  5901. // }
  5902. // recordStartTime := theStartTime.Unix()
  5903. // start_time = recordStartTime
  5904. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5905. // if err != nil {
  5906. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5907. // return
  5908. // }
  5909. // recordEndTime := theEndTime.Unix()
  5910. // end_time = recordEndTime
  5911. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  5912. // data["pre"] = prescriptions
  5913. //
  5914. // }
  5915. //
  5916. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5917. //
  5918. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5919. // timestamp := time.Now().Unix()
  5920. // tempTime := time.Unix(timestamp, 0)
  5921. // timeFormat := tempTime.Format("20060102150405")
  5922. // chrgBchno := rand.Intn(100000) + 10000
  5923. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5924. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5925. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5926. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5927. // strconv.FormatInt(his.PatientId, 10)
  5928. // client := &http.Client{}
  5929. // data["psn_no"] = his.PsnNo
  5930. // data["mdtrt_id"] = his.Number
  5931. // data["chrg_bchno"] = chrg_bchno
  5932. // data["org_name"] = miConfig.OrgName
  5933. // data["doctor"] = roles.UserName
  5934. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5935. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5936. // data["fixmedins_code"] = miConfig.Code
  5937. // data["dept_code"] = department.Number
  5938. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5939. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5940. // data["secret_key"] = miConfig.SecretKey
  5941. // var ids []int64
  5942. //
  5943. // for _, item := range prescriptions {
  5944. // ids = append(ids, item.ID)
  5945. // }
  5946. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5947. // if config.IsOpen == 1 { //对接了医保,走医保流程
  5948. // bytesData, _ := json.Marshal(data)
  5949. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  5950. // resp, _ := client.Do(req)
  5951. // defer resp.Body.Close()
  5952. // body, ioErr := ioutil.ReadAll(resp.Body)
  5953. // if ioErr != nil {
  5954. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5955. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5956. // return
  5957. // }
  5958. // var respJSON map[string]interface{}
  5959. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5960. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5961. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5962. // return
  5963. // }
  5964. //
  5965. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5966. // userJSONBytes, _ := json.Marshal(respJSON)
  5967. // var res ResultFour
  5968. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5969. // utils.ErrorLog("解析失败:%v", err)
  5970. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5971. // return
  5972. // }
  5973. //
  5974. // if res.Infcode == 0 {
  5975. // order := &models.HisOrder{
  5976. // UserOrgId: adminUser.CurrentOrgId,
  5977. // HisPatientId: his.ID,
  5978. // PatientId: his.PatientId,
  5979. // SettleAccountsDate: recordDateTime,
  5980. // Ctime: time.Now().Unix(),
  5981. // Mtime: time.Now().Unix(),
  5982. // Status: 1,
  5983. // Number: chrg_bchno,
  5984. // Infcode: res.Infcode,
  5985. // WarnMsg: res.WarnMsg,
  5986. // Cainfo: res.Cainfo,
  5987. // ErrMsg: res.ErrMsg,
  5988. // RespondTime: res.RefmsgTime,
  5989. // InfRefmsgid: res.InfRefmsgid,
  5990. // OrderStatus: 1,
  5991. // IsMedicineInsurance: 1,
  5992. // SettleType: settle_accounts_type,
  5993. // SettleStartTime: start_time,
  5994. // SettleEndTime: end_time,
  5995. // Creator: roles.ID,
  5996. // Modify: roles.ID,
  5997. // PType: 2,
  5998. // }
  5999. // err = service.CreateOrder(order)
  6000. // if err != nil {
  6001. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6002. // return
  6003. // }
  6004. //
  6005. // for _, item := range res.Output.Result {
  6006. // temp := strings.Split(item.FeedetlSn, "-")
  6007. // var advice_id int64 = 0
  6008. // var project_id int64 = 0
  6009. // var types int64 = 0
  6010. //
  6011. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  6012. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  6013. //
  6014. // if temp[1] == "1" {
  6015. // advice_id = id
  6016. // project_id = 0
  6017. // } else if temp[1] == "2" {
  6018. // advice_id = 0
  6019. // project_id = id
  6020. // }
  6021. //
  6022. // info := &models.HisOrderInfo{
  6023. // OrderNumber: order.Number,
  6024. // FeedetlSn: item.FeedetlSn,
  6025. // UploadDate: time.Now().Unix(),
  6026. // AdviceId: advice_id,
  6027. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  6028. // Cnt: item.Cnt,
  6029. // Pric: float64(item.Pric),
  6030. // PatientId: his.PatientId,
  6031. // PricUplmtAmt: item.PricUplmtAmt,
  6032. // SelfpayProp: item.SelfpayProp,
  6033. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6034. // OverlmtAmt: item.OverlmtAmt,
  6035. // PreselfpayAmt: item.PreselfpayAmt,
  6036. // BasMednFlag: item.BasMednFlag,
  6037. // MedChrgitmType: item.MedChrgitmType,
  6038. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  6039. // Status: 1,
  6040. // Memo: item.Memo,
  6041. // Mtime: time.Now().Unix(),
  6042. // InscpScpAmt: item.InscpScpAmt,
  6043. // DrtReimFlag: item.DrtReimFlag,
  6044. // Ctime: time.Now().Unix(),
  6045. // ListSpItemFlag: item.ListSpItemFlag,
  6046. // ChldMedcFlag: item.ChldMedcFlag,
  6047. // LmtUsedFlag: item.LmtUsedFlag,
  6048. // ChrgitmLv: item.ChrgitmLv,
  6049. // UserOrgId: adminUser.CurrentOrgId,
  6050. // HisPatientId: his.ID,
  6051. // OrderId: order.ID,
  6052. // ProjectId: project_id,
  6053. // Type: types,
  6054. // }
  6055. // service.CreateOrderInfo(info)
  6056. //
  6057. // }
  6058. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6059. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  6060. //
  6061. // var total float64
  6062. // for _, item := range prescriptions {
  6063. // if item.Type == 1 { //药品
  6064. // for _, subItem := range item.HisDoctorAdviceInfo {
  6065. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6066. // }
  6067. // }
  6068. // if item.Type == 2 { //项目
  6069. // for _, subItem := range item.HisPrescriptionProject {
  6070. // total = total + (subItem.Price * float64(subItem.Count))
  6071. // }
  6072. // }
  6073. // }
  6074. //
  6075. // for _, item := range prescriptions {
  6076. // for _, subItem := range item.HisAdditionalCharge {
  6077. // total = total + (subItem.Price * float64(subItem.Count))
  6078. // }
  6079. // }
  6080. //
  6081. // allTotal := fmt.Sprintf("%.2f", total)
  6082. // if res.Infcode == 0 {
  6083. // var rf []*ResultFive
  6084. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6085. // psn_no := his.PsnNo
  6086. // mdtrt_id := his.Number
  6087. // chrg_bchno := chrg_bchno
  6088. // cert_no := his.Certno
  6089. // insutype := rf[0].Insutype
  6090. //
  6091. // if his.IdCardType == 1 {
  6092. // cert_no = his.MedicalInsuranceNumber
  6093. //
  6094. // } else {
  6095. //
  6096. // cert_no = his.Certno
  6097. //
  6098. // }
  6099. //
  6100. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  6101. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  6102. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  6103. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  6104. // resp, requestErr := http.Get(api)
  6105. // if requestErr != nil {
  6106. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6107. // return
  6108. // }
  6109. // defer resp.Body.Close()
  6110. // body, ioErr := ioutil.ReadAll(resp.Body)
  6111. // if ioErr != nil {
  6112. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6113. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6114. // return
  6115. // }
  6116. // var respJSON map[string]interface{}
  6117. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6118. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6119. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6120. // return
  6121. // }
  6122. // fmt.Println(respJSON)
  6123. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6124. // userJSONBytes, _ := json.Marshal(respJSON)
  6125. // var res ResultSeven
  6126. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6127. // utils.ErrorLog("解析失败:%v", err)
  6128. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6129. // return
  6130. // }
  6131. // if res.Infcode != 0 {
  6132. // errlog := &models.HisOrderError{
  6133. // UserOrgId: adminUser.CurrentOrgId,
  6134. // Ctime: time.Now().Unix(),
  6135. // Mtime: time.Now().Unix(),
  6136. // Number: chrg_bchno,
  6137. // ErrMsg: res.ErrMsg,
  6138. // Status: 1,
  6139. // PatientId: id,
  6140. // RecordTime: recordDateTime,
  6141. // Stage: 7,
  6142. // }
  6143. // service.CreateErrMsgLog(errlog)
  6144. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6145. // return
  6146. // } else {
  6147. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6148. // order.OrderStatus = 1
  6149. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6150. // order.SetlId = res.Output.Setlinfo.SetlID
  6151. // order.PsnNo = res.Output.Setlinfo.PsnNo
  6152. // order.PsnName = res.Output.Setlinfo.PsnName
  6153. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6154. // order.Certno = res.Output.Setlinfo.Certno
  6155. // order.Gend = res.Output.Setlinfo.Gend
  6156. // order.Naty = res.Output.Setlinfo.Naty
  6157. // order.Age = res.Output.Setlinfo.Age
  6158. // order.Insutype = res.Output.Setlinfo.Insutype
  6159. // order.PsnType = res.Output.Setlinfo.PsnType
  6160. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6161. // order.SetlTime = res.Output.Setlinfo.SetlTime
  6162. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6163. // order.MedType = res.Output.Setlinfo.MedType
  6164. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6165. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6166. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6167. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6168. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6169. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6170. // order.HifpPay = res.Output.Setlinfo.HifpPay
  6171. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6172. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6173. // order.HifesPay = res.Output.Setlinfo.HifesPay
  6174. // order.HifobPay = res.Output.Setlinfo.HifobPay
  6175. // order.MafPay = res.Output.Setlinfo.MafPay
  6176. // order.OthPay = res.Output.Setlinfo.OthPay
  6177. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6178. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6179. // order.AcctPay = res.Output.Setlinfo.AcctPay
  6180. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6181. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6182. // order.Balc = res.Output.Setlinfo.Balc
  6183. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6184. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6185. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6186. // order.ClrWay = res.Output.Setlinfo.ClrWay
  6187. // order.Creator = order.Creator
  6188. // order.Modify = roles.ID
  6189. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6190. // detailStr := string(setlDetail)
  6191. // order.SetlDetail = detailStr
  6192. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6193. // err = service.UpDateOrder(order)
  6194. // if err == nil {
  6195. // c.ServeSuccessJSON(map[string]interface{}{
  6196. // "msg": "预结算成功",
  6197. // })
  6198. // } else {
  6199. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6200. // return
  6201. // }
  6202. // }
  6203. // } else {
  6204. // adminUser := c.GetAdminUserInfo()
  6205. // errlog := &models.HisOrderError{
  6206. // UserOrgId: adminUser.CurrentOrgId,
  6207. // Ctime: time.Now().Unix(),
  6208. // Mtime: time.Now().Unix(),
  6209. // ErrMsg: res.ErrMsg,
  6210. // Status: 1,
  6211. // PatientId: id,
  6212. // RecordTime: recordDateTime,
  6213. // Stage: 4,
  6214. // }
  6215. // service.CreateErrMsgLog(errlog)
  6216. //
  6217. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6218. // return
  6219. // }
  6220. // } else {
  6221. // adminUser := c.GetAdminUserInfo()
  6222. // errlog := &models.HisOrderError{
  6223. // UserOrgId: adminUser.CurrentOrgId,
  6224. // Ctime: time.Now().Unix(),
  6225. // Mtime: time.Now().Unix(),
  6226. // ErrMsg: res.ErrMsg,
  6227. // Status: 1,
  6228. // PatientId: id,
  6229. // RecordTime: recordDateTime,
  6230. // Stage: 4,
  6231. // }
  6232. // service.CreateErrMsgLog(errlog)
  6233. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6234. // return
  6235. // }
  6236. //
  6237. // } else {
  6238. // var total float64
  6239. // for _, item := range prescriptions {
  6240. // if item.Type == 1 { //药品
  6241. // for _, subItem := range item.HisDoctorAdviceInfo {
  6242. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6243. // }
  6244. // }
  6245. // if item.Type == 2 { //项目
  6246. // for _, subItem := range item.HisPrescriptionProject {
  6247. // total = total + (subItem.Price * float64(subItem.Count))
  6248. // }
  6249. // }
  6250. //
  6251. // for _, subItem := range item.HisAdditionalCharge {
  6252. // total = total + (subItem.Price * float64(subItem.Count))
  6253. // }
  6254. // }
  6255. //
  6256. // allTotal := fmt.Sprintf("%.2f", total)
  6257. // totals, _ := strconv.ParseFloat(allTotal, 64)
  6258. // order := &models.HisOrder{
  6259. // UserOrgId: adminUser.CurrentOrgId,
  6260. // HisPatientId: his.ID,
  6261. // PatientId: id,
  6262. // SettleAccountsDate: recordDateTime,
  6263. // Ctime: time.Now().Unix(),
  6264. // Mtime: time.Now().Unix(),
  6265. // Status: 1,
  6266. // OrderStatus: 2,
  6267. // Number: chrg_bchno,
  6268. // MedfeeSumamt: totals,
  6269. // }
  6270. // err = service.CreateOrder(order)
  6271. // if err != nil {
  6272. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6273. // return
  6274. // }
  6275. //
  6276. // var customs []*Custom
  6277. // for _, item := range prescriptions {
  6278. //
  6279. // if item.Type == 1 { //药品
  6280. // for _, subItem := range item.HisDoctorAdviceInfo {
  6281. // cus := &Custom{
  6282. // AdviceId: subItem.ID,
  6283. // ProjectId: 0,
  6284. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  6285. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  6286. // FeedetlSn: subItem.FeedetlSn,
  6287. // Price: fmt.Sprintf("%.2f", subItem.Price),
  6288. // MedListCodg: subItem.MedListCodg,
  6289. // Type: 1,
  6290. // }
  6291. // customs = append(customs, cus)
  6292. // }
  6293. // }
  6294. //
  6295. // if item.Type == 2 { //项目
  6296. // for _, subItem := range item.HisPrescriptionProject {
  6297. //
  6298. // cus := &Custom{
  6299. // AdviceId: 0,
  6300. // ProjectId: subItem.ID,
  6301. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  6302. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  6303. // FeedetlSn: subItem.FeedetlSn,
  6304. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  6305. // MedListCodg: subItem.MedListCodg,
  6306. // Type: 2,
  6307. // }
  6308. //
  6309. // customs = append(customs, cus)
  6310. // }
  6311. // }
  6312. //
  6313. // for _, item := range item.HisAdditionalCharge {
  6314. // cus := &Custom{
  6315. // ItemId: item.ID,
  6316. // AdviceId: 0,
  6317. // ProjectId: 0,
  6318. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  6319. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  6320. // FeedetlSn: item.FeedetlSn,
  6321. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  6322. // MedListCodg: item.XtHisAddtionConfig.Code,
  6323. // Type: 3,
  6324. // }
  6325. //
  6326. // customs = append(customs, cus)
  6327. // }
  6328. //
  6329. // }
  6330. //
  6331. // for _, item := range customs {
  6332. // var advice_id int64 = 0
  6333. // var project_id int64 = 0
  6334. // var item_id int64 = 0
  6335. //
  6336. // var types int64 = 0
  6337. //
  6338. // if item.Type == 1 {
  6339. // advice_id = item.AdviceId
  6340. // project_id = 0
  6341. // item_id = 0
  6342. // } else if item.Type == 2 {
  6343. // advice_id = 0
  6344. // item_id = 0
  6345. //
  6346. // project_id = item.ProjectId
  6347. // } else if item.Type == 3 {
  6348. // advice_id = 0
  6349. // item_id = item.ItemId
  6350. // project_id = 0
  6351. // }
  6352. //
  6353. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  6354. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  6355. // pric, _ := strconv.ParseFloat(item.Price, 32)
  6356. //
  6357. // info := &models.HisOrderInfo{
  6358. // OrderNumber: order.Number,
  6359. // UploadDate: time.Now().Unix(),
  6360. // AdviceId: advice_id,
  6361. // DetItemFeeSumamt: detItemFeeSumamt,
  6362. // Cnt: cut,
  6363. // Pric: pric,
  6364. // PatientId: id,
  6365. // Status: 1,
  6366. // Mtime: time.Now().Unix(),
  6367. // Ctime: time.Now().Unix(),
  6368. // UserOrgId: adminUser.CurrentOrgId,
  6369. // HisPatientId: his.ID,
  6370. // OrderId: order.ID,
  6371. // ProjectId: project_id,
  6372. // Type: types,
  6373. // ItemId: item_id,
  6374. // }
  6375. // service.CreateOrderInfo(info)
  6376. // }
  6377. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6378. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6379. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  6380. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6381. // if err == nil {
  6382. // c.ServeSuccessJSON(map[string]interface{}{
  6383. // "msg": "结算成功",
  6384. // })
  6385. // } else {
  6386. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6387. // return
  6388. // }
  6389. // }
  6390. //}
  6391. //上传明细-预结算-
  6392. func (c *HisApiController) GetPreUploadInfo() {
  6393. id, _ := c.GetInt64("id")
  6394. record_time := c.GetString("record_time")
  6395. his_patient_id, _ := c.GetInt64("his_patient_id")
  6396. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6397. admin_user_id, _ := c.GetInt64("admin_user_id")
  6398. diagnosis_id := c.GetString("diagnosis")
  6399. sick_type, _ := c.GetInt64("sick_type")
  6400. reg_type, _ := c.GetInt64("p_type")
  6401. begin_time := c.GetString("begin_time")
  6402. id_str := c.GetString("ids")
  6403. ids_arr := strings.Split(id_str, ",")
  6404. timeLayout := "2006-01-02"
  6405. loc, _ := time.LoadLocation("Local")
  6406. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6407. if err != nil {
  6408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6409. return
  6410. }
  6411. recordDateTime := theTime.Unix()
  6412. adminUser := c.GetAdminUserInfo()
  6413. diagnosis_ids := strings.Split(diagnosis_id, ",")
  6414. var config []*models.HisXtDiagnoseConfig
  6415. for _, item := range diagnosis_ids {
  6416. id, _ := strconv.ParseInt(item, 10, 64)
  6417. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6418. config = append(config, &diagnosisConfig)
  6419. }
  6420. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  6421. sickConfig, _ := service.FindSickById(sick_type)
  6422. var prescriptions []*models.HisPrescription
  6423. var start_time int64
  6424. var end_time int64
  6425. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6426. fmt.Println(his_patient_id)
  6427. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6428. timestamp := time.Now().Unix()
  6429. tempTime := time.Unix(timestamp, 0)
  6430. timeFormat := tempTime.Format("20060102150405")
  6431. chrgBchno := rand.Intn(100000) + 10000
  6432. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6433. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6434. var patientPrescription models.HisPrescriptionInfo
  6435. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6436. if patientPrescription.ID == 0 {
  6437. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6438. }
  6439. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6440. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6441. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6442. strconv.FormatInt(his.PatientId, 10)
  6443. var res2 ResultSix
  6444. var resSix10265 ResultSix10265
  6445. var time_stamp string
  6446. if miConfig.MdtrtareaAdmvs == "421300" {
  6447. data := make(map[string]interface{})
  6448. client := &http.Client{}
  6449. data["psn_no"] = his.PsnNo
  6450. data["mdtrt_id"] = his.Number
  6451. data["doctor"] = roles.UserName
  6452. data["department"] = department.Name
  6453. data["org_name"] = miConfig.OrgName
  6454. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6455. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6456. data["fixmedins_code"] = miConfig.Code
  6457. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6458. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6459. data["secret_key"] = miConfig.SecretKey
  6460. data["sick_code"] = sickConfig.CountryCode
  6461. data["sick_name"] = sickConfig.ClassName
  6462. data["begin_time"] = begin_time
  6463. data["dept"] = strconv.FormatInt(department.ID, 10)
  6464. data["config"] = config
  6465. fmt.Println(data)
  6466. bytesData, _ := json.Marshal(data)
  6467. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  6468. resp, _ := client.Do(req)
  6469. defer resp.Body.Close()
  6470. body, ioErr := ioutil.ReadAll(resp.Body)
  6471. if ioErr != nil {
  6472. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6474. return
  6475. }
  6476. var respJSON map[string]interface{}
  6477. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6478. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6480. return
  6481. }
  6482. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6483. userJSONBytes, _ := json.Marshal(respJSON)
  6484. fmt.Println("log")
  6485. fmt.Println(string(userJSONBytes))
  6486. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6487. utils.ErrorLog("解析失败:%v", err)
  6488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6489. return
  6490. }
  6491. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6492. //江苏地区国家医保医疗类别
  6493. //职工透析:医疗类别选特殊情况门诊9933
  6494. //居民血透门慢: 医疗类别选门诊慢病1402
  6495. //var med_type string
  6496. //if his.Insutype == "310" {
  6497. // if reg_type == 14 {
  6498. // med_type = "9933"
  6499. // } else if reg_type == 11 {
  6500. // med_type = "11"
  6501. //
  6502. // }
  6503. //} else if his.Insutype == "390" {
  6504. // if reg_type == 14 {
  6505. // med_type = "1402"
  6506. // } else if reg_type == 11 {
  6507. // med_type = "11"
  6508. // }
  6509. //}
  6510. data := make(map[string]interface{})
  6511. client := &http.Client{}
  6512. data["psn_no"] = his.PsnNo
  6513. data["mdtrt_id"] = his.Number
  6514. data["doctor"] = roles.UserName
  6515. data["department"] = department.Name
  6516. data["org_name"] = miConfig.OrgName
  6517. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6518. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6519. data["fixmedins_code"] = miConfig.Code
  6520. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6521. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6522. data["secret_key"] = miConfig.SecretKey
  6523. data["sick_code"] = sickConfig.CountryCode
  6524. data["sick_name"] = sickConfig.ClassName
  6525. data["begin_time"] = begin_time
  6526. data["dept"] = strconv.FormatInt(department.ID, 10)
  6527. data["config"] = config
  6528. data["url"] = miConfig.Url
  6529. data["ak"] = miConfig.AccessKey
  6530. data["cainfo"] = miConfig.Cainfo
  6531. bytesData, _ := json.Marshal(data)
  6532. var req *http.Request
  6533. if miConfig.MdtrtareaAdmvs == "320921" {
  6534. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6535. //api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  6536. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  6537. } else {
  6538. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6539. }
  6540. resp, _ := client.Do(req)
  6541. defer resp.Body.Close()
  6542. body, ioErr := ioutil.ReadAll(resp.Body)
  6543. if ioErr != nil {
  6544. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6546. return
  6547. }
  6548. var respJSON map[string]interface{}
  6549. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6550. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6552. return
  6553. }
  6554. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  6555. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  6556. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  6557. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6558. userJSONBytes, _ := json.Marshal(respJSON)
  6559. fmt.Println("log")
  6560. fmt.Println(string(userJSONBytes))
  6561. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6562. utils.ErrorLog("解析失败:%v", err)
  6563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6564. return
  6565. }
  6566. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6567. res2.Output = resSix10265.Output
  6568. res2.ErrMsg = resSix10265.ErrMsg
  6569. res2.Cainfo = resSix10265.Cainfo
  6570. res2.WarnMsg = resSix10265.WarnMsg
  6571. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6572. res2.Infcode = infocode
  6573. } else {
  6574. var result string
  6575. var requestLog string
  6576. if miConfig.MdtrtareaAdmvs == "440781" { //
  6577. 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)
  6578. } else {
  6579. if miConfig.Code == "H15049901371" {
  6580. //赤峰地区国家医保医疗类别
  6581. //职工透析:医疗类别选特殊情况门诊990502
  6582. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6583. var med_type string
  6584. if his.Insutype == "390" {
  6585. if reg_type == 14 {
  6586. med_type = "9933"
  6587. } else if reg_type == 11 {
  6588. med_type = "11"
  6589. }
  6590. } else if his.Insutype == "310" {
  6591. if reg_type == 14 {
  6592. med_type = "990502"
  6593. } else if reg_type == 11 {
  6594. med_type = "11"
  6595. }
  6596. }
  6597. 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)
  6598. } else {
  6599. 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)
  6600. }
  6601. saveLog(result, requestLog, "2203", "上传就诊信息")
  6602. var respJSON2 map[string]interface{}
  6603. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6604. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6606. return
  6607. }
  6608. userJSONBytes2, _ := json.Marshal(respJSON2)
  6609. if miConfig.Code == "H15049901371" {
  6610. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  6611. utils.ErrorLog("解析失败:%v", err)
  6612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6613. return
  6614. }
  6615. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6616. res2.Output = resSix10265.Output
  6617. res2.ErrMsg = resSix10265.ErrMsg
  6618. res2.Cainfo = resSix10265.Cainfo
  6619. res2.WarnMsg = resSix10265.WarnMsg
  6620. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6621. res2.Infcode = infocode
  6622. } else {
  6623. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  6624. utils.ErrorLog("解析失败:%v", err)
  6625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6626. return
  6627. }
  6628. }
  6629. }
  6630. }
  6631. if res2.Infcode != 0 {
  6632. adminUser := c.GetAdminUserInfo()
  6633. errlog := &models.HisOrderError{
  6634. UserOrgId: adminUser.CurrentOrgId,
  6635. Ctime: time.Now().Unix(),
  6636. Mtime: time.Now().Unix(),
  6637. ErrMsg: res2.ErrMsg,
  6638. Status: 1,
  6639. PatientId: id,
  6640. RecordTime: recordDateTime,
  6641. Stage: 3,
  6642. }
  6643. service.CreateErrMsgLog(errlog)
  6644. c.ServeSuccessJSON(map[string]interface{}{
  6645. "failed_code": -10,
  6646. "msg": res2.ErrMsg,
  6647. })
  6648. return
  6649. } else {
  6650. his.Diagnosis = diagnosis_id
  6651. his.SickType = sickConfig.ID
  6652. his.PType = fmt.Sprintf("%d", reg_type)
  6653. service.UpdateHisPatientThree(&his)
  6654. data := make(map[string]interface{})
  6655. if settle_accounts_type == 1 { //日结
  6656. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  6657. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  6658. } else {
  6659. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  6660. }
  6661. data["pre"] = prescriptions
  6662. } else { //月结
  6663. start_time_str := c.GetString("start_time")
  6664. end_time_str := c.GetString("end_time")
  6665. timeLayout := "2006-01-02"
  6666. loc, _ := time.LoadLocation("Local")
  6667. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6668. if err != nil {
  6669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6670. return
  6671. }
  6672. recordStartTime := theStartTime.Unix()
  6673. start_time = recordStartTime
  6674. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6675. if err != nil {
  6676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6677. return
  6678. }
  6679. recordEndTime := theEndTime.Unix()
  6680. end_time = recordEndTime
  6681. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  6682. data["pre"] = prescriptions
  6683. }
  6684. client := &http.Client{}
  6685. data["psn_no"] = his.PsnNo
  6686. data["mdtrt_id"] = his.Number
  6687. data["chrg_bchno"] = chrg_bchno
  6688. data["org_name"] = miConfig.OrgName
  6689. data["doctor"] = roles.UserName
  6690. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6691. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6692. data["fixmedins_code"] = miConfig.Code
  6693. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  6694. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  6695. data["dept_code"] = "15"
  6696. } else {
  6697. data["dept_code"] = department.Number
  6698. }
  6699. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6700. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6701. data["secret_key"] = miConfig.SecretKey
  6702. data["url"] = miConfig.Url
  6703. data["ak"] = miConfig.AccessKey
  6704. data["new_doctor_name"] = patientPrescription.Doctor
  6705. data["diag_code"] = sickConfig.CountryCode
  6706. data["time_stamp"] = time_stamp
  6707. data["cainfo"] = miConfig.Cainfo
  6708. var ids []int64
  6709. for _, item := range prescriptions {
  6710. ids = append(ids, item.ID)
  6711. }
  6712. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6713. if config.IsOpen == 1 { //对接了医保,走医保流程
  6714. var res ResultFour
  6715. var resFour10265 ResultFour10265
  6716. if miConfig.MdtrtareaAdmvs == "421300" {
  6717. bytesData, _ := json.Marshal(data)
  6718. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  6719. resp, _ := client.Do(req)
  6720. defer resp.Body.Close()
  6721. body, ioErr := ioutil.ReadAll(resp.Body)
  6722. if ioErr != nil {
  6723. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6725. return
  6726. }
  6727. var respJSON map[string]interface{}
  6728. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6729. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6731. return
  6732. }
  6733. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6734. userJSONBytes, _ := json.Marshal(respJSON)
  6735. fmt.Println("log")
  6736. fmt.Println(string(userJSONBytes))
  6737. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6738. utils.ErrorLog("解析失败:%v", err)
  6739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6740. return
  6741. }
  6742. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6743. bytesData, _ := json.Marshal(data)
  6744. var req *http.Request
  6745. if miConfig.MdtrtareaAdmvs == "320921" {
  6746. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6747. } else {
  6748. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6749. }
  6750. resp, _ := client.Do(req)
  6751. defer resp.Body.Close()
  6752. body, ioErr := ioutil.ReadAll(resp.Body)
  6753. if ioErr != nil {
  6754. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6756. return
  6757. }
  6758. var respJSON map[string]interface{}
  6759. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6760. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6762. return
  6763. }
  6764. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6765. userJSONBytes, _ := json.Marshal(respJSON)
  6766. fmt.Println("log")
  6767. fmt.Println(string(userJSONBytes))
  6768. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6769. utils.ErrorLog("解析失败:%v", err)
  6770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6771. return
  6772. }
  6773. res.InfRefmsgid = resFour10265.InfRefmsgid
  6774. res.Output = resFour10265.Output
  6775. res.ErrMsg = resFour10265.ErrMsg
  6776. res.Cainfo = resFour10265.Cainfo
  6777. res.WarnMsg = resFour10265.WarnMsg
  6778. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6779. res.Infcode = infocode
  6780. } else {
  6781. if miConfig.Code == "H15049901371" {
  6782. 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)
  6783. var dat map[string]interface{}
  6784. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6785. fmt.Println(dat)
  6786. } else {
  6787. fmt.Println(err)
  6788. }
  6789. saveLog(result, request_log, "2204", "上传费用明细")
  6790. userJSONBytes, _ := json.Marshal(dat)
  6791. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6792. utils.ErrorLog("解析失败:%v", err)
  6793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6794. return
  6795. }
  6796. res.InfRefmsgid = resFour10265.InfRefmsgid
  6797. res.Output = resFour10265.Output
  6798. res.ErrMsg = resFour10265.ErrMsg
  6799. res.Cainfo = resFour10265.Cainfo
  6800. res.WarnMsg = resFour10265.WarnMsg
  6801. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6802. res.Infcode = infocode
  6803. } else {
  6804. 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)
  6805. var dat map[string]interface{}
  6806. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6807. fmt.Println(dat)
  6808. } else {
  6809. fmt.Println(err)
  6810. }
  6811. saveLog(result, request_log, "2204", "上传费用明细")
  6812. userJSONBytes, _ := json.Marshal(dat)
  6813. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6814. utils.ErrorLog("解析失败:%v", err)
  6815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6816. return
  6817. }
  6818. }
  6819. }
  6820. if res.Infcode == 0 {
  6821. order := &models.HisOrder{
  6822. UserOrgId: adminUser.CurrentOrgId,
  6823. HisPatientId: his.ID,
  6824. PatientId: his.PatientId,
  6825. SettleAccountsDate: recordDateTime,
  6826. Ctime: time.Now().Unix(),
  6827. Mtime: time.Now().Unix(),
  6828. MdtrtId: his.Number,
  6829. PsnNo: his.PsnNo,
  6830. MedType: strconv.FormatInt(reg_type, 10),
  6831. Status: 1,
  6832. Number: chrg_bchno,
  6833. Infcode: res.Infcode,
  6834. WarnMsg: res.WarnMsg,
  6835. Cainfo: res.Cainfo,
  6836. ErrMsg: res.ErrMsg,
  6837. RespondTime: res.RefmsgTime,
  6838. InfRefmsgid: res.InfRefmsgid,
  6839. OrderStatus: 1,
  6840. IsMedicineInsurance: 1,
  6841. SettleType: settle_accounts_type,
  6842. SettleStartTime: start_time,
  6843. SettleEndTime: end_time,
  6844. Creator: roles.AdminUserId,
  6845. Modify: roles.AdminUserId,
  6846. PType: 2,
  6847. Diagnosis: diagnosis_id,
  6848. }
  6849. err = service.CreateOrder(order)
  6850. if err != nil {
  6851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6852. return
  6853. }
  6854. for _, item := range res.Output.Result {
  6855. temp := strings.Split(item.FeedetlSn, "-")
  6856. var advice_id int64 = 0
  6857. var project_id int64 = 0
  6858. var types int64 = 0
  6859. id, _ := strconv.ParseInt(temp[2], 10, 64)
  6860. types, _ = strconv.ParseInt(temp[1], 10, 64)
  6861. if temp[1] == "1" {
  6862. advice_id = id
  6863. project_id = 0
  6864. } else if temp[1] == "2" {
  6865. advice_id = 0
  6866. project_id = id
  6867. }
  6868. info := &models.HisOrderInfo{
  6869. OrderNumber: order.Number,
  6870. FeedetlSn: item.FeedetlSn,
  6871. UploadDate: time.Now().Unix(),
  6872. AdviceId: advice_id,
  6873. DetItemFeeSumamt: item.DetItemFeeSumamt,
  6874. Cnt: item.Cnt,
  6875. Pric: float64(item.Pric),
  6876. PatientId: his.PatientId,
  6877. PricUplmtAmt: item.PricUplmtAmt,
  6878. SelfpayProp: item.SelfpayProp,
  6879. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6880. OverlmtAmt: item.OverlmtAmt,
  6881. PreselfpayAmt: item.PreselfpayAmt,
  6882. BasMednFlag: item.BasMednFlag,
  6883. MedChrgitmType: item.MedChrgitmType,
  6884. HiNegoDrugFlag: item.HiNegoDrugFlag,
  6885. Status: 1,
  6886. Memo: item.Memo,
  6887. Mtime: time.Now().Unix(),
  6888. InscpScpAmt: item.InscpScpAmt,
  6889. DrtReimFlag: item.DrtReimFlag,
  6890. Ctime: time.Now().Unix(),
  6891. ListSpItemFlag: item.ListSpItemFlag,
  6892. ChldMedcFlag: item.ChldMedcFlag,
  6893. LmtUsedFlag: item.LmtUsedFlag,
  6894. ChrgitmLv: item.ChrgitmLv,
  6895. UserOrgId: adminUser.CurrentOrgId,
  6896. HisPatientId: his.ID,
  6897. OrderId: order.ID,
  6898. ProjectId: project_id,
  6899. Type: types,
  6900. }
  6901. service.CreateOrderInfo(info)
  6902. }
  6903. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6904. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  6905. var total float64
  6906. for _, item := range prescriptions {
  6907. if item.Type == 1 { //药品
  6908. for _, subItem := range item.HisDoctorAdviceInfo {
  6909. total = total + (subItem.Price * subItem.PrescribingNumber)
  6910. }
  6911. }
  6912. if item.Type == 2 { //项目
  6913. for _, subItem := range item.HisPrescriptionProject {
  6914. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6915. total = total + (subItem.Price * cnt)
  6916. }
  6917. }
  6918. }
  6919. for _, item := range prescriptions {
  6920. for _, subItem := range item.HisAdditionalCharge {
  6921. total = total + (subItem.Price * float64(subItem.Count))
  6922. }
  6923. }
  6924. allTotal := fmt.Sprintf("%.4f", total)
  6925. if res.Infcode == 0 {
  6926. var rf []*ResultFive
  6927. json.Unmarshal([]byte(his.Iinfo), &rf)
  6928. chrg_bchno := chrg_bchno
  6929. cert_no := his.Certno
  6930. var insutypes []string
  6931. var insutype string
  6932. var is390 int = 0
  6933. var is310 int = 0
  6934. for _, item := range rf {
  6935. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6936. insutypes = append(insutypes, item.Insutype)
  6937. }
  6938. }
  6939. if len(insutypes) == 1 {
  6940. insutype = insutypes[0]
  6941. } else {
  6942. for _, i := range insutypes {
  6943. if i == "390" {
  6944. is390 = 1
  6945. }
  6946. if i == "310" {
  6947. is310 = 1
  6948. }
  6949. }
  6950. }
  6951. if is390 == 1 {
  6952. insutype = "390"
  6953. }
  6954. if is310 == 1 {
  6955. insutype = "310"
  6956. }
  6957. if len(insutypes) == 0 {
  6958. insutype = "310"
  6959. }
  6960. if len(insutypes) == 2 {
  6961. insutype = strconv.FormatInt(his.SocialType, 64)
  6962. }
  6963. //insutype = "390"
  6964. if his.IdCardType == 1 {
  6965. cert_no = his.MedicalInsuranceNumber
  6966. } else {
  6967. cert_no = his.Certno
  6968. }
  6969. var res ResultSeven
  6970. var resSeven10265 ResultSeven10265
  6971. if miConfig.MdtrtareaAdmvs == "421300" {
  6972. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6973. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6974. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6975. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6976. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6977. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6978. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  6979. resp, requestErr := http.Get(api)
  6980. if requestErr != nil {
  6981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6982. return
  6983. }
  6984. body, ioErr := ioutil.ReadAll(resp.Body)
  6985. if ioErr != nil {
  6986. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6988. return
  6989. }
  6990. var respJSON map[string]interface{}
  6991. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6992. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6994. return
  6995. }
  6996. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6997. result, _ := json.Marshal(respJSON)
  6998. fmt.Println("log")
  6999. fmt.Println(string(result))
  7000. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7001. utils.ErrorLog("解析失败:%v", err)
  7002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7003. return
  7004. }
  7005. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7006. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7007. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7008. bas := strings.Split(psn_info.CardInfo, "|")
  7009. if his.IdCardType == 1 {
  7010. cert_no = bas[2]
  7011. } else {
  7012. cert_no = bas[1]
  7013. }
  7014. //江苏地区国家医保医疗类别
  7015. //职工透析:医疗类别选特殊情况门诊9933
  7016. //居民血透门慢: 医疗类别选门诊慢病1402
  7017. //var med_type string
  7018. //if his.Insutype == "310" {
  7019. // if reg_type == 14 {
  7020. // med_type = "9933"
  7021. // } else if reg_type == 11 {
  7022. // med_type = "11"
  7023. //
  7024. // }
  7025. //} else if his.Insutype == "390" {
  7026. // if reg_type == 14 {
  7027. // med_type = "1402"
  7028. // } else if reg_type == 11 {
  7029. // med_type = "11"
  7030. // }
  7031. //}
  7032. var api string
  7033. if miConfig.MdtrtareaAdmvs == "320921" {
  7034. api = "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7035. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7036. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7037. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7038. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7039. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7040. "&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
  7041. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7042. } else {
  7043. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7044. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7045. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7046. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7047. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7048. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7049. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7050. "&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
  7051. }
  7052. resp, requestErr := http.Get(api)
  7053. if requestErr != nil {
  7054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7055. return
  7056. }
  7057. body, ioErr := ioutil.ReadAll(resp.Body)
  7058. if ioErr != nil {
  7059. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7061. return
  7062. }
  7063. var respJSON map[string]interface{}
  7064. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7065. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7067. return
  7068. }
  7069. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7070. result, _ := json.Marshal(respJSON)
  7071. fmt.Println("log")
  7072. fmt.Println(string(result))
  7073. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7074. utils.ErrorLog("解析失败:%v", err)
  7075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7076. return
  7077. }
  7078. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7079. res.Output = resSeven10265.Output
  7080. res.ErrMsg = resSeven10265.ErrMsg
  7081. res.Cainfo = resSeven10265.Cainfo
  7082. res.WarnMsg = resSeven10265.WarnMsg
  7083. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7084. res.Infcode = infocode
  7085. } else {
  7086. var result string
  7087. var request_log string
  7088. if miConfig.Code == "H15049901371" {
  7089. //赤峰地区国家医保医疗类别
  7090. //职工透析:医疗类别选特殊情况门诊990502
  7091. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7092. var med_type string
  7093. if his.Insutype == "390" {
  7094. if reg_type == 14 {
  7095. med_type = "9933"
  7096. } else if reg_type == 11 {
  7097. med_type = "11"
  7098. }
  7099. } else if his.Insutype == "310" {
  7100. if reg_type == 14 {
  7101. med_type = "990502"
  7102. } else if reg_type == 11 {
  7103. med_type = "11"
  7104. }
  7105. }
  7106. 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)
  7107. } else {
  7108. 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)
  7109. }
  7110. var dat map[string]interface{}
  7111. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7112. fmt.Println(dat)
  7113. } else {
  7114. fmt.Println(err)
  7115. }
  7116. saveLog(result, request_log, "2206", "预结算")
  7117. //userJSONBytes, _ := json.Marshal(dat)
  7118. //
  7119. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7120. // utils.ErrorLog("解析失败:%v", err)
  7121. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7122. // return
  7123. //}
  7124. userJSONBytes, _ := json.Marshal(dat)
  7125. if miConfig.Code == "H15049901371" {
  7126. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7127. utils.ErrorLog("解析失败:%v", err)
  7128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7129. return
  7130. }
  7131. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7132. res.Output = resSeven10265.Output
  7133. res.ErrMsg = resSeven10265.ErrMsg
  7134. res.Cainfo = resSeven10265.Cainfo
  7135. res.WarnMsg = resSeven10265.WarnMsg
  7136. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7137. res.Infcode = infocode
  7138. } else {
  7139. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7140. utils.ErrorLog("解析失败:%v", err)
  7141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7142. return
  7143. }
  7144. }
  7145. }
  7146. if res.Infcode != 0 {
  7147. errlog := &models.HisOrderError{
  7148. UserOrgId: adminUser.CurrentOrgId,
  7149. Ctime: time.Now().Unix(),
  7150. Mtime: time.Now().Unix(),
  7151. Number: chrg_bchno,
  7152. ErrMsg: res.ErrMsg,
  7153. Status: 1,
  7154. PatientId: id,
  7155. RecordTime: recordDateTime,
  7156. Stage: 20,
  7157. }
  7158. service.CreateErrMsgLog(errlog)
  7159. c.ServeSuccessJSON(map[string]interface{}{
  7160. "failed_code": -10,
  7161. "msg": res.ErrMsg,
  7162. })
  7163. return
  7164. } else {
  7165. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7166. order.OrderStatus = 1
  7167. order.IsPre = 1
  7168. order.Status = 1
  7169. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7170. order.SetlId = res.Output.Setlinfo.SetlID
  7171. order.PsnNo = res.Output.Setlinfo.PsnNo
  7172. order.PsnName = res.Output.Setlinfo.PsnName
  7173. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7174. order.Certno = res.Output.Setlinfo.Certno
  7175. order.Gend = res.Output.Setlinfo.Gend
  7176. order.Naty = res.Output.Setlinfo.Naty
  7177. order.Age = res.Output.Setlinfo.Age
  7178. order.Insutype = res.Output.Setlinfo.Insutype
  7179. order.PsnType = res.Output.Setlinfo.PsnType
  7180. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7181. order.SetlTime = res.Output.Setlinfo.SetlTime
  7182. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7183. if res.Output.Setlinfo.MedType == "140101" {
  7184. order.MedType = "14"
  7185. } else {
  7186. order.MedType = res.Output.Setlinfo.MedType
  7187. }
  7188. if reg_type == 1112 {
  7189. order.MedType = "1112"
  7190. }
  7191. if reg_type == 1111 {
  7192. order.MedType = "1111"
  7193. }
  7194. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7195. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7196. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7197. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7198. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7199. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7200. order.HifpPay = res.Output.Setlinfo.HifpPay
  7201. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7202. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7203. order.HifesPay = res.Output.Setlinfo.HifesPay
  7204. order.HifobPay = res.Output.Setlinfo.HifobPay
  7205. order.MafPay = res.Output.Setlinfo.MafPay
  7206. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  7207. order.OthPay = res.Output.Setlinfo.OthPay
  7208. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7209. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7210. order.AcctPay = res.Output.Setlinfo.AcctPay
  7211. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7212. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7213. order.Balc = res.Output.Setlinfo.Balc
  7214. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7215. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7216. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7217. order.ClrWay = res.Output.Setlinfo.ClrWay
  7218. order.Creator = order.Creator
  7219. order.Modify = roles.AdminUserId
  7220. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7221. detailStr := string(setlDetail)
  7222. order.SetlDetail = detailStr
  7223. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7224. err = service.UpDateOrder(order)
  7225. if err == nil {
  7226. c.ServeSuccessJSON(map[string]interface{}{
  7227. "msg": "预结算成功",
  7228. })
  7229. } else {
  7230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7231. return
  7232. }
  7233. }
  7234. } else {
  7235. adminUser := c.GetAdminUserInfo()
  7236. errlog := &models.HisOrderError{
  7237. UserOrgId: adminUser.CurrentOrgId,
  7238. Ctime: time.Now().Unix(),
  7239. Mtime: time.Now().Unix(),
  7240. ErrMsg: res.ErrMsg,
  7241. Status: 1,
  7242. PatientId: id,
  7243. RecordTime: recordDateTime,
  7244. Stage: 4,
  7245. }
  7246. service.CreateErrMsgLog(errlog)
  7247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7248. return
  7249. }
  7250. } else {
  7251. adminUser := c.GetAdminUserInfo()
  7252. errlog := &models.HisOrderError{
  7253. UserOrgId: adminUser.CurrentOrgId,
  7254. Ctime: time.Now().Unix(),
  7255. Mtime: time.Now().Unix(),
  7256. ErrMsg: res.ErrMsg,
  7257. Status: 1,
  7258. PatientId: id,
  7259. RecordTime: recordDateTime,
  7260. Stage: 4,
  7261. }
  7262. service.CreateErrMsgLog(errlog)
  7263. c.ServeSuccessJSON(map[string]interface{}{
  7264. "failed_code": -10,
  7265. "msg": res.ErrMsg,
  7266. })
  7267. return
  7268. }
  7269. }
  7270. }
  7271. }
  7272. //func (c *HisApiController) GetSettleInfo() {
  7273. // id, _ := c.GetInt64("id")
  7274. // order_id, _ := c.GetInt64("order_id")
  7275. //
  7276. // record_time := c.GetString("record_time")
  7277. // pay_way, _ := c.GetInt64("pay_way")
  7278. // pay_price, _ := c.GetFloat("pay_price")
  7279. // pay_card_no := c.GetString("pay_card_no")
  7280. // discount_price, _ := c.GetFloat("discount_price")
  7281. // preferential_price, _ := c.GetFloat("preferential_price")
  7282. // reality_price, _ := c.GetFloat("reality_price")
  7283. // found_price, _ := c.GetFloat("found_price")
  7284. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  7285. // private_price, _ := c.GetFloat("private_price")
  7286. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7287. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7288. //
  7289. // timeLayout := "2006-01-02"
  7290. // loc, _ := time.LoadLocation("Local")
  7291. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7292. // if err != nil {
  7293. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7294. // return
  7295. // }
  7296. // recordDateTime := theTime.Unix()
  7297. // adminUser := c.GetAdminUserInfo()
  7298. //
  7299. // var prescriptions []*models.HisPrescription
  7300. //
  7301. // data := make(map[string]interface{})
  7302. // if settle_accounts_type == 1 { //日结
  7303. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  7304. // data["pre"] = prescriptions
  7305. //
  7306. // } else { //月结
  7307. // start_time_str := c.GetString("start_time")
  7308. // end_time_str := c.GetString("end_time")
  7309. // timeLayout := "2006-01-02"
  7310. // loc, _ := time.LoadLocation("Local")
  7311. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7312. // if err != nil {
  7313. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7314. // return
  7315. // }
  7316. // recordStartTime := theStartTime.Unix()
  7317. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7318. // if err != nil {
  7319. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7320. // return
  7321. // }
  7322. // recordEndTime := theEndTime.Unix()
  7323. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  7324. // data["pre"] = prescriptions
  7325. //
  7326. // }
  7327. //
  7328. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7329. //
  7330. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7331. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7332. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7333. // strconv.FormatInt(his.PatientId, 10)
  7334. //
  7335. // order_src, _ := service.GetHisOrderByID(order_id)
  7336. //
  7337. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7338. // if config.IsOpen == 1 { //对接了医保,走医保流程
  7339. //
  7340. // var total float64
  7341. // for _, item := range prescriptions {
  7342. // if item.Type == 1 { //药品
  7343. // for _, subItem := range item.HisDoctorAdviceInfo {
  7344. // total = total + (subItem.Price * subItem.PrescribingNumber)
  7345. // }
  7346. // }
  7347. // if item.Type == 2 { //项目
  7348. // for _, subItem := range item.HisPrescriptionProject {
  7349. // total = total + (subItem.Price * float64(subItem.Count))
  7350. // }
  7351. // }
  7352. // }
  7353. //
  7354. // for _, item := range prescriptions {
  7355. // for _, subItem := range item.HisAdditionalCharge {
  7356. // total = total + (subItem.Price * float64(subItem.Count))
  7357. // }
  7358. // }
  7359. //
  7360. // allTotal := fmt.Sprintf("%.2f", total)
  7361. // var rf []*ResultFive
  7362. // json.Unmarshal([]byte(his.Iinfo), &rf)
  7363. // psn_no := order_src.PsnNo
  7364. // mdtrt_id := order_src.MdtrtId
  7365. // chrg_bchno := order_src.Number
  7366. // cert_no := order_src.Certno
  7367. // insutype := rf[0].Insutype
  7368. //
  7369. // if his.IdCardType == 1 {
  7370. // cert_no = his.MedicalInsuranceNumber
  7371. // } else {
  7372. // cert_no = his.Certno
  7373. // }
  7374. //
  7375. // 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)
  7376. // var dat map[string]interface{}
  7377. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7378. // fmt.Println(dat)
  7379. // } else {
  7380. // fmt.Println(err)
  7381. // }
  7382. //
  7383. // userJSONBytes, _ := json.Marshal(dat)
  7384. //
  7385. //
  7386. //
  7387. // var res ResultSeven
  7388. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7389. // utils.ErrorLog("解析失败:%v", err)
  7390. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7391. // return
  7392. // }
  7393. // if res.Infcode == -1 {
  7394. // errlog := &models.HisOrderError{
  7395. // UserOrgId: adminUser.CurrentOrgId,
  7396. // Ctime: time.Now().Unix(),
  7397. // Mtime: time.Now().Unix(),
  7398. // Number: chrg_bchno,
  7399. // ErrMsg: res.ErrMsg,
  7400. // Status: 1,
  7401. // PatientId: id,
  7402. // RecordTime: recordDateTime,
  7403. // Stage: 6,
  7404. // }
  7405. // service.CreateErrMsgLog(errlog)
  7406. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7407. // return
  7408. // } else {
  7409. // order_src.OrderStatus = 2
  7410. // order_src.PayWay = pay_way
  7411. // order_src.PayPrice = pay_price
  7412. // order_src.PayCardNo = pay_card_no
  7413. // order_src.DiscountPrice = discount_price
  7414. // order_src.PreferentialPrice = preferential_price
  7415. // order_src.RealityPrice = reality_price
  7416. // order_src.FoundPrice = found_price
  7417. // order_src.MedicalInsurancePrice = medical_insurance_price
  7418. // order_src.PrivatePrice = private_price
  7419. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  7420. // order_src.SetlId = res.Output.Setlinfo.SetlID
  7421. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  7422. // order_src.PsnName = res.Output.Setlinfo.PsnName
  7423. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  7424. // order_src.Certno = res.Output.Setlinfo.Certno
  7425. // order_src.Gend = res.Output.Setlinfo.Gend
  7426. // order_src.Naty = res.Output.Setlinfo.Naty
  7427. // order_src.Age = res.Output.Setlinfo.Age
  7428. // order_src.Insutype = res.Output.Setlinfo.Insutype
  7429. // order_src.PsnType = res.Output.Setlinfo.PsnType
  7430. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7431. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  7432. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7433. // order_src.MedType = res.Output.Setlinfo.MedType
  7434. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7435. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7436. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7437. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7438. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7439. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7440. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  7441. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  7442. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7443. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  7444. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  7445. // order_src.MafPay = res.Output.Setlinfo.MafPay
  7446. // order_src.OthPay = res.Output.Setlinfo.OthPay
  7447. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7448. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7449. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  7450. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7451. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7452. // order_src.Balc = res.Output.Setlinfo.Balc
  7453. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7454. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7455. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  7456. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  7457. // order_src.Creator = order_src.Creator
  7458. // order_src.Modify = roles.ID
  7459. // order_src.RequestLog = src_resquest
  7460. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7461. // detailStr := string(setlDetail)
  7462. // order_src.SetlDetail = detailStr
  7463. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7464. // err = service.UpDateOrder(order_src)
  7465. //
  7466. // if err == nil {
  7467. // c.ServeSuccessJSON(map[string]interface{}{
  7468. // "msg": "结算成功",
  7469. // })
  7470. // } else {
  7471. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7472. // return
  7473. // }
  7474. // }
  7475. // }
  7476. //}
  7477. //退款
  7478. func (c *HisApiController) Refund() {
  7479. order_id, _ := c.GetInt64("order_id")
  7480. admin_user_id, _ := c.GetInt64("admin_user_id")
  7481. adminUser := c.GetAdminUserInfo()
  7482. var order models.HisOrder
  7483. order, _ = service.GetHisOrderByID(order_id)
  7484. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7485. if order.ID == 0 {
  7486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7487. return
  7488. }
  7489. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7490. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7491. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7492. if config.IsOpen == 1 { //对接了医保,走医保流程
  7493. var res ResultSixteen
  7494. var resSixteen10265 ResultSixteen10265
  7495. var src_resquest string
  7496. var result string
  7497. if miConfig.MdtrtareaAdmvs == "421300" {
  7498. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  7499. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7500. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7501. resp3, requestErr3 := http.Get(api3)
  7502. if requestErr3 != nil {
  7503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7504. return
  7505. }
  7506. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7507. if ioErr3 != nil {
  7508. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7510. return
  7511. }
  7512. var respJSON3 map[string]interface{}
  7513. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7514. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7516. return
  7517. }
  7518. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7519. userJSONBytes3, _ := json.Marshal(respJSON3)
  7520. fmt.Println("log")
  7521. fmt.Println(string(userJSONBytes3))
  7522. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  7523. utils.ErrorLog("解析失败:%v", err)
  7524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7525. return
  7526. }
  7527. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7528. var api3 string
  7529. if miConfig.MdtrtareaAdmvs == "320921" {
  7530. api3 = "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7531. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7532. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7533. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7534. } else {
  7535. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7536. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7537. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7538. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7539. }
  7540. resp3, requestErr3 := http.Get(api3)
  7541. if requestErr3 != nil {
  7542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7543. return
  7544. }
  7545. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7546. if ioErr3 != nil {
  7547. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7549. return
  7550. }
  7551. var respJSON3 map[string]interface{}
  7552. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7553. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7555. return
  7556. }
  7557. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7558. userJSONBytes3, _ := json.Marshal(respJSON3)
  7559. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  7560. utils.ErrorLog("解析失败:%v", err)
  7561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7562. return
  7563. }
  7564. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7565. res.Output = resSixteen10265.Output
  7566. res.ErrMsg = resSixteen10265.ErrMsg
  7567. res.Cainfo = resSixteen10265.Cainfo
  7568. res.WarnMsg = resSixteen10265.WarnMsg
  7569. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7570. res.Infcode = infocode
  7571. } else {
  7572. if miConfig.Code == "H15049901371" {
  7573. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7574. var dat map[string]interface{}
  7575. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7576. fmt.Println(dat)
  7577. } else {
  7578. fmt.Println(err)
  7579. }
  7580. saveLog(result, src_resquest, "2208", "退费")
  7581. userJSONBytes, _ := json.Marshal(dat)
  7582. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  7583. utils.ErrorLog("解析失败:%v", err)
  7584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7585. return
  7586. }
  7587. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7588. res.Output = resSixteen10265.Output
  7589. res.ErrMsg = resSixteen10265.ErrMsg
  7590. res.Cainfo = resSixteen10265.Cainfo
  7591. res.WarnMsg = resSixteen10265.WarnMsg
  7592. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7593. res.Infcode = infocode
  7594. } else {
  7595. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7596. var dat map[string]interface{}
  7597. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7598. fmt.Println(dat)
  7599. } else {
  7600. fmt.Println(err)
  7601. }
  7602. saveLog(result, src_resquest, "2208", "退费")
  7603. userJSONBytes, _ := json.Marshal(dat)
  7604. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7605. utils.ErrorLog("解析失败:%v", err)
  7606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7607. return
  7608. }
  7609. }
  7610. }
  7611. if res.Infcode == 0 {
  7612. var res2 ResultSix
  7613. var resSix10265 ResultSix10265
  7614. if miConfig.MdtrtareaAdmvs == "421300" {
  7615. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7616. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7617. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7618. resp3, requestErr3 := http.Get(api3)
  7619. if requestErr3 != nil {
  7620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7621. return
  7622. }
  7623. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7624. if ioErr3 != nil {
  7625. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7627. return
  7628. }
  7629. var respJSON3 map[string]interface{}
  7630. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7631. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7633. return
  7634. }
  7635. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7636. userJSONBytes3, _ := json.Marshal(respJSON3)
  7637. fmt.Println("log")
  7638. fmt.Println(string(userJSONBytes3))
  7639. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7640. utils.ErrorLog("解析失败:%v", err)
  7641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7642. return
  7643. }
  7644. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7645. var api3 string
  7646. if miConfig.MdtrtareaAdmvs == "320921" {
  7647. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7648. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7649. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7650. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7651. } else {
  7652. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7653. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7654. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7655. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7656. }
  7657. resp3, requestErr3 := http.Get(api3)
  7658. if requestErr3 != nil {
  7659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7660. return
  7661. }
  7662. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7663. if ioErr3 != nil {
  7664. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7666. return
  7667. }
  7668. var respJSON3 map[string]interface{}
  7669. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7670. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7672. return
  7673. }
  7674. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7675. userJSONBytes3, _ := json.Marshal(respJSON3)
  7676. fmt.Println("log")
  7677. fmt.Println(string(userJSONBytes3))
  7678. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7679. utils.ErrorLog("解析失败:%v", err)
  7680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7681. return
  7682. }
  7683. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7684. res2.Output = resSix10265.Output
  7685. res2.ErrMsg = resSix10265.ErrMsg
  7686. res2.Cainfo = resSix10265.Cainfo
  7687. res2.WarnMsg = resSix10265.WarnMsg
  7688. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7689. res2.Infcode = infocode
  7690. } else {
  7691. if miConfig.Code == "H15049901371" {
  7692. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7693. var dat map[string]interface{}
  7694. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7695. fmt.Println(dat)
  7696. } else {
  7697. fmt.Println(err)
  7698. }
  7699. saveLog(result2, src_request, "2205", "撤销明细")
  7700. userJSONBytes, _ := json.Marshal(dat)
  7701. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7702. utils.ErrorLog("解析失败:%v", err)
  7703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7704. return
  7705. }
  7706. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7707. res2.Output = resSix10265.Output
  7708. res2.ErrMsg = resSix10265.ErrMsg
  7709. res2.Cainfo = resSix10265.Cainfo
  7710. res2.WarnMsg = resSix10265.WarnMsg
  7711. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7712. res2.Infcode = infocode
  7713. } else {
  7714. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7715. var dat map[string]interface{}
  7716. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7717. fmt.Println(dat)
  7718. } else {
  7719. fmt.Println(err)
  7720. }
  7721. saveLog(result2, src_request, "2205", "撤销明细")
  7722. userJSONBytes, _ := json.Marshal(dat)
  7723. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7724. utils.ErrorLog("解析失败:%v", err)
  7725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7726. return
  7727. }
  7728. }
  7729. }
  7730. if res2.Infcode == 0 {
  7731. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  7732. if err == nil {
  7733. c.ServeSuccessJSON(map[string]interface{}{
  7734. "msg": "退费成功",
  7735. })
  7736. } else {
  7737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7738. return
  7739. }
  7740. } else {
  7741. c.ServeSuccessJSON(map[string]interface{}{
  7742. "code": -10,
  7743. "msg": res2.ErrMsg,
  7744. })
  7745. }
  7746. } else {
  7747. c.ServeSuccessJSON(map[string]interface{}{
  7748. "code": -10,
  7749. "msg": res.ErrMsg,
  7750. })
  7751. }
  7752. }
  7753. }
  7754. func (c *HisApiController) RefundNumber() {
  7755. record_time := c.GetString("record_time")
  7756. //patient_id, _ := c.GetInt64("patient_id")
  7757. admin_user_id, _ := c.GetInt64("admin_user_id")
  7758. his_patient_id, _ := c.GetInt64("id")
  7759. timeLayout := "2006-01-02"
  7760. loc, _ := time.LoadLocation("Local")
  7761. adminUser := c.GetAdminUserInfo()
  7762. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7763. fmt.Println(err)
  7764. if err != nil {
  7765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7766. return
  7767. }
  7768. recordDateTime := theTime.Unix()
  7769. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7770. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  7771. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7772. //order, _ := service.GetHisOrderByID(order_id)
  7773. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7774. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7775. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7776. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  7777. if count > 0 {
  7778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  7779. return
  7780. }
  7781. if config.IsOpen == 1 { //对接了医保,走医保流程
  7782. var res2 ResultSix
  7783. var resSix10265 ResultSix10265
  7784. if miConfig.MdtrtareaAdmvs == "421300" {
  7785. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  7786. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7787. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7788. resp3, requestErr3 := http.Get(api3)
  7789. if requestErr3 != nil {
  7790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7791. return
  7792. }
  7793. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7794. if ioErr3 != nil {
  7795. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7797. return
  7798. }
  7799. var respJSON3 map[string]interface{}
  7800. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7801. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7803. return
  7804. }
  7805. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7806. userJSONBytes3, _ := json.Marshal(respJSON3)
  7807. fmt.Println("log")
  7808. fmt.Println(string(userJSONBytes3))
  7809. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7810. utils.ErrorLog("解析失败:%v", err)
  7811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7812. return
  7813. }
  7814. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7815. var api3 string
  7816. if miConfig.MdtrtareaAdmvs == "320921" {
  7817. api3 = "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  7818. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7819. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7820. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7821. } else {
  7822. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7823. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  7824. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7825. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7826. }
  7827. resp3, requestErr3 := http.Get(api3)
  7828. if requestErr3 != nil {
  7829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7830. return
  7831. }
  7832. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7833. if ioErr3 != nil {
  7834. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7836. return
  7837. }
  7838. var respJSON3 map[string]interface{}
  7839. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7840. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7842. return
  7843. }
  7844. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7845. userJSONBytes3, _ := json.Marshal(respJSON3)
  7846. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7847. utils.ErrorLog("解析失败:%v", err)
  7848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7849. return
  7850. }
  7851. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7852. res2.Output = resSix10265.Output
  7853. res2.ErrMsg = resSix10265.ErrMsg
  7854. res2.Cainfo = resSix10265.Cainfo
  7855. res2.WarnMsg = resSix10265.WarnMsg
  7856. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7857. res2.Infcode = infocode
  7858. } else {
  7859. var api3 string
  7860. if miConfig.Code == "H15049901371" {
  7861. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7862. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7863. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7864. } else {
  7865. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7866. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7867. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7868. }
  7869. resp3, requestErr3 := http.Get(api3)
  7870. if requestErr3 != nil {
  7871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7872. return
  7873. }
  7874. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7875. if ioErr3 != nil {
  7876. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7878. return
  7879. }
  7880. var respJSON3 map[string]interface{}
  7881. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7882. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7884. return
  7885. }
  7886. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7887. userJSONBytes3, _ := json.Marshal(respJSON3)
  7888. if miConfig.Code == "H15049901371" {
  7889. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7890. utils.ErrorLog("解析失败:%v", err)
  7891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7892. return
  7893. }
  7894. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7895. res2.Output = resSix10265.Output
  7896. res2.ErrMsg = resSix10265.ErrMsg
  7897. res2.Cainfo = resSix10265.Cainfo
  7898. res2.WarnMsg = resSix10265.WarnMsg
  7899. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7900. res2.Infcode = infocode
  7901. } else {
  7902. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7903. utils.ErrorLog("解析失败:%v", err)
  7904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7905. return
  7906. }
  7907. }
  7908. }
  7909. if res2.Infcode == 0 {
  7910. if err == nil {
  7911. c.ServeSuccessJSON(map[string]interface{}{
  7912. "msg": "退号成功",
  7913. })
  7914. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  7915. } else {
  7916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7917. return
  7918. }
  7919. } else {
  7920. c.ServeSuccessJSON(map[string]interface{}{
  7921. "code": -10,
  7922. "msg": res2.ErrMsg,
  7923. })
  7924. }
  7925. } else {
  7926. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  7927. //if err == nil {
  7928. // c.ServeSuccessJSON(map[string]interface{}{
  7929. // "msg": "退费成功",
  7930. // })
  7931. //} else {
  7932. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7933. // return
  7934. //}
  7935. }
  7936. }
  7937. func (c *HisApiController) RefundDetail() {
  7938. order_id, _ := c.GetInt64("order_id")
  7939. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7940. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7941. number := c.GetString("number")
  7942. record_time := c.GetString("record_time")
  7943. patient_id, _ := c.GetInt64("patient_id")
  7944. //med_type, _ := c.GetInt64("med_type")
  7945. timeLayout := "2006-01-02"
  7946. loc, _ := time.LoadLocation("Local")
  7947. adminUser := c.GetAdminUserInfo()
  7948. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7949. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7950. fmt.Println(err)
  7951. if err != nil {
  7952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7953. return
  7954. }
  7955. recordDateTime := theTime.Unix()
  7956. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7957. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7958. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7959. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7960. var order models.HisOrder
  7961. order, _ = service.GetHisOrderByID(order_id)
  7962. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7963. if config.IsOpen == 1 { //对接了医保,走医保流程
  7964. var res2 ResultSix
  7965. if miConfig.MdtrtareaAdmvs == "421300" {
  7966. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7967. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7968. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7969. resp3, requestErr3 := http.Get(api3)
  7970. if requestErr3 != nil {
  7971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7972. return
  7973. }
  7974. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7975. if ioErr3 != nil {
  7976. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7978. return
  7979. }
  7980. var respJSON3 map[string]interface{}
  7981. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7982. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7984. return
  7985. }
  7986. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7987. userJSONBytes3, _ := json.Marshal(respJSON3)
  7988. fmt.Println("log")
  7989. fmt.Println(string(userJSONBytes3))
  7990. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7991. utils.ErrorLog("解析失败:%v", err)
  7992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7993. return
  7994. }
  7995. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7996. if err == nil {
  7997. c.ServeSuccessJSON(map[string]interface{}{
  7998. "msg": "撤销明细成功",
  7999. })
  8000. return
  8001. } else {
  8002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8003. return
  8004. }
  8005. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8006. var resSix10265 ResultSix10265
  8007. var api3 string
  8008. if miConfig.MdtrtareaAdmvs == "320921" {
  8009. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8010. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8011. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8012. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8013. } else {
  8014. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8015. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8016. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8017. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8018. }
  8019. resp3, requestErr3 := http.Get(api3)
  8020. if requestErr3 != nil {
  8021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8022. return
  8023. }
  8024. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8025. if ioErr3 != nil {
  8026. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8028. return
  8029. }
  8030. var respJSON3 map[string]interface{}
  8031. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8032. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8034. return
  8035. }
  8036. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8037. userJSONBytes3, _ := json.Marshal(respJSON3)
  8038. fmt.Println("log")
  8039. fmt.Println(string(userJSONBytes3))
  8040. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8041. utils.ErrorLog("解析失败:%v", err)
  8042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8043. return
  8044. }
  8045. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8046. res2.Output = resSix10265.Output
  8047. res2.ErrMsg = resSix10265.ErrMsg
  8048. res2.Cainfo = resSix10265.Cainfo
  8049. res2.WarnMsg = resSix10265.WarnMsg
  8050. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8051. res2.Infcode = infocode
  8052. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8053. if err == nil {
  8054. c.ServeSuccessJSON(map[string]interface{}{
  8055. "msg": "撤销明细成功",
  8056. })
  8057. return
  8058. } else {
  8059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8060. return
  8061. }
  8062. } else {
  8063. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  8064. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8065. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8066. resp2, requestErr2 := http.Get(api2)
  8067. if requestErr2 != nil {
  8068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8069. return
  8070. }
  8071. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8072. if ioErr2 != nil {
  8073. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8075. return
  8076. }
  8077. var respJSON2 map[string]interface{}
  8078. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8079. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8081. return
  8082. }
  8083. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8084. if err == nil {
  8085. c.ServeSuccessJSON(map[string]interface{}{
  8086. "msg": "撤销明细成功",
  8087. })
  8088. return
  8089. } else {
  8090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8091. return
  8092. }
  8093. }
  8094. } else {
  8095. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8096. if err == nil {
  8097. c.ServeSuccessJSON(map[string]interface{}{
  8098. "msg": "退费成功",
  8099. })
  8100. } else {
  8101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8102. return
  8103. }
  8104. }
  8105. }
  8106. //对账
  8107. func (c *HisApiController) GetCheckAccount() {
  8108. start_time := c.GetString("start_time")
  8109. end_time := c.GetString("end_time")
  8110. insutype := c.GetString("insutype")
  8111. clr_type := c.GetString("clr_type")
  8112. clr_org := c.GetString("clr_optins")
  8113. admin_user_id, _ := c.GetInt64("admin_user_id")
  8114. adminUser := c.GetAdminUserInfo()
  8115. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8116. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8117. if len(clr_org) == 0 {
  8118. clr_org = miConfig.MdtrtareaAdmvs
  8119. }
  8120. timeLayout := "2006-01-02"
  8121. loc, _ := time.LoadLocation("Local")
  8122. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8123. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8124. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  8125. fixmedins_setl_cnt := int64(len(orders))
  8126. var medfee_sumamt float64
  8127. var acct_pay float64
  8128. var fund_pay_sumamt float64
  8129. for _, item := range orders {
  8130. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8131. acct_pay = acct_pay + item.AcctPay
  8132. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8133. }
  8134. var user_name string
  8135. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8136. if role.ID == 0 {
  8137. user_name = "xxx"
  8138. } else {
  8139. user_name = role.UserName
  8140. }
  8141. var res ResultEight
  8142. var res10188 ResultEightFor10188
  8143. if config.IsOpen == 1 {
  8144. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8145. api := "http://192.168.3.111:9532/" + "jsyb/3201?" +
  8146. "insutype=" + insutype +
  8147. "&clr_type=" + "11" +
  8148. "&setl_optins=" + clr_org +
  8149. "&stmt_begndate=" + start_time +
  8150. "&stm_enddate=" + end_time +
  8151. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8152. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8153. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8154. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8155. "&fixmedins_code=" + miConfig.Code +
  8156. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8157. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8158. "&secret_key=" + miConfig.SecretKey +
  8159. "&org_name=" + miConfig.OrgName +
  8160. "&doctor=" + user_name +
  8161. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8162. fmt.Println(api)
  8163. resp, requestErr := http.Get(api)
  8164. if requestErr != nil {
  8165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8166. return
  8167. }
  8168. body, ioErr := ioutil.ReadAll(resp.Body)
  8169. fmt.Println(body)
  8170. if ioErr != nil {
  8171. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8173. return
  8174. }
  8175. var respJSON map[string]interface{}
  8176. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8177. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8179. return
  8180. }
  8181. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8182. userJSONBytes, _ := json.Marshal(respJSON)
  8183. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8184. utils.ErrorLog("解析失败:%v", err)
  8185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8186. return
  8187. }
  8188. res.InfRefmsgid = res10188.InfRefmsgid
  8189. res.Output = res10188.Output
  8190. res.ErrMsg = res10188.ErrMsg
  8191. res.Cainfo = res10188.Cainfo
  8192. res.WarnMsg = res10188.WarnMsg
  8193. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8194. res.Infcode = infocode
  8195. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8196. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  8197. "insutype=" + insutype +
  8198. "&clr_type=" + "11" +
  8199. "&setl_optins=" + clr_org +
  8200. "&stmt_begndate=" + start_time +
  8201. "&stm_enddate=" + end_time +
  8202. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8203. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8204. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8205. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8206. "&fixmedins_code=" + miConfig.Code +
  8207. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8208. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8209. "&secret_key=" + miConfig.SecretKey +
  8210. "&org_name=" + miConfig.OrgName +
  8211. "&doctor=" + user_name
  8212. resp, requestErr := http.Get(api)
  8213. if requestErr != nil {
  8214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8215. return
  8216. }
  8217. body, ioErr := ioutil.ReadAll(resp.Body)
  8218. if ioErr != nil {
  8219. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8221. return
  8222. }
  8223. var respJSON map[string]interface{}
  8224. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8225. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8227. return
  8228. }
  8229. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8230. result, _ := json.Marshal(respJSON)
  8231. fmt.Println("log")
  8232. fmt.Println(string(result))
  8233. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  8234. utils.ErrorLog("解析失败:%v", err)
  8235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8236. return
  8237. }
  8238. res.InfRefmsgid = res10188.InfRefmsgid
  8239. res.Output = res10188.Output
  8240. res.ErrMsg = res10188.ErrMsg
  8241. res.Cainfo = res10188.Cainfo
  8242. res.WarnMsg = res10188.WarnMsg
  8243. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8244. res.Infcode = infocode
  8245. } else {
  8246. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8247. "insutype=" + insutype +
  8248. "&clr_type=" + clr_type +
  8249. "&setl_optins=" + clr_org +
  8250. "&stmt_begndate=" + start_time +
  8251. "&stm_enddate=" + end_time +
  8252. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8253. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8254. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8255. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8256. "&fixmedins_code=" + miConfig.Code +
  8257. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8258. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8259. "&secret_key=" + miConfig.SecretKey +
  8260. "&org_name=" + miConfig.OrgName +
  8261. "&doctor=" + user_name
  8262. fmt.Println(api)
  8263. resp, requestErr := http.Get(api)
  8264. if requestErr != nil {
  8265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8266. return
  8267. }
  8268. body, ioErr := ioutil.ReadAll(resp.Body)
  8269. fmt.Println(body)
  8270. if ioErr != nil {
  8271. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8273. return
  8274. }
  8275. var respJSON map[string]interface{}
  8276. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8277. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8279. return
  8280. }
  8281. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8282. userJSONBytes, _ := json.Marshal(respJSON)
  8283. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8284. utils.ErrorLog("解析失败:%v", err)
  8285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8286. return
  8287. }
  8288. }
  8289. if res.Infcode == 0 {
  8290. if res.Output.Stmtinfo.StmtRslt == "0" {
  8291. micc := &models.MedicalInsuranceCostCompare{
  8292. StartTime: startime.Unix(),
  8293. EndTime: endtime.Unix(),
  8294. Insutype: insutype,
  8295. CheckType: 1,
  8296. Num: fixmedins_setl_cnt,
  8297. Mtime: time.Now().Unix(),
  8298. Status: 1,
  8299. UserOrgId: adminUser.CurrentOrgId,
  8300. CostTotal: medfee_sumamt,
  8301. FuncTotal: fund_pay_sumamt,
  8302. PsnPay: acct_pay,
  8303. Creator: admin_user_id,
  8304. Ctime: time.Now().Unix(),
  8305. ClrType: clr_type,
  8306. }
  8307. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  8308. if err == nil {
  8309. c.ServeSuccessJSON(map[string]interface{}{
  8310. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8311. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8312. })
  8313. } else {
  8314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8315. }
  8316. } else {
  8317. c.ServeSuccessJSON(map[string]interface{}{
  8318. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8319. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8320. })
  8321. }
  8322. } else {
  8323. c.ServeSuccessJSON(map[string]interface{}{
  8324. "code": -10,
  8325. "msg": res.ErrMsg,
  8326. })
  8327. }
  8328. }
  8329. }
  8330. func (c *HisApiController) Check310() {
  8331. adminUser := c.GetAdminUserInfo()
  8332. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8333. var user_name string
  8334. user_name = "高慧裕"
  8335. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8336. "insutype=" + "310" +
  8337. "&clr_type=" + "" +
  8338. "&setl_optins=" + "441202" +
  8339. "&stmt_begndate=" + "2022-03-01" +
  8340. "&stm_enddate=" + "2022-03-31" +
  8341. "&medfee_sumamt=" + "194930.12" +
  8342. "&fund_pay_sumamt=" + "188741.46" +
  8343. "&acct_pay=" + "0" +
  8344. "&fixmedins_setl_cnt=" + "452" +
  8345. "&fixmedins_code=" + miConfig.Code +
  8346. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8347. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8348. "&secret_key=" + miConfig.SecretKey +
  8349. "&org_name=" + miConfig.OrgName +
  8350. "&doctor=" + user_name
  8351. fmt.Println(api)
  8352. resp, requestErr := http.Get(api)
  8353. if requestErr != nil {
  8354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8355. return
  8356. }
  8357. body, ioErr := ioutil.ReadAll(resp.Body)
  8358. fmt.Println(body)
  8359. if ioErr != nil {
  8360. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8362. return
  8363. }
  8364. var respJSON map[string]interface{}
  8365. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8366. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8368. return
  8369. }
  8370. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8371. userJSONBytes, _ := json.Marshal(respJSON)
  8372. var res ResultEight
  8373. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8374. utils.ErrorLog("解析失败:%v", err)
  8375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8376. return
  8377. }
  8378. }
  8379. func (c *HisApiController) Check390() {
  8380. adminUser := c.GetAdminUserInfo()
  8381. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8382. var user_name string
  8383. user_name = "高慧裕"
  8384. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8385. "insutype=" + "390" +
  8386. "&clr_type=" + "" +
  8387. "&setl_optins=" + "441202" +
  8388. "&stmt_begndate=" + "2022-03-01" +
  8389. "&stm_enddate=" + "2022-03-31" +
  8390. "&medfee_sumamt=" + "1068448.89" +
  8391. "&fund_pay_sumamt=" + "1014677.62" +
  8392. "&acct_pay=" + "0" +
  8393. "&fixmedins_setl_cnt=" + "1950" +
  8394. "&fixmedins_code=" + miConfig.Code +
  8395. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8396. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8397. "&secret_key=" + miConfig.SecretKey +
  8398. "&org_name=" + miConfig.OrgName +
  8399. "&doctor=" + user_name
  8400. fmt.Println(api)
  8401. resp, requestErr := http.Get(api)
  8402. if requestErr != nil {
  8403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8404. return
  8405. }
  8406. body, ioErr := ioutil.ReadAll(resp.Body)
  8407. fmt.Println(body)
  8408. if ioErr != nil {
  8409. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8411. return
  8412. }
  8413. var respJSON map[string]interface{}
  8414. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8415. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8417. return
  8418. }
  8419. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8420. userJSONBytes, _ := json.Marshal(respJSON)
  8421. var res ResultEight
  8422. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8423. utils.ErrorLog("解析失败:%v", err)
  8424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8425. return
  8426. }
  8427. }
  8428. //对账明细
  8429. func (c *HisApiController) GetCheckDetailAccount() {
  8430. start_time := c.GetString("start_time")
  8431. end_time := c.GetString("end_time")
  8432. admin_user_id, _ := c.GetInt64("admin_user_id")
  8433. adminUser := c.GetAdminUserInfo()
  8434. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8435. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8436. timeLayout := "2006-01-02"
  8437. loc, _ := time.LoadLocation("Local")
  8438. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8439. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8440. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  8441. Mkdir(miConfig.OrgName)
  8442. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  8443. file_name := file + ".txt"
  8444. zip_name := file + ".zip"
  8445. zip_path := miConfig.OrgName + "/" + zip_name
  8446. file_path := miConfig.OrgName + "/" + file_name
  8447. decimal.DivisionPrecision = 2
  8448. var medfee_sumamt float64
  8449. var psn_cash_pay float64
  8450. var fund_pay_sumamt float64
  8451. fixmedins_setl_cnt := int64(len(orders))
  8452. for _, item := range orders {
  8453. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8454. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  8455. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8456. }
  8457. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  8458. defer f.Close()
  8459. if err != nil {
  8460. fmt.Println(err.Error())
  8461. } else {
  8462. for _, item := range orders {
  8463. var refd_setl_flag string
  8464. if item.OrderStatus == 2 {
  8465. refd_setl_flag = "0"
  8466. var str string
  8467. str = item.SetlId + " " +
  8468. item.MdtrtId + " " +
  8469. item.PsnNo + " " +
  8470. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8471. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8472. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  8473. _, err = f.Write([]byte(str))
  8474. }
  8475. if item.OrderStatus == 3 {
  8476. var str string
  8477. str = item.SetlId + " " +
  8478. item.MdtrtId + " " +
  8479. item.PsnNo + " " +
  8480. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8481. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8482. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  8483. _, err = f.Write([]byte(str))
  8484. var str2 string
  8485. str2 = item.SetlId + " " +
  8486. item.MdtrtId + " " +
  8487. item.PsnNo + " " +
  8488. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  8489. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  8490. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  8491. _, err = f.Write([]byte(str2))
  8492. }
  8493. }
  8494. }
  8495. Zip(file_path, zip_path)
  8496. fmt.Println(ReadFile(zip_path))
  8497. fmt.Println(string(ReadFile(zip_path)))
  8498. if config.IsOpen == 1 {
  8499. var user_name string
  8500. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8501. if role.ID == 0 {
  8502. user_name = "管理员"
  8503. } else {
  8504. user_name = role.UserName
  8505. }
  8506. baseParams := models.BaseParams{
  8507. SecretKey: miConfig.SecretKey,
  8508. FixmedinsCode: miConfig.Code,
  8509. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8510. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8511. OrgName: miConfig.OrgName,
  8512. Doctor: user_name,
  8513. }
  8514. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  8515. var dat map[string]interface{}
  8516. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8517. fmt.Println(dat)
  8518. } else {
  8519. fmt.Println(err)
  8520. }
  8521. userJSONBytes, _ := json.Marshal(dat)
  8522. var res ResultNine
  8523. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8524. utils.ErrorLog("解析失败:%v", err)
  8525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8526. return
  8527. }
  8528. if res.Infcode == 0 {
  8529. fileNo := res.Output.FileQuryNo
  8530. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  8531. "file_qury_no=" + fileNo +
  8532. "&setl_optins=" + "定点医保中心" +
  8533. "&stmt_begndate=" + start_time +
  8534. "&stm_enddate=" + end_time +
  8535. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8536. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8537. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  8538. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8539. "&fixmedins_code=" + miConfig.Code +
  8540. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8541. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8542. "&secret_key=" + miConfig.SecretKey +
  8543. "&org_name=" + miConfig.OrgName +
  8544. "&doctor=" + user_name
  8545. resp, requestErr := http.Get(api)
  8546. if requestErr != nil {
  8547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8548. return
  8549. }
  8550. body, ioErr := ioutil.ReadAll(resp.Body)
  8551. if ioErr != nil {
  8552. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8554. return
  8555. }
  8556. var respJSON map[string]interface{}
  8557. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8558. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8560. return
  8561. }
  8562. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8563. userJSONBytes, _ := json.Marshal(respJSON)
  8564. var res ResultTen
  8565. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8566. utils.ErrorLog("解析失败:%v", err)
  8567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8568. return
  8569. }
  8570. if res.Infcode == 0 {
  8571. service.Gdyb9102(baseParams, zip_name, fileNo)
  8572. micc := &models.MedicalInsuranceCostCompare{
  8573. StartTime: startime.Unix(),
  8574. EndTime: endtime.Unix(),
  8575. Insutype: "0",
  8576. CheckType: 2,
  8577. Num: fixmedins_setl_cnt,
  8578. Mtime: time.Now().Unix(),
  8579. Status: 1,
  8580. UserOrgId: adminUser.CurrentOrgId,
  8581. CostTotal: medfee_sumamt,
  8582. FuncTotal: fund_pay_sumamt,
  8583. PsnPay: psn_cash_pay,
  8584. Creator: admin_user_id,
  8585. Ctime: time.Now().Unix(),
  8586. }
  8587. service.CreateMedicalInsuranceCostCompareRecord(micc)
  8588. c.ServeSuccessJSON(map[string]interface{}{
  8589. "msg": "明细对账成功",
  8590. })
  8591. }
  8592. } else {
  8593. }
  8594. }
  8595. }
  8596. type CustomOrderInfo struct {
  8597. Name string
  8598. Spec string
  8599. Unit string
  8600. Count float64
  8601. Price float64
  8602. Total float64
  8603. }
  8604. func (c *HisApiController) GetSettleAccounts() {
  8605. //id, _ := c.GetInt64("id")
  8606. //record_time := c.GetString("record_time")
  8607. order_id, _ := c.GetInt64("order_id")
  8608. admin_user_id, _ := c.GetInt64("admin_user_id")
  8609. //timeLayout := "2006-01-02"
  8610. //loc, _ := time.LoadLocation("Local")
  8611. //
  8612. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8613. //if err != nil {
  8614. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8615. // return
  8616. //}
  8617. //recordDateTime := theTime.Unix()
  8618. adminUser := c.GetAdminUserInfo()
  8619. order, _ := service.GetHisOrderByID(order_id)
  8620. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8621. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  8622. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8623. orderInfos = append(orderInfos, orderInfos_two...)
  8624. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8625. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  8626. var diagnosis_ids []string
  8627. if his.ID > 0 {
  8628. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  8629. } else {
  8630. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  8631. }
  8632. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  8633. var dia_config []*models.HisXtDiagnoseConfig
  8634. var name string
  8635. for _, item := range diagnosis_ids {
  8636. id, _ := strconv.ParseInt(item, 10, 64)
  8637. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8638. dia_config = append(dia_config, &diagnosisConfig)
  8639. if len(name) == 0 {
  8640. name = diagnosisConfig.ClassName
  8641. } else {
  8642. name = name + "," + diagnosisConfig.ClassName
  8643. }
  8644. }
  8645. var bedCostTotal float64 = 0 //床位总费
  8646. var bedCostSelfTotal float64 = 0 //床位自费
  8647. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  8648. var operationCostTotal float64 = 0 //手术费
  8649. var operationCostSelfTotal float64 = 0 //手术费
  8650. var operationCostPartSelfTotal float64 = 0 //手术费
  8651. var otherCostTotal float64 = 0 //其他费用
  8652. var otherCostSelfTotal float64 = 0 //其他费用
  8653. var otherCostPartSelfTotal float64 = 0 //其他费用
  8654. var materialCostTotal float64 = 0 //材料费
  8655. var materialCostSelfTotal float64 = 0 //材料费
  8656. var materialCostPartSelfTotal float64 = 0 //材料费
  8657. var westernMedicineCostTotal float64 = 0 //西药费
  8658. var westernMedicineCostSelfTotal float64 = 0 //西药费
  8659. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  8660. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  8661. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  8662. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  8663. var checkCostTotal float64 = 0 //检查费
  8664. var checkCostSelfTotal float64 = 0 //检查费
  8665. var checkCostPartSelfTotal float64 = 0 //检查费
  8666. var laboratoryCostTotal float64 = 0 //化验费
  8667. var laboratoryCostSelfTotal float64 = 0 //化验费
  8668. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  8669. var treatCostTotal float64 = 0 //治疗费用
  8670. var treatCostSelfTotal float64 = 0 //治疗费用
  8671. var treatCostPartSelfTotal float64 = 0 //治疗费用
  8672. decimal.DivisionPrecision = 2
  8673. for _, item := range orderInfos {
  8674. if item.MedChrgitmType == "01" { //床位费
  8675. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8676. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8677. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8678. }
  8679. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  8680. if item.MedChrgitmType == "03" { //检查费
  8681. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8682. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8683. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8684. }
  8685. } else {
  8686. if item.MedChrgitmType == "03" { //检查费
  8687. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8688. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8689. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8690. }
  8691. }
  8692. if item.MedChrgitmType == "04" { //化验费
  8693. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8694. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8695. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8696. }
  8697. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  8698. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8699. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8700. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8701. }
  8702. if item.MedChrgitmType == "06" { //手术费
  8703. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8704. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8705. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8706. }
  8707. if item.MedChrgitmType == "08" { //材料费
  8708. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8709. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8710. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8711. }
  8712. if item.MedChrgitmType == "09" { //西药费
  8713. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8714. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8715. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8716. }
  8717. if item.MedChrgitmType == "11" { //中成费
  8718. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8719. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8720. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8721. }
  8722. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  8723. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8724. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8725. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8726. }
  8727. }
  8728. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8729. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8730. var user_name string
  8731. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8732. if role.ID == 0 {
  8733. user_name = "管理员"
  8734. } else {
  8735. user_name = role.UserName
  8736. }
  8737. baseParams := models.BaseParams{
  8738. SecretKey: miConfig.SecretKey,
  8739. FixmedinsCode: miConfig.Code,
  8740. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8741. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8742. OrgName: miConfig.OrgName,
  8743. Doctor: user_name,
  8744. }
  8745. businessParams := models.BusinessParams{
  8746. PsnNo: order.PsnNo,
  8747. MdtrtId: order.MdtrtId,
  8748. SetlId: order.SetlId,
  8749. }
  8750. var res ResultEleven
  8751. var resEleven10265 ResultEleven10265
  8752. if config.IsOpen == 1 {
  8753. if miConfig.MdtrtareaAdmvs == "421300" {
  8754. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8755. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8756. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8757. resp, requestErr := http.Get(api)
  8758. if requestErr != nil {
  8759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8760. return
  8761. }
  8762. body, ioErr := ioutil.ReadAll(resp.Body)
  8763. if ioErr != nil {
  8764. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8766. return
  8767. }
  8768. var respJSON map[string]interface{}
  8769. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8770. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8772. return
  8773. }
  8774. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8775. result, _ := json.Marshal(respJSON)
  8776. fmt.Println("log")
  8777. fmt.Println(string(result))
  8778. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8779. utils.ErrorLog("解析失败:%v", err)
  8780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8781. return
  8782. }
  8783. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8784. var api string
  8785. if miConfig.MdtrtareaAdmvs == "320921" {
  8786. api = "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8787. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8788. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8789. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8790. } else {
  8791. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8792. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8793. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8794. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8795. }
  8796. resp, requestErr := http.Get(api)
  8797. if requestErr != nil {
  8798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8799. return
  8800. }
  8801. body, ioErr := ioutil.ReadAll(resp.Body)
  8802. if ioErr != nil {
  8803. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8805. return
  8806. }
  8807. var respJSON map[string]interface{}
  8808. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8809. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8811. return
  8812. }
  8813. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8814. result, _ := json.Marshal(respJSON)
  8815. fmt.Println("log")
  8816. fmt.Println(string(result))
  8817. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  8818. utils.ErrorLog("解析失败:%v", err)
  8819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8820. return
  8821. }
  8822. res.InfRefmsgid = resEleven10265.InfRefmsgid
  8823. res.Output = resEleven10265.Output
  8824. res.ErrMsg = resEleven10265.ErrMsg
  8825. res.Cainfo = resEleven10265.Cainfo
  8826. res.WarnMsg = resEleven10265.WarnMsg
  8827. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  8828. res.Infcode = infocode
  8829. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8830. fmt.Println("~~~~~~~")
  8831. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8832. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8833. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8834. resp, requestErr := http.Get(api)
  8835. if requestErr != nil {
  8836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8837. return
  8838. }
  8839. body, ioErr := ioutil.ReadAll(resp.Body)
  8840. if ioErr != nil {
  8841. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8843. return
  8844. }
  8845. var respJSON map[string]interface{}
  8846. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8847. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8849. return
  8850. }
  8851. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8852. result, _ := json.Marshal(respJSON)
  8853. fmt.Println("log")
  8854. fmt.Println(string(result))
  8855. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  8856. utils.ErrorLog("解析失败:%v", err)
  8857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8858. return
  8859. }
  8860. res.InfRefmsgid = resEleven10265.InfRefmsgid
  8861. res.Output = resEleven10265.Output
  8862. res.ErrMsg = resEleven10265.ErrMsg
  8863. res.Cainfo = resEleven10265.Cainfo
  8864. res.WarnMsg = resEleven10265.WarnMsg
  8865. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  8866. res.Infcode = infocode
  8867. } else {
  8868. result := service.Gdyb5203(baseParams, businessParams)
  8869. //service.Gdyb5204(baseParams, businessParams)
  8870. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  8871. var dat map[string]interface{}
  8872. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8873. fmt.Println(dat)
  8874. } else {
  8875. fmt.Println(err)
  8876. }
  8877. userJSONBytes, _ := json.Marshal(dat)
  8878. if miConfig.Code == "H15049901371" {
  8879. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  8880. utils.ErrorLog("解析失败:%v", err)
  8881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8882. return
  8883. }
  8884. res.InfRefmsgid = resEleven10265.InfRefmsgid
  8885. res.Output = resEleven10265.Output
  8886. res.ErrMsg = resEleven10265.ErrMsg
  8887. res.Cainfo = resEleven10265.Cainfo
  8888. res.WarnMsg = resEleven10265.WarnMsg
  8889. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  8890. res.Infcode = infocode
  8891. } else {
  8892. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8893. utils.ErrorLog("解析失败:%v", err)
  8894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8895. return
  8896. }
  8897. }
  8898. }
  8899. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8900. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  8901. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  8902. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  8903. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  8904. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8905. var doctor_name string
  8906. if roles.ID == 0 {
  8907. doctor_name = "管理员"
  8908. } else {
  8909. doctor_name = roles.UserName
  8910. }
  8911. yiliao_leibie := ""
  8912. switch order.MedType {
  8913. case "11":
  8914. yiliao_leibie = "普通门诊"
  8915. break
  8916. case "12":
  8917. yiliao_leibie = "门诊挂号"
  8918. break
  8919. case "13":
  8920. yiliao_leibie = "急诊"
  8921. break
  8922. case "14":
  8923. yiliao_leibie = "门诊特殊病"
  8924. break
  8925. case "15":
  8926. yiliao_leibie = "门诊统筹"
  8927. break
  8928. case "16":
  8929. yiliao_leibie = "门诊慢性病"
  8930. break
  8931. case "21":
  8932. yiliao_leibie = "普通住院"
  8933. break
  8934. }
  8935. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8936. if res.Infcode == 0 {
  8937. c.ServeSuccessJSON(map[string]interface{}{
  8938. "diagnosis": name,
  8939. "order_infos": orderInfos,
  8940. "number": order.MdtrtId,
  8941. "date": order.SettleAccountsDate,
  8942. "charge_admin": charge_admin,
  8943. "printor_admin": printor_admin,
  8944. "info": res.Output.Setlinfo,
  8945. "order": order,
  8946. "bedCostTotal": bedCostTotal,
  8947. "bedCostSelfTotal": bedCostSelfTotal,
  8948. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  8949. "operationCostTotal": operationCostTotal,
  8950. "operationCostSelfTotal": operationCostSelfTotal,
  8951. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  8952. "otherCostTotal": otherCostTotal,
  8953. "otherCostSelfTotal": otherCostSelfTotal,
  8954. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  8955. "materialCostTotal": materialCostTotal,
  8956. "materialCostSelfTotal": materialCostSelfTotal,
  8957. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  8958. "westernMedicineCostTotal": westernMedicineCostTotal,
  8959. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  8960. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  8961. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  8962. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  8963. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  8964. "checkCostTotal": checkCostTotal,
  8965. "checkCostSelfTotal": checkCostSelfTotal,
  8966. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  8967. "laboratoryCostTotal": laboratoryCostTotal,
  8968. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  8969. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  8970. "treatCostTotal": treatCostTotal,
  8971. "treatCostSelfTotal": treatCostSelfTotal,
  8972. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  8973. "doctor_info": doctor_info,
  8974. "doctor_code": adminRole_two.DoctorCode,
  8975. "doctor_name": doctor_name,
  8976. "health_card_no": order.PsnNo,
  8977. "department": departments.Name,
  8978. "yiliao_leibie": yiliao_leibie,
  8979. "after_money": order.AccountPrice,
  8980. "patient": patient,
  8981. "org_name": miConfig.OrgName,
  8982. "org_code": miConfig.Code,
  8983. "order_number": order.Number,
  8984. "his_hospital": his_hospital,
  8985. "his": his,
  8986. "dia_config": dia_config,
  8987. //"check_order_info": cus_slice,
  8988. })
  8989. }
  8990. }
  8991. }
  8992. func (c *HisApiController) CheckTreatment() {
  8993. patient_id, _ := c.GetInt64("patient_id")
  8994. id_card_no := c.GetString("id_card_no")
  8995. insutype := c.GetString("insutype")
  8996. med_type := c.GetString("med_type")
  8997. admin_user_id, _ := c.GetInt64("admin_user_id")
  8998. adminUser := c.GetAdminUserInfo()
  8999. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9000. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9001. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9002. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9003. if miConfig.MdtrtareaAdmvs == "421300" {
  9004. var res ResultTwo
  9005. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  9006. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9007. "&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)
  9008. resp, requestErr := http.Get(api)
  9009. if requestErr != nil {
  9010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9011. return
  9012. }
  9013. body, ioErr := ioutil.ReadAll(resp.Body)
  9014. if ioErr != nil {
  9015. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9017. return
  9018. }
  9019. var respJSON map[string]interface{}
  9020. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9021. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9023. return
  9024. }
  9025. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9026. result, _ := json.Marshal(respJSON)
  9027. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9028. utils.ErrorLog("解析失败:%v", err)
  9029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9030. return
  9031. }
  9032. if res.Infcode == 0 {
  9033. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  9034. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9035. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  9036. resp, requestErr := http.Get(api)
  9037. if requestErr != nil {
  9038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9039. return
  9040. }
  9041. body, ioErr := ioutil.ReadAll(resp.Body)
  9042. if ioErr != nil {
  9043. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9045. return
  9046. }
  9047. var respJSON map[string]interface{}
  9048. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9049. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9051. return
  9052. }
  9053. var res Result2001
  9054. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9055. result2, _ := json.Marshal(respJSON)
  9056. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9057. utils.ErrorLog("解析失败:%v", err)
  9058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9059. return
  9060. }
  9061. if res.Infcode == 0 {
  9062. c.ServeSuccessJSON(map[string]interface{}{
  9063. "msg": res.Output.Trtinfo,
  9064. })
  9065. }
  9066. } else {
  9067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9068. return
  9069. }
  9070. } else {
  9071. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9072. var dat map[string]interface{}
  9073. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9074. fmt.Println(dat)
  9075. } else {
  9076. fmt.Println(err)
  9077. }
  9078. userJSONBytes, _ := json.Marshal(dat)
  9079. var res ResultTwo
  9080. var res10265 ResultTwo10265
  9081. if miConfig.Code == "H15049901371" {
  9082. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9083. utils.ErrorLog("解析失败:%v", err)
  9084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9085. return
  9086. }
  9087. res.ErrMsg = res10265.ErrMsg
  9088. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9089. res.Infcode = infocode
  9090. res.Output = res10265.Output
  9091. res.InfRefmsgid = res10265.InfRefmsgid
  9092. } else {
  9093. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9094. utils.ErrorLog("解析失败:%v", err)
  9095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9096. return
  9097. }
  9098. }
  9099. var user_name string
  9100. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  9101. if role.ID == 0 {
  9102. user_name = "xxx"
  9103. } else {
  9104. user_name = role.UserName
  9105. }
  9106. baseParams := models.BaseParams{
  9107. SecretKey: miConfig.SecretKey,
  9108. FixmedinsCode: miConfig.Code,
  9109. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9110. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9111. OrgName: miConfig.OrgName,
  9112. Doctor: user_name,
  9113. }
  9114. if config.IsOpen == 1 {
  9115. if miConfig.Code == "H15049901371" {
  9116. if med_type == "14" {
  9117. if insutype == "390" {
  9118. med_type = "9933"
  9119. } else if insutype == "310" {
  9120. med_type = "990502"
  9121. }
  9122. } else if med_type == "11" {
  9123. med_type = "11"
  9124. }
  9125. }
  9126. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  9127. var dat map[string]interface{}
  9128. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9129. fmt.Println(dat)
  9130. } else {
  9131. fmt.Println(err)
  9132. }
  9133. var res Result2001
  9134. var res10265 Result2001Org10265
  9135. if miConfig.Code == "H15049901371" {
  9136. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9137. utils.ErrorLog("解析失败:%v", err)
  9138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9139. return
  9140. }
  9141. res.ErrMsg = res10265.ErrMsg
  9142. res.Output = res10265.Output
  9143. res.InfRefmsgid = res10265.InfRefmsgid
  9144. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9145. res.Infcode = infocode
  9146. } else {
  9147. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9148. utils.ErrorLog("解析失败:%v", err)
  9149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9150. return
  9151. }
  9152. }
  9153. if res.Infcode == 0 {
  9154. c.ServeSuccessJSON(map[string]interface{}{
  9155. "msg": res.Output.Trtinfo,
  9156. })
  9157. }
  9158. }
  9159. }
  9160. }
  9161. //func (c *HisApiController) PutRecord() {
  9162. // id, _ := c.GetInt64("id")
  9163. // record_time := c.GetString("record_time")
  9164. // timeLayout := "2006-01-02"
  9165. // loc, _ := time.LoadLocation("Local")
  9166. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9167. // if err != nil {
  9168. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9169. // return
  9170. // }
  9171. // recordDateTime := theTime.Unix()
  9172. //
  9173. // adminInfo := c.GetAdminUserInfo()
  9174. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  9175. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9176. //
  9177. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9178. //
  9179. // fmt.Println(miConfig.SecretKey)
  9180. //
  9181. // if patient == nil {
  9182. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9183. // return
  9184. // }
  9185. // if len(patient.IdCardNo) == 0 {
  9186. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  9187. // return
  9188. // }
  9189. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  9190. // if config.IsOpen == 1 {
  9191. // 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
  9192. // resp, requestErr := http.Get(api)
  9193. // if requestErr != nil {
  9194. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9195. // return
  9196. // }
  9197. // defer resp.Body.Close()
  9198. // body, ioErr := ioutil.ReadAll(resp.Body)
  9199. // if ioErr != nil {
  9200. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9201. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9202. // return
  9203. // }
  9204. // var respJSON map[string]interface{}
  9205. //
  9206. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9207. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9208. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9209. // return
  9210. // }
  9211. //
  9212. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9213. // userJSONBytes, _ := json.Marshal(userJSON)
  9214. // var res ResultTwo
  9215. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9216. // utils.ErrorLog("解析失败:%v", err)
  9217. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9218. // return
  9219. // }
  9220. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9221. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9222. // infoStr := string(Iinfos)
  9223. // idetinfoStr := string(Idetinfos)
  9224. //
  9225. // if res.Infcode == 0 {
  9226. // his := models.VMHisPatient{
  9227. // Status: 1,
  9228. // Ctime: time.Now().Unix(),
  9229. // Mtime: time.Now().Unix(),
  9230. // PsnNo: res.Output.Baseinfo.PsnNo,
  9231. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  9232. // Certno: res.Output.Baseinfo.Certno,
  9233. // PsnName: res.Output.Baseinfo.PsnName,
  9234. // Gend: res.Output.Baseinfo.Gend,
  9235. // Naty: res.Output.Baseinfo.Naty,
  9236. // Brdy: res.Output.Baseinfo.Brdy,
  9237. // Age: res.Output.Baseinfo.Age,
  9238. // Iinfo: infoStr,
  9239. // Idetinfo: idetinfoStr,
  9240. // PatientId: patient.ID,
  9241. // RecordDate: theTime.Unix(),
  9242. // UserOrgId: adminInfo.CurrentOrgId,
  9243. // AdminUserId: adminInfo.AdminUser.Id,
  9244. // IsReturn: 1,
  9245. // }
  9246. //
  9247. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  9248. // //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")
  9249. // //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")
  9250. //
  9251. // //var dat map[string]interface{}
  9252. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9253. // // fmt.Println(dat)
  9254. // //} else {
  9255. // // fmt.Println(err)
  9256. // //}
  9257. //
  9258. // var dat2 map[string]interface{}
  9259. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9260. // fmt.Println(dat2)
  9261. // } else {
  9262. // fmt.Println(err)
  9263. // }
  9264. //
  9265. // } else {
  9266. // adminUser := c.GetAdminUserInfo()
  9267. // errlog := &models.HisOrderError{
  9268. // UserOrgId: adminUser.CurrentOrgId,
  9269. // Ctime: time.Now().Unix(),
  9270. // Mtime: time.Now().Unix(),
  9271. // ErrMsg: res.ErrMsg,
  9272. // Status: 1,
  9273. // PatientId: id,
  9274. // RecordTime: recordDateTime,
  9275. // Stage: 1,
  9276. // }
  9277. // service.CreateErrMsgLog(errlog)
  9278. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  9279. // return
  9280. // }
  9281. // }
  9282. //
  9283. //}
  9284. //func (c *HisApiController) GetUploadDiag() {
  9285. // id, _ := c.GetInt64("id")
  9286. // record_time := c.GetString("record_time")
  9287. //
  9288. // diagnosis_id, _ := c.GetInt64("diagnosis")
  9289. // sick_type, _ := c.GetInt64("sick_type")
  9290. // reg_type, _ := c.GetInt64("reg_type")
  9291. //
  9292. // timeLayout := "2006-01-02"
  9293. // loc, _ := time.LoadLocation("Local")
  9294. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9295. // if err != nil {
  9296. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9297. // return
  9298. // }
  9299. //
  9300. // var patientPrescription models.HisPrescriptionInfo
  9301. // recordDateTime := theTime.Unix()
  9302. // adminInfo := c.GetAdminUserInfo()
  9303. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9304. //
  9305. // if patientPrescription.ID == 0 {
  9306. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9307. // }
  9308. //
  9309. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9310. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9311. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9312. // sickConfig, _ := service.FindSickById(sick_type)
  9313. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9314. //
  9315. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  9316. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  9317. // "&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 +
  9318. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  9319. // resp2, requestErr2 := http.Get(api2)
  9320. // if requestErr2 != nil {
  9321. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9322. // return
  9323. // }
  9324. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  9325. // if ioErr2 != nil {
  9326. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  9327. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9328. // return
  9329. // }
  9330. // var respJSON2 map[string]interface{}
  9331. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  9332. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9333. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9334. // return
  9335. // }
  9336. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9337. // userJSONBytes2, _ := json.Marshal(respJSON2)
  9338. //
  9339. // var res2 ResultSix
  9340. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9341. // utils.ErrorLog("解析失败:%v", err)
  9342. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9343. // return
  9344. // }
  9345. // if res2.Infcode != 0 {
  9346. // adminUser := c.GetAdminUserInfo()
  9347. // errlog := &models.HisOrderError{
  9348. // UserOrgId: adminUser.CurrentOrgId,
  9349. // Ctime: time.Now().Unix(),
  9350. // Mtime: time.Now().Unix(),
  9351. // ErrMsg: res2.ErrMsg,
  9352. // Status: 1,
  9353. // PatientId: id,
  9354. // RecordTime: recordDateTime,
  9355. // Stage: 3,
  9356. // }
  9357. // service.CreateErrMsgLog(errlog)
  9358. //
  9359. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  9360. // return
  9361. // }
  9362. //
  9363. // c.ServeSuccessJSON(map[string]interface{}{
  9364. // "msg": "上传成功",
  9365. // })
  9366. //
  9367. //}
  9368. type QueryResult struct {
  9369. ID int64
  9370. Name string
  9371. Code string
  9372. List_type_code string
  9373. }
  9374. func (c *HisApiController) GetCheckCode() {
  9375. ids_str := c.GetString("ids")
  9376. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9377. ids_arr := strings.Split(ids_str, ",")
  9378. var queryResult []QueryResult
  9379. ids := make([]int64, 0)
  9380. for _, item := range ids_arr {
  9381. id, _ := strconv.ParseInt(item, 10, 64)
  9382. ids = append(ids, id)
  9383. }
  9384. if record_type == 1 {
  9385. drugs, _ := service.GetBatchDrugList(ids)
  9386. for _, item := range drugs {
  9387. result := QueryResult{
  9388. ID: item.ID,
  9389. Name: item.DrugName,
  9390. Code: item.MedicalInsuranceNumber,
  9391. List_type_code: "101",
  9392. }
  9393. queryResult = append(queryResult, result)
  9394. }
  9395. } else if record_type == 2 {
  9396. goods, _ := service.GetBatchGoodInformationList(ids)
  9397. for _, item := range goods {
  9398. result := QueryResult{
  9399. ID: item.ID,
  9400. Name: item.GoodName,
  9401. Code: item.MedicalInsuranceNumber,
  9402. List_type_code: "301",
  9403. }
  9404. queryResult = append(queryResult, result)
  9405. }
  9406. } else if record_type == 3 {
  9407. projects, _ := service.GetBathchMyPorjecgList(ids)
  9408. for _, item := range projects {
  9409. result := QueryResult{
  9410. ID: item.ID,
  9411. Name: item.ProjectName,
  9412. Code: item.MedicalCode,
  9413. List_type_code: "201",
  9414. }
  9415. queryResult = append(queryResult, result)
  9416. }
  9417. }
  9418. admin_user_id, _ := c.GetInt64("admin_user_id")
  9419. adminUser := c.GetAdminUserInfo()
  9420. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9421. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9422. var user_name string
  9423. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9424. if role.ID == 0 {
  9425. user_name = "xxx"
  9426. } else {
  9427. user_name = role.UserName
  9428. }
  9429. baseParams := &models.BaseParams{
  9430. SecretKey: miConfig.SecretKey,
  9431. FixmedinsCode: miConfig.Code,
  9432. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9433. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9434. OrgName: miConfig.OrgName,
  9435. Doctor: user_name,
  9436. }
  9437. if config.IsOpen == 1 {
  9438. for _, item := range queryResult {
  9439. var result string
  9440. if record_type == 1 {
  9441. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9442. } else if record_type == 2 {
  9443. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9444. } else if record_type == 3 {
  9445. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9446. }
  9447. var dat map[string]interface{}
  9448. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9449. fmt.Println(dat)
  9450. } else {
  9451. fmt.Println(err)
  9452. }
  9453. userJSONBytes, _ := json.Marshal(dat)
  9454. var res ResultSix
  9455. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9456. utils.ErrorLog("解析失败:%v", err)
  9457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9458. return
  9459. }
  9460. if res.Infcode == 0 {
  9461. if record_type == 1 {
  9462. service.UpdateBaseDrugById(item.ID)
  9463. } else if record_type == 2 {
  9464. service.UpdateGoodInformaitonByDetail(item.ID)
  9465. } else if record_type == 3 {
  9466. service.UpdateProjectById(item.ID)
  9467. }
  9468. c.ServeSuccessJSON(map[string]interface{}{
  9469. "failed_code": 0,
  9470. "msg": "目录对照成功",
  9471. })
  9472. } else {
  9473. c.ServeSuccessJSON(map[string]interface{}{
  9474. "failed_code": -10,
  9475. "msg": res.ErrMsg,
  9476. })
  9477. }
  9478. }
  9479. }
  9480. }
  9481. func (c *HisApiController) UnCheckCode() {
  9482. ids_str := c.GetString("ids")
  9483. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9484. admin_user_id, _ := c.GetInt64("admin_user_id")
  9485. ids_arr := strings.Split(ids_str, ",")
  9486. var queryResult []QueryResult
  9487. ids := make([]int64, 0)
  9488. for _, item := range ids_arr {
  9489. id, _ := strconv.ParseInt(item, 10, 64)
  9490. ids = append(ids, id)
  9491. }
  9492. if record_type == 1 {
  9493. drugs, _ := service.GetBatchDrugList(ids)
  9494. for _, item := range drugs {
  9495. result := QueryResult{
  9496. ID: item.ID,
  9497. Name: item.DrugName,
  9498. Code: item.MedicalInsuranceNumber,
  9499. List_type_code: "101",
  9500. }
  9501. queryResult = append(queryResult, result)
  9502. }
  9503. } else if record_type == 2 {
  9504. goods, _ := service.GetBatchGoodInformationList(ids)
  9505. for _, item := range goods {
  9506. result := QueryResult{
  9507. ID: item.ID,
  9508. Name: item.GoodName,
  9509. Code: item.MedicalInsuranceNumber,
  9510. List_type_code: "301",
  9511. }
  9512. queryResult = append(queryResult, result)
  9513. }
  9514. } else if record_type == 3 {
  9515. projects, _ := service.GetBathchMyPorjecgList(ids)
  9516. for _, item := range projects {
  9517. result := QueryResult{
  9518. ID: item.ID,
  9519. Name: item.ProjectName,
  9520. Code: item.MedicalCode,
  9521. List_type_code: "201",
  9522. }
  9523. queryResult = append(queryResult, result)
  9524. }
  9525. }
  9526. adminUser := c.GetAdminUserInfo()
  9527. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9528. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9529. var user_name string
  9530. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9531. if role.ID == 0 {
  9532. user_name = "xxx"
  9533. } else {
  9534. user_name = role.UserName
  9535. }
  9536. baseParams := &models.BaseParams{
  9537. SecretKey: miConfig.SecretKey,
  9538. FixmedinsCode: miConfig.Code,
  9539. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9540. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9541. OrgName: miConfig.OrgName,
  9542. Doctor: user_name,
  9543. }
  9544. if config.IsOpen == 1 {
  9545. for _, item := range queryResult {
  9546. var result string
  9547. if record_type == 1 {
  9548. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9549. } else if record_type == 2 {
  9550. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9551. } else if record_type == 3 {
  9552. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9553. }
  9554. var dat2 map[string]interface{}
  9555. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  9556. fmt.Println(dat2)
  9557. } else {
  9558. fmt.Println(err)
  9559. }
  9560. userJSONBytes, _ := json.Marshal(dat2)
  9561. var res ResultSix
  9562. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9563. utils.ErrorLog("解析失败:%v", err)
  9564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9565. return
  9566. }
  9567. if res.Infcode == 0 {
  9568. if record_type == 1 {
  9569. service.UpdateDrugByIdDetail(item.ID)
  9570. } else if record_type == 2 {
  9571. service.UpdateGoodInfoById(item.ID)
  9572. } else if record_type == 3 {
  9573. service.UpdateMyProjectById(item.ID)
  9574. }
  9575. c.ServeSuccessJSON(map[string]interface{}{
  9576. "failed_code": 0,
  9577. "msg": "撤销目录对照成功",
  9578. })
  9579. } else {
  9580. c.ServeSuccessJSON(map[string]interface{}{
  9581. "failed_code": -10,
  9582. "msg": res.ErrMsg,
  9583. })
  9584. }
  9585. }
  9586. }
  9587. }
  9588. func (c *HisApiController) GetPatientInfo() {
  9589. id_card_no := c.GetString("id_card_no")
  9590. admin_user_id, _ := c.GetInt64("admin_user_id")
  9591. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  9592. if patient.ID == 0 {
  9593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9594. return
  9595. }
  9596. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9597. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9598. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  9599. if config.IsOpen == 1 {
  9600. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9601. var dat map[string]interface{}
  9602. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9603. fmt.Println(dat)
  9604. } else {
  9605. fmt.Println(err)
  9606. }
  9607. userJSONBytes, _ := json.Marshal(dat)
  9608. var res ResultTwo
  9609. var res10265 ResultTwo10265
  9610. if miConfig.Code == "H15049901371" {
  9611. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9612. utils.ErrorLog("解析失败:%v", err)
  9613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9614. return
  9615. }
  9616. res.ErrMsg = res10265.ErrMsg
  9617. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9618. res.Infcode = infocode
  9619. res.Output = res10265.Output
  9620. res.InfRefmsgid = res10265.InfRefmsgid
  9621. } else {
  9622. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9623. utils.ErrorLog("解析失败:%v", err)
  9624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9625. return
  9626. }
  9627. }
  9628. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9629. // utils.ErrorLog("解析失败:%v", err)
  9630. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9631. // return
  9632. //}
  9633. if res.Infcode != 0 {
  9634. c.ServeSuccessJSON(map[string]interface{}{
  9635. "failed_code": -10,
  9636. "msg": res.ErrMsg,
  9637. })
  9638. } else {
  9639. c.ServeSuccessJSON(map[string]interface{}{
  9640. "failed_code": 0,
  9641. "info": res,
  9642. })
  9643. }
  9644. }
  9645. }
  9646. func (c *HisApiController) PsnPutOnRecord() {
  9647. record_type, _ := c.GetInt64("type")
  9648. patient_id, _ := c.GetInt64("patient_id")
  9649. admin_user_id, _ := c.GetInt64("admin_user_id")
  9650. start_time := c.GetString("start_time")
  9651. end_time := c.GetString("end_time")
  9652. adminUser := c.GetAdminUserInfo()
  9653. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9654. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9655. var patients []*models.Patients
  9656. if record_type == 1 { //全部备案
  9657. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  9658. patients = append(patients, patient...)
  9659. } else { //单个备案
  9660. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9661. patients = append(patients, patient)
  9662. }
  9663. var user_name string
  9664. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9665. if role.ID == 0 {
  9666. user_name = "xxx"
  9667. } else {
  9668. user_name = role.UserName
  9669. }
  9670. if config.IsOpen == 1 {
  9671. for _, item := range patients {
  9672. 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
  9673. resp, requestErr := http.Get(api)
  9674. if requestErr != nil {
  9675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9676. return
  9677. }
  9678. defer resp.Body.Close()
  9679. body, ioErr := ioutil.ReadAll(resp.Body)
  9680. if ioErr != nil {
  9681. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9683. return
  9684. }
  9685. var respJSON map[string]interface{}
  9686. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9687. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9689. return
  9690. }
  9691. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9692. userJSONBytes, _ := json.Marshal(userJSON)
  9693. var res ResultTwo
  9694. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9695. utils.ErrorLog("解析失败:%v", err)
  9696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9697. return
  9698. }
  9699. if res.Infcode == 0 {
  9700. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  9701. var dat map[string]interface{}
  9702. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9703. fmt.Println(dat)
  9704. } else {
  9705. fmt.Println(err)
  9706. }
  9707. userJSONBytes, _ := json.Marshal(dat)
  9708. var res2 ResultThirteen
  9709. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9710. utils.ErrorLog("解析失败:%v", err)
  9711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9712. return
  9713. }
  9714. if res2.Infcode == 0 {
  9715. psnResult := &models.GdybPsnRecord{
  9716. UserOrgId: adminUser.CurrentOrgId,
  9717. PatientId: item.ID,
  9718. PsnNo: res.Output.Baseinfo.PsnNo,
  9719. Ctime: time.Now().Unix(),
  9720. Mtime: time.Now().Unix(),
  9721. Status: 1,
  9722. IsCancel: 1,
  9723. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  9724. }
  9725. service.CreatePsnRecord(psnResult)
  9726. } else {
  9727. c.ServeSuccessJSON(map[string]interface{}{
  9728. "failed_code": -10,
  9729. "msg": res2.ErrMsg,
  9730. })
  9731. return
  9732. }
  9733. }
  9734. }
  9735. }
  9736. }
  9737. func (c *HisApiController) PsnUnPutOnRecord() {
  9738. id, _ := c.GetInt64("id")
  9739. //record_type, _ := c.GetInt64("type")
  9740. admin_user_id, _ := c.GetInt64("admin_user_id")
  9741. adminUser := c.GetAdminUserInfo()
  9742. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9743. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9744. var user_name string
  9745. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9746. if role.ID == 0 {
  9747. user_name = "xxx"
  9748. } else {
  9749. user_name = role.UserName
  9750. }
  9751. psn_record, _ := service.GetPsnRecordById(id)
  9752. if psn_record.ID == 0 {
  9753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  9754. return
  9755. }
  9756. if config.IsOpen == 1 {
  9757. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  9758. var dat map[string]interface{}
  9759. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9760. fmt.Println(dat)
  9761. } else {
  9762. fmt.Println(err)
  9763. }
  9764. userJSONBytes, _ := json.Marshal(dat)
  9765. var res ResultFourteen
  9766. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9767. utils.ErrorLog("解析失败:%v", err)
  9768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9769. return
  9770. }
  9771. if res.Infcode == 0 {
  9772. psn_record.IsCancel = 2
  9773. service.CreatePsnRecord(&psn_record)
  9774. } else {
  9775. c.ServeSuccessJSON(map[string]interface{}{
  9776. "failed_code": -10,
  9777. "msg": res.ErrMsg,
  9778. })
  9779. return
  9780. }
  9781. }
  9782. }
  9783. func (c *HisApiController) PsnPutNCDSOnRecord() {
  9784. patient_id, _ := c.GetInt64("patient_id")
  9785. insutype_two := c.GetString("insutype")
  9786. psn_no := c.GetString("psn_no")
  9787. doctor_id, _ := c.GetInt64("doctor_id")
  9788. sick_id, _ := c.GetInt64("sick_id")
  9789. department_id, _ := c.GetInt64("department_id")
  9790. start_time := c.GetString("start_time")
  9791. end_time := c.GetString("end_time")
  9792. check_time := c.GetString("check_time")
  9793. adminUser := c.GetAdminUserInfo()
  9794. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9795. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9796. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9797. sick, _ := service.FindSickById(sick_id)
  9798. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  9799. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  9800. var res ResultTwo
  9801. var res10265 ResultTwo10265
  9802. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9803. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  9804. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  9805. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  9806. "&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
  9807. resp, requestErr := http.Get(api)
  9808. if requestErr != nil {
  9809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9810. return
  9811. }
  9812. body, ioErr := ioutil.ReadAll(resp.Body)
  9813. if ioErr != nil {
  9814. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9816. return
  9817. }
  9818. var respJSON map[string]interface{}
  9819. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9820. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9822. return
  9823. }
  9824. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9825. result, _ := json.Marshal(respJSON)
  9826. fmt.Println("log")
  9827. fmt.Println(string(result))
  9828. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9829. utils.ErrorLog("解析失败:%v", err)
  9830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9831. return
  9832. }
  9833. res.ErrMsg = res10265.ErrMsg
  9834. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9835. res.Infcode = infocode
  9836. res.Output = res10265.Output
  9837. res.InfRefmsgid = res10265.InfRefmsgid
  9838. } else {
  9839. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  9840. if miConfig.Code == "H15049901371" {
  9841. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9842. utils.ErrorLog("解析失败:%v", err)
  9843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9844. return
  9845. }
  9846. res.ErrMsg = res10265.ErrMsg
  9847. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9848. res.Infcode = infocode
  9849. res.Output = res10265.Output
  9850. res.InfRefmsgid = res10265.InfRefmsgid
  9851. } else {
  9852. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9853. utils.ErrorLog("解析失败:%v", err)
  9854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9855. return
  9856. }
  9857. }
  9858. }
  9859. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9860. infoStr := string(Iinfos)
  9861. var rf []*ResultFive
  9862. json.Unmarshal([]byte(infoStr), &rf)
  9863. var insuplc_admdvs string
  9864. var insutype string
  9865. var is390 int = 0
  9866. var is310 int = 0
  9867. var insutypes []*ResultFive
  9868. for _, item := range rf {
  9869. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9870. insutypes = append(insutypes, item)
  9871. }
  9872. }
  9873. if len(insutypes) == 1 {
  9874. insutype = insutypes[0].Insutype
  9875. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9876. } else {
  9877. for _, i := range insutypes {
  9878. if i.Insutype == "390" {
  9879. is390 = 1
  9880. }
  9881. if i.Insutype == "310" {
  9882. is310 = 1
  9883. }
  9884. }
  9885. }
  9886. if is390 == 1 {
  9887. insutype = "390"
  9888. }
  9889. if is310 == 1 {
  9890. insutype = "310"
  9891. }
  9892. if len(insutypes) == 2 {
  9893. insutype = insutype_two
  9894. }
  9895. if len(insutypes) == 0 {
  9896. insutype = "310"
  9897. }
  9898. insutype = insutype_two
  9899. fmt.Println(insutype)
  9900. for _, item := range rf {
  9901. fmt.Println(item.Insutype)
  9902. fmt.Println(insutype)
  9903. if item.Insutype == insutype {
  9904. fmt.Println(item.Insutype)
  9905. fmt.Println(insutype)
  9906. insuplc_admdvs = item.InsuplcAdmdvs
  9907. }
  9908. }
  9909. fmt.Println(insuplc_admdvs)
  9910. var res2 ResultThirteen
  9911. var res10265_2 ResultThirteen10265
  9912. if config.IsOpen == 1 {
  9913. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9914. } else {
  9915. 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)
  9916. var dat map[string]interface{}
  9917. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9918. fmt.Println(dat)
  9919. } else {
  9920. fmt.Println(err)
  9921. }
  9922. userJSONBytes, _ := json.Marshal(dat)
  9923. if miConfig.Code == "H15049901371" {
  9924. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  9925. utils.ErrorLog("解析失败:%v", err)
  9926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9927. return
  9928. }
  9929. res2.ErrMsg = res10265_2.ErrMsg
  9930. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  9931. res2.Infcode = infocode
  9932. res2.Output = res10265_2.Output
  9933. res2.InfRefmsgid = res10265_2.InfRefmsgid
  9934. } else {
  9935. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9936. utils.ErrorLog("解析失败:%v", err)
  9937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9938. return
  9939. }
  9940. }
  9941. }
  9942. if res2.Infcode == 0 {
  9943. psnResult := &models.GdybPsnNcdsRecord{
  9944. UserOrgId: adminUser.CurrentOrgId,
  9945. PatientId: patient.ID,
  9946. PsnNo: psn_no,
  9947. DoctorId: doctor.AdminUserId,
  9948. DepartmentId: department_id,
  9949. SickType: sick_id,
  9950. Insutype: insutype,
  9951. Ctime: time.Now().Unix(),
  9952. Mtime: time.Now().Unix(),
  9953. Status: 1,
  9954. IsCancel: 1,
  9955. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  9956. }
  9957. service.CreatePsnNCDSRecord(psnResult)
  9958. c.ServeSuccessJSON(map[string]interface{}{
  9959. "failed_code": 0,
  9960. "msg": "备案成功",
  9961. "result": psnResult,
  9962. })
  9963. } else {
  9964. c.ServeSuccessJSON(map[string]interface{}{
  9965. "failed_code": -10,
  9966. "msg": res2.ErrMsg,
  9967. })
  9968. return
  9969. }
  9970. }
  9971. }
  9972. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  9973. id, _ := c.GetInt64("id")
  9974. admin_user_id, _ := c.GetInt64("admin_user_id")
  9975. adminUser := c.GetAdminUserInfo()
  9976. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9977. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9978. //config, _ := service.Ge(adminUser.CurrentOrgId)
  9979. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  9980. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9981. //var user_name string
  9982. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9983. //if role.ID == 0 {
  9984. // user_name = "xxx"
  9985. //} else {
  9986. // user_name = role.UserName
  9987. //}
  9988. psn_record, _ := service.GetPsnNCDSRecordById(id)
  9989. if psn_record.ID == 0 {
  9990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  9991. return
  9992. }
  9993. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  9994. var res ResultTwo
  9995. var res10265 ResultTwo10265
  9996. if miConfig.Code == "H15049901371" {
  9997. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9998. utils.ErrorLog("解析失败:%v", err)
  9999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10000. return
  10001. }
  10002. res.ErrMsg = res10265.ErrMsg
  10003. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10004. res.Infcode = infocode
  10005. res.Output = res10265.Output
  10006. res.InfRefmsgid = res10265.InfRefmsgid
  10007. } else {
  10008. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10009. utils.ErrorLog("解析失败:%v", err)
  10010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10011. return
  10012. }
  10013. }
  10014. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10015. infoStr := string(Iinfos)
  10016. var rf []*ResultFive
  10017. json.Unmarshal([]byte(infoStr), &rf)
  10018. var insuplc_admdvs string
  10019. var insutype string
  10020. var is390 int = 0
  10021. var is310 int = 0
  10022. var insutypes []*ResultFive
  10023. for _, item := range rf {
  10024. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10025. insutypes = append(insutypes, item)
  10026. }
  10027. }
  10028. if len(insutypes) == 1 {
  10029. insutype = insutypes[0].Insutype
  10030. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10031. } else {
  10032. for _, i := range insutypes {
  10033. if i.Insutype == "390" {
  10034. is390 = 1
  10035. }
  10036. if i.Insutype == "310" {
  10037. is310 = 1
  10038. }
  10039. }
  10040. }
  10041. if is390 == 1 {
  10042. insutype = "390"
  10043. }
  10044. if is310 == 1 {
  10045. insutype = "310"
  10046. }
  10047. if len(insutypes) == 0 {
  10048. insutype = "310"
  10049. }
  10050. insutype = psn_record.Insutype
  10051. for _, item := range rf {
  10052. if item.Insutype == insutype {
  10053. insuplc_admdvs = item.InsuplcAdmdvs
  10054. }
  10055. }
  10056. if config.IsOpen == 1 {
  10057. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10058. var dat map[string]interface{}
  10059. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10060. fmt.Println(dat)
  10061. } else {
  10062. fmt.Println(err)
  10063. }
  10064. userJSONBytes, _ := json.Marshal(dat)
  10065. var res ResultFourteen
  10066. var res10265 ResultFourteen10265
  10067. if miConfig.Code == "H15049901371" {
  10068. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10069. utils.ErrorLog("解析失败:%v", err)
  10070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10071. return
  10072. }
  10073. res.ErrMsg = res10265.ErrMsg
  10074. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10075. res.Infcode = infocode
  10076. res.Output = res10265.Output
  10077. res.InfRefmsgid = res10265.InfRefmsgid
  10078. } else {
  10079. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10080. utils.ErrorLog("解析失败:%v", err)
  10081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10082. return
  10083. }
  10084. }
  10085. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10086. // utils.ErrorLog("解析失败:%v", err)
  10087. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10088. // return
  10089. //}
  10090. if res.Infcode == 0 {
  10091. psn_record.IsCancel = 2
  10092. service.CreatePsnNCDSRecord(&psn_record)
  10093. c.ServeSuccessJSON(map[string]interface{}{
  10094. "failed_code": 0,
  10095. "msg": "撤销备案成功",
  10096. })
  10097. } else {
  10098. c.ServeSuccessJSON(map[string]interface{}{
  10099. "failed_code": -10,
  10100. "msg": res.ErrMsg,
  10101. })
  10102. return
  10103. }
  10104. }
  10105. }
  10106. func (c *HisApiController) TestTest() {
  10107. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  10108. fmt.Println(patient.Iinfo)
  10109. }
  10110. type CustomData struct {
  10111. MsgId string
  10112. PsnNo string
  10113. Info string
  10114. }
  10115. func (c *HisApiController) ReversalData() {
  10116. var customData []*CustomData
  10117. custom := &CustomData{
  10118. MsgId: "H44022900158202103301714472004",
  10119. PsnNo: "44020000001101329945",
  10120. Info: "2207",
  10121. }
  10122. customData = append(customData, custom)
  10123. custom1 := &CustomData{
  10124. MsgId: "H4402290015820210330172057803",
  10125. PsnNo: "44020000001101161813",
  10126. Info: "2207",
  10127. }
  10128. customData = append(customData, custom1)
  10129. custom2 := &CustomData{
  10130. MsgId: "H44022900158202103301705198813",
  10131. PsnNo: "44190000133097375417",
  10132. Info: "2207",
  10133. }
  10134. customData = append(customData, custom2)
  10135. custom3 := &CustomData{
  10136. MsgId: "H44022900158202103301715524756",
  10137. PsnNo: "44020000001100187221",
  10138. Info: "2207",
  10139. }
  10140. customData = append(customData, custom3)
  10141. custom4 := &CustomData{
  10142. MsgId: "H44022900158202103301730376224",
  10143. PsnNo: "44020000001101959155",
  10144. Info: "2207",
  10145. }
  10146. customData = append(customData, custom4)
  10147. custom5 := &CustomData{
  10148. MsgId: "H44022900158202103301748008725",
  10149. PsnNo: "44020000001104246641",
  10150. Info: "2207",
  10151. }
  10152. customData = append(customData, custom5)
  10153. custom6 := &CustomData{
  10154. MsgId: "H44022900158202103301718096755",
  10155. PsnNo: "44020000001102211860",
  10156. Info: "2207",
  10157. }
  10158. customData = append(customData, custom6)
  10159. custom7 := &CustomData{
  10160. MsgId: "H44022900158202103301736551640",
  10161. PsnNo: "44020000001102687718",
  10162. Info: "2207",
  10163. }
  10164. customData = append(customData, custom7)
  10165. custom8 := &CustomData{
  10166. MsgId: "H44022900158202103301743097676",
  10167. PsnNo: "44020000001102127785",
  10168. Info: "2207",
  10169. }
  10170. customData = append(customData, custom8)
  10171. custom9 := &CustomData{
  10172. MsgId: "H44022900158202103301712304203",
  10173. PsnNo: "44020000001101518097",
  10174. Info: "2207",
  10175. }
  10176. customData = append(customData, custom9)
  10177. custom10 := &CustomData{
  10178. MsgId: "H44022900158202103301738448785",
  10179. PsnNo: "44020000001100500813",
  10180. Info: "2207",
  10181. }
  10182. customData = append(customData, custom10)
  10183. custom11 := &CustomData{
  10184. MsgId: "H44022900158202103301732455843",
  10185. PsnNo: "44020000001102690557",
  10186. Info: "2207",
  10187. }
  10188. customData = append(customData, custom11)
  10189. custom12 := &CustomData{
  10190. MsgId: "H44022900158202103301745421708",
  10191. PsnNo: "44020000001102211928",
  10192. Info: "2207",
  10193. }
  10194. customData = append(customData, custom12)
  10195. custom1212 := &CustomData{
  10196. MsgId: "H440229001582021033017351627",
  10197. PsnNo: "44020000001102481733",
  10198. Info: "2207",
  10199. }
  10200. customData = append(customData, custom1212)
  10201. custom13 := &CustomData{
  10202. MsgId: "H44022900158202103301740327951",
  10203. PsnNo: "44020000001103174866",
  10204. Info: "2207",
  10205. }
  10206. customData = append(customData, custom13)
  10207. custom14 := &CustomData{
  10208. MsgId: "H4402290015820210330174922668",
  10209. PsnNo: "44020000001102927272",
  10210. Info: "2207",
  10211. }
  10212. customData = append(customData, custom14)
  10213. custom15 := &CustomData{
  10214. MsgId: "H44022900158202103301752362273",
  10215. PsnNo: "44020000001102942890",
  10216. Info: "2207",
  10217. }
  10218. customData = append(customData, custom15)
  10219. custom16 := &CustomData{
  10220. MsgId: "H44022900158202103301751082917",
  10221. PsnNo: "44020000001101662162",
  10222. Info: "2207",
  10223. }
  10224. customData = append(customData, custom16)
  10225. custom17 := &CustomData{
  10226. MsgId: "H44022900158202103301754147728",
  10227. PsnNo: "44020000000229014511",
  10228. Info: "2207",
  10229. }
  10230. customData = append(customData, custom17)
  10231. adminUser := c.GetAdminUserInfo()
  10232. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10233. for _, item := range customData {
  10234. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10235. fmt.Println(result)
  10236. }
  10237. }
  10238. func (c *HisApiController) GetAllopatry() {
  10239. year := c.GetString("year")
  10240. month := c.GetString("month")
  10241. admin_user_id, _ := c.GetInt64("admin_user_id")
  10242. adminUser := c.GetAdminUserInfo()
  10243. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10244. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10245. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10246. var dat map[string]interface{}
  10247. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10248. fmt.Println(dat)
  10249. } else {
  10250. fmt.Println(err)
  10251. }
  10252. userJSONBytes, _ := json.Marshal(dat)
  10253. var res models.Result9001
  10254. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10255. utils.ErrorLog("解析失败:%v", err)
  10256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10257. return
  10258. }
  10259. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10260. var dat2 map[string]interface{}
  10261. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10262. fmt.Println(dat)
  10263. } else {
  10264. fmt.Println(err)
  10265. }
  10266. userJSONBytes2, _ := json.Marshal(dat2)
  10267. var res2 models.Result3260
  10268. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10269. utils.ErrorLog("解析失败:%v", err)
  10270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10271. return
  10272. }
  10273. if res2.Infcode == 0 {
  10274. c.ServeSuccessJSON(map[string]interface{}{
  10275. "list": res2.Output.Data,
  10276. })
  10277. return
  10278. } else {
  10279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10280. return
  10281. }
  10282. }
  10283. func (c *HisApiController) ComfirmAllopatry() {
  10284. year := c.GetString("year")
  10285. month := c.GetString("month")
  10286. admin_user_id, _ := c.GetInt64("admin_user_id")
  10287. adminUser := c.GetAdminUserInfo()
  10288. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10289. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10290. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10291. var dat map[string]interface{}
  10292. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10293. fmt.Println(dat)
  10294. } else {
  10295. fmt.Println(err)
  10296. }
  10297. userJSONBytes, _ := json.Marshal(dat)
  10298. var res models.Result9001
  10299. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10300. utils.ErrorLog("解析失败:%v", err)
  10301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10302. return
  10303. }
  10304. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10305. var dat2 map[string]interface{}
  10306. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10307. fmt.Println(dat)
  10308. } else {
  10309. fmt.Println(err)
  10310. }
  10311. userJSONBytes2, _ := json.Marshal(dat2)
  10312. var res2 models.Result3260
  10313. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10314. utils.ErrorLog("解析失败:%v", err)
  10315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10316. return
  10317. }
  10318. if res2.Infcode == 0 {
  10319. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  10320. var dat map[string]interface{}
  10321. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10322. fmt.Println(dat)
  10323. } else {
  10324. fmt.Println(err)
  10325. }
  10326. userJSONBytes, _ := json.Marshal(dat)
  10327. var res3 models.Result3261
  10328. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  10329. utils.ErrorLog("解析失败:%v", err)
  10330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10331. return
  10332. }
  10333. if res3.Infcode == 0 {
  10334. record := &models.HisYidiClearRecord{
  10335. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10336. Ctime: time.Now().Unix(),
  10337. Mtime: time.Now().Unix(),
  10338. Status: 1,
  10339. MsgId: msgId,
  10340. }
  10341. service.SaveClearRecord(record)
  10342. c.ServeSuccessJSON(map[string]interface{}{
  10343. "msg": "提取成功",
  10344. })
  10345. }
  10346. }
  10347. }
  10348. func (c *HisApiController) RefundAllopatry() {
  10349. year := c.GetString("year")
  10350. month := c.GetString("month")
  10351. id, _ := c.GetInt64("id")
  10352. admin_user_id, _ := c.GetInt64("admin_user_id")
  10353. adminUser := c.GetAdminUserInfo()
  10354. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10355. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10356. record, _ := service.GetClearRecordById(id)
  10357. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  10358. var dat map[string]interface{}
  10359. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10360. fmt.Println(dat)
  10361. } else {
  10362. fmt.Println(err)
  10363. }
  10364. userJSONBytes, _ := json.Marshal(dat)
  10365. var empty ResultFourteen
  10366. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  10367. utils.ErrorLog("解析失败:%v", err)
  10368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10369. return
  10370. }
  10371. if empty.Infcode == 0 {
  10372. c.ServeSuccessJSON(map[string]interface{}{
  10373. "msg": "撤销成功",
  10374. })
  10375. return
  10376. }
  10377. }
  10378. func (c *HisApiController) ReversalOtherData() {
  10379. var customData []*CustomData
  10380. custom := &CustomData{
  10381. MsgId: "H44022900158202103301714472004",
  10382. PsnNo: "44020000001101329945",
  10383. Info: "2208",
  10384. }
  10385. customData = append(customData, custom)
  10386. custom1 := &CustomData{
  10387. MsgId: "H4402290015820210330172057803",
  10388. PsnNo: "44020000001101161813",
  10389. Info: "2208",
  10390. }
  10391. customData = append(customData, custom1)
  10392. custom2 := &CustomData{
  10393. MsgId: "H44022900158202103301705198813",
  10394. PsnNo: "44190000133097375417",
  10395. Info: "2208",
  10396. }
  10397. customData = append(customData, custom2)
  10398. custom3 := &CustomData{
  10399. MsgId: "H44022900158202103301715524756",
  10400. PsnNo: "44020000001100187221",
  10401. Info: "2208",
  10402. }
  10403. customData = append(customData, custom3)
  10404. custom4 := &CustomData{
  10405. MsgId: "H44022900158202103301730376224",
  10406. PsnNo: "44020000001101959155",
  10407. Info: "2208",
  10408. }
  10409. customData = append(customData, custom4)
  10410. custom5 := &CustomData{
  10411. MsgId: "H44022900158202103301748008725",
  10412. PsnNo: "44020000001104246641",
  10413. Info: "2208",
  10414. }
  10415. customData = append(customData, custom5)
  10416. custom6 := &CustomData{
  10417. MsgId: "H44022900158202103301718096755",
  10418. PsnNo: "44020000001102211860",
  10419. Info: "2208",
  10420. }
  10421. customData = append(customData, custom6)
  10422. custom7 := &CustomData{
  10423. MsgId: "H44022900158202103301736551640",
  10424. PsnNo: "44020000001102687718",
  10425. Info: "2208",
  10426. }
  10427. customData = append(customData, custom7)
  10428. custom8 := &CustomData{
  10429. MsgId: "H44022900158202103301743097676",
  10430. PsnNo: "44020000001102127785",
  10431. Info: "2208",
  10432. }
  10433. customData = append(customData, custom8)
  10434. custom9 := &CustomData{
  10435. MsgId: "H44022900158202103301712304203",
  10436. PsnNo: "44020000001101518097",
  10437. Info: "2208",
  10438. }
  10439. customData = append(customData, custom9)
  10440. custom10 := &CustomData{
  10441. MsgId: "H44022900158202103301738448785",
  10442. PsnNo: "44020000001100500813",
  10443. Info: "2208",
  10444. }
  10445. customData = append(customData, custom10)
  10446. custom11 := &CustomData{
  10447. MsgId: "H44022900158202103301732455843",
  10448. PsnNo: "44020000001102690557",
  10449. Info: "2208",
  10450. }
  10451. customData = append(customData, custom11)
  10452. custom12 := &CustomData{
  10453. MsgId: "H44022900158202103301745421708",
  10454. PsnNo: "44020000001102211928",
  10455. Info: "2208",
  10456. }
  10457. customData = append(customData, custom12)
  10458. custom1212 := &CustomData{
  10459. MsgId: "H440229001582021033017351627",
  10460. PsnNo: "44020000001102481733",
  10461. Info: "2208",
  10462. }
  10463. customData = append(customData, custom1212)
  10464. custom13 := &CustomData{
  10465. MsgId: "H44022900158202103301740327951",
  10466. PsnNo: "44020000001103174866",
  10467. Info: "2208",
  10468. }
  10469. customData = append(customData, custom13)
  10470. custom14 := &CustomData{
  10471. MsgId: "H4402290015820210330174922668",
  10472. PsnNo: "44020000001102927272",
  10473. Info: "2208",
  10474. }
  10475. customData = append(customData, custom14)
  10476. custom15 := &CustomData{
  10477. MsgId: "H44022900158202103301752362273",
  10478. PsnNo: "44020000001102942890",
  10479. Info: "2208",
  10480. }
  10481. customData = append(customData, custom15)
  10482. custom16 := &CustomData{
  10483. MsgId: "H44022900158202103301751082917",
  10484. PsnNo: "44020000001101662162",
  10485. Info: "2208",
  10486. }
  10487. customData = append(customData, custom16)
  10488. custom17 := &CustomData{
  10489. MsgId: "H44022900158202103301754147728",
  10490. PsnNo: "44020000000229014511",
  10491. Info: "2208",
  10492. }
  10493. customData = append(customData, custom17)
  10494. adminUser := c.GetAdminUserInfo()
  10495. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10496. for _, item := range customData {
  10497. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10498. fmt.Println(result)
  10499. }
  10500. }
  10501. func PathExists(path string) (bool, error) {
  10502. _, err := os.Stat(path)
  10503. if err == nil {
  10504. return true, nil
  10505. }
  10506. if os.IsNotExist(err) {
  10507. return false, nil
  10508. }
  10509. return false, err
  10510. }
  10511. //创建文件夹
  10512. func Mkdir(dir string) {
  10513. // 创建文件夹
  10514. exist, err := PathExists(dir)
  10515. if err != nil {
  10516. fmt.Println(err.Error())
  10517. } else {
  10518. if exist {
  10519. fmt.Println(dir + "文件夹已存在!")
  10520. } else {
  10521. // 文件夹名称,权限
  10522. err := os.Mkdir(dir, os.ModePerm)
  10523. if err != nil {
  10524. fmt.Println(dir+"文件夹创建失败:", err.Error())
  10525. } else {
  10526. fmt.Println(dir + "文件夹创建成功!")
  10527. }
  10528. }
  10529. }
  10530. }
  10531. //压缩文件
  10532. func Zip(srcFile string, destZip string) error {
  10533. zipfile, err := os.Create(destZip)
  10534. if err != nil {
  10535. return err
  10536. }
  10537. defer zipfile.Close()
  10538. archive := zip.NewWriter(zipfile)
  10539. defer archive.Close()
  10540. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  10541. if err != nil {
  10542. return err
  10543. }
  10544. header, err := zip.FileInfoHeader(info)
  10545. if err != nil {
  10546. return err
  10547. }
  10548. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  10549. // header.Name = path
  10550. if info.IsDir() {
  10551. header.Name += "/"
  10552. } else {
  10553. header.Method = zip.Deflate
  10554. }
  10555. writer, err := archive.CreateHeader(header)
  10556. if err != nil {
  10557. return err
  10558. }
  10559. if !info.IsDir() {
  10560. file, err := os.Open(path)
  10561. if err != nil {
  10562. return err
  10563. }
  10564. defer file.Close()
  10565. _, err = io.Copy(writer, file)
  10566. }
  10567. return err
  10568. })
  10569. return err
  10570. }
  10571. func ReadFile(filePath string) []byte {
  10572. f, err := os.Open(filePath)
  10573. if err != nil {
  10574. fmt.Println("read file fail", err)
  10575. return nil
  10576. }
  10577. defer f.Close()
  10578. fd, err := ioutil.ReadAll(f)
  10579. if err != nil {
  10580. fmt.Println("read to fd fail", err)
  10581. return nil
  10582. }
  10583. return fd
  10584. }
  10585. func saveLog(result string, request string, infno string, desc string) {
  10586. org_id, _ := beego.AppConfig.Int64("org_id")
  10587. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  10588. dir := miConfig.OrgName + "日志"
  10589. utils.Mkdir(dir)
  10590. month := time.Unix(1557042972, 0).Format("1")
  10591. year := time.Now().Format("2006")
  10592. month = time.Now().Format("01")
  10593. day := time.Now().Format("02")
  10594. hour := time.Now().Format("15")
  10595. min := time.Now().Format("04")
  10596. sec := time.Now().Format("05")
  10597. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  10598. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  10599. file_name := file + ".txt"
  10600. file_path := miConfig.OrgName + "日志" + "/" + file_name
  10601. exist, _ := utils.PathExists(file_path)
  10602. if exist { //存在
  10603. fmt.Println("存在")
  10604. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  10605. if err != nil {
  10606. fmt.Println("read fail")
  10607. }
  10608. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  10609. n, _ := f.Seek(0, 2)
  10610. _, err = f.WriteAt([]byte(content), n)
  10611. } else { //不存在
  10612. fmt.Println("文件不存在,创建文件")
  10613. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  10614. defer f.Close()
  10615. if err != nil {
  10616. } else {
  10617. _, err = f.Write([]byte("记录日志"))
  10618. }
  10619. }
  10620. }
  10621. type Charset string
  10622. const (
  10623. UTF8 = Charset("UTF-8")
  10624. GB18030 = Charset("GB18030")
  10625. )
  10626. func ConvertToString(src string, srcCode string, tagCode string) string {
  10627. srcCoder := mahonia.NewDecoder(srcCode)
  10628. srcResult := srcCoder.ConvertString(src)
  10629. tagCoder := mahonia.NewDecoder(tagCode)
  10630. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  10631. result := string(cdata)
  10632. return result
  10633. }